Skip to content

Commit

Permalink
Add Unique ID and Key Tracking in SFMC Events (#2631)
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-joshi99 authored Dec 10, 2024
1 parent bb9512a commit 3961661
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,23 @@ const action: ActionDefinition<Settings, Payload> = {
perform: async (request, { settings, payload }) => {
return upsertRows(request, settings.subdomain, [payload])
},
performBatch: async (request, { settings, payload }) => {
performBatch: async (request, { settings, payload, statsContext, features }) => {
if (features && features['enable-sfmc-id-key-stats']) {
const statsClient = statsContext?.statsClient
const tags = statsContext?.tags
const setKey = new Set()
const setId = new Set()
payload.forEach((profile) => {
if (profile.id != undefined && profile.id != null) {
setId.add(profile.id)
}
if (profile.key != undefined && profile.key != null) {
setKey.add(profile.key)
}
})
statsClient?.histogram(`sfmc_id`, setId.size, tags)
statsClient?.histogram(`sfmc_key`, setKey.size, tags)
}
return upsertRows(request, settings.subdomain, payload)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,23 @@ const action: ActionDefinition<Settings, Payload> = {
perform: async (request, { settings, payload }) => {
return upsertRows(request, settings.subdomain, [payload])
},
performBatch: async (request, { settings, payload }) => {
performBatch: async (request, { settings, payload, statsContext, features }) => {
if (features && features['enable-sfmc-id-key-stats']) {
const statsClient = statsContext?.statsClient
const tags = statsContext?.tags
const setKey = new Set()
const setId = new Set()
payload.forEach((profile) => {
if (profile.id != undefined && profile.id != null) {
setId.add(profile.id)
}
if (profile.key != undefined && profile.key != null) {
setKey.add(profile.key)
}
})
statsClient?.histogram(`sfmc_id`, setId.size, tags)
statsClient?.histogram(`sfmc_key`, setKey.size, tags)
}
return upsertRows(request, settings.subdomain, payload)
}
}
Expand Down

0 comments on commit 3961661

Please sign in to comment.