Skip to content

Commit

Permalink
Heap Fix for empty event name (#1004)
Browse files Browse the repository at this point in the history
* fix for pe-52

* fixing breaking tests
  • Loading branch information
joe-ayoub-segment authored Jan 26, 2023
1 parent 7d29962 commit 30c7af3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Object {
exports[`Testing snapshot for actions-heap destination: trackEvent action - all fields 1`] = `
Object {
"app_id": "kFJwrNh$DP38FB",
"event": "track",
"idempotency_key": "kFJwrNh$DP38FB",
"identity": "kFJwrNh$DP38FB",
"properties": Object {
Expand All @@ -33,6 +34,7 @@ Object {
exports[`Testing snapshot for actions-heap destination: trackEvent action - required fields 1`] = `
Object {
"app_id": "kFJwrNh$DP38FB",
"event": "track",
"idempotency_key": "kFJwrNh$DP38FB",
"identity": "kFJwrNh$DP38FB",
"properties": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`Testing snapshot for Heap's trackEvent destination action: all fields 1`] = `
Object {
"app_id": "xqYHVWXiU0In",
"event": "track",
"idempotency_key": "xqYHVWXiU0In",
"identity": "xqYHVWXiU0In",
"properties": Object {
Expand All @@ -17,6 +18,7 @@ Object {
exports[`Testing snapshot for Heap's trackEvent destination action: required fields 1`] = `
Object {
"app_id": "xqYHVWXiU0In",
"event": "track",
"idempotency_key": "xqYHVWXiU0In",
"identity": "xqYHVWXiU0In",
"properties": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,26 @@ const action: ActionDefinition<Settings, Payload> = {
}

const getEventName = (payload: Payload) => {
let eventName: string | undefined
switch (payload.type) {
case 'track':
return payload.event
eventName = payload.event
break
case 'page':
eventName = payload.name ? payload.name : 'Page Viewed'
break
case 'screen':
return payload.name
eventName = payload.name ? payload.name : 'Screen Viewed'
break
default:
return undefined
eventName = 'track'
break
}

if (!eventName) {
return 'track'
}
return eventName
}

export default action

0 comments on commit 30c7af3

Please sign in to comment.