Improve Rudderstack event logging (#1593)
## Description * Fire of Identify event on RepoInit to identify user for analytics tools * Flatten Payload structure for better mapping to analytics tools * Snake case convention for event properties ## Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [ ] 🐹 Trivial/Minor ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> ## Test Plan <!-- How will this be tested prior to merging.--> - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
22ff7f5d98
commit
108023efd2
@ -17,30 +17,29 @@ import (
|
|||||||
|
|
||||||
// keys for ease of use
|
// keys for ease of use
|
||||||
const (
|
const (
|
||||||
corsoVersion = "corso-version"
|
corsoVersion = "corso_version"
|
||||||
repoID = "repo-id"
|
repoID = "repo_id"
|
||||||
payload = "payload"
|
|
||||||
|
|
||||||
// Event Keys
|
// Event Keys
|
||||||
RepoInit = "repo-init"
|
RepoInit = "repo_init"
|
||||||
BackupStart = "backup-start"
|
BackupStart = "backup_start"
|
||||||
BackupEnd = "backup-end"
|
BackupEnd = "backup_end"
|
||||||
RestoreStart = "restore-start"
|
RestoreStart = "restore_start"
|
||||||
RestoreEnd = "restore-end"
|
RestoreEnd = "restore_end"
|
||||||
|
|
||||||
// Event Data Keys
|
// Event Data Keys
|
||||||
BackupCreateTime = "backup-creation-time"
|
BackupCreateTime = "backup_creation_time"
|
||||||
BackupID = "backup-id"
|
BackupID = "backup_id"
|
||||||
DataRetrieved = "data-retrieved"
|
DataRetrieved = "data_retrieved"
|
||||||
DataStored = "data-stored"
|
DataStored = "data_stored"
|
||||||
Duration = "duration"
|
Duration = "duration"
|
||||||
EndTime = "end-time"
|
EndTime = "end_time"
|
||||||
ItemsRead = "items-read"
|
ItemsRead = "items_read"
|
||||||
ItemsWritten = "items-written"
|
ItemsWritten = "items_written"
|
||||||
Resources = "resources"
|
Resources = "resources"
|
||||||
RestoreID = "restore-id"
|
RestoreID = "restore_id"
|
||||||
Service = "service"
|
Service = "service"
|
||||||
StartTime = "start-time"
|
StartTime = "start_time"
|
||||||
Status = "status"
|
Status = "status"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -120,8 +119,20 @@ func (b Bus) Event(ctx context.Context, key string, data map[string]any) {
|
|||||||
Set(repoID, b.repoID).
|
Set(repoID, b.repoID).
|
||||||
Set(corsoVersion, b.version)
|
Set(corsoVersion, b.version)
|
||||||
|
|
||||||
if len(data) > 0 {
|
for k, v := range data {
|
||||||
props.Set(payload, data)
|
props.Set(k, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// need to setup identity when initializing a new repo
|
||||||
|
if key == RepoInit {
|
||||||
|
err := b.client.Enqueue(analytics.Identify{
|
||||||
|
UserId: b.repoID,
|
||||||
|
Traits: analytics.NewTraits().
|
||||||
|
SetName(b.repoID),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logger.Ctx(ctx).Debugw("analytics event failure", "err", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := b.client.Enqueue(analytics.Track{
|
err := b.client.Enqueue(analytics.Track{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user