@simplybusiness/services 0.8.0 → 0.13.1

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/cjs/mocks/eventDefinitions.js +39 -0
  3. package/dist/cjs/mocks/eventDefinitions.js.map +1 -1
  4. package/dist/cjs/snowplow/Snowplow.js +13 -2
  5. package/dist/cjs/snowplow/Snowplow.js.map +1 -1
  6. package/dist/cjs/snowplow/event-definitions/base.js +39 -0
  7. package/dist/cjs/snowplow/event-definitions/base.js.map +1 -1
  8. package/dist/cjs/snowplow/event-definitions/index.js +9 -2
  9. package/dist/cjs/snowplow/event-definitions/index.js.map +1 -1
  10. package/dist/cjs/snowplow/event-definitions/qcp.js +14 -0
  11. package/dist/cjs/snowplow/event-definitions/qcp.js.map +1 -1
  12. package/dist/cjs/snowplow/event-definitions/questionnaire.js +49 -0
  13. package/dist/cjs/snowplow/event-definitions/questionnaire.js.map +1 -0
  14. package/dist/cjs/snowplow/event-definitions/redaction.js +152 -0
  15. package/dist/cjs/snowplow/event-definitions/redaction.js.map +1 -0
  16. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  17. package/dist/esm/mocks/eventDefinitions.js +39 -0
  18. package/dist/esm/mocks/eventDefinitions.js.map +1 -1
  19. package/dist/esm/snowplow/Snowplow.js +13 -2
  20. package/dist/esm/snowplow/Snowplow.js.map +1 -1
  21. package/dist/esm/snowplow/event-definitions/base.js +39 -0
  22. package/dist/esm/snowplow/event-definitions/base.js.map +1 -1
  23. package/dist/esm/snowplow/event-definitions/index.js +6 -2
  24. package/dist/esm/snowplow/event-definitions/index.js.map +1 -1
  25. package/dist/esm/snowplow/event-definitions/qcp.js +14 -0
  26. package/dist/esm/snowplow/event-definitions/qcp.js.map +1 -1
  27. package/dist/esm/snowplow/event-definitions/questionnaire.js +40 -0
  28. package/dist/esm/snowplow/event-definitions/questionnaire.js.map +1 -0
  29. package/dist/esm/snowplow/event-definitions/redaction.js +142 -0
  30. package/dist/esm/snowplow/event-definitions/redaction.js.map +1 -0
  31. package/dist/esm/snowplow/types.js.map +1 -1
  32. package/dist/types/mocks/eventDefinitions.d.ts +30 -0
  33. package/dist/types/snowplow/Snowplow.d.ts +1 -0
  34. package/dist/types/snowplow/event-definitions/index.d.ts +1 -0
  35. package/dist/types/snowplow/event-definitions/questionnaire.d.ts +2 -0
  36. package/dist/types/snowplow/event-definitions/redaction.d.ts +5 -0
  37. package/dist/types/snowplow/types.d.ts +15 -1
  38. package/package.json +2 -2
  39. package/src/mocks/eventDefinitions.ts +44 -0
  40. package/src/snowplow/Snowplow.ts +16 -2
  41. package/src/snowplow/event-definitions/base.ts +43 -2
  42. package/src/snowplow/event-definitions/index.ts +4 -0
  43. package/src/snowplow/event-definitions/qcp.ts +17 -1
  44. package/src/snowplow/event-definitions/questionnaire.ts +43 -0
  45. package/src/snowplow/event-definitions/redaction.ts +144 -0
  46. package/src/snowplow/index.test.ts +179 -6
  47. package/src/snowplow/types.ts +17 -15
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @simplybusiness/mobius@5.15.5
8
+
9
+ ## 0.13.0
10
+
11
+ ### Minor Changes
12
+
13
+ - fc1e967: Add GL+IM combined QCPRedirect component
14
+
15
+ ## 0.12.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 54bfcb4: Redact question and answers for snowplow event - form_question_answered
20
+ - 0683996: adding help text opened event definition and trigger it
21
+
22
+ ## 0.11.0
23
+
24
+ ### Minor Changes
25
+
26
+ - 059302c: Add manual address analytics event
27
+
28
+ ## 0.10.0
29
+
30
+ ### Minor Changes
31
+
32
+ - d5c6ff8: Questionnaire: Add navigation analytics events
33
+ - 1016003: Add Assumptions page analytics events
34
+
35
+ ## 0.9.0
36
+
37
+ ### Minor Changes
38
+
39
+ - 666f5a5: Add context to makePayload function
40
+
3
41
  ## 0.8.0
4
42
 
5
43
  ### Minor Changes
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "default", {
8
8
  return _default;
9
9
  }
10
10
  });
11
+ const _redaction = require("../snowplow/event-definitions/redaction");
11
12
  const _default = [
12
13
  {
13
14
  name: "navButtonClicked",
@@ -40,6 +41,44 @@ const _default = [
40
41
  }
41
42
  };
42
43
  }
44
+ },
45
+ {
46
+ name: "questionAnswered",
47
+ type: "unstructured",
48
+ makePayload: (params)=>{
49
+ const { section, context } = params;
50
+ const { question, answer } = (0, _redaction.redact)(params);
51
+ return {
52
+ schema: "iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-3",
53
+ data: {
54
+ site: context.site,
55
+ page_index: 1,
56
+ page_name: "quick_to_quote",
57
+ submitted_from: "quick_to_quote_experiment",
58
+ section_name: section,
59
+ question,
60
+ answer,
61
+ vertical: context.vertical
62
+ }
63
+ };
64
+ }
65
+ },
66
+ {
67
+ name: "helpTextOpened",
68
+ type: "unstructured",
69
+ makePayload: (params)=>{
70
+ const { primaryText, label, context } = params;
71
+ return {
72
+ schema: "iglu:com.simplybusiness/help_text_opened/jsonschema/1-1-0",
73
+ data: {
74
+ vertical: context.vertical,
75
+ site: context.site,
76
+ primary_text: primaryText,
77
+ label,
78
+ page_name: "quick_to_quote"
79
+ }
80
+ };
81
+ }
43
82
  }
44
83
  ];
