Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/actions-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"cheerio": "^1.0.0-rc.10",
"dayjs": "^1.10.7",
"escape-goat": "^3",
"liquidjs": "^9.37.0",
"liquidjs": "^10.0.0",
"lodash": "^4.17.21"
},
"jest": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const subscriptions: Subscription[] = [
},
userId: {
'@path': '$.userId'
},
properties: {
'@path': '$.properties'
}
}
}
Expand All @@ -32,19 +35,20 @@ describe('trackEvent', () => {
destination.actions.trackEvent.perform = jest.fn()
jest.spyOn(destination.actions.trackEvent, 'perform')
await trackEvent.load(Context.system(), {} as Analytics)

const properties = { property1: 'value1', property2: false }
await trackEvent.track?.(
new Context({
type: 'track',
name: 'Button Clicked',
anonymousId: 'anonymous-id-0'
anonymousId: 'anonymous-id-0',
properties
})
)

expect(destination.actions.trackEvent.perform).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
payload: { name: 'Button Clicked', anonymousId: 'anonymous-id-0' }
payload: { name: 'Button Clicked', anonymousId: 'anonymous-id-0', properties }
})
)
})
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ const action: BrowserActionDefinition<Settings, Sprig, Payload> = {
default: {
'@path': '$.anonymousId'
}
},
properties: {
type: 'object',
required: false,
description: 'Object containing the properties of the event',
label: 'Event Properties',
default: {
'@path': '$.properties'
}
}
},
perform: (Sprig, event) => {
Expand All @@ -44,7 +53,12 @@ const action: BrowserActionDefinition<Settings, Sprig, Payload> = {
return
}

const sprigIdentifyAndTrackPayload: { eventName: string; userId?: string; anonymousId?: string } = {
const sprigIdentifyAndTrackPayload: {
eventName: string
userId?: string
anonymousId?: string
properties?: { [key: string]: unknown }
} = {
eventName: payload.name
}
if (payload.userId) {
Expand All @@ -55,6 +69,10 @@ const action: BrowserActionDefinition<Settings, Sprig, Payload> = {
sprigIdentifyAndTrackPayload.anonymousId = payload.anonymousId
}

if (payload.properties) {
sprigIdentifyAndTrackPayload.properties = payload.properties
}

Sprig('identifyAndTrack', sprigIdentifyAndTrackPayload)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/destination-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"cheerio": "^1.0.0-rc.10",
"dayjs": "^1.10.7",
"escape-goat": "^3",
"liquidjs": "^9.37.0",
"liquidjs": "^10.0.0",
"lodash": "^4.17.21"
},
"jest": {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8487,10 +8487,10 @@ lint-staged@^10.5.3:
string-argv "0.3.1"
stringify-object "^3.3.0"

liquidjs@^9.37.0:
version "9.37.0"
resolved "https://registry.yarnpkg.com/liquidjs/-/liquidjs-9.37.0.tgz#58e0dd2fa779635ead589e82cfa9baffe49f490e"
integrity sha512-qDj9iiNdB+QNZTR4iKjiQzoHQma7V8Itx5oZG/ZCP7xjebh1LI+s5IG2ZYUbs1ALO6hBzmW36Ptd8RR4eohuDA==
liquidjs@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/liquidjs/-/liquidjs-10.0.0.tgz#282579e9f90f4bfd92ef7d09ad4f5aac3ec9fd61"
integrity sha512-uY3fKqBSRmnat0wB5qWk0W5N5iT78OUhuIXNRiMfhYQ3p35al9mEWKQ68/Z+WD54V2upaxEM8nHaZ6o1B8WCMA==

listr2@^3.2.2:
version "3.11.0"
Expand Down