@simplybusiness/services 2.7.7 → 2.9.0
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 +19 -0
- package/dist/cjs/index.js +41 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/meta.json +23 -23
- package/dist/cjs/snowplow/Snowplow.js.map +1 -1
- package/dist/cjs/snowplow/SnowplowContext.js +41 -0
- package/dist/cjs/snowplow/SnowplowContext.js.map +2 -2
- package/dist/cjs/snowplow/contexts.js.map +1 -1
- package/dist/cjs/snowplow/event-definitions/index.js +41 -0
- package/dist/cjs/snowplow/event-definitions/index.js.map +2 -2
- package/dist/cjs/snowplow/event-definitions/questionnaire/questionnaire.js +41 -0
- package/dist/cjs/snowplow/event-definitions/questionnaire/questionnaire.js.map +2 -2
- package/dist/cjs/snowplow/index.js +41 -0
- package/dist/cjs/snowplow/index.js.map +2 -2
- package/dist/cjs/utils/testUtils.js +41 -0
- package/dist/cjs/utils/testUtils.js.map +2 -2
- package/dist/esm/{chunk-3U2OGG7X.js → chunk-GVMIPHNF.js} +42 -1
- package/dist/esm/{chunk-3U2OGG7X.js.map → chunk-GVMIPHNF.js.map} +2 -2
- package/dist/esm/{chunk-TN5IBPWO.js → chunk-MZ7BEV3O.js} +1 -1
- package/dist/esm/{chunk-TN5IBPWO.js.map → chunk-MZ7BEV3O.js.map} +1 -1
- package/dist/esm/{chunk-2TWF6FRS.js → chunk-N5QMO2XU.js} +2 -2
- package/dist/esm/{chunk-YL4B2IYT.js → chunk-OO2V7OSK.js} +4 -4
- package/dist/esm/{chunk-2NJVETWD.js → chunk-WZR7RV55.js} +2 -2
- package/dist/esm/index.js +5 -5
- package/dist/esm/meta.json +49 -49
- package/dist/esm/snowplow/Snowplow.js +2 -2
- package/dist/esm/snowplow/SnowplowContext.js +5 -5
- package/dist/esm/snowplow/contexts.js +1 -1
- package/dist/esm/snowplow/event-definitions/index.js +2 -2
- package/dist/esm/snowplow/event-definitions/questionnaire/questionnaire.js +1 -1
- package/dist/esm/snowplow/index.js +5 -5
- package/dist/esm/utils/testUtils.js +5 -5
- package/dist/esm/utils/testUtils.js.map +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/mocks/eventDefinitions.d.ts +3 -3
- package/package.json +19 -18
- package/src/snowplow/SnowplowContext.test.tsx +1 -4
- package/src/snowplow/contexts.test.ts +2 -2
- package/src/snowplow/contexts.ts +1 -1
- package/src/snowplow/event-definitions/questionnaire/questionnaire.test.ts +78 -0
- package/src/snowplow/event-definitions/questionnaire/questionnaire.ts +43 -0
- package/src/snowplow/index.test.ts +5 -5
- package/src/utils/testUtils.tsx +1 -2
- /package/dist/esm/{chunk-2TWF6FRS.js.map → chunk-N5QMO2XU.js.map} +0 -0
- /package/dist/esm/{chunk-YL4B2IYT.js.map → chunk-OO2V7OSK.js.map} +0 -0
- /package/dist/esm/{chunk-2NJVETWD.js.map → chunk-WZR7RV55.js.map} +0 -0
|
@@ -927,4 +927,82 @@ describe("questionnaireEventDefinitions", () => {
|
|
|
927
927
|
});
|
|
928
928
|
});
|
|
929
929
|
});
|
|
930
|
+
|
|
931
|
+
describe("interstitialUsPhoneNumberSmsConsentSkipped", () => {
|
|
932
|
+
it("should create correct payload", () => {
|
|
933
|
+
const result = findEventByName(
|
|
934
|
+
questionnaireEventDefinitions,
|
|
935
|
+
"interstitialUsPhoneNumberSmsConsentSkipped",
|
|
936
|
+
).makePayload({});
|
|
937
|
+
|
|
938
|
+
expect(result).toEqual({
|
|
939
|
+
category: "us_phone_number_modal",
|
|
940
|
+
action: "interstitial_us_phone_number_sms_consent_skipped",
|
|
941
|
+
property: window?.location?.href ?? "",
|
|
942
|
+
});
|
|
943
|
+
});
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
describe("interstitialUsPhoneNumberSubmitted", () => {
|
|
947
|
+
it("should create correct payload with consent label and view name", () => {
|
|
948
|
+
const result = findEventByName(
|
|
949
|
+
questionnaireEventDefinitions,
|
|
950
|
+
"interstitialUsPhoneNumberSubmitted",
|
|
951
|
+
).makePayload({
|
|
952
|
+
consentLabel: "Yes, I agree",
|
|
953
|
+
viewName: "smsConsent",
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
expect(result).toEqual({
|
|
957
|
+
category: "us_phone_number_modal",
|
|
958
|
+
action: "interstitial_us_phone_number_submitted",
|
|
959
|
+
label: "consent_given_from_smsConsent",
|
|
960
|
+
property: window?.location?.href ?? "",
|
|
961
|
+
});
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
it("should handle empty consent label and view name", () => {
|
|
965
|
+
const result = findEventByName(
|
|
966
|
+
questionnaireEventDefinitions,
|
|
967
|
+
"interstitialUsPhoneNumberSubmitted",
|
|
968
|
+
).makePayload({});
|
|
969
|
+
|
|
970
|
+
expect(result).toEqual({
|
|
971
|
+
category: "us_phone_number_modal",
|
|
972
|
+
action: "interstitial_us_phone_number_submitted",
|
|
973
|
+
label: "no_consent_from_no_view",
|
|
974
|
+
property: window?.location?.href ?? "",
|
|
975
|
+
});
|
|
976
|
+
});
|
|
977
|
+
});
|
|
978
|
+
|
|
979
|
+
describe("interstitialUsPhoneNumberInvalidPhoneNumber", () => {
|
|
980
|
+
it("should create correct payload", () => {
|
|
981
|
+
const result = findEventByName(
|
|
982
|
+
questionnaireEventDefinitions,
|
|
983
|
+
"interstitialUsPhoneNumberInvalidPhoneNumber",
|
|
984
|
+
).makePayload({});
|
|
985
|
+
|
|
986
|
+
expect(result).toEqual({
|
|
987
|
+
category: "us_phone_number_modal",
|
|
988
|
+
action: "interstitial_us_invalid_phone_number_submitted",
|
|
989
|
+
label: "invalid_phone_number_submitted_from_no_view",
|
|
990
|
+
property: window?.location?.href ?? "",
|
|
991
|
+
});
|
|
992
|
+
});
|
|
993
|
+
|
|
994
|
+
it("should include viewName in label when provided", () => {
|
|
995
|
+
const result = findEventByName(
|
|
996
|
+
questionnaireEventDefinitions,
|
|
997
|
+
"interstitialUsPhoneNumberInvalidPhoneNumber",
|
|
998
|
+
).makePayload({ viewName: "smsConsent" });
|
|
999
|
+
|
|
1000
|
+
expect(result).toEqual({
|
|
1001
|
+
category: "us_phone_number_modal",
|
|
1002
|
+
action: "interstitial_us_invalid_phone_number_submitted",
|
|
1003
|
+
label: "invalid_phone_number_submitted_from_smsConsent",
|
|
1004
|
+
property: window?.location?.href ?? "",
|
|
1005
|
+
});
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
930
1008
|
});
|
|
@@ -359,4 +359,47 @@ export const questionnaireEventDefinitions: EventDefinition[] = [
|
|
|
359
359
|
};
|
|
360
360
|
},
|
|
361
361
|
},
|
|
362
|
+
{
|
|
363
|
+
name: "interstitialUsPhoneNumberSmsConsentSkipped",
|
|
364
|
+
type: "structured",
|
|
365
|
+
makePayload: () => {
|
|
366
|
+
return {
|
|
367
|
+
category: "us_phone_number_modal",
|
|
368
|
+
action: "interstitial_us_phone_number_sms_consent_skipped",
|
|
369
|
+
property: window?.location?.href ?? "",
|
|
370
|
+
};
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: "interstitialUsPhoneNumberSubmitted",
|
|
375
|
+
type: "structured",
|
|
376
|
+
makePayload: params => {
|
|
377
|
+
const { consentLabel, viewName } = params as ParamsType;
|
|
378
|
+
const consent = consentLabel?.trim();
|
|
379
|
+
const consentName =
|
|
380
|
+
consent === "Yes, I agree" ? "consent_given" : consent || "no_consent";
|
|
381
|
+
const name = viewName?.trim() || "no_view";
|
|
382
|
+
|
|
383
|
+
return {
|
|
384
|
+
category: "us_phone_number_modal",
|
|
385
|
+
action: "interstitial_us_phone_number_submitted",
|
|
386
|
+
label: `${consentName}_from_${name}`,
|
|
387
|
+
property: window?.location?.href ?? "",
|
|
388
|
+
};
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
name: "interstitialUsPhoneNumberInvalidPhoneNumber",
|
|
393
|
+
type: "structured",
|
|
394
|
+
makePayload: params => {
|
|
395
|
+
const { viewName } = params as ParamsType;
|
|
396
|
+
const name = viewName?.trim() || "no_view";
|
|
397
|
+
return {
|
|
398
|
+
category: "us_phone_number_modal",
|
|
399
|
+
action: "interstitial_us_invalid_phone_number_submitted",
|
|
400
|
+
label: `invalid_phone_number_submitted_from_${name}`,
|
|
401
|
+
property: window?.location?.href ?? "",
|
|
402
|
+
};
|
|
403
|
+
},
|
|
404
|
+
},
|
|
362
405
|
];
|
|
@@ -5,13 +5,13 @@ import { pageData } from "../mocks/scripts-mock";
|
|
|
5
5
|
import { getContexts, makeContexts } from "./contexts";
|
|
6
6
|
import { getSnowplowConfig } from "./getSnowplowConfig";
|
|
7
7
|
import { Snowplow } from "./Snowplow";
|
|
8
|
-
import type { EventDefinition,
|
|
8
|
+
import type { EventDefinition, TrackingProps } from "./types";
|
|
9
9
|
|
|
10
|
-
const snowplowProps = getSnowplowConfig(pageData
|
|
10
|
+
const snowplowProps = getSnowplowConfig(pageData);
|
|
11
11
|
const contexts = getContexts(snowplowProps as TrackingProps);
|
|
12
12
|
const fqaContext = makeContexts(["distributionChannelContext"], contexts);
|
|
13
13
|
|
|
14
|
-
let testSnowplow = new Snowplow(snowplowProps
|
|
14
|
+
let testSnowplow = new Snowplow(snowplowProps);
|
|
15
15
|
testSnowplow.setContexts(contexts);
|
|
16
16
|
|
|
17
17
|
describe("Snowplow Analytics Class", () => {
|
|
@@ -24,14 +24,14 @@ describe("Snowplow Analytics Class", () => {
|
|
|
24
24
|
|
|
25
25
|
describe("given snowplowProps exist", () => {
|
|
26
26
|
beforeEach(() => {
|
|
27
|
-
testSnowplow = new Snowplow(snowplowProps
|
|
27
|
+
testSnowplow = new Snowplow(snowplowProps);
|
|
28
28
|
testSnowplow.setContexts(contexts);
|
|
29
29
|
vi.clearAllMocks();
|
|
30
30
|
vi.resetModules();
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
it("exports a Singleton instance with static properties", () => {
|
|
34
|
-
const secondInstance = new Snowplow(snowplowProps
|
|
34
|
+
const secondInstance = new Snowplow(snowplowProps);
|
|
35
35
|
secondInstance.setContexts(contexts);
|
|
36
36
|
|
|
37
37
|
expect(testSnowplow).toEqual(secondInstance);
|
package/src/utils/testUtils.tsx
CHANGED
|
@@ -4,10 +4,9 @@ import type { ReactElement, ReactNode } from "react";
|
|
|
4
4
|
import { pageData } from "../mocks/scripts-mock";
|
|
5
5
|
import { SnowplowProvider } from "../snowplow/SnowplowContext";
|
|
6
6
|
import { getSnowplowConfig } from "../snowplow/getSnowplowConfig";
|
|
7
|
-
import type { PageDataProps } from "../snowplow/types";
|
|
8
7
|
|
|
9
8
|
// Snowplow analytics
|
|
10
|
-
const snowplowProps = getSnowplowConfig(pageData
|
|
9
|
+
const snowplowProps = getSnowplowConfig(pageData);
|
|
11
10
|
|
|
12
11
|
const ProvidersMock = ({ children }: { children: ReactNode }) => (
|
|
13
12
|
<SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|