45
84
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mocks/eventDefinitions.ts"],"sourcesContent":["export default [\n {\n name: \"navButtonClicked\",\n type: \"structured\",\n makePayload: (params: { label: \"next\" | \"back\" | \"redirect\" }) => {\n const { label } = params;\n return {\n category: \"navigation\",\n action: \"thankyou_navigation_button_click\",\n label,\n property: \"test-property\",\n };\n },\n },\n {\n name: \"questionAnswered\",\n type: \"unstructured\",\n makePayload: (params: {\n vertical?: string;\n question: string;\n answer?: string;\n }) => {\n const { vertical, question, answer } = params;\n return {\n schema:\n \"iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-1\",\n data: {\n site: \"\",\n vertical: vertical || \"business\",\n page_index: 1,\n page_name: \"Coverage diagnosis questionnaire\",\n section_name: \"Coverage diagnosis questionnaire\",\n question,\n answer,\n },\n };\n },\n },\n];\n"],"names":["name","type","makePayload","params","label","category","action","property","vertical","question","answer","schema","data","site","page_index","page_name","section_name"],"mappings":";;;;+BAAA;;;eAAA;;;MAAA,WAAe;IACb;QACEA,MAAM;QACNC,MAAM;QACNC,aAAa,CAACC;YACZ,MAAM,EAAEC,KAAK,EAAE,GAAGD;YAClB,OAAO;gBACLE,UAAU;gBACVC,QAAQ;gBACRF;gBACAG,UAAU;YACZ;QACF;IACF;IACA;QACEP,MAAM;QACNC,MAAM;QACNC,aAAa,CAACC;YAKZ,MAAM,EAAEK,QAAQ,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGP;YACvC,OAAO;gBACLQ,QACE;gBACFC,MAAM;oBACJC,MAAM;oBACNL,UAAUA,YAAY;oBACtBM,YAAY;oBACZC,WAAW;oBACXC,cAAc;oBACdP;oBACAC;gBACF;YACF;QACF;IACF;CACD"}
1
+ {"version":3,"sources":["../../../src/mocks/eventDefinitions.ts"],"sourcesContent":["import { ParamsType } from \"../snowplow\";\nimport { redact } from \"../snowplow/event-definitions/redaction\";\n\nexport default [\n {\n name: \"navButtonClicked\",\n type: \"structured\",\n makePayload: (params: { label: \"next\" | \"back\" | \"redirect\" }) => {\n const { label } = params;\n return {\n category: \"navigation\",\n action: \"thankyou_navigation_button_click\",\n label,\n property: \"test-property\",\n };\n },\n },\n {\n name: \"questionAnswered\",\n type: \"unstructured\",\n makePayload: (params: {\n vertical?: string;\n question: string;\n answer?: string;\n }) => {\n const { vertical, question, answer } = params;\n return {\n schema:\n \"iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-1\",\n data: {\n site: \"\",\n vertical: vertical || \"business\",\n page_index: 1,\n page_name: \"Coverage diagnosis questionnaire\",\n section_name: \"Coverage diagnosis questionnaire\",\n question,\n answer,\n },\n };\n },\n },\n {\n name: \"questionAnswered\",\n type: \"unstructured\",\n makePayload: (params: ParamsType) => {\n const { section, context } = params as ParamsType;\n const { question, answer } = redact(params as ParamsType);\n\n return {\n schema:\n \"iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-3\",\n data: {\n site: context.site,\n page_index: 1,\n page_name: \"quick_to_quote\",\n submitted_from: \"quick_to_quote_experiment\",\n section_name: section,\n question,\n answer,\n vertical: context.vertical,\n },\n };\n },\n },\n {\n name: \"helpTextOpened\",\n type: \"unstructured\",\n makePayload: (params: ParamsType) => {\n const { primaryText, label, context } = params as ParamsType;\n\n return {\n schema: \"iglu:com.simplybusiness/help_text_opened/jsonschema/1-1-0\",\n data: {\n vertical: context.vertical,\n site: context.site,\n primary_text: primaryText,\n label,\n page_name: \"quick_to_quote\",\n },\n };\n },\n },\n];\n"],"names":["name","type","makePayload","params","label","category","action","property","vertical","question","answer","schema","data","site","page_index","page_name","section_name","section","context","redact","submitted_from","primaryText","primary_text"],"mappings":";;;;+BAGA;;;eAAA;;;2BAFuB;MAEvB,WAAe;IACb;QACEA,MAAM;QACNC,MAAM;QACNC,aAAa,CAACC;YACZ,MAAM,EAAEC,KAAK,EAAE,GAAGD;YAClB,OAAO;gBACLE,UAAU;gBACVC,QAAQ;gBACRF;gBACAG,UAAU;YACZ;QACF;IACF;IACA;QACEP,MAAM;QACNC,MAAM;QACNC,aAAa,CAACC;YAKZ,MAAM,EAAEK,QAAQ,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGP;YACvC,OAAO;gBACLQ,QACE;gBACFC,MAAM;oBACJC,MAAM;oBACNL,UAAUA,YAAY;oBACtBM,YAAY;oBACZC,WAAW;oBACXC,cAAc;oBACdP;oBACAC;gBACF;YACF;QACF;IACF;IACA;QACEV,MAAM;QACNC,MAAM;QACNC,aAAa,CAACC;YACZ,MAAM,EAAEc,OAAO,EAAEC,OAAO,EAAE,GAAGf;YAC7B,MAAM,EAAEM,QAAQ,EAAEC,MAAM,EAAE,GAAGS,IAAAA,iBAAM,EAAChB;YAEpC,OAAO;gBACLQ,QACE;gBACFC,MAAM;oBACJC,MAAMK,QAAQL,IAAI;oBAClBC,YAAY;oBACZC,WAAW;oBACXK,gBAAgB;oBAChBJ,cAAcC;oBACdR;oBACAC;oBACAF,UAAUU,QAAQV,QAAQ;gBAC5B;YACF;QACF;IACF;IACA;QACER,MAAM;QACNC,MAAM;QACNC,aAAa,CAACC;YACZ,MAAM,EAAEkB,WAAW,EAAEjB,KAAK,EAAEc,OAAO,EAAE,GAAGf;YAExC,OAAO;gBACLQ,QAAQ;gBACRC,MAAM;oBACJJ,UAAUU,QAAQV,QAAQ;oBAC1BK,MAAMK,QAAQL,IAAI;oBAClBS,cAAcD;oBACdjB;oBACAW,WAAW;gBACb;YACF;QACF;IACF;CACD"}
@@ -69,15 +69,23 @@ class Snowplow {
69
69
  return this;
70
70
  }
