@simplybusiness/services 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/snowplow/event-definitions/base.js.map +1 -1
  3. package/dist/cjs/snowplow/event-definitions/index.js +6 -6
  4. package/dist/cjs/snowplow/event-definitions/index.js.map +1 -1
  5. package/dist/cjs/snowplow/event-definitions/qcp.js.map +1 -1
  6. package/dist/cjs/snowplow/event-definitions/{thankYou.js → referral.js} +4 -4
  7. package/dist/cjs/snowplow/event-definitions/{thankYou.js.map → referral.js.map} +1 -1
  8. package/dist/esm/snowplow/event-definitions/base.js +8 -4
  9. package/dist/esm/snowplow/event-definitions/base.js.map +1 -1
  10. package/dist/esm/snowplow/event-definitions/index.js +4 -4
  11. package/dist/esm/snowplow/event-definitions/index.js.map +1 -1
  12. package/dist/esm/snowplow/event-definitions/qcp.js +8 -4
  13. package/dist/esm/snowplow/event-definitions/qcp.js.map +1 -1
  14. package/dist/esm/snowplow/event-definitions/{thankYou.js → referral.js} +3 -3
  15. package/dist/esm/snowplow/event-definitions/{thankYou.js.map → referral.js.map} +1 -1
  16. package/dist/types/snowplow/event-definitions/base.d.ts +8 -4
  17. package/dist/types/snowplow/event-definitions/index.d.ts +1 -1
  18. package/dist/types/snowplow/event-definitions/qcp.d.ts +8 -4
  19. package/dist/types/snowplow/event-definitions/referral.d.ts +2 -0
  20. package/package.json +2 -2
  21. package/src/snowplow/event-definitions/base.ts +8 -4
  22. package/src/snowplow/event-definitions/index.ts +4 -4
  23. package/src/snowplow/event-definitions/qcp.ts +8 -4
  24. package/src/snowplow/event-definitions/{thankYou.ts → referral.ts} +2 -2
  25. package/dist/types/snowplow/event-definitions/thankYou.d.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c801be9: **Breaking change** - Rename all `ThankYou` components to `Referral`
8
+
9
+ ### Patch Changes
10
+
11
+ - 45e9667: Add `<EditLimits>` to `<HeadlineExperimentIteratedQCP>`
12
+ - Updated dependencies [d1d1631]
13
+ - Updated dependencies [5979683]
14
+ - Updated dependencies [45e9667]
15
+ - @simplybusiness/mobius@4.16.0
16
+
3
17
  ## 0.2.1
4
18
 
5
19
  ### Patch Changes
