@simplybusiness/services 2.2.2 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/index.js +20 -9
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/meta.json +16 -6
- package/dist/esm/index.js +20 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/meta.json +16 -6
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +11 -10
- package/src/snowplow/Snowplow.ts +11 -2
- package/src/snowplow/event-definitions/qcp.ts +8 -6
- package/src/snowplow/index.test.ts +11 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplybusiness/services",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.4",
|
|
5
5
|
"description": "Internal library for services",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@eslint/compat": "^2.0.2",
|
|
61
|
-
"@eslint/eslintrc": "^3.3.
|
|
62
|
-
"@eslint/js": "^9.39.
|
|
63
|
-
"@simplybusiness/build-scripts": "^2.0.
|
|
64
|
-
"@simplybusiness/eslint-config": "^2.0.
|
|
61
|
+
"@eslint/eslintrc": "^3.3.4",
|
|
62
|
+
"@eslint/js": "^9.39.3",
|
|
63
|
+
"@simplybusiness/build-scripts": "^2.0.2",
|
|
64
|
+
"@simplybusiness/eslint-config": "^2.0.2",
|
|
65
65
|
"@testing-library/dom": "^10.4.1",
|
|
66
66
|
"@testing-library/jest-dom": "6.9.1",
|
|
67
67
|
"@testing-library/react": "^16.3.2",
|
|
68
|
-
"@types/react": "^19.2.
|
|
68
|
+
"@types/react": "^19.2.14",
|
|
69
69
|
"@types/react-dom": "^19.2.3",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
71
|
-
"@typescript-eslint/parser": "^8.
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
71
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
72
72
|
"@vitest/coverage-v8": "^4.0.18",
|
|
73
|
-
"eslint": "^9.39.
|
|
73
|
+
"eslint": "^9.39.3",
|
|
74
74
|
"eslint-config-prettier": "^10.1.8",
|
|
75
75
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
76
76
|
"eslint-plugin-import": "^2.32.0",
|
|
@@ -88,7 +88,8 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@airbrake/browser": "^2.1.9",
|
|
91
|
-
"@simplybusiness/mobius": "^9.0.
|
|
91
|
+
"@simplybusiness/mobius": "^9.0.2",
|
|
92
|
+
"@snowplow/browser-plugin-ga-cookies": "^3.24.0",
|
|
92
93
|
"@snowplow/browser-tracker": "^3.24.6",
|
|
93
94
|
"classnames": "^2.5.1"
|
|
94
95
|
},
|
package/src/snowplow/Snowplow.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
trackSelfDescribingEvent,
|
|
12
12
|
trackStructEvent,
|
|
13
13
|
} from "@snowplow/browser-tracker";
|
|
14
|
+
import { GaCookiesPlugin } from "@snowplow/browser-plugin-ga-cookies";
|
|
14
15
|
import { makeContexts, updateIdentityContext } from "./contexts";
|
|
15
16
|
import type { EventDefinition, SerialisedEvent, TrackingProps } from "./types";
|
|
16
17
|
|
|
@@ -86,6 +87,7 @@ export class Snowplow {
|
|
|
86
87
|
newTracker(this.pvAvalancheTrackerName, avalancheCollector, {
|
|
87
88
|
...baseOptions,
|
|
88
89
|
eventMethod: eventMethod === "post" ? "beacon" : eventMethod,
|
|
90
|
+
plugins: [GaCookiesPlugin()],
|
|
89
91
|
});
|
|
90
92
|
|
|
91
93
|
setCookiePath("/");
|
|
@@ -98,7 +100,14 @@ export class Snowplow {
|
|
|
98
100
|
|
|
99
101
|
setContexts(contexts: Record<string, SerialisedEvent>) {
|
|
100
102
|
this.contexts = updateIdentityContext(contexts, this.uid);
|
|
101
|
-
this.pvContext =
|
|
103
|
+
this.pvContext = makeContexts(
|
|
104
|
+
[
|
|
105
|
+
"pageViewContext",
|
|
106
|
+
"distributionChannelContext",
|
|
107
|
+
"serviceChannelContext",
|
|
108
|
+
],
|
|
109
|
+
this.contexts,
|
|
110
|
+
);
|
|
102
111
|
this.structContext = makeContexts(
|
|
103
112
|
["distributionChannelContext", "serviceChannelContext"],
|
|
104
113
|
this.contexts,
|
|
@@ -110,7 +119,7 @@ export class Snowplow {
|
|
|
110
119
|
trackView(event?: PageViewEvent) {
|
|
111
120
|
if (this.trackPageView) {
|
|
112
121
|
trackPageView({ ...event, context: this.pvContext }, [
|
|
113
|
-
this.
|
|
122
|
+
this.pvAvalancheTrackerName,
|
|
114
123
|
]);
|
|
115
124
|
}
|
|
116
125
|
return this;
|
|
@@ -369,11 +369,13 @@ export const qcpEventDefinitions: EventDefinition[] = [
|
|
|
369
369
|
{
|
|
370
370
|
name: "cancelAnytimeBadgeClicked",
|
|
371
371
|
type: "structured",
|
|
372
|
-
makePayload:
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
372
|
+
makePayload: payload => {
|
|
373
|
+
return {
|
|
374
|
+
category: "us-26-02-qcp-cancel-anytime-test",
|
|
375
|
+
action: "cancel_anytime_badge_clicked",
|
|
376
|
+
label: (payload?.label as string) || "cancel_anytime",
|
|
377
|
+
property: window.location.href,
|
|
378
|
+
};
|
|
379
|
+
},
|
|
378
380
|
},
|
|
379
381
|
];
|
|
@@ -40,7 +40,16 @@ describe("Snowplow Analytics Class", () => {
|
|
|
40
40
|
|
|
41
41
|
it("sets contexts on instantiation", () => {
|
|
42
42
|
expect(testSnowplow.contexts).toEqual(contexts);
|
|
43
|
-
expect(testSnowplow.pvContext).toEqual(
|
|
43
|
+
expect(testSnowplow.pvContext).toEqual(
|
|
44
|
+
makeContexts(
|
|
45
|
+
[
|
|
46
|
+
"pageViewContext",
|
|
47
|
+
"distributionChannelContext",
|
|
48
|
+
"serviceChannelContext",
|
|
49
|
+
],
|
|
50
|
+
contexts,
|
|
51
|
+
),
|
|
52
|
+
);
|
|
44
53
|
});
|
|
45
54
|
|
|
46
55
|
it("tracks page view event and adds contexts", async () => {
|
|
@@ -63,7 +72,7 @@ describe("Snowplow Analytics Class", () => {
|
|
|
63
72
|
await waitFor(() => {
|
|
64
73
|
expect(innerSpy).toHaveBeenCalledWith(
|
|
65
74
|
{ context: testSnowplow.pvContext },
|
|
66
|
-
["sb-ava"],
|
|
75
|
+
["sb-ava-pv"],
|
|
67
76
|
);
|
|
68
77
|
});
|
|
69
78
|
});
|