71
71
  addEventHandlers(eventDefinitions) {
72
+ // Add server context to makePayload functions
73
+ const context = this.serverData;
72
74
  eventDefinitions.forEach(({ name, type, makePayload })=>{
73
75
  // Convert type into relevant function
74
76
  if (type === "structured") {
75
77
  this.addEventHandler(name, (params)=>{
76
- this.trackEvent(makePayload(params));
78
+ this.trackEvent(makePayload({
79
+ ...params,
80
+ context
81
+ }));
77
82
  });
78
83
  } else {
79
84
  this.addEventHandler(name, (params)=>{
80
- this.trackUnstructEvent(makePayload(params));
85
+ this.trackUnstructEvent(makePayload({
86
+ ...params,
87
+ context
88
+ }));
81
89
  });
82
90
  }
83
91
  });
@@ -98,12 +106,14 @@ class Snowplow {
98
106
  return this;
99
107
  }
100
108
  constructor(props){
109
+ var _props_pageViewContext;
101
110
  _define_property(this, "avalancheTrackerName", "sb-ava");
102
111
  _define_property(this, "bronzeAvalancheTrackerName", "sb-ava-br");
103
112
  _define_property(this, "pvAvalancheTrackerName", "sb-ava-pv");
104
113
  _define_property(this, "uid", "");
105
114
  _define_property(this, "trackPageView", false);
106
115
  _define_property(this, "contexts", []);
116
+ _define_property(this, "serverData", {});
107
117
  _define_property(this, "eventHandlers", {});
108
118
  if (!props) return;
109
119
  const { appId, cookieDomain, avalancheCollector, eventMethod, uid, postPath, // includeGAContext,
@@ -111,6 +121,7 @@ class Snowplow {
111
121
  trackPageView: tpv } = props;
112
122
  this.uid = uid;
113
123
  this.trackPageView = tpv;
124
+ this.serverData = (props === null || props === void 0 ? void 0 : (_props_pageViewContext = props.pageViewContext) === null || _props_pageViewContext === void 0 ? void 0 : _props_pageViewContext.data) || {};
114
125
  // Set options
115
126
  const stateStorageStrategy = "cookieAndLocalStorage";
116
127
  const baseOptions = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/snowplow/Snowplow.ts"],"sourcesContent":["import {\n SelfDescribingJson,\n StructuredEvent,\n TrackerConfiguration,\n newTracker,\n setCookiePath,\n setUserId,\n trackPageView,\n trackSelfDescribingEvent,\n trackStructEvent,\n} from \"@snowplow/browser-tracker\";\nimport { EventDefinition, TrackingProps } from \"./types\";\n\nexport type FrontOfficeStructuredEvent = StructuredEvent & {\n serviceChannelIdentifier: string;\n};\n\n/**\n * This class is an abstraction which wraps Snowplow\n * and exposes common methods with other services:\n * - trackEvent : sends a standard payload\n * - trackUnstructEvent : sends a payload for custom schema\n */\nexport class Snowplow {\n avalancheTrackerName = \"sb-ava\";\n\n bronzeAvalancheTrackerName = \"sb-ava-br\";\n\n pvAvalancheTrackerName = \"sb-ava-pv\";\n\n uid: unknown = \"\";\n\n trackPageView: boolean = false;\n\n contexts: SelfDescribingJson<Record<string, unknown>>[] = [];\n\n eventHandlers: Record<string, (params?: Record<string, unknown>) => void> =\n {};\n\n constructor(props?: TrackingProps) {\n if (!props) return;\n\n const {\n appId,\n cookieDomain,\n avalancheCollector,\n eventMethod,\n uid,\n postPath,\n // includeGAContext,\n // trackActivity,\n trackPageView: tpv,\n } = props;\n this.uid = uid;\n this.trackPageView = tpv;\n\n // Set options\n const stateStorageStrategy = \"cookieAndLocalStorage\";\n const baseOptions: TrackerConfiguration = {\n appId,\n cookieDomain,\n eventMethod,\n stateStorageStrategy,\n postPath,\n };\n // Initialize trackers\n newTracker(this.avalancheTrackerName, avalancheCollector, baseOptions);\n\n newTracker(\n this.bronzeAvalancheTrackerName,\n avalancheCollector,\n baseOptions,\n );\n\n // Page view tracker\n newTracker(this.pvAvalancheTrackerName, avalancheCollector, {\n ...baseOptions,\n eventMethod: eventMethod === \"post\" ? \"beacon\" : eventMethod,\n });\n\n setCookiePath(\"/\");\n if (uid) {\n setUserId(uid);\n }\n }\n\n setContexts(contexts: SelfDescribingJson<Record<string, unknown>>[]) {\n this.contexts = contexts;\n // Update identity context\n const index = this.contexts?.findIndex(ctx =>\n ctx.schema?.includes(\"identity_context\"),\n );\n if (index > -1) {\n this.contexts[index].data.domain_userid = this.uid;\n }\n return this;\n }\n\n // Send a page view event\n trackView() {\n if (this.trackPageView) {\n trackPageView({ context: this.contexts });\n }\n return this;\n }\n\n // Send a structured event with contexts\n async trackEvent(event: StructuredEvent) {\n await trackStructEvent({ ...event, context: this.contexts }, [\n this.bronzeAvalancheTrackerName,\n ]);\n return this;\n }\n\n // Send a custom event with defined schema and optional contexts\n async trackUnstructEvent(event: SelfDescribingJson<Record<string, unknown>>) {\n if (!event) {\n return this;\n }\n await trackSelfDescribingEvent({ event, context: this.contexts }, [\n this.avalancheTrackerName,\n ]);\n return this;\n }\n\n addEventHandlers(eventDefinitions: EventDefinition[]) {\n eventDefinitions.forEach(({ name, type, makePayload }) => {\n // Convert type into relevant function\n if (type === \"structured\") {\n this.addEventHandler(name, (params?: Record<string, unknown>) => {\n this.trackEvent(makePayload(params) as StructuredEvent);\n });\n } else {\n this.addEventHandler(name, (params?: Record<string, unknown>) => {\n this.trackUnstructEvent(\n makePayload(params) as SelfDescribingJson<Record<string, unknown>>,\n );\n });\n }\n });\n return this;\n }\n\n private addEventHandler(\n name: string,\n handler: (params?: Record<string, unknown>) => void,\n ) {\n this.eventHandlers[name] = handler;\n return this;\n }\n\n private removeEventHandler(name: string) {\n delete this.eventHandlers[name];\n return this;\n }\n\n trigger(name: string, params?: Record<string, unknown>) {\n if (this.eventHandlers[name]) {\n this.eventHandlers[name](params);\n }\n return this;\n }\n}\n"],"names":["Snowplow","setContexts","contexts","index","findIndex","ctx","schema","includes","data","domain_userid","uid","trackView","trackPageView","context","trackEvent","event","trackStructEvent","bronzeAvalancheTrackerName","trackUnstructEvent","trackSelfDescribingEvent","avalancheTrackerName","addEventHandlers","eventDefinitions","forEach","name","type","makePayload","addEventHandler","params","handler","eventHandlers","removeEventHandler","trigger","constructor","props","pvAvalancheTrackerName","appId","cookieDomain","avalancheCollector","eventMethod","postPath","tpv","stateStorageStrategy","baseOptions","newTracker","setCookiePath","setUserId"],"mappings":";;;;+BAuBaA;;;eAAAA;;;gCAbN;;;;;;;;;;;;;;AAaA,MAAMA;IA+DXC,YAAYC,QAAuD,EAAE;YAGrD;QAFd,IAAI,CAACA,QAAQ,GAAGA;QAChB,0BAA0B;QAC1B,MAAMC,SAAQ,iBAAA,IAAI,CAACD,QAAQ,cAAb,qCAAA,eAAeE,SAAS,CAACC,CAAAA;gBACrCA;oBAAAA,cAAAA,IAAIC,MAAM,cAAVD,kCAAAA,YAAYE,QAAQ,CAAC;;QAEvB,IAAIJ,QAAQ,CAAC,GAAG;YACd,IAAI,CAACD,QAAQ,CAACC,MAAM,CAACK,IAAI,CAACC,aAAa,GAAG,IAAI,CAACC,GAAG;QACpD;QACA,OAAO,IAAI;IACb;IAEA,yBAAyB;IACzBC,YAAY;QACV,IAAI,IAAI,CAACC,aAAa,EAAE;YACtBA,IAAAA,6BAAa,EAAC;gBAAEC,SAAS,IAAI,CAACX,QAAQ;YAAC;QACzC;QACA,OAAO,IAAI;IACb;IAEA,wCAAwC;IACxC,MAAMY,WAAWC,KAAsB,EAAE;QACvC,MAAMC,IAAAA,gCAAgB,EAAC;YAAE,GAAGD,KAAK;YAAEF,SAAS,IAAI,CAACX,QAAQ;QAAC,GAAG;YAC3D,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,iBACE,CAAC;QAGD,IAAI,CAACI,OAAO;QAEZ,MAAM,EACJE,KAAK,EACLC,YAAY,EACZC,kBAAkB,EAClBC,WAAW,EACX7B,GAAG,EACH8B,QAAQ,EACR,oBAAoB;QACpB,iBAAiB;QACjB5B,eAAe6B,GAAG,EACnB,GAAGP;QACJ,IAAI,CAACxB,GAAG,GAAGA;QACX,IAAI,CAACE,aAAa,GAAG6B;QAErB,cAAc;QACd,MAAMC,uBAAuB;QAC7B,MAAMC,cAAoC;YACxCP;YACAC;YACAE;YACAG;YACAF;QACF;QACA,sBAAsB;QACtBI,IAAAA,0BAAU,EAAC,IAAI,CAACxB,oBAAoB,EAAEkB,oBAAoBK;QAE1DC,IAAAA,0BAAU,EACR,IAAI,CAAC3B,0BAA0B,EAC/BqB,oBACAK;QAGF,oBAAoB;QACpBC,IAAAA,0BAAU,EAAC,IAAI,CAACT,sBAAsB,EAAEG,oBAAoB;YAC1D,GAAGK,WAAW;YACdJ,aAAaA,gBAAgB,SAAS,WAAWA;QACnD;QAEAM,IAAAA,6BAAa,EAAC;QACd,IAAInC,KAAK;YACPoC,IAAAA,yBAAS,EAACpC;QACZ;IACF;AA8EF"}
1
+ {"version":3,"sources":["../../../src/snowplow/Snowplow.ts"],"sourcesContent":["import {\n SelfDescribingJson,\n StructuredEvent,\n TrackerConfiguration,\n newTracker,\n setCookiePath,\n setUserId,\n trackPageView,\n trackSelfDescribingEvent,\n trackStructEvent,\n} from \"@snowplow/browser-tracker\";\nimport { EventDefinition, TrackingProps } from \"./types\";\n\nexport type FrontOfficeStructuredEvent = StructuredEvent & {\n serviceChannelIdentifier: string;\n};\n\n/**\n * This class is an abstraction which wraps Snowplow\n * and exposes common methods with other services:\n * - trackEvent : sends a standard payload\n * - trackUnstructEvent : sends a payload for custom schema\n */\nexport class Snowplow {\n avalancheTrackerName = \"sb-ava\";\n\n bronzeAvalancheTrackerName = \"sb-ava-br\";\n\n pvAvalancheTrackerName = \"sb-ava-pv\";\n\n uid: unknown = \"\";\n\n trackPageView: boolean = false;\n\n contexts: SelfDescribingJson<Record<string, unknown>>[] = [];\n\n serverData: Record<string, unknown> = {};\n\n eventHandlers: Record<string, (params?: Record<string, unknown>) => void> =\n {};\n\n constructor(props?: TrackingProps) {\n if (!props) return;\n\n const {\n appId,\n cookieDomain,\n avalancheCollector,\n eventMethod,\n uid,\n postPath,\n // includeGAContext,\n // trackActivity,\n trackPageView: tpv,\n } = props;\n this.uid = uid;\n this.trackPageView = tpv;\n this.serverData = props?.pageViewContext?.data || {};\n\n // Set options\n const stateStorageStrategy = \"cookieAndLocalStorage\";\n const baseOptions: TrackerConfiguration = {\n appId,\n cookieDomain,\n eventMethod,\n stateStorageStrategy,\n postPath,\n };\n // Initialize trackers\n newTracker(this.avalancheTrackerName, avalancheCollector, baseOptions);\n\n newTracker(\n this.bronzeAvalancheTrackerName,\n avalancheCollector,\n baseOptions,\n );\n\n // Page view tracker\n newTracker(this.pvAvalancheTrackerName, avalancheCollector, {\n ...baseOptions,\n eventMethod: eventMethod === \"post\" ? \"beacon\" : eventMethod,\n });\n\n setCookiePath(\"/\");\n if (uid) {\n setUserId(uid);\n }\n }\n\n setContexts(contexts: SelfDescribingJson<Record<string, unknown>>[]) {\n this.contexts = contexts;\n // Update identity context\n const index = this.contexts?.findIndex(ctx =>\n ctx.schema?.includes(\"identity_context\"),\n );\n if (index > -1) {\n this.contexts[index].data.domain_userid = this.uid;\n }\n return this;\n }\n\n // Send a page view event\n trackView() {\n if (this.trackPageView) {\n trackPageView({ context: this.contexts });\n }\n return this;\n }\n\n // Send a structured event with contexts\n async trackEvent(event: StructuredEvent) {\n await trackStructEvent({ ...event, context: this.contexts }, [\n this.bronzeAvalancheTrackerName,\n ]);\n return this;\n }\n\n // Send a custom event with defined schema and optional contexts\n async trackUnstructEvent(event: SelfDescribingJson<Record<string, unknown>>) {\n if (!event) {\n return this;\n }\n await trackSelfDescribingEvent({ event, context: this.contexts }, [\n this.avalancheTrackerName,\n ]);\n return this;\n }\n\n addEventHandlers(eventDefinitions: EventDefinition[]) {\n // Add server context to makePayload functions\n const context = this.serverData;\n\n eventDefinitions.forEach(({ name, type, makePayload }) => {\n // Convert type into relevant function\n if (type === \"structured\") {\n this.addEventHandler(name, (params?: Record<string, unknown>) => {\n this.trackEvent(\n makePayload({\n ...params,\n context,\n }) as StructuredEvent,\n );\n });\n } else {\n this.addEventHandler(name, (params?: Record<string, unknown>) => {\n this.trackUnstructEvent(\n makePayload({\n ...params,\n context,\n }) as SelfDescribingJson<Record<string, unknown>>,\n );\n });\n }\n });\n return this;\n }\n\n private addEventHandler(\n name: string,\n handler: (params?: Record<string, unknown>) => void,\n ) {\n this.eventHandlers[name] = handler;\n return this;\n }\n\n private removeEventHandler(name: string) {\n delete this.eventHandlers[name];\n return this;\n }\n\n trigger(name: string, params?: Record<string, unknown>) {\n if (this.eventHandlers[name]) {\n this.eventHandlers[name](params);\n }\n return this;\n }\n}\n"],"names":["Snowplow","setContexts","contexts","index","findIndex","ctx","schema","includes","data","domain_userid","uid","trackView","trackPageView","context","trackEvent","event","trackStructEvent","bronzeAvalancheTrackerName","trackUnstructEvent","trackSelfDescribingEvent","avalancheTrackerName","addEventHandlers","eventDefinitions","serverData","forEach","name","type","makePayload","addEventHandler","params","handler","eventHandlers","removeEventHandler","trigger","constructor","props","pvAvalancheTrackerName","appId","cookieDomain","avalancheCollector","eventMethod","postPath","tpv","pageViewContext","stateStorageStrategy","baseOptions","newTracker","setCookiePath","setUserId"],"mappings":";;;;+BAuBaA;;;eAAAA;;;gCAbN;;;;;;;;;;;;;;AAaA,MAAMA;IAkEXC,YAAYC,QAAuD,EAAE;YAGrD;QAFd,IAAI,CAACA,QAAQ,GAAGA;QAChB,0BAA0B;QAC1B,MAAMC,SAAQ,iBAAA,IAAI,CAACD,QAAQ,cAAb,qCAAA,eAAeE,SAAS,CAACC,CAAAA;gBACrCA;oBAAAA,cAAAA,IAAIC,MAAM,cAAVD,kCAAAA,YAAYE,QAAQ,CAAC;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oBACAM;QAGF,oBAAoB;QACpBC,IAAAA,0BAAU,EAAC,IAAI,CAACV,sBAAsB,EAAEG,oBAAoB;YAC1D,GAAGM,WAAW;YACdL,aAAaA,gBAAgB,SAAS,WAAWA;QACnD;QAEAO,IAAAA,6BAAa,EAAC;QACd,IAAIrC,KAAK;YACPsC,IAAAA,yBAAS,EAACtC;QACZ;IACF;AAyFF"}
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "baseEventDefinitions", {
8
8
  return baseEventDefinitions;
9
9
  }
10
10
  });