@@ -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 * 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"}
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"}
@@ -15,25 +15,25 @@ _export(exports, {
15
15
  qcpPageEvents: function() {
16
16
  return qcpPageEvents;
17
17
  },
18
- thankYouPageEvents: function() {
19
- return thankYouPageEvents;
18
+ referralPageEvents: function() {
19
+ return referralPageEvents;
20
20
  }
21
21
  });
22
22
  const _base = require("./base");
23
23
  const _qcp = require("./qcp");
24
- const _thankYou = require("./thankYou");
24
+ const _referral = require("./referral");
25
25
  const eventDefinitions = [
26
26
  ..._base.baseEventDefinitions,
27
27
  ..._qcp.qcpEventDefinitions,
28
- ..._thankYou.thankYouEventDefinitions
28
+ ..._referral.referralEventDefinitions
29
29
  ];
30
30
  const qcpPageEvents = [
31
31
  ..._base.baseEventDefinitions,
32
32
  ..._qcp.qcpEventDefinitions
33
33
  ];
34
- const thankYouPageEvents = [
34
+ const referralPageEvents = [
35
35
  ..._base.baseEventDefinitions,
36
- ..._thankYou.thankYouEventDefinitions
36
+ ..._referral.referralEventDefinitions
37
37
  ]; // Create a new export for each kind of page below
38
38
  // containing just the subset needed for that page
39
39
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/snowplow/event-definitions/index.ts"],"sourcesContent":["import { baseEventDefinitions } from \"./base\";\nimport { qcpEventDefinitions } from \"./qcp\";\nimport { thankYouEventDefinitions } from \"./thankYou\";\n\n// All events (keep up to date with new files)\nexport const eventDefinitions = [\n ...baseEventDefinitions,\n ...qcpEventDefinitions,\n ...thankYouEventDefinitions,\n];\n\nexport const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];\n\nexport const thankYouPageEvents = [\n ...baseEventDefinitions,\n ...thankYouEventDefinitions,\n];\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","thankYouPageEvents","baseEventDefinitions","qcpEventDefinitions","thankYouEventDefinitions"],"mappings":";;;;;;;;;;;IAKaA,gBAAgB;eAAhBA;;IAMAC,aAAa;eAAbA;;IAEAC,kBAAkB;eAAlBA;;;sBAbwB;qBACD;0BACK;AAGlC,MAAMF,mBAAmB;OAC3BG,0BAAoB;OACpBC,wBAAmB;OACnBC,kCAAwB;CAC5B;AAEM,MAAMJ,gBAAgB;OAAIE,0BAAoB;OAAKC,wBAAmB;CAAC;AAEvE,MAAMF,qBAAqB;OAC7BC,0BAAoB;OACpBE,kCAAwB;CAC5B,EAED,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\";\n\n// All events (keep up to date with new files)\nexport const eventDefinitions = [\n ...baseEventDefinitions,\n ...qcpEventDefinitions,\n ...referralEventDefinitions,\n];\n\nexport const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];\n\nexport const referralPageEvents = [\n ...baseEventDefinitions,\n ...referralEventDefinitions,\n];\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","referralPageEvents","baseEventDefinitions","qcpEventDefinitions","referralEventDefinitions"],"mappings":";;;;;;;;;;;IAKaA,gBAAgB;eAAhBA;;IAMAC,aAAa;eAAbA;;IAEAC,kBAAkB;eAAlBA;;;sBAbwB;qBACD;0BACK;AAGlC,MAAMF,mBAAmB;OAC3BG,0BAAoB;OACpBC,wBAAmB;OACnBC,kCAAwB;CAC5B;AAEM,MAAMJ,gBAAgB;OAAIE,0BAAoB;OAAKC,wBAAmB;CAAC;AAEvE,MAAMF,qBAAqB;OAC7BC,0BAAoB;OACpBE,kCAAwB;CAC5B,EAED,kDAAkD;CAClD,kDAAkD"}
@@ -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 * 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 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"],"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":";;;;+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;g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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;CACD"}
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: \"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 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"],"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,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;IAC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C,MAAM;oBACJK,YAAYF;oBACZC;gBACF;YACF;QACF;IACF;CACD"}
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "thankYouEventDefinitions", {
5
+ Object.defineProperty(exports, "referralEventDefinitions", {
6
6
  enumerable: true,
7
7
  get: function() {
8
- return thankYouEventDefinitions;
8
+ return referralEventDefinitions;
9
9
  }
10
10
  });
11
- const thankYouEventDefinitions = [
11
+ const referralEventDefinitions = [
12
12
  {
13
13
  name: "nextCoverageClicked",
14
14
  type: "structured",
@@ -25,4 +25,4 @@ const thankYouEventDefinitions = [
25
25
  }
26
26
  ];
27
27
 
28
- //# sourceMappingURL=thankYou.js.map
28
+ //# sourceMappingURL=referral.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/snowplow/event-definitions/thankYou.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"../types\";\n\n// ThankYou page events\nexport const thankYouEventDefinitions: EventDefinition[] = [\n {\n name: \"nextCoverageClicked\",\n type: \"structured\",\n makePayload: params => {\n const { url } = params as ParamsType;\n const eventName = \"post_referral_workers_compensation_continuation_link\";\n\n return {\n category: eventName,\n action: \"link_click\",\n label: eventName,\n property: url,\n };\n },\n },\n];\n"],"names":["thankYouEventDefinitions","name","type","makePayload","params","url","eventName","category","action","label","property"],"mappings":";;;;+BAGaA;;;eAAAA;;;AAAN,MAAMA,2BAA8C;IACzD;QACEC,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEC,GAAG,EAAE,GAAGD;YAChB,MAAME,YAAY;YAElB,OAAO;gBACLC,UAAUD;gBACVE,QAAQ;gBACRC,OAAOH;gBACPI,UAAUL;YACZ;QACF;IACF;CACD"}
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/referral.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"../types\";\n\n// Referral page events\nexport const referralEventDefinitions: EventDefinition[] = [\n {\n name: \"nextCoverageClicked\",\n type: \"structured\",\n makePayload: params => {\n const { url } = params as ParamsType;\n const eventName = \"post_referral_workers_compensation_continuation_link\";\n\n return {\n category: eventName,\n action: \"link_click\",\n label: eventName,\n property: url,\n };\n },\n },\n];\n"],"names":["referralEventDefinitions","name","type","makePayload","params","url","eventName","category","action","label","property"],"mappings":";;;;+BAGaA;;;eAAAA;;;AAAN,MAAMA,2BAA8C;IACzD;QACEC,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEC,GAAG,EAAE,GAAGD;YAChB,MAAME,YAAY;YAElB,OAAO;gBACLC,UAAUD;gBACVE,QAAQ;gBACRC,OAAOH;gBACPI,UAAUL;YACZ;QACF;IACF;CACD"}
@@ -8,11 +8,15 @@
8
8
  * - Allows optional params object to be passed in
9
9
  *
10
10
  * @example
11
- * import { Snowplow } from "./Snowplow";
12
- * import { eventDefinitions } from "./event-definitions";
11
+ * Parent
12
+ * import { getSnowplowConfig, SnowplowProvider } from "@simplybusiness/services";
13
+ * const snowplowProps = getSnowplowConfig(pageData);
14
+ * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>
13
15
  *
14
- * const snowplow = new Snowplow();
15
- * snowplow.addEventHandlers(eventDefinitions);
16
+ * Child
17
+ * import { useSnowplowContext } from "@simplybusiness/services";
18
+ * const { snowplow } = useSnowplowContext();
19
+ * const handlerFunction = () => snowplow?.trigger("eventNameHere");
16
20
  */ // Base page events
17
21
  export const baseEventDefinitions = [
18
22
  // Mobile link in header
@@ -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 * 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"}
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":"AAEA;;;;;;;;;;;;;;;;;;;CAmBC,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"}
@@ -1,19 +1,19 @@
1
1
  import { baseEventDefinitions } from "./base";
2
2
  import { qcpEventDefinitions } from "./qcp";
3
- import { thankYouEventDefinitions } from "./thankYou";
3
+ import { referralEventDefinitions } from "./referral";
4
4
  // All events (keep up to date with new files)
5
5
  export const eventDefinitions = [
6
6
  ...baseEventDefinitions,
7
7
  ...qcpEventDefinitions,
8
- ...thankYouEventDefinitions
8
+ ...referralEventDefinitions
9
9
  ];
10
10
  export const qcpPageEvents = [
11
11
  ...baseEventDefinitions,
12
12
  ...qcpEventDefinitions
13
13
  ];
14
- export const thankYouPageEvents = [
14
+ export const referralPageEvents = [
15
15
  ...baseEventDefinitions,
16
- ...thankYouEventDefinitions
16
+ ...referralEventDefinitions
17
17
  ]; // Create a new export for each kind of page below
18
18
  // containing just the subset needed for that page
19
19
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/snowplow/event-definitions/index.ts"],"sourcesContent":["import { baseEventDefinitions } from \"./base\";\nimport { qcpEventDefinitions } from \"./qcp\";\nimport { thankYouEventDefinitions } from \"./thankYou\";\n\n// All events (keep up to date with new files)\nexport const eventDefinitions = [\n ...baseEventDefinitions,\n ...qcpEventDefinitions,\n ...thankYouEventDefinitions,\n];\n\nexport const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];\n\nexport const thankYouPageEvents = [\n ...baseEventDefinitions,\n ...thankYouEventDefinitions,\n];\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","thankYouEventDefinitions","eventDefinitions","qcpPageEvents","thankYouPageEvents"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,SAAS;AAC9C,SAASC,mBAAmB,QAAQ,QAAQ;AAC5C,SAASC,wBAAwB,QAAQ,aAAa;AAEtD,8CAA8C;AAC9C,OAAO,MAAMC,mBAAmB;OAC3BH;OACAC;OACAC;CACJ,CAAC;AAEF,OAAO,MAAME,gBAAgB;OAAIJ;OAAyBC;CAAoB,CAAC;AAE/E,OAAO,MAAMI,qBAAqB;OAC7BL;OACAE;CACJ,CAAC,CAEF,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\";\n\n// All events (keep up to date with new files)\nexport const eventDefinitions = [\n ...baseEventDefinitions,\n ...qcpEventDefinitions,\n ...referralEventDefinitions,\n];\n\nexport const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];\n\nexport const referralPageEvents = [\n ...baseEventDefinitions,\n ...referralEventDefinitions,\n];\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","referralEventDefinitions","eventDefinitions","qcpPageEvents","referralPageEvents"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,SAAS;AAC9C,SAASC,mBAAmB,QAAQ,QAAQ;AAC5C,SAASC,wBAAwB,QAAQ,aAAa;AAEtD,8CAA8C;AAC9C,OAAO,MAAMC,mBAAmB;OAC3BH;OACAC;OACAC;CACJ,CAAC;AAEF,OAAO,MAAME,gBAAgB;OAAIJ;OAAyBC;CAAoB,CAAC;AAE/E,OAAO,MAAMI,qBAAqB;OAC7BL;OACAE;CACJ,CAAC,CAEF,kDAAkD;CAClD,kDAAkD"}
@@ -9,11 +9,15 @@ import { snakeCase } from "../../utils";
9
9
  * - Allows optional params object to be passed in
10
10
  *
11
11
  * @example
12
- * import { Snowplow } from "./Snowplow";
13
- * import { eventDefinitions } from "./event-definitions";
12
+ * Parent
13
+ * import { getSnowplowConfig, SnowplowProvider } from "@simplybusiness/services";
14
+ * const snowplowProps = getSnowplowConfig(pageData);
15
+ * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>
14
16
  *
15
- * const snowplow = new Snowplow();
16
- * snowplow.addEventHandlers(eventDefinitions);
17
+ * Child
18
+ * import { useSnowplowContext } from "@simplybusiness/services";
19
+ * const { snowplow } = useSnowplowContext();
20
+ * const handlerFunction = () => snowplow?.trigger("eventNameHere");
17
21
  */ // QCP page events
18
22
  export const qcpEventDefinitions = [
19
23
  {
@@ -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 * 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 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"],"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","journeyId","vertical","journey_id"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAGxC;;;;;;;;;;;;;;;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;gBACVC,QAAQ;gBACRC,OAAO;YACT,CAAA;IACF;IACA;QACE,+BAA+B;QAC/BL,MAAM;QACNC,M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;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,EAAEc,SAAS,EAAEC,QAAQ,EAAE,GAAGf;YAEhC,OAAO;gBACLU,QAAQ;gBACRC,MAAM;oBACJK,YAAYF;oBACZC;gBACF;YACF;QACF;IACF;CACD,CAAC"}
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: \"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 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"],"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","journeyId","vertical","journey_id"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAGxC;;;;;;;;;;;;;;;;;;;CAmBC,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;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,aAAaQ,CAAA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ou page events
2
- export const thankYouEventDefinitions = [
1
+ // Referral page events
2
+ export const referralEventDefinitions = [
3
3
  {
4
4
  name: "nextCoverageClicked",
5
5
  type: "structured",
@@ -16,4 +16,4 @@ export const thankYouEventDefinitions = [
16
16
  }
17
17
  ];
18
18
 
19
- //# sourceMappingURL=thankYou.js.map
19
+ //# sourceMappingURL=referral.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/snowplow/event-definitions/thankYou.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"../types\";\n\n// ThankYou page events\nexport const thankYouEventDefinitions: EventDefinition[] = [\n {\n name: \"nextCoverageClicked\",\n type: \"structured\",\n makePayload: params => {\n const { url } = params as ParamsType;\n const eventName = \"post_referral_workers_compensation_continuation_link\";\n\n return {\n category: eventName,\n action: \"link_click\",\n label: eventName,\n property: url,\n };\n },\n },\n];\n"],"names":["thankYouEventDefinitions","name","type","makePayload","params","url","eventName","category","action","label","property"],"mappings":"AAEA,uBAAuB;AACvB,OAAO,MAAMA,2BAA8C;IACzD;QACEC,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEC,GAAG,EAAE,GAAGD;YAChB,MAAME,YAAY;YAElB,OAAO;gBACLC,UAAUD;gBACVE,QAAQ;gBACRC,OAAOH;gBACPI,UAAUL;YACZ;QACF;IACF;CACD,CAAC"}
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/referral.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"../types\";\n\n// Referral page events\nexport const referralEventDefinitions: EventDefinition[] = [\n {\n name: \"nextCoverageClicked\",\n type: \"structured\",\n makePayload: params => {\n const { url } = params as ParamsType;\n const eventName = \"post_referral_workers_compensation_continuation_link\";\n\n return {\n category: eventName,\n action: \"link_click\",\n label: eventName,\n property: url,\n };\n },\n },\n];\n"],"names":["referralEventDefinitions","name","type","makePayload","params","url","eventName","category","action","label","property"],"mappings":"AAEA,uBAAuB;AACvB,OAAO,MAAMA,2BAA8C;IACzD;QACEC,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEC,GAAG,EAAE,GAAGD;YAChB,MAAME,YAAY;YAElB,OAAO;gBACLC,UAAUD;gBACVE,QAAQ;gBACRC,OAAOH;gBACPI,UAAUL;YACZ;QACF;IACF;CACD,CAAC"}
@@ -9,10 +9,14 @@ import { EventDefinition } from "../types";
9
9
  * - Allows optional params object to be passed in
10
10
  *
11
11
  * @example
12
- * import { Snowplow } from "./Snowplow";
13
- * import { eventDefinitions } from "./event-definitions";
12
+ * Parent
13
+ * import { getSnowplowConfig, SnowplowProvider } from "@simplybusiness/services";
14
+ * const snowplowProps = getSnowplowConfig(pageData);
15
+ * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>
14
16
  *
15
- * const snowplow = new Snowplow();
16
- * snowplow.addEventHandlers(eventDefinitions);
17
+ * Child
18
+ * import { useSnowplowContext } from "@simplybusiness/services";
19
+ * const { snowplow } = useSnowplowContext();
20
+ * const handlerFunction = () => snowplow?.trigger("eventNameHere");
17
21
  */
18
22
  export declare const baseEventDefinitions: EventDefinition[];
@@ -1,3 +1,3 @@
1
1
  export declare const eventDefinitions: import("..").EventDefinition[];
2
2
  export declare const qcpPageEvents: import("..").EventDefinition[];
3
- export declare const thankYouPageEvents: import("..").EventDefinition[];
3
+ export declare const referralPageEvents: import("..").EventDefinition[];
@@ -9,10 +9,14 @@ import { EventDefinition } from "../types";
9
9
  * - Allows optional params object to be passed in
10
10
  *
11
11
  * @example
12
- * import { Snowplow } from "./Snowplow";
13
- * import { eventDefinitions } from "./event-definitions";
12
+ * Parent
13
+ * import { getSnowplowConfig, SnowplowProvider } from "@simplybusiness/services";
14
+ * const snowplowProps = getSnowplowConfig(pageData);
15
+ * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>
14
16
  *
15
- * const snowplow = new Snowplow();
16
- * snowplow.addEventHandlers(eventDefinitions);
17
+ * Child
18
+ * import { useSnowplowContext } from "@simplybusiness/services";
19
+ * const { snowplow } = useSnowplowContext();
20
+ * const handlerFunction = () => snowplow?.trigger("eventNameHere");
17
21
  */
18
22
  export declare const qcpEventDefinitions: EventDefinition[];
@@ -0,0 +1,2 @@
1
+ import { EventDefinition } from "../types";
2
+ export declare const referralEventDefinitions: EventDefinition[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simplybusiness/services",
3
3
  "license": "UNLICENSED",
4
- "version": "0.2.1",
4
+ "version": "0.3.0",
5
5
  "description": "Internal library for services",
6
6
  "repository": {
7
7
  "type": "git",
@@ -76,7 +76,7 @@
76
76
  },
77
77
  "dependencies": {
78
78
  "@airbrake/browser": "^2.1.8",
79
- "@simplybusiness/mobius": "^4.15.1",
79
+ "@simplybusiness/mobius": "^4.16.0",
80
80
  "@snowplow/browser-tracker": "^3.24.2",
81
81
  "classnames": "^2.5.1"
82
82
  },
@@ -10,11 +10,15 @@ import { EventDefinition } from "../types";
10
10
  * - Allows optional params object to be passed in
11
11
  *
12
12
  * @example
13
- * import { Snowplow } from "./Snowplow";
14
- * import { eventDefinitions } from "./event-definitions";
13
+ * Parent
14
+ * import { getSnowplowConfig, SnowplowProvider } from "@simplybusiness/services";
15
+ * const snowplowProps = getSnowplowConfig(pageData);
16
+ * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>
15
17
  *
16
- * const snowplow = new Snowplow();
17
- * snowplow.addEventHandlers(eventDefinitions);
18
+ * Child
19
+ * import { useSnowplowContext } from "@simplybusiness/services";
20
+ * const { snowplow } = useSnowplowContext();
21
+ * const handlerFunction = () => snowplow?.trigger("eventNameHere");
18
22
  */
19
23
 
20
24
  // Base page events
@@ -1,19 +1,19 @@
1
1
  import { baseEventDefinitions } from "./base";
2
2
  import { qcpEventDefinitions } from "./qcp";
3
- import { thankYouEventDefinitions } from "./thankYou";
3
+ import { referralEventDefinitions } from "./referral";
4
4
 
5
5
  // All events (keep up to date with new files)
6
6
  export const eventDefinitions = [
7
7
  ...baseEventDefinitions,
8
8
  ...qcpEventDefinitions,
9
- ...thankYouEventDefinitions,
9
+ ...referralEventDefinitions,
10
10
  ];
11
11
 
12
12
  export const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];
13
13
 
14
- export const thankYouPageEvents = [
14
+ export const referralPageEvents = [
15
15
  ...baseEventDefinitions,
16
- ...thankYouEventDefinitions,
16
+ ...referralEventDefinitions,
17
17
  ];
18
18
 
19
19
  // Create a new export for each kind of page below
@@ -11,11 +11,15 @@ import { EventDefinition, ParamsType } from "../types";
11
11
  * - Allows optional params object to be passed in
12
12
  *
13
13
  * @example
14
- * import { Snowplow } from "./Snowplow";
15
- * import { eventDefinitions } from "./event-definitions";
14
+ * Parent
15
+ * import { getSnowplowConfig, SnowplowProvider } from "@simplybusiness/services";
16
+ * const snowplowProps = getSnowplowConfig(pageData);
17
+ * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>
16
18
  *
17
- * const snowplow = new Snowplow();
18
- * snowplow.addEventHandlers(eventDefinitions);
19
+ * Child
20
+ * import { useSnowplowContext } from "@simplybusiness/services";
21
+ * const { snowplow } = useSnowplowContext();
22
+ * const handlerFunction = () => snowplow?.trigger("eventNameHere");
19
23
  */
20
24
 
21
25
  // QCP page events
@@ -1,7 +1,7 @@
1
1
  import { EventDefinition, ParamsType } from "../types";
2
2
 
3
- // ThankYou page events
4
- export const thankYouEventDefinitions: EventDefinition[] = [
3
+ // Referral page events
4
+ export const referralEventDefinitions: EventDefinition[] = [
5
5
  {
6
6
  name: "nextCoverageClicked",
7
7
  type: "structured",
@@ -1,2 +0,0 @@
1
- import { EventDefinition } from "../types";
2
- export declare const thankYouEventDefinitions: EventDefinition[];