@simplybusiness/services 0.1.3 → 0.1.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 +10 -0
- package/dist/cjs/services/snowplow/SnowplowContext.js.map +1 -1
- package/dist/cjs/services/snowplow/event-definitions/base.js +37 -0
- package/dist/cjs/services/snowplow/event-definitions/base.js.map +1 -0
- package/dist/cjs/services/snowplow/event-definitions/index.js +31 -0
- package/dist/cjs/services/snowplow/event-definitions/index.js.map +1 -0
- package/dist/cjs/services/snowplow/{event-definitions.js → event-definitions/qcp.js} +5 -26
- package/dist/cjs/services/snowplow/event-definitions/qcp.js.map +1 -0
- package/dist/cjs/services/snowplow/index.js +1 -0
- package/dist/cjs/services/snowplow/index.js.map +1 -1
- package/dist/esm/services/snowplow/SnowplowContext.js.map +1 -1
- package/dist/esm/services/snowplow/event-definitions/base.js +43 -0
- package/dist/esm/services/snowplow/event-definitions/base.js.map +1 -0
- package/dist/esm/services/snowplow/event-definitions/index.js +14 -0
- package/dist/esm/services/snowplow/event-definitions/index.js.map +1 -0
- package/dist/esm/services/snowplow/{event-definitions.js → event-definitions/qcp.js} +4 -24
- package/dist/esm/services/snowplow/event-definitions/qcp.js.map +1 -0
- package/dist/esm/services/snowplow/index.js +1 -0
- package/dist/esm/services/snowplow/index.js.map +1 -1
- package/dist/types/services/snowplow/SnowplowContext.d.ts +1 -1
- package/dist/types/services/snowplow/event-definitions/base.d.ts +18 -0
- package/dist/types/services/snowplow/event-definitions/index.d.ts +2 -0
- package/dist/types/services/snowplow/{event-definitions.d.ts → event-definitions/qcp.d.ts} +2 -2
- package/dist/types/services/snowplow/index.d.ts +1 -0
- package/package.json +15 -15
- package/src/services/snowplow/SnowplowContext.tsx +1 -1
- package/src/services/snowplow/event-definitions/base.ts +47 -0
- package/src/services/snowplow/event-definitions/index.ts +13 -0
- package/src/services/snowplow/{event-definitions.ts → event-definitions/qcp.ts} +5 -26
- package/src/services/snowplow/index.ts +1 -0
- package/dist/cjs/services/snowplow/event-definitions.js.map +0 -1
- package/dist/esm/services/snowplow/event-definitions.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 10f56ea: Refactor event definitions
|
|
8
|
+
- 1f347dd: Dependency updates
|
|
9
|
+
- Updated dependencies [a03d10d]
|
|
10
|
+
- Updated dependencies [1f347dd]
|
|
11
|
+
- @simplybusiness/mobius@4.14.0
|
|
12
|
+
|
|
3
13
|
## 0.1.3
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/snowplow/SnowplowContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\nimport { getContexts } from \"./contexts\";\nimport { eventDefinitions } from \"./event-definitions\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/services/snowplow/SnowplowContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\nimport { getContexts } from \"./contexts\";\nimport { eventDefinitions } from \"./event-definitions\";\nimport { Snowplow } from \"./Snowplow\";\nimport { EventDefinition, TrackingProps } from \"./types\";\n\nexport interface SnowplowContextInterface {\n config: TrackingProps;\n snowplow?: Snowplow;\n}\n\nconst SnowplowContext = createContext<SnowplowContextInterface | null>(null);\n\ntype ProviderProps = {\n scripts: TrackingProps;\n children: ReactNode;\n};\n\nexport const SnowplowProvider = ({ scripts, children }: ProviderProps) => {\n const [config, _setConfig] = useState<TrackingProps>(scripts);\n const [snowplow, setSnowplow] = useState<Snowplow>(new Snowplow(config));\n\n // Attach event handlers and set contexts\n useEffect(() => {\n if (snowplow && scripts) {\n const contexts = getContexts(config);\n\n snowplow\n .setContexts(contexts)\n .addEventHandlers(eventDefinitions as EventDefinition[]);\n // Send page view event\n if (config.trackPageView) snowplow.trackView();\n }\n }, [config, snowplow, scripts]);\n\n const value: SnowplowContextInterface = useMemo(\n () => ({\n config,\n snowplow,\n }),\n [config, snowplow],\n );\n\n return (\n <SnowplowContext.Provider value={value}>\n {children}\n </SnowplowContext.Provider>\n );\n};\n\nexport function useSnowplowContext() {\n const context = useContext(SnowplowContext);\n\n if (!context) {\n throw new Error(\n \"useSnowplowContext must be used inside a `SnowplowProvider`\",\n );\n }\n return context;\n}\n"],"names":["SnowplowProvider","useSnowplowContext","SnowplowContext","createContext","scripts","children","config","_setConfig","useState","snowplow","setSnowplow","Snowplow","useEffect","contexts","getContexts","setContexts","addEventHandlers","eventDefinitions","trackPageView","trackView","value","useMemo","Provider","context","useContext","Error"],"mappings":"AAAA,oDAAoD;;;;;;;;;;;IA0BvCA,gBAAgB;eAAhBA;;IAgCGC,kBAAkB;eAAlBA;;;;uBAlDT;0BACqB;kCACK;0BACR;AAQzB,MAAMC,gCAAkBC,IAAAA,oBAAa,EAAkC;AAOhE,MAAMH,mBAAmB,CAAC,EAAEI,OAAO,EAAEC,QAAQ,EAAiB;IACnE,MAAM,CAACC,QAAQC,WAAW,GAAGC,IAAAA,eAAQ,EAAgBJ;IACrD,MAAM,CAACK,UAAUC,YAAY,GAAGF,IAAAA,eAAQ,EAAW,IAAIG,kBAAQ,CAACL;IAEhE,yCAAyC;IACzCM,IAAAA,gBAAS,EAAC;QACR,IAAIH,YAAYL,SAAS;YACvB,MAAMS,WAAWC,IAAAA,qBAAW,EAACR;YAE7BG,SACGM,WAAW,CAACF,UACZG,gBAAgB,CAACC,kCAAgB;YACpC,uBAAuB;YACvB,IAAIX,OAAOY,aAAa,EAAET,SAASU,SAAS;QAC9C;IACF,GAAG;QAACb;QAAQG;QAAUL;KAAQ;IAE9B,MAAMgB,QAAkCC,IAAAA,cAAO,EAC7C,IAAO,CAAA;YACLf;YACAG;QACF,CAAA,GACA;QAACH;QAAQG;KAAS;IAGpB,qBACE,qBAACP,gBAAgBoB,QAAQ;QAACF,OAAOA;kBAC9Bf;;AAGP;AAEO,SAASJ;IACd,MAAMsB,UAAUC,IAAAA,iBAAU,EAACtB;IAE3B,IAAI,CAACqB,SAAS;QACZ,MAAM,IAAIE,MACR;IAEJ;IACA,OAAOF;AACT"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "baseEventDefinitions", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return baseEventDefinitions;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const baseEventDefinitions = [
|
|
12
|
+
// Mobile link in header
|
|
13
|
+
{
|
|
14
|
+
name: "mobileLinkClick",
|
|
15
|
+
type: "structured",
|
|
16
|
+
makePayload: ()=>({
|
|
17
|
+
category: "marketing",
|
|
18
|
+
action: "link-click",
|
|
19
|
+
label: "mobile_call_button",
|
|
20
|
+
property: window.location.href
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
// Operating hours link in footer
|
|
24
|
+
{
|
|
25
|
+
name: "operatingHoursClick",
|
|
26
|
+
type: "unstructured",
|
|
27
|
+
makePayload: ()=>({
|
|
28
|
+
schema: "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
|
|
29
|
+
data: {
|
|
30
|
+
schema: "iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2",
|
|
31
|
+
data: {}
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/services/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 * import { Snowplow } from \"./Snowplow\";\n * import { eventDefinitions } from \"./event-definitions\";\n *\n * const snowplow = new Snowplow();\n * snowplow.addEventHandlers(eventDefinitions);\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":";;;;+BAoBaA;;;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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
eventDefinitions: function() {
|
|
13
|
+
return eventDefinitions;
|
|
14
|
+
},
|
|
15
|
+
qcpPageEvents: function() {
|
|
16
|
+
return qcpPageEvents;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _base = require("./base");
|
|
20
|
+
const _qcp = require("./qcp");
|
|
21
|
+
const eventDefinitions = [
|
|
22
|
+
..._base.baseEventDefinitions,
|
|
23
|
+
..._qcp.qcpEventDefinitions
|
|
24
|
+
];
|
|
25
|
+
const qcpPageEvents = [
|
|
26
|
+
..._base.baseEventDefinitions,
|
|
27
|
+
..._qcp.qcpEventDefinitions
|
|
28
|
+
]; // Create a new export for each kind of page below
|
|
29
|
+
// containing just the subset needed for that page
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/services/snowplow/event-definitions/index.ts"],"sourcesContent":["import { baseEventDefinitions } from \"./base\";\nimport { qcpEventDefinitions } from \"./qcp\";\n\n// All events (keep up to date with new files)\nexport const eventDefinitions = [\n ...baseEventDefinitions,\n ...qcpEventDefinitions,\n];\n\nexport const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];\n\n// Create a new export for each kind of page below\n// containing just the subset needed for that page\n"],"names":["eventDefinitions","qcpPageEvents","baseEventDefinitions","qcpEventDefinitions"],"mappings":";;;;;;;;;;;IAIaA,gBAAgB;eAAhBA;;IAKAC,aAAa;eAAbA;;;sBATwB;qBACD;AAG7B,MAAMD,mBAAmB;OAC3BE,0BAAoB;OACpBC,wBAAmB;CACvB;AAEM,MAAMF,gBAAgB;OAAIC,0BAAoB;OAAKC,wBAAmB;CAAC,EAE9E,kDAAkD;CAClD,kDAAkD"}
|
|
@@ -2,35 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
Object.defineProperty(exports, "
|
|
5
|
+
Object.defineProperty(exports, "qcpEventDefinitions", {
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: function() {
|
|
8
|
-
return
|
|
8
|
+
return qcpEventDefinitions;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _utils = require("
|
|
12
|
-
const
|
|
13
|
-
{
|
|
14
|
-
name: "mobileLinkClick",
|
|
15
|
-
type: "structured",
|
|
16
|
-
makePayload: ()=>({
|
|
17
|
-
category: "marketing",
|
|
18
|
-
action: "link-click",
|
|
19
|
-
label: "mobile_call_button",
|
|
20
|
-
property: window.location.href
|
|
21
|
-
})
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: "operatingHoursClick",
|
|
25
|
-
type: "unstructured",
|
|
26
|
-
makePayload: ()=>({
|
|
27
|
-
schema: "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
|
|
28
|
-
data: {
|
|
29
|
-
schema: "iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2",
|
|
30
|
-
data: {}
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
},
|
|
11
|
+
const _utils = require("../../../utils");
|
|
12
|
+
const qcpEventDefinitions = [
|
|
34
13
|
{
|
|
35
14
|
// QDP details button
|
|
36
15
|
name: "detailsClicked",
|
|
@@ -232,4 +211,4 @@ const eventDefinitions = [
|
|
|
232
211
|
}
|
|
233
212
|
];
|
|
234
213
|
|
|
235
|
-
//# sourceMappingURL=
|
|
214
|
+
//# sourceMappingURL=qcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/services/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 * import { Snowplow } from \"./Snowplow\";\n * import { eventDefinitions } from \"./event-definitions\";\n *\n * const snowplow = new Snowplow();\n * snowplow.addEventHandlers(eventDefinitions);\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: \"Select\",\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"],"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"],"mappings":";;;;+BAqBaA;;;eAAAA;;;uBArBa;AAqBnB,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,UAA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AAC,aAAa,EAAEQ,WAAW,0BAA0B,CAAC;gBAChEN,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC;QACF;IACF;CACD"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
_export_star(require("./contexts"), exports);
|
|
6
|
+
_export_star(require("./event-definitions"), exports);
|
|
6
7
|
_export_star(require("./getSnowplowConfig"), exports);
|
|
7
8
|
_export_star(require("./Snowplow"), exports);
|
|
8
9
|
_export_star(require("./SnowplowContext"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/snowplow/index.ts"],"sourcesContent":["export * from \"./contexts\";\nexport * from \"./getSnowplowConfig\";\nexport * from \"./Snowplow\";\nexport * from \"./SnowplowContext\";\nexport * from \"./types\";\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/services/snowplow/index.ts"],"sourcesContent":["export * from \"./contexts\";\nexport * from \"./event-definitions\";\nexport * from \"./getSnowplowConfig\";\nexport * from \"./Snowplow\";\nexport * from \"./SnowplowContext\";\nexport * from \"./types\";\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/snowplow/SnowplowContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\nimport { getContexts } from \"./contexts\";\nimport { eventDefinitions } from \"./event-definitions\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/services/snowplow/SnowplowContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\nimport { getContexts } from \"./contexts\";\nimport { eventDefinitions } from \"./event-definitions\";\nimport { Snowplow } from \"./Snowplow\";\nimport { EventDefinition, TrackingProps } from \"./types\";\n\nexport interface SnowplowContextInterface {\n config: TrackingProps;\n snowplow?: Snowplow;\n}\n\nconst SnowplowContext = createContext<SnowplowContextInterface | null>(null);\n\ntype ProviderProps = {\n scripts: TrackingProps;\n children: ReactNode;\n};\n\nexport const SnowplowProvider = ({ scripts, children }: ProviderProps) => {\n const [config, _setConfig] = useState<TrackingProps>(scripts);\n const [snowplow, setSnowplow] = useState<Snowplow>(new Snowplow(config));\n\n // Attach event handlers and set contexts\n useEffect(() => {\n if (snowplow && scripts) {\n const contexts = getContexts(config);\n\n snowplow\n .setContexts(contexts)\n .addEventHandlers(eventDefinitions as EventDefinition[]);\n // Send page view event\n if (config.trackPageView) snowplow.trackView();\n }\n }, [config, snowplow, scripts]);\n\n const value: SnowplowContextInterface = useMemo(\n () => ({\n config,\n snowplow,\n }),\n [config, snowplow],\n );\n\n return (\n <SnowplowContext.Provider value={value}>\n {children}\n </SnowplowContext.Provider>\n );\n};\n\nexport function useSnowplowContext() {\n const context = useContext(SnowplowContext);\n\n if (!context) {\n throw new Error(\n \"useSnowplowContext must be used inside a `SnowplowProvider`\",\n );\n }\n return context;\n}\n"],"names":["createContext","useContext","useEffect","useMemo","useState","getContexts","eventDefinitions","Snowplow","SnowplowContext","SnowplowProvider","scripts","children","config","_setConfig","snowplow","setSnowplow","contexts","setContexts","addEventHandlers","trackPageView","trackView","value","Provider","useSnowplowContext","context","Error"],"mappings":"AAAA,oDAAoD;AACpD,SACEA,aAAa,EACbC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QAEH,QAAQ;AACf,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,QAAQ,QAAQ,aAAa;AAQtC,MAAMC,gCAAkBR,cAA+C;AAOvE,OAAO,MAAMS,mBAAmB,CAAC,EAAEC,OAAO,EAAEC,QAAQ,EAAiB;IACnE,MAAM,CAACC,QAAQC,WAAW,GAAGT,SAAwBM;IACrD,MAAM,CAACI,UAAUC,YAAY,GAAGX,SAAmB,IAAIG,SAASK;IAEhE,yCAAyC;IACzCV,UAAU;QACR,IAAIY,YAAYJ,SAAS;YACvB,MAAMM,WAAWX,YAAYO;YAE7BE,SACGG,WAAW,CAACD,UACZE,gBAAgB,CAACZ;YACpB,uBAAuB;YACvB,IAAIM,OAAOO,aAAa,EAAEL,SAASM,SAAS;QAC9C;IACF,GAAG;QAACR;QAAQE;QAAUJ;KAAQ;IAE9B,MAAMW,QAAkClB,QACtC,IAAO,CAAA;YACLS;YACAE;QACF,CAAA,GACA;QAACF;QAAQE;KAAS;IAGpB,qBACE,KAACN,gBAAgBc,QAAQ;QAACD,OAAOA;kBAC9BV;;AAGP,EAAE;AAEF,OAAO,SAASY;IACd,MAAMC,UAAUvB,WAAWO;IAE3B,IAAI,CAACgB,SAAS;QACZ,MAAM,IAAIC,MACR;IAEJ;IACA,OAAOD;AACT"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event definitions for Snowplow
|
|
3
|
+
* @type {EventDefinition[]}
|
|
4
|
+
* @property {string} name - The name of the event, to use when triggering
|
|
5
|
+
* @property {string} type - The type of the event (structured | unstructured)
|
|
6
|
+
* @property {makePayload} makePayload
|
|
7
|
+
* - Function that creates the payload for the event;
|
|
8
|
+
* - Allows optional params object to be passed in
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { Snowplow } from "./Snowplow";
|
|
12
|
+
* import { eventDefinitions } from "./event-definitions";
|
|
13
|
+
*
|
|
14
|
+
* const snowplow = new Snowplow();
|
|
15
|
+
* snowplow.addEventHandlers(eventDefinitions);
|
|
16
|
+
*/ // Base page events
|
|
17
|
+
export const baseEventDefinitions = [
|
|
18
|
+
// Mobile link in header
|
|
19
|
+
{
|
|
20
|
+
name: "mobileLinkClick",
|
|
21
|
+
type: "structured",
|
|
22
|
+
makePayload: ()=>({
|
|
23
|
+
category: "marketing",
|
|
24
|
+
action: "link-click",
|
|
25
|
+
label: "mobile_call_button",
|
|
26
|
+
property: window.location.href
|
|
27
|
+
})
|
|
28
|
+
},
|
|
29
|
+
// Operating hours link in footer
|
|
30
|
+
{
|
|
31
|
+
name: "operatingHoursClick",
|
|
32
|
+
type: "unstructured",
|
|
33
|
+
makePayload: ()=>({
|
|
34
|
+
schema: "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
|
|
35
|
+
data: {
|
|
36
|
+
schema: "iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2",
|
|
37
|
+
data: {}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/services/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 * import { Snowplow } from \"./Snowplow\";\n * import { eventDefinitions } from \"./event-definitions\";\n *\n * const snowplow = new Snowplow();\n * snowplow.addEventHandlers(eventDefinitions);\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":"AAEA;;;;;;;;;;;;;;;CAeC,GAED,mBAAmB;AACnB,OAAO,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,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { baseEventDefinitions } from "./base";
|
|
2
|
+
import { qcpEventDefinitions } from "./qcp";
|
|
3
|
+
// All events (keep up to date with new files)
|
|
4
|
+
export const eventDefinitions = [
|
|
5
|
+
...baseEventDefinitions,
|
|
6
|
+
...qcpEventDefinitions
|
|
7
|
+
];
|
|
8
|
+
export const qcpPageEvents = [
|
|
9
|
+
...baseEventDefinitions,
|
|
10
|
+
...qcpEventDefinitions
|
|
11
|
+
]; // Create a new export for each kind of page below
|
|
12
|
+
// containing just the subset needed for that page
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/services/snowplow/event-definitions/index.ts"],"sourcesContent":["import { baseEventDefinitions } from \"./base\";\nimport { qcpEventDefinitions } from \"./qcp\";\n\n// All events (keep up to date with new files)\nexport const eventDefinitions = [\n ...baseEventDefinitions,\n ...qcpEventDefinitions,\n];\n\nexport const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];\n\n// Create a new export for each kind of page below\n// containing just the subset needed for that page\n"],"names":["baseEventDefinitions","qcpEventDefinitions","eventDefinitions","qcpPageEvents"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,SAAS;AAC9C,SAASC,mBAAmB,QAAQ,QAAQ;AAE5C,8CAA8C;AAC9C,OAAO,MAAMC,mBAAmB;OAC3BF;OACAC;CACJ,CAAC;AAEF,OAAO,MAAME,gBAAgB;OAAIH;OAAyBC;CAAoB,CAAC,CAE/E,kDAAkD;CAClD,kDAAkD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { snakeCase } from "
|
|
1
|
+
import { snakeCase } from "../../../utils";
|
|
2
2
|
/**
|
|
3
3
|
* Event definitions for Snowplow
|
|
4
4
|
* @type {EventDefinition[]}
|
|
@@ -14,28 +14,8 @@ import { snakeCase } from "../../utils";
|
|
|
14
14
|
*
|
|
15
15
|
* const snowplow = new Snowplow();
|
|
16
16
|
* snowplow.addEventHandlers(eventDefinitions);
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
name: "mobileLinkClick",
|
|
20
|
-
type: "structured",
|
|
21
|
-
makePayload: ()=>({
|
|
22
|
-
category: "marketing",
|
|
23
|
-
action: "link-click",
|
|
24
|
-
label: "mobile_call_button",
|
|
25
|
-
property: window.location.href
|
|
26
|
-
})
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: "operatingHoursClick",
|
|
30
|
-
type: "unstructured",
|
|
31
|
-
makePayload: ()=>({
|
|
32
|
-
schema: "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
|
|
33
|
-
data: {
|
|
34
|
-
schema: "iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2",
|
|
35
|
-
data: {}
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
},
|
|
17
|
+
*/ // QCP page events
|
|
18
|
+
export const qcpEventDefinitions = [
|
|
39
19
|
{
|
|
40
20
|
// QDP details button
|
|
41
21
|
name: "detailsClicked",
|
|
@@ -237,4 +217,4 @@ import { snakeCase } from "../../utils";
|
|
|
237
217
|
}
|
|
238
218
|
];
|
|
239
219
|
|
|
240
|
-
//# sourceMappingURL=
|
|
220
|
+
//# sourceMappingURL=qcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/services/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 * import { Snowplow } from \"./Snowplow\";\n * import { eventDefinitions } from \"./event-definitions\";\n *\n * const snowplow = new Snowplow();\n * snowplow.addEventHandlers(eventDefinitions);\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: \"Select\",\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"],"names":["snakeCase","qcpEventDefinitions","name","type","makePayload","category","action","label","property","window","location","href","params","deviceType","urlFriendlyLabel","replace","toLowerCase","product","title","productLabel","fromValue","toValue","schema","data","from_value","to_value"],"mappings":"AAAA,SAASA,SAAS,QAAQ,iBAAiB;AAG3C;;;;;;;;;;;;;;;CAeC,GAED,kBAAkB;AAClB,OAAO,MAAMC,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;g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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,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;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/snowplow/index.ts"],"sourcesContent":["export * from \"./contexts\";\nexport * from \"./getSnowplowConfig\";\nexport * from \"./Snowplow\";\nexport * from \"./SnowplowContext\";\nexport * from \"./types\";\n"],"names":[],"mappings":"AAAA,cAAc,aAAa;AAC3B,cAAc,sBAAsB;AACpC,cAAc,aAAa;AAC3B,cAAc,oBAAoB;AAClC,cAAc,UAAU"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/services/snowplow/index.ts"],"sourcesContent":["export * from \"./contexts\";\nexport * from \"./event-definitions\";\nexport * from \"./getSnowplowConfig\";\nexport * from \"./Snowplow\";\nexport * from \"./SnowplowContext\";\nexport * from \"./types\";\n"],"names":[],"mappings":"AAAA,cAAc,aAAa;AAC3B,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,aAAa;AAC3B,cAAc,oBAAoB;AAClC,cAAc,UAAU"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventDefinition } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Event definitions for Snowplow
|
|
4
|
+
* @type {EventDefinition[]}
|
|
5
|
+
* @property {string} name - The name of the event, to use when triggering
|
|
6
|
+
* @property {string} type - The type of the event (structured | unstructured)
|
|
7
|
+
* @property {makePayload} makePayload
|
|
8
|
+
* - Function that creates the payload for the event;
|
|
9
|
+
* - Allows optional params object to be passed in
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { Snowplow } from "./Snowplow";
|
|
13
|
+
* import { eventDefinitions } from "./event-definitions";
|
|
14
|
+
*
|
|
15
|
+
* const snowplow = new Snowplow();
|
|
16
|
+
* snowplow.addEventHandlers(eventDefinitions);
|
|
17
|
+
*/
|
|
18
|
+
export declare const baseEventDefinitions: EventDefinition[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventDefinition } from "
|
|
1
|
+
import { EventDefinition } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Event definitions for Snowplow
|
|
4
4
|
* @type {EventDefinition[]}
|
|
@@ -15,4 +15,4 @@ import { EventDefinition } from "./types";
|
|
|
15
15
|
* const snowplow = new Snowplow();
|
|
16
16
|
* snowplow.addEventHandlers(eventDefinitions);
|
|
17
17
|
*/
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const qcpEventDefinitions: EventDefinition[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplybusiness/services",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"description": "Internal library for services",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
"react-dom": "^18.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@react-types/shared": "^3.
|
|
46
|
-
"@swc/cli": "^0.
|
|
47
|
-
"@swc/core": "^1.
|
|
45
|
+
"@react-types/shared": "^3.24.1",
|
|
46
|
+
"@swc/cli": "^0.4.0",
|
|
47
|
+
"@swc/core": "^1.7.1",
|
|
48
48
|
"@swc/jest": "^0.2.36",
|
|
49
|
-
"@testing-library/dom": "^10.
|
|
50
|
-
"@testing-library/jest-dom": "6.4.
|
|
49
|
+
"@testing-library/dom": "^10.4.0",
|
|
50
|
+
"@testing-library/jest-dom": "6.4.8",
|
|
51
51
|
"@testing-library/react": "^16.0.0",
|
|
52
52
|
"@types/jest": "^29.5.12",
|
|
53
53
|
"@types/react": "^18.3.3",
|
|
54
54
|
"@types/react-dom": "^18.3.0",
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
56
|
-
"@typescript-eslint/parser": "^7.
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
56
|
+
"@typescript-eslint/parser": "^7.17.0",
|
|
57
57
|
"eslint": "^8.57.0",
|
|
58
58
|
"eslint-config-airbnb": "^19.0.4",
|
|
59
59
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -61,23 +61,23 @@
|
|
|
61
61
|
"eslint-plugin-import": "^2.29.1",
|
|
62
62
|
"eslint-plugin-jsx-a11y": "^6.9.0",
|
|
63
63
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
64
|
-
"eslint-plugin-prettier": "^5.1
|
|
65
|
-
"eslint-plugin-react": "^7.
|
|
64
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
65
|
+
"eslint-plugin-react": "^7.35.0",
|
|
66
66
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
67
67
|
"identity-obj-proxy": "^3.0.0",
|
|
68
68
|
"jest": "^29.7.0",
|
|
69
69
|
"jest-environment-jsdom": "^29.7.0",
|
|
70
|
-
"prettier": "^3.3.
|
|
70
|
+
"prettier": "^3.3.3",
|
|
71
71
|
"react": "^18.3.1",
|
|
72
72
|
"react-dom": "^18.3.1",
|
|
73
|
-
"ts-jest": "^29.
|
|
73
|
+
"ts-jest": "^29.2.3",
|
|
74
74
|
"tslib": "^2.6.3",
|
|
75
|
-
"typescript": "^5.5.
|
|
75
|
+
"typescript": "^5.5.4"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@airbrake/browser": "^2.1.8",
|
|
79
|
-
"@simplybusiness/mobius": "^4.
|
|
80
|
-
"@snowplow/browser-tracker": "^3.24.
|
|
79
|
+
"@simplybusiness/mobius": "^4.14.0",
|
|
80
|
+
"@snowplow/browser-tracker": "^3.24.2",
|
|
81
81
|
"classnames": "^2.5.1"
|
|
82
82
|
},
|
|
83
83
|
"lint-staged": {
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
} from "react";
|
|
10
10
|
import { getContexts } from "./contexts";
|
|
11
11
|
import { eventDefinitions } from "./event-definitions";
|
|
12
|
-
import { EventDefinition, TrackingProps } from "./types";
|
|
13
12
|
import { Snowplow } from "./Snowplow";
|
|
13
|
+
import { EventDefinition, TrackingProps } from "./types";
|
|
14
14
|
|
|
15
15
|
export interface SnowplowContextInterface {
|
|
16
16
|
config: TrackingProps;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { EventDefinition } from "../types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Event definitions for Snowplow
|
|
5
|
+
* @type {EventDefinition[]}
|
|
6
|
+
* @property {string} name - The name of the event, to use when triggering
|
|
7
|
+
* @property {string} type - The type of the event (structured | unstructured)
|
|
8
|
+
* @property {makePayload} makePayload
|
|
9
|
+
* - Function that creates the payload for the event;
|
|
10
|
+
* - Allows optional params object to be passed in
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { Snowplow } from "./Snowplow";
|
|
14
|
+
* import { eventDefinitions } from "./event-definitions";
|
|
15
|
+
*
|
|
16
|
+
* const snowplow = new Snowplow();
|
|
17
|
+
* snowplow.addEventHandlers(eventDefinitions);
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// Base page events
|
|
21
|
+
export const baseEventDefinitions: EventDefinition[] = [
|
|
22
|
+
// Mobile link in header
|
|
23
|
+
{
|
|
24
|
+
name: "mobileLinkClick",
|
|
25
|
+
type: "structured",
|
|
26
|
+
makePayload: () => ({
|
|
27
|
+
category: "marketing",
|
|
28
|
+
action: "link-click",
|
|
29
|
+
label: "mobile_call_button",
|
|
30
|
+
property: window.location.href,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
// Operating hours link in footer
|
|
34
|
+
{
|
|
35
|
+
name: "operatingHoursClick",
|
|
36
|
+
type: "unstructured",
|
|
37
|
+
makePayload: () => ({
|
|
38
|
+
schema:
|
|
39
|
+
"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
|
|
40
|
+
data: {
|
|
41
|
+
schema:
|
|
42
|
+
"iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2",
|
|
43
|
+
data: {},
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { baseEventDefinitions } from "./base";
|
|
2
|
+
import { qcpEventDefinitions } from "./qcp";
|
|
3
|
+
|
|
4
|
+
// All events (keep up to date with new files)
|
|
5
|
+
export const eventDefinitions = [
|
|
6
|
+
...baseEventDefinitions,
|
|
7
|
+
...qcpEventDefinitions,
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];
|
|
11
|
+
|
|
12
|
+
// Create a new export for each kind of page below
|
|
13
|
+
// containing just the subset needed for that page
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { snakeCase } from "../../../utils";
|
|
2
|
+
import { EventDefinition, ParamsType } from "../types";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Event definitions for Snowplow
|
|
@@ -17,30 +17,9 @@ import { snakeCase } from "../../utils";
|
|
|
17
17
|
* const snowplow = new Snowplow();
|
|
18
18
|
* snowplow.addEventHandlers(eventDefinitions);
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type: "structured",
|
|
24
|
-
makePayload: () => ({
|
|
25
|
-
category: "marketing",
|
|
26
|
-
action: "link-click",
|
|
27
|
-
label: "mobile_call_button",
|
|
28
|
-
property: window.location.href,
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: "operatingHoursClick",
|
|
33
|
-
type: "unstructured",
|
|
34
|
-
makePayload: () => ({
|
|
35
|
-
schema:
|
|
36
|
-
"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
|
|
37
|
-
data: {
|
|
38
|
-
schema:
|
|
39
|
-
"iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2",
|
|
40
|
-
data: {},
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
},
|
|
20
|
+
|
|
21
|
+
// QCP page events
|
|
22
|
+
export const qcpEventDefinitions: EventDefinition[] = [
|
|
44
23
|
{
|
|
45
24
|
// QDP details button
|
|
46
25
|
name: "detailsClicked",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/snowplow/event-definitions.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"./types\";\nimport { snakeCase } from \"../../utils\";\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 * import { Snowplow } from \"./Snowplow\";\n * import { eventDefinitions } from \"./event-definitions\";\n *\n * const snowplow = new Snowplow();\n * snowplow.addEventHandlers(eventDefinitions);\n */\nexport const eventDefinitions: EventDefinition[] = [\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 {\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 // 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: \"Select\",\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"],"names":["eventDefinitions","name","type","makePayload","category","action","label","property","window","location","href","schema","data","params","deviceType","urlFriendlyLabel","replace","toLowerCase","product","title","productLabel","snakeCase","fromValue","toValue","from_value","to_value"],"mappings":";;;;+BAmBaA;;;eAAAA;;;uBAlBa;AAkBnB,MAAMA,mBAAsC;IACjD;QACEC,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;gBAClBQ,QACE;gBACFC,MAAM;oBACJD,QACE;oBACFC,MAAM,CAAC;gBACT;YACF,CAAA;IACF;IACA;QACE,qBAAqB;QACrBX,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,aAAaU,CAAAA;YACX,MAAM,EAAEP,KAAK,EAAEQ,UAAU,EAAE,GAAGD;YAC9B,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;gBAChER,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC;QACF;IACF;CACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/services/snowplow/event-definitions.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"./types\";\nimport { snakeCase } from \"../../utils\";\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 * import { Snowplow } from \"./Snowplow\";\n * import { eventDefinitions } from \"./event-definitions\";\n *\n * const snowplow = new Snowplow();\n * snowplow.addEventHandlers(eventDefinitions);\n */\nexport const eventDefinitions: EventDefinition[] = [\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 {\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 // 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: \"Select\",\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"],"names":["snakeCase","eventDefinitions","name","type","makePayload","category","action","label","property","window","location","href","schema","data","params","deviceType","urlFriendlyLabel","replace","toLowerCase","product","title","productLabel","fromValue","toValue","from_value","to_value"],"mappings":"AACA,SAASA,SAAS,QAAQ,cAAc;AAExC;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMC,mBAAsC;IACjD;QACEC,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA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