11
+ const _redaction = require("./redaction");
11
12
  const baseEventDefinitions = [
12
13
  // Mobile link in header
13
14
  {
@@ -31,6 +32,44 @@ const baseEventDefinitions = [
31
32
  data: {}
32
33
  }
33
34
  })
35
+ },
36
+ {
37
+ name: "questionAnswered",
38
+ type: "unstructured",
39
+ makePayload: (params)=>{
40
+ const { section, context } = params;
41
+ const { question, answer } = (0, _redaction.redact)(params);
42
+ return {
43
+ schema: "iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-3",
44
+ data: {
45
+ site: context.site,
46
+ page_index: 1,
47
+ page_name: "quick_to_quote",
48
+ submitted_from: "quick_to_quote_experiment",
49
+ section_name: section,
50
+ question,
51
+ answer,
52
+ vertical: context.vertical
53
+ }
54
+ };
55
+ }
56
+ },
57
+ {
58
+ name: "helpTextOpened",
59
+ type: "unstructured",
60
+ makePayload: (params)=>{
61
+ const { primaryText, label, context } = params;
62
+ return {
63
+ schema: "iglu:com.simplybusiness/help_text_opened/jsonschema/1-1-0",
64
+ data: {
65
+ vertical: context.vertical,
66
+ site: context.site,
67
+ primary_text: primaryText,
68
+ label,
69
+ page_name: "quick_to_quote"
70
+ }
71
+ };
72
+ }
34
73
  }
35
74
  ];
