From d40964972f6fe5b28507caef656c27048a4dfdd0 Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Thu, 3 Nov 2022 17:48:06 -0500 Subject: [PATCH 1/2] event properties --- .../trackEvent/__tests__/index.test.ts | 10 +++++++--- .../sprig-web/trackEvent/generated-types.ts | 6 ++++++ .../sprig-web/trackEvent/index.ts | 20 ++++++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/browser-destinations/src/destinations/sprig-web/trackEvent/__tests__/index.test.ts b/packages/browser-destinations/src/destinations/sprig-web/trackEvent/__tests__/index.test.ts index b6725f3b2b1..674b5914a5e 100644 --- a/packages/browser-destinations/src/destinations/sprig-web/trackEvent/__tests__/index.test.ts +++ b/packages/browser-destinations/src/destinations/sprig-web/trackEvent/__tests__/index.test.ts @@ -17,6 +17,9 @@ const subscriptions: Subscription[] = [ }, userId: { '@path': '$.userId' + }, + properties: { + '@path': '$.properties' } } } @@ -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 } }) ) }) diff --git a/packages/browser-destinations/src/destinations/sprig-web/trackEvent/generated-types.ts b/packages/browser-destinations/src/destinations/sprig-web/trackEvent/generated-types.ts index 8351b6a7a0a..07cbc0af4d8 100644 --- a/packages/browser-destinations/src/destinations/sprig-web/trackEvent/generated-types.ts +++ b/packages/browser-destinations/src/destinations/sprig-web/trackEvent/generated-types.ts @@ -13,4 +13,10 @@ export interface Payload { * Anonymous identifier for the user */ anonymousId?: string + /** + * Object containing the properties of the event + */ + properties?: { + [k: string]: unknown + } } diff --git a/packages/browser-destinations/src/destinations/sprig-web/trackEvent/index.ts b/packages/browser-destinations/src/destinations/sprig-web/trackEvent/index.ts index a3024a224a2..256cc2e8ef2 100644 --- a/packages/browser-destinations/src/destinations/sprig-web/trackEvent/index.ts +++ b/packages/browser-destinations/src/destinations/sprig-web/trackEvent/index.ts @@ -35,6 +35,15 @@ const action: BrowserActionDefinition = { 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) => { @@ -44,7 +53,12 @@ const action: BrowserActionDefinition = { 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) { @@ -55,6 +69,10 @@ const action: BrowserActionDefinition = { sprigIdentifyAndTrackPayload.anonymousId = payload.anonymousId } + if (payload.properties) { + sprigIdentifyAndTrackPayload.properties = payload.properties + } + Sprig('identifyAndTrack', sprigIdentifyAndTrackPayload) } } From a93495527ce5542fed5393ad9d777de63c861ea5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Dec 2022 20:35:15 +0000 Subject: [PATCH 2/2] Bump liquidjs from 9.37.0 to 10.0.0 Bumps [liquidjs](https://github.com/harttle/liquidjs) from 9.37.0 to 10.0.0. - [Release notes](https://github.com/harttle/liquidjs/releases) - [Changelog](https://github.com/harttle/liquidjs/blob/master/CHANGELOG.md) - [Commits](https://github.com/harttle/liquidjs/compare/v9.37.0...v10.0.0) --- updated-dependencies: - dependency-name: liquidjs dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- packages/actions-shared/package.json | 2 +- packages/destination-actions/package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/actions-shared/package.json b/packages/actions-shared/package.json index 4681e480b96..c20cb50e189 100644 --- a/packages/actions-shared/package.json +++ b/packages/actions-shared/package.json @@ -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": { diff --git a/packages/destination-actions/package.json b/packages/destination-actions/package.json index 5869d570113..121b9dd24d0 100644 --- a/packages/destination-actions/package.json +++ b/packages/destination-actions/package.json @@ -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": { diff --git a/yarn.lock b/yarn.lock index 7bf893645fe..3f10d01f335 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"