36
75
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/snowplow/event-definitions/base.ts"],"sourcesContent":["import { EventDefinition } from \"../types\";\n\n/**\n * Event definitions for Snowplow\n * @type {EventDefinition[]}\n * @property {string} name - The name of the event, to use when triggering\n * @property {string} type - The type of the event (structured | unstructured)\n * @property {makePayload} makePayload\n * - Function that creates the payload for the event;\n * - Allows optional params object to be passed in\n *\n * @example\n * Parent\n * import { getSnowplowConfig, SnowplowProvider } from \"@simplybusiness/services\";\n * const snowplowProps = getSnowplowConfig(pageData);\n * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>\n *\n * Child\n * import { useSnowplowContext } from \"@simplybusiness/services\";\n * const { snowplow } = useSnowplowContext();\n * const handlerFunction = () => snowplow?.trigger(\"eventNameHere\");\n */\n\n// Base page events\nexport const baseEventDefinitions: EventDefinition[] = [\n // Mobile link in header\n {\n name: \"mobileLinkClick\",\n type: \"structured\",\n makePayload: () => ({\n category: \"marketing\",\n action: \"link-click\",\n label: \"mobile_call_button\",\n property: window.location.href,\n }),\n },\n // Operating hours link in footer\n {\n name: \"operatingHoursClick\",\n type: \"unstructured\",\n makePayload: () => ({\n schema:\n \"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0\",\n data: {\n schema:\n \"iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2\",\n data: {},\n },\n }),\n },\n];\n"],"names":["baseEventDefinitions","name","type","makePayload","category","action","label","property","window","location","href","schema","data"],"mappings":";;;;+BAwBaA;;;eAAAA;;;AAAN,MAAMA,uBAA0C;IACrD,wBAAwB;IACxB;QACEC,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA,iCAAiC;IACjC;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBQ,QACE;gBACFC,MAAM;oBACJD,QACE;oBACFC,MAAM,CAAC;gBACT;YACF,CAAA;IACF;CACD"}
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/base.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"../types\";\nimport { redact } from \"./redaction\";\n/**\n * Event definitions for Snowplow\n * @type {EventDefinition[]}\n * @property {string} name - The name of the event, to use when triggering\n * @property {string} type - The type of the event (structured | unstructured)\n * @property {makePayload} makePayload\n * - Function that creates the payload for the event;\n * - Allows optional params object to be passed in\n *\n * @example\n * Parent\n * import { getSnowplowConfig, SnowplowProvider } from \"@simplybusiness/services\";\n * const snowplowProps = getSnowplowConfig(pageData);\n * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>\n *\n * Child\n * import { useSnowplowContext } from \"@simplybusiness/services\";\n * const { snowplow } = useSnowplowContext();\n * const handlerFunction = () => snowplow?.trigger(\"eventNameHere\");\n */\n\n// Base page events\nexport const baseEventDefinitions: EventDefinition[] = [\n // Mobile link in header\n {\n name: \"mobileLinkClick\",\n type: \"structured\",\n makePayload: () => ({\n category: \"marketing\",\n action: \"link-click\",\n label: \"mobile_call_button\",\n property: window.location.href,\n }),\n },\n // Operating hours link in footer\n {\n name: \"operatingHoursClick\",\n type: \"unstructured\",\n makePayload: () => ({\n schema:\n \"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0\",\n data: {\n schema:\n \"iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2\",\n data: {},\n },\n }),\n },\n {\n name: \"questionAnswered\",\n type: \"unstructured\",\n makePayload: params => {\n const { section, context } = params as ParamsType;\n const { question, answer } = redact(params as ParamsType);\n\n return {\n schema:\n \"iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-3\",\n data: {\n site: context.site,\n page_index: 1,\n page_name: \"quick_to_quote\",\n submitted_from: \"quick_to_quote_experiment\",\n section_name: section,\n question,\n answer,\n vertical: context.vertical,\n },\n };\n },\n },\n {\n name: \"helpTextOpened\",\n type: \"unstructured\",\n makePayload: params => {\n const { primaryText, label, context } = params as ParamsType;\n\n return {\n schema: \"iglu:com.simplybusiness/help_text_opened/jsonschema/1-1-0\",\n data: {\n vertical: context.vertical,\n site: context.site,\n primary_text: primaryText,\n label,\n page_name: \"quick_to_quote\",\n },\n };\n },\n },\n];\n"],"names":["baseEventDefinitions","name","type","makePayload","category","action","label","property","window","location","href","schema","data","params","section","context","question","answer","redact","site","page_index","page_name","submitted_from","section_name","vertical","primaryText","primary_text"],"mappings":";;;;+BAwBaA;;;eAAAA;;;2BAvBU;AAuBhB,MAAMA,uBAA0C;IACrD,wBAAwB;IACxB;QACEC,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA,iCAAiC;IACjC;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBQ,QACE;gBACFC,MAAM;oBACJD,QACE;oBACFC,MAAM,CAAC;gBACT;YACF,CAAA;IACF;IACA;QACEX,MAAM;QACNC,MAAM;QACNC,aAAaU,CAAAA;YACX,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGF;YAC7B,MAAM,EAAEG,QAAQ,EAAEC,MAAM,EAAE,GAAGC,IAAAA,iBAAM,EAACL;YAEpC,OAAO;gBACLF,QACE;gBACFC,MAAM;oBACJO,MAAMJ,QAAQI,IAAI;oBAClBC,YAAY;oBACZC,WAAW;oBACXC,gBAAgB;oBAChBC,cAAcT;oBACdE;oBACAC;oBACAO,UAAUT,QAAQS,QAAQ;gBAC5B;YACF;QACF;IACF;IACA;QACEvB,MAAM;QACNC,MAAM;QACNC,aAAaU,CAAAA;YACX,MAAM,EAAEY,WAAW,EAAEnB,KAAK,EAAES,OAAO,EAAE,GAAGF;YAExC,OAAO;gBACLF,QAAQ;gBACRC,MAAM;oBACJY,UAAUT,QAAQS,QAAQ;oBAC1BL,MAAMJ,QAAQI,IAAI;oBAClBO,cAAcD;oBACdnB;oBACAe,WAAW;gBACb;YACF;QACF;IACF;CACD"}
@@ -18,6 +18,9 @@ _export(exports, {
18
18
  qcpPageEvents: function() {
19
19
  return qcpPageEvents;
20
20
  },
21
+ questionnairePageEvents: function() {
22
+ return questionnairePageEvents;
23
+ },
21
24
  referralPageEvents: function() {
22
25
  return referralPageEvents;
23
26
  }
@@ -26,11 +29,13 @@ const _base = require("./base");
26
29
  const _qcp = require("./qcp");
27
30
  const _referral = require("./referral");
28
31
  const _intervention = require("./intervention");
32
+ const _questionnaire = require("./questionnaire");
29
33
  const eventDefinitions = [
30
34
  ..._base.baseEventDefinitions,
31
35
  ..._qcp.qcpEventDefinitions,
32
36
  ..._referral.referralEventDefinitions,
33
- ..._intervention.interventionEventDefinitions
37
+ ..._intervention.interventionEventDefinitions,
38
+ ..._questionnaire.questionnaireEventDefinitions
34
39
  ];
35
40
  const qcpPageEvents = [
36
41
  ..._base.baseEventDefinitions,
@@ -43,7 +48,9 @@ const referralPageEvents = [
43
48
  const interventionPageEvents = [
44
49
  ..._intervention.interventionEventDefinitions
45
50
  ];
46
- // Create a new export for each kind of page below
51
+ const questionnairePageEvents = [
52
+ ..._questionnaire.questionnaireEventDefinitions
53
+ ]; // Create a new export for each kind of page below
47
54
  // containing just the subset needed for that page
48
55
 
49
56
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/snowplow/event-definitions/index.ts"],"sourcesContent":["import { baseEventDefinitions } from \"./base\";\nimport { qcpEventDefinitions } from \"./qcp\";\nimport { referralEventDefinitions } from \"./referral\";\nimport { interventionEventDefinitions } from \"./intervention\";\n\n// All events (keep up to date with new files)\nexport const eventDefinitions = [\n ...baseEventDefinitions,\n ...qcpEventDefinitions,\n ...referralEventDefinitions,\n ...interventionEventDefinitions,\n];\n\nexport const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];\n\nexport const referralPageEvents = [\n ...baseEventDefinitions,\n ...referralEventDefinitions,\n];\n\nexport const interventionPageEvents = [...interventionEventDefinitions];\n\nexport type { InterventionPayload } from \"./intervention\";\n\n// Create a new export for each kind of page below\n// containing just the subset needed for that page\n"],"names":["eventDefinitions","interventionPageEvents","qcpPageEvents","referralPageEvents","baseEventDefinitions","qcpEventDefinitions","referralEventDefinitions","interventionEventDefinitions"],"mappings":";;;;;;;;;;;IAMaA,gBAAgB;eAAhBA;;IAcAC,sBAAsB;eAAtBA;;IAPAC,aAAa;eAAbA;;IAEAC,kBAAkB;eAAlBA;;;sBAfwB;qBACD;0BACK;8BACI;AAGtC,MAAMH,mBAAmB;OAC3BI,0BAAoB;OACpBC,wBAAmB;OACnBC,kCAAwB;OACxBC,0CAA4B;CAChC;AAEM,MAAML,gBAAgB;OAAIE,0BAAoB;OAAKC,wBAAmB;CAAC;AAEvE,MAAMF,qBAAqB;OAC7BC,0BAAoB;OACpBE,kCAAwB;CAC5B;AAEM,MAAML,yBAAyB;OAAIM,0CAA4B;CAAC;CAIvE,kDAAkD;CAClD,kDAAkD"}
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/index.ts"],"sourcesContent":["import { baseEventDefinitions } from \"./base\";\nimport { qcpEventDefinitions } from \"./qcp\";\nimport { referralEventDefinitions } from \"./referral\";\nimport { interventionEventDefinitions } from \"./intervention\";\nimport { questionnaireEventDefinitions } from \"./questionnaire\";\n\n// All events (keep up to date with new files)\nexport const eventDefinitions = [\n ...baseEventDefinitions,\n ...qcpEventDefinitions,\n ...referralEventDefinitions,\n ...interventionEventDefinitions,\n ...questionnaireEventDefinitions,\n];\n\nexport const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];\n\nexport const referralPageEvents = [\n ...baseEventDefinitions,\n ...referralEventDefinitions,\n];\n\nexport const interventionPageEvents = [...interventionEventDefinitions];\n\nexport type { InterventionPayload } from \"./intervention\";\n\nexport const questionnairePageEvents = [...questionnaireEventDefinitions];\n\n// Create a new export for each kind of page below\n// containing just the subset needed for that page\n"],"names":["eventDefinitions","interventionPageEvents","qcpPageEvents","questionnairePageEvents","referralPageEvents","baseEventDefinitions","qcpEventDefinitions","referralEventDefinitions","interventionEventDefinitions","questionnaireEventDefinitions"],"mappings":";;;;;;;;;;;IAOaA,gBAAgB;eAAhBA;;IAeAC,sBAAsB;eAAtBA;;IAPAC,aAAa;eAAbA;;IAWAC,uBAAuB;eAAvBA;;IATAC,kBAAkB;eAAlBA;;;sBAjBwB;qBACD;0BACK;8BACI;+BACC;AAGvC,MAAMJ,mBAAmB;OAC3BK,0BAAoB;OACpBC,wBAAmB;OACnBC,kCAAwB;OACxBC,0CAA4B;OAC5BC,4CAA6B;CACjC;AAEM,MAAMP,gBAAgB;OAAIG,0BAAoB;OAAKC,wBAAmB;CAAC;AAEvE,MAAMF,qBAAqB;OAC7BC,0BAAoB;OACpBE,kCAAwB;CAC5B;AAEM,MAAMN,yBAAyB;OAAIO,0CAA4B;CAAC;AAIhE,MAAML,0BAA0B;OAAIM,4CAA6B;CAAC,EAEzE,kDAAkD;CAClD,kDAAkD"}
@@ -252,6 +252,20 @@ const qcpEventDefinitions = [
252
252
  label: "phone_number_link_clicked",
253
253
  property: window.location.href
254
254
  })
255
+ },
256
+ {
257
+ name: "linkClicked",
258
+ type: "unstructured",
259
+ makePayload: (params)=>{
260
+ const { targetUrl, elementContent } = params;
261
+ return {
262
+ schema: "iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",
263
+ data: {
264
+ targetUrl,
265
+ elementContent
266
+ }
267
+ };
268
+ }
255
269
  }
256
270
  ];
257
271
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/snowplow/event-definitions/qcp.ts"],"sourcesContent":["import { snakeCase } from \"../../utils\";\nimport { EventDefinition, ParamsType } from \"../types\";\n\n/**\n * Event definitions for Snowplow\n * @type {EventDefinition[]}\n * @property {string} name - The name of the event, to use when triggering\n * @property {string} type - The type of the event (structured | unstructured)\n * @property {makePayload} makePayload\n * - Function that creates the payload for the event;\n * - Allows optional params object to be passed in\n *\n * @example\n * Parent\n * import { getSnowplowConfig, SnowplowProvider } from \"@simplybusiness/services\";\n * const snowplowProps = getSnowplowConfig(pageData);\n * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>\n *\n * Child\n * import { useSnowplowContext } from \"@simplybusiness/services\";\n * const { snowplow } = useSnowplowContext();\n * const handlerFunction = () => snowplow?.trigger(\"eventNameHere\");\n */\n\n// QCP page events\nexport const qcpEventDefinitions: EventDefinition[] = [\n {\n // QDP details button\n name: \"detailsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Details\",\n }),\n },\n {\n // Buy button\n name: \"selectClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Buy\",\n }),\n },\n {\n // Quote Details Slider Next steps button\n name: \"nextStepsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_next_step_cta\",\n action: \"link_click\",\n label: \"Next steps\",\n }),\n },\n {\n // Toggle deductibles accordion\n name: \"deductiblesClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"us-qcp-react\",\n action: \"view_deductables_clicked\",\n label: \"view_deductables_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"deductiblesClickedUk\",\n type: \"structured\",\n makePayload: params => {\n const { label, deviceType } = params as ParamsType;\n const urlFriendlyLabel = label.replace(/ /g, \"-\").toLowerCase();\n\n return {\n category: `uk-qcp-react-${deviceType}-${urlFriendlyLabel}-view-excess-toggle`,\n action: \"view_excess_clicked\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n // Quote Details Slider opened\n name: \"sliderOpened\",\n type: \"structured\",\n makePayload: params => {\n const { label } = params as ParamsType;\n\n return {\n category: \"comparison_cta\",\n action: \"quote_details_slider_opened\",\n label,\n };\n },\n },\n {\n // Coverage modal opened\n name: \"coverageModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const {\n category,\n product = \"extra_coverage\",\n title,\n } = params as ParamsType;\n const productLabel = snakeCase(product);\n\n return {\n category,\n action: `${productLabel}_${snakeCase(title)}_popup_opened`,\n label: productLabel,\n property: window.location.href,\n };\n },\n },\n {\n // Toggle cover select\n name: \"coverChanged\",\n type: \"unstructured\",\n makePayload: params => {\n const { name = \"\", fromValue = \"\", toValue = \"\" } = params as ParamsType;\n // Derive data\n let action = \"change\";\n\n // This logic is taken directly from Chopin without documentation:\n // If a cover has zero value, then change the action to add or remove\n if (fromValue === \"0\") {\n action = \"add\";\n }\n if (toValue === \"0\") {\n action = \"remove\";\n }\n\n return {\n schema:\n \"iglu:com.simplybusiness/comparison_page_cover_changed/jsonschema/1-0-0\",\n data: {\n name,\n action,\n from_value: fromValue,\n to_value: toValue,\n },\n };\n },\n },\n {\n name: \"ratingsModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"insurer_rating_help_popup_triggered\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"coverToggleOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"qcp_limit_interaction\",\n label: \"limit_interaction\",\n action: \"limit_interaction_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"paymentToggleClicked\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"button_click\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"insurerDetailsAccordionClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_insurer_details_description\",\n action: \"accordion_clicked\",\n label: \"accordion_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"priceDetailsPopUpOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"price_details\",\n action: \"price_details_popup_opened\",\n label: \"Price details\",\n property: window.location.href,\n }),\n },\n {\n name: \"editLimitButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"edit_limit_button_clicked\",\n label: \"Edit Limit\",\n property: window.location.href,\n }),\n },\n {\n name: \"applyButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"apply_button_clicked\",\n label: \"Apply Button Clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"coverageInfoClicked\",\n type: \"structured\",\n makePayload: params => {\n const { deviceType } = params as ParamsType;\n\n return {\n action: \"show_coverage_info_clicked\",\n category: `uk-qcp-react-${deviceType}-show-coverage-info-toggle`,\n label: \"show_coverage_info_clicked\",\n property: window.location.href,\n };\n },\n },\n {\n name: \"backToApplication\",\n type: \"unstructured\",\n makePayload: params => {\n const { journeyId, vertical } = params as ParamsType;\n\n return {\n schema: \"iglu:com.simplybusiness/back_to_application/jsonschema/1-0-0\",\n data: {\n journey_id: journeyId,\n vertical,\n },\n };\n },\n },\n {\n name: \"helpChatLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"help chat for question\",\n action: \"help_chat_for_question_clicked\",\n property: window.location.href,\n }),\n },\n // No quotes referral\n {\n name: \"coverOptionsLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"uk-qcp-react-cover-options-link\",\n action: \"cover_options_link_clicked\",\n label: \"cover_options_link_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"phoneNumberLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"uk-qcp-react-phone-number-link\",\n action: \"phone_number_link_clicked\",\n label: \"phone_number_link_clicked\",\n property: window.location.href,\n }),\n },\n];\n"],"names":["qcpEventDefinitions","name","type","makePayload","category","action","label","property","window","location","href","params","deviceType","urlFriendlyLabel","replace","toLowerCase","product","title","productLabel","snakeCase","fromValue","toValue","schema","data","from_value","to_value","journeyId","vertical","journey_id"],"mappings":";;;;+BAyBaA;;;eAAAA;;;uBAzBa;AAyBnB,MAAMA,sBAAyC;IACpD;QACE,qBAAqB;QACrBC,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;YACT,CAAA;IACF;IACA;QACE,aAAa;QACbL,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,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AAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAaQ,CAAAA;YACX,MAAM,EAAEC,UAAU,EAAE,GAAGD;YAEvB,OAAO;gBACLN,QAAQ;gBACRD,UAAU,CAAC,aAAa,EAAEQ,WAAW,0BAA0B,CAAC;gBAChEN,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC;QACF;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAaQ,CAAAA;YACX,MAAM,EAAEe,SAAS,EAAEC,QAAQ,EAAE,GAAGhB;YAEhC,OAAO;gBACLW,QAAQ;gBACRC,MAAM;oBACJK,YAAYF;oBACZC;gBACF;YACF;QACF;IACF;IACA;QACE1B,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRE,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA,qBAAqB;IACrB;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;CACD"}
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/qcp.ts"],"sourcesContent":["import { snakeCase } from \"../../utils\";\nimport { EventDefinition, LinkType, ParamsType } from \"../types\";\n\n/**\n * Event definitions for Snowplow\n * @type {EventDefinition[]}\n * @property {string} name - The name of the event, to use when triggering\n * @property {string} type - The type of the event (structured | unstructured)\n * @property {makePayload} makePayload\n * - Function that creates the payload for the event;\n * - Allows optional params object to be passed in\n *\n * @example\n * Parent\n * import { getSnowplowConfig, SnowplowProvider } from \"@simplybusiness/services\";\n * const snowplowProps = getSnowplowConfig(pageData);\n * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>\n *\n * Child\n * import { useSnowplowContext } from \"@simplybusiness/services\";\n * const { snowplow } = useSnowplowContext();\n * const handlerFunction = () => snowplow?.trigger(\"eventNameHere\");\n */\n\n// QCP page events\nexport const qcpEventDefinitions: EventDefinition[] = [\n {\n // QDP details button\n name: \"detailsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Details\",\n }),\n },\n {\n // Buy button\n name: \"selectClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Buy\",\n }),\n },\n {\n // Quote Details Slider Next steps button\n name: \"nextStepsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_next_step_cta\",\n action: \"link_click\",\n label: \"Next steps\",\n }),\n },\n {\n // Toggle deductibles accordion\n name: \"deductiblesClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"us-qcp-react\",\n action: \"view_deductables_clicked\",\n label: \"view_deductables_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"deductiblesClickedUk\",\n type: \"structured\",\n makePayload: params => {\n const { label, deviceType } = params as ParamsType;\n const urlFriendlyLabel = label.replace(/ /g, \"-\").toLowerCase();\n\n return {\n category: `uk-qcp-react-${deviceType}-${urlFriendlyLabel}-view-excess-toggle`,\n action: \"view_excess_clicked\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n // Quote Details Slider opened\n name: \"sliderOpened\",\n type: \"structured\",\n makePayload: params => {\n const { label } = params as ParamsType;\n\n return {\n category: \"comparison_cta\",\n action: \"quote_details_slider_opened\",\n label,\n };\n },\n },\n {\n // Coverage modal opened\n name: \"coverageModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const {\n category,\n product = \"extra_coverage\",\n title,\n } = params as ParamsType;\n const productLabel = snakeCase(product);\n\n return {\n category,\n action: `${productLabel}_${snakeCase(title)}_popup_opened`,\n label: productLabel,\n property: window.location.href,\n };\n },\n },\n {\n // Toggle cover select\n name: \"coverChanged\",\n type: \"unstructured\",\n makePayload: params => {\n const { name = \"\", fromValue = \"\", toValue = \"\" } = params as ParamsType;\n // Derive data\n let action = \"change\";\n\n // This logic is taken directly from Chopin without documentation:\n // If a cover has zero value, then change the action to add or remove\n if (fromValue === \"0\") {\n action = \"add\";\n }\n if (toValue === \"0\") {\n action = \"remove\";\n }\n\n return {\n schema:\n \"iglu:com.simplybusiness/comparison_page_cover_changed/jsonschema/1-0-0\",\n data: {\n name,\n action,\n from_value: fromValue,\n to_value: toValue,\n },\n };\n },\n },\n {\n name: \"ratingsModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"insurer_rating_help_popup_triggered\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"coverToggleOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"qcp_limit_interaction\",\n label: \"limit_interaction\",\n action: \"limit_interaction_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"paymentToggleClicked\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"button_click\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"insurerDetailsAccordionClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_insurer_details_description\",\n action: \"accordion_clicked\",\n label: \"accordion_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"priceDetailsPopUpOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"price_details\",\n action: \"price_details_popup_opened\",\n label: \"Price details\",\n property: window.location.href,\n }),\n },\n {\n name: \"editLimitButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"edit_limit_button_clicked\",\n label: \"Edit Limit\",\n property: window.location.href,\n }),\n },\n {\n name: \"applyButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"apply_button_clicked\",\n label: \"Apply Button Clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"coverageInfoClicked\",\n type: \"structured\",\n makePayload: params => {\n const { deviceType } = params as ParamsType;\n\n return {\n action: \"show_coverage_info_clicked\",\n category: `uk-qcp-react-${deviceType}-show-coverage-info-toggle`,\n label: \"show_coverage_info_clicked\",\n property: window.location.href,\n };\n },\n },\n {\n name: \"backToApplication\",\n type: \"unstructured\",\n makePayload: params => {\n const { journeyId, vertical } = params as ParamsType;\n\n return {\n schema: \"iglu:com.simplybusiness/back_to_application/jsonschema/1-0-0\",\n data: {\n journey_id: journeyId,\n vertical,\n },\n };\n },\n },\n {\n name: \"helpChatLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"help chat for question\",\n action: \"help_chat_for_question_clicked\",\n property: window.location.href,\n }),\n },\n // No quotes referral\n {\n name: \"coverOptionsLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"uk-qcp-react-cover-options-link\",\n action: \"cover_options_link_clicked\",\n label: \"cover_options_link_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"phoneNumberLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"uk-qcp-react-phone-number-link\",\n action: \"phone_number_link_clicked\",\n label: \"phone_number_link_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"linkClicked\",\n type: \"unstructured\",\n makePayload: params => {\n const { targetUrl, elementContent } = params as LinkType;\n\n return {\n schema:\n \"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1\",\n data: {\n targetUrl,\n elementContent,\n },\n };\n },\n },\n];\n"],"names":["qcpEventDefinitions","name","type","makePayload","category","action","label","property","window","location","href","params","deviceType","urlFriendlyLabel","replace","toLowerCase","product","title","productLabel","snakeCase","fromValue","toValue","schema","data","from_value","to_value","journeyId","vertical","journey_id","targetUrl","elementContent"],"mappings":";;;;+BAyBaA;;;eAAAA;;;uBAzBa;AAyBnB,MAAMA,sBAAyC;IACpD;QACE,qBAAqB;QACrBC,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;YACT,CAAA;IACF;IACA;QACE,aAAa;QACbL,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;YACT,CAAA;IACF;IACA;QACE,yCAAyC;QACzCL,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;YACT,CAAA;IACF;IACA;QACE,+BAA+B;QAC/BL,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAaQ,CAAAA;YACX,MAAM,EAAEL,KAAK,EAAEM,UAAU,EAAE,GAAGD;YAC9B,MAAME,mBAAmBP,MAAMQ,OAAO,CAAC,MAAM,KAAKC,WAAW;YAE7D,OAAO;gBACLX,UAAU,CAAC,aAAa,EAAEQ,WAAW,CAAC,EAAEC,iBAAiB,mBAAmB,CAAC;gBAC7ER,QAAQ;gBACRC;gBACAC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC;QACF;IACF;IACA;QACE,8BAA8B;QAC9BT,MAAM;QACNC,MAAM;QACNC,aAA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MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRE,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA,qBAAqB;IACrB;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAaQ,CAAAA;YACX,MAAM,EAAEkB,SAAS,EAAEC,cAAc,EAAE,GAAGnB;YAEtC,OAAO;gBACLW,QACE;gBACFC,MAAM;oBACJM;oBACAC;gBACF;YACF;QACF;IACF;CACD"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "questionnaireEventDefinitions", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return questionnaireEventDefinitions;
9
+ }
10
+ });
11
+ const questionnaireEventDefinitions = [
12
+ {
13
+ name: "assumptionsButtonClicked",
14
+ type: "structured",
15
+ makePayload: (params)=>{
16
+ const { source, presentationGroup } = params;
17
+ return {
18
+ action: source,
19
+ category: presentationGroup
20
+ };
21
+ }
22
+ },
23
+ {
24
+ name: "navButtonClicked",
25
+ type: "structured",
26
+ makePayload: (params)=>{
27
+ const { label, category } = params;
28
+ return {
29
+ label,
30
+ action: "link_click",
31
+ category
32
+ };
33
+ }
34
+ },
35
+ {
36
+ name: "manualAddressClicked",
37
+ type: "structured",
38
+ makePayload: (params)=>{
39
+ const { category } = params;
40
+ return {
41
+ action: "link_click",
42
+ category,
43
+ label: "Enter address manually"
44
+ };
45
+ }
46
+ }
47
+ ];
48
+
49
+ //# sourceMappingURL=questionnaire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/questionnaire.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"../types\";\n\n// Questionnaire events\nexport const questionnaireEventDefinitions: EventDefinition[] = [\n {\n name: \"assumptionsButtonClicked\",\n type: \"structured\",\n makePayload: params => {\n const { source, presentationGroup } = params as ParamsType;\n\n return {\n action: source,\n category: presentationGroup,\n };\n },\n },\n {\n name: \"navButtonClicked\",\n type: \"structured\",\n makePayload: params => {\n const { label, category } = params as ParamsType;\n\n return {\n label,\n action: \"link_click\",\n category,\n };\n },\n },\n {\n name: \"manualAddressClicked\",\n type: \"structured\",\n makePayload: params => {\n const { category } = params as ParamsType;\n\n return {\n action: \"link_click\",\n category,\n label: \"Enter address manually\",\n };\n },\n },\n];\n"],"names":["questionnaireEventDefinitions","name","type","makePayload","params","source","presentationGroup","action","category","label"],"mappings":";;;;+BAGaA;;;eAAAA;;;AAAN,MAAMA,gCAAmD;IAC9D;QACEC,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAE,GAAGF;YAEtC,OAAO;gBACLG,QAAQF;gBACRG,UAAUF;YACZ;QACF;IACF;IACA;QACEL,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEK,KAAK,EAAED,QAAQ,EAAE,GAAGJ;YAE5B,OAAO;gBACLK;gBACAF,QAAQ;gBACRC;YACF;QACF;IACF;IACA;QACEP,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEI,QAAQ,EAAE,GAAGJ;YAErB,OAAO;gBACLG,QAAQ;gBACRC;gBACAC,OAAO;YACT;QACF;IACF;CACD"}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "redact", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return redact;
9
+ }
10
+ });
11
+ const PII_ANSWER = [
12
+ "customer_title",
13
+ "customer_first_name",
14
+ "customer_last_name",
15
+ "customer_email_address",
16
+ "preapp_email_address",
17
+ "customer_telephone_number",
18
+ "customer_alternative_telephone_number",
19
+ "customer_address_1_pre_quote",
20
+ "customer_address_2_pre_quote",
21
+ "customer_town_pre_quote",
22
+ "customer_postcode_pre_quote",
23
+ "customer_address_1",
24
+ "customer_address_2",
25
+ "customer_town",
26
+ "customer_postcode",
27
+ "address_1_pre_quote",
28
+ "address_2_pre_quote",
29
+ "uk_postcode_pre_quote",
30
+ "town_pre_quote",
31
+ "owner_first_name",
32
+ "owner_last_name",
33
+ "beneficiary_first_name",
34
+ "beneficiary_last_name",
35
+ "gender",
36
+ "dynamic_ssn_fein",
37
+ "ssn",
38
+ "fein",
39
+ "sof_county_court_judgement_online_yes",
40
+ "sof_county_court_judgement_online_no",
41
+ "sof_ccj_count",
42
+ "sof_ccj_value",
43
+ "sof_ccj_date",
44
+ "sof_court_judgement_yes",
45
+ "sof_court_judgement_no",
46
+ "ccj_date",
47
+ "sof_single_ccj_no",
48
+ "sof_single_ccj_yes",
49
+ "sof_ccj_yes",
50
+ "sof_ccj_no",
51
+ "ccj_count",
52
+ "sof_bankrupt_yes",
53
+ "sof_bankrupt_no",
54
+ "sof_multiple_bankruptcies_yes",
55
+ "sof_multiple_bankruptcies_no",
56
+ "bankruptcy_date",
57
+ "sof_single_bankruptcy_no",
58
+ "sof_single_bankruptcy_yes",
59
+ "sof_bankruptcy_yes",
60
+ "sof_bankruptcy_no",
61
+ "bankruptcy_discharged",
62
+ "sof_liquidation_yes",
63
+ "sof_liquidation_no",
64
+ "sof_multiple_liquidations",
65
+ "liquidation_date",
66
+ "sof_criminal_offence_yes",
67
+ "sof_criminal_offence_no",
68
+ "sof_criminal_yes",
69
+ "sof_criminal_no",
70
+ "hcp_date_of_birth_1",
71
+ "hcp_date_of_birth_2",
72
+ "hcp_date_of_birth_3",
73
+ "hcp_date_of_birth_4",
74
+ "hcp_date_of_birth_5",
75
+ "hcp_date_of_birth_6",
76
+ "hcp_date_of_birth_7",
77
+ "hcp_date_of_birth_8",
78
+ "hcp_date_of_birth_9",
79
+ "hcp_date_of_birth_10",
80
+ "sof_previous_claims_yes",
81
+ "sof_previous_claims_no",
82
+ "sof_claims_yes",
83
+ "sof_claims_no",
84
+ "sof_property_claims_in_the_last_5_years_yes",
85
+ "sof_property_claims_in_the_last_5_years_no",
86
+ "sof_property_claims_in_the_last_0_to_4_years_yes",
87
+ "sof_property_claims_in_the_last_0_to_4_years_no",
88
+ "claim_count",
89
+ "sof_number_of_claims",
90
+ "number_of_claims_in_last_5_years",
91
+ "number_of_claims_in_time_owned",
92
+ "date_of_incident_1",
93
+ "date_of_incident_2",
94
+ "date_of_incident_3",
95
+ "date_of_incident_4",
96
+ "date_of_incident_5",
97
+ "type_of_incident_1",
98
+ "type_of_incident_2",
99
+ "type_of_incident_3",
100
+ "type_of_incident_4",
101
+ "type_of_incident_5",
102
+ "incident_value_1",
103
+ "incident_value_2",
104
+ "incident_value_3",
105
+ "incident_value_4",
106
+ "incident_value_5",
107
+ "sof_pollution_disease_claims_yes",
108
+ "sof_pollution_disease_claims_no",
109
+ "sof_potential_claims_yes",
110
+ "sof_potential_claims_no",
111
+ "sof_previous_circumstances_yes",
112
+ "sof_previous_circumstances_no",
113
+ "sof_possible_claims_yes",
114
+ "sof_possible_claims_no",
115
+ "date_of_possible_incident",
116
+ "type_of_possible_incident",
117
+ "possible_incident_value",
118
+ "sof_property_claims_yes",
119
+ "sof_property_claims_no",
120
+ "sof_liability_claims_yes",
121
+ "sof_liability_claims_no",
122
+ "van_registration",
123
+ "sof_disqualified_director_yes",
124
+ "sof_disqualified_director_no",
125
+ "sof_insurance_refused_yes",
126
+ "sof_insurance_refused_no",
127
+ "sof_insurance_declined_yes",
128
+ "sof_insurance_declined_no",
129
+ "insurance_refused"
130
+ ];
131
+ const RADIO_ANSWER_FROM_QUESTIONS = [
132
+ "have_secondary_trade_yes",
133
+ "have_secondary_trade_no"
134
+ ];
135
+ const ANSWER_SUFFIX_PATTERN = /_(yes|no)$/;
136
+ const redact = (params)=>{
137
+ let { question, answer } = params;
138
+ const piiAnswer = new Set(PII_ANSWER);
139
+ const radioAnswerFromQuestions = new Set(RADIO_ANSWER_FROM_QUESTIONS);
140
+ if (piiAnswer.has(question)) {
141
+ answer = "REDACTED";
142
+ question = question === null || question === void 0 ? void 0 : question.replace(ANSWER_SUFFIX_PATTERN, "");
143
+ } else if (radioAnswerFromQuestions.has(question)) {
144
+ question = question === null || question === void 0 ? void 0 : question.replace(ANSWER_SUFFIX_PATTERN, "");
145
+ }
146
+ return {
147
+ question,
148
+ answer
149
+ };
150
+ };
151
+
152
+ //# sourceMappingURL=redaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/redaction.ts"],"sourcesContent":["import { ParamsType } from \"../types\";\n\nconst PII_ANSWER = [\n \"customer_title\",\n \"customer_first_name\",\n \"customer_last_name\",\n \"customer_email_address\",\n \"preapp_email_address\",\n \"customer_telephone_number\",\n \"customer_alternative_telephone_number\",\n \"customer_address_1_pre_quote\",\n \"customer_address_2_pre_quote\",\n \"customer_town_pre_quote\",\n \"customer_postcode_pre_quote\",\n \"customer_address_1\",\n \"customer_address_2\",\n \"customer_town\",\n \"customer_postcode\",\n \"address_1_pre_quote\",\n \"address_2_pre_quote\",\n \"uk_postcode_pre_quote\",\n \"town_pre_quote\",\n \"owner_first_name\",\n \"owner_last_name\",\n \"beneficiary_first_name\",\n \"beneficiary_last_name\",\n \"gender\",\n \"dynamic_ssn_fein\",\n \"ssn\",\n \"fein\",\n \"sof_county_court_judgement_online_yes\",\n \"sof_county_court_judgement_online_no\",\n \"sof_ccj_count\",\n \"sof_ccj_value\",\n \"sof_ccj_date\",\n \"sof_court_judgement_yes\",\n \"sof_court_judgement_no\",\n \"ccj_date\",\n \"sof_single_ccj_no\",\n \"sof_single_ccj_yes\",\n \"sof_ccj_yes\",\n \"sof_ccj_no\",\n \"ccj_count\",\n \"sof_bankrupt_yes\",\n \"sof_bankrupt_no\",\n \"sof_multiple_bankruptcies_yes\",\n \"sof_multiple_bankruptcies_no\",\n \"bankruptcy_date\",\n \"sof_single_bankruptcy_no\",\n \"sof_single_bankruptcy_yes\",\n \"sof_bankruptcy_yes\",\n \"sof_bankruptcy_no\",\n \"bankruptcy_discharged\",\n \"sof_liquidation_yes\",\n \"sof_liquidation_no\",\n \"sof_multiple_liquidations\",\n \"liquidation_date\",\n \"sof_criminal_offence_yes\",\n \"sof_criminal_offence_no\",\n \"sof_criminal_yes\",\n \"sof_criminal_no\",\n \"hcp_date_of_birth_1\",\n \"hcp_date_of_birth_2\",\n \"hcp_date_of_birth_3\",\n \"hcp_date_of_birth_4\",\n \"hcp_date_of_birth_5\",\n \"hcp_date_of_birth_6\",\n \"hcp_date_of_birth_7\",\n \"hcp_date_of_birth_8\",\n \"hcp_date_of_birth_9\",\n \"hcp_date_of_birth_10\",\n \"sof_previous_claims_yes\",\n \"sof_previous_claims_no\",\n \"sof_claims_yes\",\n \"sof_claims_no\",\n \"sof_property_claims_in_the_last_5_years_yes\",\n \"sof_property_claims_in_the_last_5_years_no\",\n \"sof_property_claims_in_the_last_0_to_4_years_yes\",\n \"sof_property_claims_in_the_last_0_to_4_years_no\",\n \"claim_count\",\n \"sof_number_of_claims\",\n \"number_of_claims_in_last_5_years\",\n \"number_of_claims_in_time_owned\",\n \"date_of_incident_1\",\n \"date_of_incident_2\",\n \"date_of_incident_3\",\n \"date_of_incident_4\",\n \"date_of_incident_5\",\n \"type_of_incident_1\",\n \"type_of_incident_2\",\n \"type_of_incident_3\",\n \"type_of_incident_4\",\n \"type_of_incident_5\",\n \"incident_value_1\",\n \"incident_value_2\",\n \"incident_value_3\",\n \"incident_value_4\",\n \"incident_value_5\",\n \"sof_pollution_disease_claims_yes\",\n \"sof_pollution_disease_claims_no\",\n \"sof_potential_claims_yes\",\n \"sof_potential_claims_no\",\n \"sof_previous_circumstances_yes\",\n \"sof_previous_circumstances_no\",\n \"sof_possible_claims_yes\",\n \"sof_possible_claims_no\",\n \"date_of_possible_incident\",\n \"type_of_possible_incident\",\n \"possible_incident_value\",\n \"sof_property_claims_yes\",\n \"sof_property_claims_no\",\n \"sof_liability_claims_yes\",\n \"sof_liability_claims_no\",\n \"van_registration\",\n \"sof_disqualified_director_yes\",\n \"sof_disqualified_director_no\",\n \"sof_insurance_refused_yes\",\n \"sof_insurance_refused_no\",\n \"sof_insurance_declined_yes\",\n \"sof_insurance_declined_no\",\n \"insurance_refused\",\n];\n\nconst RADIO_ANSWER_FROM_QUESTIONS = [\n \"have_secondary_trade_yes\",\n \"have_secondary_trade_no\",\n];\n\nconst ANSWER_SUFFIX_PATTERN = /_(yes|no)$/;\n\nexport const redact = (params: ParamsType) => {\n let { question, answer } = params as ParamsType;\n\n const piiAnswer = new Set(PII_ANSWER);\n const radioAnswerFromQuestions = new Set(RADIO_ANSWER_FROM_QUESTIONS);\n\n if (piiAnswer.has(question)) {\n answer = \"REDACTED\";\n question = question?.replace(ANSWER_SUFFIX_PATTERN, \"\");\n } else if (radioAnswerFromQuestions.has(question)) {\n question = question?.replace(ANSWER_SUFFIX_PATTERN, \"\");\n }\n return { question, answer };\n};\n"],"names":["redact","PII_ANSWER","RADIO_ANSWER_FROM_QUESTIONS","ANSWER_SUFFIX_PATTERN","params","question","answer","piiAnswer","Set","radioAnswerFromQuestions","has","replace"],"mappings":";;;;+BAkIaA;;;eAAAA;;;AAhIb,MAAMC,aAAa;IACjB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,8BAA8B;IAClC;IACA;CACD;AAED,MAAMC,wBAAwB;AAEvB,MAAMH,SAAS,CAACI;IACrB,IAAI,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGF;IAE3B,MAAMG,YAAY,IAAIC,IAAIP;IAC1B,MAAMQ,2BAA2B,IAAID,IAAIN;IAEzC,IAAIK,UAAUG,GAAG,CAACL,WAAW;QAC3BC,SAAS;QACTD,WAAWA,qBAAAA,+BAAAA,SAAUM,OAAO,CAACR,uBAAuB;IACtD,OAAO,IAAIM,yBAAyBC,GAAG,CAACL,WAAW;QACjDA,WAAWA,qBAAAA,+BAAAA,SAAUM,OAAO,CAACR,uBAAuB;IACtD;IACA,OAAO;QAAEE;QAAUC;IAAO;AAC5B"}