@simplybusiness/services 0.8.0 → 0.13.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 (47) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cjs/mocks/eventDefinitions.js +39 -0
  3. package/dist/cjs/mocks/eventDefinitions.js.map +1 -1
  4. package/dist/cjs/snowplow/Snowplow.js +13 -2
  5. package/dist/cjs/snowplow/Snowplow.js.map +1 -1
  6. package/dist/cjs/snowplow/event-definitions/base.js +39 -0
  7. package/dist/cjs/snowplow/event-definitions/base.js.map +1 -1
  8. package/dist/cjs/snowplow/event-definitions/index.js +9 -2
  9. package/dist/cjs/snowplow/event-definitions/index.js.map +1 -1
  10. package/dist/cjs/snowplow/event-definitions/qcp.js +14 -0
  11. package/dist/cjs/snowplow/event-definitions/qcp.js.map +1 -1
  12. package/dist/cjs/snowplow/event-definitions/questionnaire.js +49 -0
  13. package/dist/cjs/snowplow/event-definitions/questionnaire.js.map +1 -0
  14. package/dist/cjs/snowplow/event-definitions/redaction.js +152 -0
  15. package/dist/cjs/snowplow/event-definitions/redaction.js.map +1 -0
  16. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  17. package/dist/esm/mocks/eventDefinitions.js +39 -0
  18. package/dist/esm/mocks/eventDefinitions.js.map +1 -1
  19. package/dist/esm/snowplow/Snowplow.js +13 -2
  20. package/dist/esm/snowplow/Snowplow.js.map +1 -1
  21. package/dist/esm/snowplow/event-definitions/base.js +39 -0
  22. package/dist/esm/snowplow/event-definitions/base.js.map +1 -1
  23. package/dist/esm/snowplow/event-definitions/index.js +6 -2
  24. package/dist/esm/snowplow/event-definitions/index.js.map +1 -1
  25. package/dist/esm/snowplow/event-definitions/qcp.js +14 -0
  26. package/dist/esm/snowplow/event-definitions/qcp.js.map +1 -1
  27. package/dist/esm/snowplow/event-definitions/questionnaire.js +40 -0
  28. package/dist/esm/snowplow/event-definitions/questionnaire.js.map +1 -0
  29. package/dist/esm/snowplow/event-definitions/redaction.js +142 -0
  30. package/dist/esm/snowplow/event-definitions/redaction.js.map +1 -0
  31. package/dist/esm/snowplow/types.js.map +1 -1
  32. package/dist/types/mocks/eventDefinitions.d.ts +30 -0
  33. package/dist/types/snowplow/Snowplow.d.ts +1 -0
  34. package/dist/types/snowplow/event-definitions/index.d.ts +1 -0
  35. package/dist/types/snowplow/event-definitions/questionnaire.d.ts +2 -0
  36. package/dist/types/snowplow/event-definitions/redaction.d.ts +5 -0
  37. package/dist/types/snowplow/types.d.ts +15 -1
  38. package/package.json +1 -1
  39. package/src/mocks/eventDefinitions.ts +44 -0
  40. package/src/snowplow/Snowplow.ts +16 -2
  41. package/src/snowplow/event-definitions/base.ts +43 -2
  42. package/src/snowplow/event-definitions/index.ts +4 -0
  43. package/src/snowplow/event-definitions/qcp.ts +17 -1
  44. package/src/snowplow/event-definitions/questionnaire.ts +43 -0
  45. package/src/snowplow/event-definitions/redaction.ts +144 -0
  46. package/src/snowplow/index.test.ts +179 -6
  47. package/src/snowplow/types.ts +17 -15
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/snowplow/event-definitions/qcp.ts"],"sourcesContent":["import { snakeCase } from \"../../utils\";\nimport { EventDefinition, ParamsType } from \"../types\";\n\n/**\n * Event definitions for Snowplow\n * @type {EventDefinition[]}\n * @property {string} name - The name of the event, to use when triggering\n * @property {string} type - The type of the event (structured | unstructured)\n * @property {makePayload} makePayload\n * - Function that creates the payload for the event;\n * - Allows optional params object to be passed in\n *\n * @example\n * Parent\n * import { getSnowplowConfig, SnowplowProvider } from \"@simplybusiness/services\";\n * const snowplowProps = getSnowplowConfig(pageData);\n * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>\n *\n * Child\n * import { useSnowplowContext } from \"@simplybusiness/services\";\n * const { snowplow } = useSnowplowContext();\n * const handlerFunction = () => snowplow?.trigger(\"eventNameHere\");\n */\n\n// QCP page events\nexport const qcpEventDefinitions: EventDefinition[] = [\n {\n // QDP details button\n name: \"detailsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Details\",\n }),\n },\n {\n // Buy button\n name: \"selectClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Buy\",\n }),\n },\n {\n // Quote Details Slider Next steps button\n name: \"nextStepsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_next_step_cta\",\n action: \"link_click\",\n label: \"Next steps\",\n }),\n },\n {\n // Toggle deductibles accordion\n name: \"deductiblesClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"us-qcp-react\",\n action: \"view_deductables_clicked\",\n label: \"view_deductables_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"deductiblesClickedUk\",\n type: \"structured\",\n makePayload: params => {\n const { label, deviceType } = params as ParamsType;\n const urlFriendlyLabel = label.replace(/ /g, \"-\").toLowerCase();\n\n return {\n category: `uk-qcp-react-${deviceType}-${urlFriendlyLabel}-view-excess-toggle`,\n action: \"view_excess_clicked\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n // Quote Details Slider opened\n name: \"sliderOpened\",\n type: \"structured\",\n makePayload: params => {\n const { label } = params as ParamsType;\n\n return {\n category: \"comparison_cta\",\n action: \"quote_details_slider_opened\",\n label,\n };\n },\n },\n {\n // Coverage modal opened\n name: \"coverageModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const {\n category,\n product = \"extra_coverage\",\n title,\n } = params as ParamsType;\n const productLabel = snakeCase(product);\n\n return {\n category,\n action: `${productLabel}_${snakeCase(title)}_popup_opened`,\n label: productLabel,\n property: window.location.href,\n };\n },\n },\n {\n // Toggle cover select\n name: \"coverChanged\",\n type: \"unstructured\",\n makePayload: params => {\n const { name = \"\", fromValue = \"\", toValue = \"\" } = params as ParamsType;\n // Derive data\n let action = \"change\";\n\n // This logic is taken directly from Chopin without documentation:\n // If a cover has zero value, then change the action to add or remove\n if (fromValue === \"0\") {\n action = \"add\";\n }\n if (toValue === \"0\") {\n action = \"remove\";\n }\n\n return {\n schema:\n \"iglu:com.simplybusiness/comparison_page_cover_changed/jsonschema/1-0-0\",\n data: {\n name,\n action,\n from_value: fromValue,\n to_value: toValue,\n },\n };\n },\n },\n {\n name: \"ratingsModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"insurer_rating_help_popup_triggered\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"coverToggleOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"qcp_limit_interaction\",\n label: \"limit_interaction\",\n action: \"limit_interaction_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"paymentToggleClicked\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"button_click\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"insurerDetailsAccordionClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_insurer_details_description\",\n action: \"accordion_clicked\",\n label: \"accordion_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"priceDetailsPopUpOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"price_details\",\n action: \"price_details_popup_opened\",\n label: \"Price details\",\n property: window.location.href,\n }),\n },\n {\n name: \"editLimitButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"edit_limit_button_clicked\",\n label: \"Edit Limit\",\n property: window.location.href,\n }),\n },\n {\n name: \"applyButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"apply_button_clicked\",\n label: \"Apply Button Clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"coverageInfoClicked\",\n type: \"structured\",\n makePayload: params => {\n const { deviceType } = params as ParamsType;\n\n return {\n action: \"show_coverage_info_clicked\",\n category: `uk-qcp-react-${deviceType}-show-coverage-info-toggle`,\n label: \"show_coverage_info_clicked\",\n property: window.location.href,\n };\n },\n },\n {\n name: \"backToApplication\",\n type: \"unstructured\",\n makePayload: params => {\n const { journeyId, vertical } = params as ParamsType;\n\n return {\n schema: \"iglu:com.simplybusiness/back_to_application/jsonschema/1-0-0\",\n data: {\n journey_id: journeyId,\n vertical,\n },\n };\n },\n },\n {\n name: \"helpChatLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"help chat for question\",\n action: \"help_chat_for_question_clicked\",\n property: window.location.href,\n }),\n },\n // No quotes referral\n {\n name: \"coverOptionsLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"uk-qcp-react-cover-options-link\",\n action: \"cover_options_link_clicked\",\n label: \"cover_options_link_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"phoneNumberLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"uk-qcp-react-phone-number-link\",\n action: \"phone_number_link_clicked\",\n label: \"phone_number_link_clicked\",\n property: window.location.href,\n }),\n },\n];\n"],"names":["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,O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,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,EAAEc,SAAS,EAAEC,QAAQ,EAAE,GAAGf;YAEhC,OAAO;gBACLU,QAAQ;gBACRC,MAAM;oBACJK,YAAYF;oBACZC;gBACF;YACF;QACF;IACF;IACA;QACEzB,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRE,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA,qBAAqB;IACrB;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;CACD,CAAC"}
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/qcp.ts"],"sourcesContent":["import { snakeCase } from \"../../utils\";\nimport { EventDefinition, LinkType, ParamsType } from \"../types\";\n\n/**\n * Event definitions for Snowplow\n * @type {EventDefinition[]}\n * @property {string} name - The name of the event, to use when triggering\n * @property {string} type - The type of the event (structured | unstructured)\n * @property {makePayload} makePayload\n * - Function that creates the payload for the event;\n * - Allows optional params object to be passed in\n *\n * @example\n * Parent\n * import { getSnowplowConfig, SnowplowProvider } from \"@simplybusiness/services\";\n * const snowplowProps = getSnowplowConfig(pageData);\n * <SnowplowProvider scripts={snowplowProps!}>{children}</SnowplowProvider>\n *\n * Child\n * import { useSnowplowContext } from \"@simplybusiness/services\";\n * const { snowplow } = useSnowplowContext();\n * const handlerFunction = () => snowplow?.trigger(\"eventNameHere\");\n */\n\n// QCP page events\nexport const qcpEventDefinitions: EventDefinition[] = [\n {\n // QDP details button\n name: \"detailsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Details\",\n }),\n },\n {\n // Buy button\n name: \"selectClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Buy\",\n }),\n },\n {\n // Quote Details Slider Next steps button\n name: \"nextStepsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_next_step_cta\",\n action: \"link_click\",\n label: \"Next steps\",\n }),\n },\n {\n // Toggle deductibles accordion\n name: \"deductiblesClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"us-qcp-react\",\n action: \"view_deductables_clicked\",\n label: \"view_deductables_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"deductiblesClickedUk\",\n type: \"structured\",\n makePayload: params => {\n const { label, deviceType } = params as ParamsType;\n const urlFriendlyLabel = label.replace(/ /g, \"-\").toLowerCase();\n\n return {\n category: `uk-qcp-react-${deviceType}-${urlFriendlyLabel}-view-excess-toggle`,\n action: \"view_excess_clicked\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n // Quote Details Slider opened\n name: \"sliderOpened\",\n type: \"structured\",\n makePayload: params => {\n const { label } = params as ParamsType;\n\n return {\n category: \"comparison_cta\",\n action: \"quote_details_slider_opened\",\n label,\n };\n },\n },\n {\n // Coverage modal opened\n name: \"coverageModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const {\n category,\n product = \"extra_coverage\",\n title,\n } = params as ParamsType;\n const productLabel = snakeCase(product);\n\n return {\n category,\n action: `${productLabel}_${snakeCase(title)}_popup_opened`,\n label: productLabel,\n property: window.location.href,\n };\n },\n },\n {\n // Toggle cover select\n name: \"coverChanged\",\n type: \"unstructured\",\n makePayload: params => {\n const { name = \"\", fromValue = \"\", toValue = \"\" } = params as ParamsType;\n // Derive data\n let action = \"change\";\n\n // This logic is taken directly from Chopin without documentation:\n // If a cover has zero value, then change the action to add or remove\n if (fromValue === \"0\") {\n action = \"add\";\n }\n if (toValue === \"0\") {\n action = \"remove\";\n }\n\n return {\n schema:\n \"iglu:com.simplybusiness/comparison_page_cover_changed/jsonschema/1-0-0\",\n data: {\n name,\n action,\n from_value: fromValue,\n to_value: toValue,\n },\n };\n },\n },\n {\n name: \"ratingsModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"insurer_rating_help_popup_triggered\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"coverToggleOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"qcp_limit_interaction\",\n label: \"limit_interaction\",\n action: \"limit_interaction_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"paymentToggleClicked\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"button_click\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"insurerDetailsAccordionClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_insurer_details_description\",\n action: \"accordion_clicked\",\n label: \"accordion_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"priceDetailsPopUpOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"price_details\",\n action: \"price_details_popup_opened\",\n label: \"Price details\",\n property: window.location.href,\n }),\n },\n {\n name: \"editLimitButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"edit_limit_button_clicked\",\n label: \"Edit Limit\",\n property: window.location.href,\n }),\n },\n {\n name: \"applyButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"apply_button_clicked\",\n label: \"Apply Button Clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"coverageInfoClicked\",\n type: \"structured\",\n makePayload: params => {\n const { deviceType } = params as ParamsType;\n\n return {\n action: \"show_coverage_info_clicked\",\n category: `uk-qcp-react-${deviceType}-show-coverage-info-toggle`,\n label: \"show_coverage_info_clicked\",\n property: window.location.href,\n };\n },\n },\n {\n name: \"backToApplication\",\n type: \"unstructured\",\n makePayload: params => {\n const { journeyId, vertical } = params as ParamsType;\n\n return {\n schema: \"iglu:com.simplybusiness/back_to_application/jsonschema/1-0-0\",\n data: {\n journey_id: journeyId,\n vertical,\n },\n };\n },\n },\n {\n name: \"helpChatLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"help chat for question\",\n action: \"help_chat_for_question_clicked\",\n property: window.location.href,\n }),\n },\n // No quotes referral\n {\n name: \"coverOptionsLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"uk-qcp-react-cover-options-link\",\n action: \"cover_options_link_clicked\",\n label: \"cover_options_link_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"phoneNumberLinkClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"uk-qcp-react-phone-number-link\",\n action: \"phone_number_link_clicked\",\n label: \"phone_number_link_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"linkClicked\",\n type: \"unstructured\",\n makePayload: params => {\n const { targetUrl, elementContent } = params as LinkType;\n\n return {\n schema:\n \"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1\",\n data: {\n targetUrl,\n elementContent,\n },\n };\n },\n },\n];\n"],"names":["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","targetUrl","elementContent"],"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,CAAAA;YACX,MAAM,EAAEL,KAAK,EAAE,GAAGK;YAElB,OAAO;gBACLP,UAAU;gBACVC,QAAQ;gBACRC;YACF;QACF;IACF;IACA;QACE,wBA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ET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAa,IAAO,CAAA;gBAClBC,UAAU;gBACVC,QAAQ;gBACRC,OAAO;gBACPC,UAAUC,OAAOC,QAAQ,CAACC,IAAI;YAChC,CAAA;IACF;IACA;QACET,MAAM;QACNC,MAAM;QACNC,aAAaQ,CAAAA;YACX,MAAM,EAAEiB,SAAS,EAAEC,cAAc,EAAE,GAAGlB;YAEtC,OAAO;gBACLU,QACE;gBACFC,MAAM;oBACJM;oBACAC;gBACF;YACF;QACF;IACF;CACD,CAAC"}
@@ -0,0 +1,40 @@
1
+ // Questionnaire events
2
+ export const questionnaireEventDefinitions = [
3
+ {
4
+ name: "assumptionsButtonClicked",
5
+ type: "structured",
6
+ makePayload: (params)=>{
7
+ const { source, presentationGroup } = params;
8
+ return {
9
+ action: source,
10
+ category: presentationGroup
11
+ };
12
+ }
13
+ },
14
+ {
15
+ name: "navButtonClicked",
16
+ type: "structured",
17
+ makePayload: (params)=>{
18
+ const { label, category } = params;
19
+ return {
20
+ label,
21
+ action: "link_click",
22
+ category
23
+ };
24
+ }
25
+ },
26
+ {
27
+ name: "manualAddressClicked",
28
+ type: "structured",
29
+ makePayload: (params)=>{
30
+ const { category } = params;
31
+ return {
32
+ action: "link_click",
33
+ category,
34
+ label: "Enter address manually"
35
+ };
36
+ }
37
+ }
38
+ ];
39
+
40
+ //# sourceMappingURL=questionnaire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/questionnaire.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"../types\";\n\n// Questionnaire events\nexport const questionnaireEventDefinitions: EventDefinition[] = [\n {\n name: \"assumptionsButtonClicked\",\n type: \"structured\",\n makePayload: params => {\n const { source, presentationGroup } = params as ParamsType;\n\n return {\n action: source,\n category: presentationGroup,\n };\n },\n },\n {\n name: \"navButtonClicked\",\n type: \"structured\",\n makePayload: params => {\n const { label, category } = params as ParamsType;\n\n return {\n label,\n action: \"link_click\",\n category,\n };\n },\n },\n {\n name: \"manualAddressClicked\",\n type: \"structured\",\n makePayload: params => {\n const { category } = params as ParamsType;\n\n return {\n action: \"link_click\",\n category,\n label: \"Enter address manually\",\n };\n },\n },\n];\n"],"names":["questionnaireEventDefinitions","name","type","makePayload","params","source","presentationGroup","action","category","label"],"mappings":"AAEA,uBAAuB;AACvB,OAAO,MAAMA,gCAAmD;IAC9D;QACEC,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAE,GAAGF;YAEtC,OAAO;gBACLG,QAAQF;gBACRG,UAAUF;YACZ;QACF;IACF;IACA;QACEL,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEK,KAAK,EAAED,QAAQ,EAAE,GAAGJ;YAE5B,OAAO;gBACLK;gBACAF,QAAQ;gBACRC;YACF;QACF;IACF;IACA;QACEP,MAAM;QACNC,MAAM;QACNC,aAAaC,CAAAA;YACX,MAAM,EAAEI,QAAQ,EAAE,GAAGJ;YAErB,OAAO;gBACLG,QAAQ;gBACRC;gBACAC,OAAO;YACT;QACF;IACF;CACD,CAAC"}
@@ -0,0 +1,142 @@
1
+ const PII_ANSWER = [
2
+ "customer_title",
3
+ "customer_first_name",
4
+ "customer_last_name",
5
+ "customer_email_address",
6
+ "preapp_email_address",
7
+ "customer_telephone_number",
8
+ "customer_alternative_telephone_number",
9
+ "customer_address_1_pre_quote",
10
+ "customer_address_2_pre_quote",
11
+ "customer_town_pre_quote",
12
+ "customer_postcode_pre_quote",
13
+ "customer_address_1",
14
+ "customer_address_2",
15
+ "customer_town",
16
+ "customer_postcode",
17
+ "address_1_pre_quote",
18
+ "address_2_pre_quote",
19
+ "uk_postcode_pre_quote",
20
+ "town_pre_quote",
21
+ "owner_first_name",
22
+ "owner_last_name",
23
+ "beneficiary_first_name",
24
+ "beneficiary_last_name",
25
+ "gender",
26
+ "dynamic_ssn_fein",
27
+ "ssn",
28
+ "fein",
29
+ "sof_county_court_judgement_online_yes",
30
+ "sof_county_court_judgement_online_no",
31
+ "sof_ccj_count",
32
+ "sof_ccj_value",
33
+ "sof_ccj_date",
34
+ "sof_court_judgement_yes",
35
+ "sof_court_judgement_no",
36
+ "ccj_date",
37
+ "sof_single_ccj_no",
38
+ "sof_single_ccj_yes",
39
+ "sof_ccj_yes",
40
+ "sof_ccj_no",
41
+ "ccj_count",
42
+ "sof_bankrupt_yes",
43
+ "sof_bankrupt_no",
44
+ "sof_multiple_bankruptcies_yes",
45
+ "sof_multiple_bankruptcies_no",
46
+ "bankruptcy_date",
47
+ "sof_single_bankruptcy_no",
48
+ "sof_single_bankruptcy_yes",
49
+ "sof_bankruptcy_yes",
50
+ "sof_bankruptcy_no",
51
+ "bankruptcy_discharged",
52
+ "sof_liquidation_yes",
53
+ "sof_liquidation_no",
54
+ "sof_multiple_liquidations",
55
+ "liquidation_date",
56
+ "sof_criminal_offence_yes",
57
+ "sof_criminal_offence_no",
58
+ "sof_criminal_yes",
59
+ "sof_criminal_no",
60
+ "hcp_date_of_birth_1",
61
+ "hcp_date_of_birth_2",
62
+ "hcp_date_of_birth_3",
63
+ "hcp_date_of_birth_4",
64
+ "hcp_date_of_birth_5",
65
+ "hcp_date_of_birth_6",
66
+ "hcp_date_of_birth_7",
67
+ "hcp_date_of_birth_8",
68
+ "hcp_date_of_birth_9",
69
+ "hcp_date_of_birth_10",
70
+ "sof_previous_claims_yes",
71
+ "sof_previous_claims_no",
72
+ "sof_claims_yes",
73
+ "sof_claims_no",
74
+ "sof_property_claims_in_the_last_5_years_yes",
75
+ "sof_property_claims_in_the_last_5_years_no",
76
+ "sof_property_claims_in_the_last_0_to_4_years_yes",
77
+ "sof_property_claims_in_the_last_0_to_4_years_no",
78
+ "claim_count",
79
+ "sof_number_of_claims",
80
+ "number_of_claims_in_last_5_years",
81
+ "number_of_claims_in_time_owned",
82
+ "date_of_incident_1",
83
+ "date_of_incident_2",
84
+ "date_of_incident_3",
85
+ "date_of_incident_4",
86
+ "date_of_incident_5",
87
+ "type_of_incident_1",
88
+ "type_of_incident_2",
89
+ "type_of_incident_3",
90
+ "type_of_incident_4",
91
+ "type_of_incident_5",
92
+ "incident_value_1",
93
+ "incident_value_2",
94
+ "incident_value_3",
95
+ "incident_value_4",
96
+ "incident_value_5",
97
+ "sof_pollution_disease_claims_yes",
98
+ "sof_pollution_disease_claims_no",
99
+ "sof_potential_claims_yes",
100
+ "sof_potential_claims_no",
101
+ "sof_previous_circumstances_yes",
102
+ "sof_previous_circumstances_no",
103
+ "sof_possible_claims_yes",
104
+ "sof_possible_claims_no",
105
+ "date_of_possible_incident",
106
+ "type_of_possible_incident",
107
+ "possible_incident_value",
108
+ "sof_property_claims_yes",
109
+ "sof_property_claims_no",
110
+ "sof_liability_claims_yes",
111
+ "sof_liability_claims_no",
112
+ "van_registration",
113
+ "sof_disqualified_director_yes",
114
+ "sof_disqualified_director_no",
115
+ "sof_insurance_refused_yes",
116
+ "sof_insurance_refused_no",
117
+ "sof_insurance_declined_yes",
118
+ "sof_insurance_declined_no",
119
+ "insurance_refused"
120
+ ];
121
+ const RADIO_ANSWER_FROM_QUESTIONS = [
122
+ "have_secondary_trade_yes",
123
+ "have_secondary_trade_no"
124
+ ];
125
+ const ANSWER_SUFFIX_PATTERN = /_(yes|no)$/;
126
+ export const redact = (params)=>{
127
+ let { question, answer } = params;
128
+ const piiAnswer = new Set(PII_ANSWER);
129
+ const radioAnswerFromQuestions = new Set(RADIO_ANSWER_FROM_QUESTIONS);
130
+ if (piiAnswer.has(question)) {
131
+ answer = "REDACTED";
132
+ question = question === null || question === void 0 ? void 0 : question.replace(ANSWER_SUFFIX_PATTERN, "");
133
+ } else if (radioAnswerFromQuestions.has(question)) {
134
+ question = question === null || question === void 0 ? void 0 : question.replace(ANSWER_SUFFIX_PATTERN, "");
135
+ }
136
+ return {
137
+ question,
138
+ answer
139
+ };
140
+ };
141
+
142
+ //# sourceMappingURL=redaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/snowplow/event-definitions/redaction.ts"],"sourcesContent":["import { ParamsType } from \"../types\";\n\nconst PII_ANSWER = [\n \"customer_title\",\n \"customer_first_name\",\n \"customer_last_name\",\n \"customer_email_address\",\n \"preapp_email_address\",\n \"customer_telephone_number\",\n \"customer_alternative_telephone_number\",\n \"customer_address_1_pre_quote\",\n \"customer_address_2_pre_quote\",\n \"customer_town_pre_quote\",\n \"customer_postcode_pre_quote\",\n \"customer_address_1\",\n \"customer_address_2\",\n \"customer_town\",\n \"customer_postcode\",\n \"address_1_pre_quote\",\n \"address_2_pre_quote\",\n \"uk_postcode_pre_quote\",\n \"town_pre_quote\",\n \"owner_first_name\",\n \"owner_last_name\",\n \"beneficiary_first_name\",\n \"beneficiary_last_name\",\n \"gender\",\n \"dynamic_ssn_fein\",\n \"ssn\",\n \"fein\",\n \"sof_county_court_judgement_online_yes\",\n \"sof_county_court_judgement_online_no\",\n \"sof_ccj_count\",\n \"sof_ccj_value\",\n \"sof_ccj_date\",\n \"sof_court_judgement_yes\",\n \"sof_court_judgement_no\",\n \"ccj_date\",\n \"sof_single_ccj_no\",\n \"sof_single_ccj_yes\",\n \"sof_ccj_yes\",\n \"sof_ccj_no\",\n \"ccj_count\",\n \"sof_bankrupt_yes\",\n \"sof_bankrupt_no\",\n \"sof_multiple_bankruptcies_yes\",\n \"sof_multiple_bankruptcies_no\",\n \"bankruptcy_date\",\n \"sof_single_bankruptcy_no\",\n \"sof_single_bankruptcy_yes\",\n \"sof_bankruptcy_yes\",\n \"sof_bankruptcy_no\",\n \"bankruptcy_discharged\",\n \"sof_liquidation_yes\",\n \"sof_liquidation_no\",\n \"sof_multiple_liquidations\",\n \"liquidation_date\",\n \"sof_criminal_offence_yes\",\n \"sof_criminal_offence_no\",\n \"sof_criminal_yes\",\n \"sof_criminal_no\",\n \"hcp_date_of_birth_1\",\n \"hcp_date_of_birth_2\",\n \"hcp_date_of_birth_3\",\n \"hcp_date_of_birth_4\",\n \"hcp_date_of_birth_5\",\n \"hcp_date_of_birth_6\",\n \"hcp_date_of_birth_7\",\n \"hcp_date_of_birth_8\",\n \"hcp_date_of_birth_9\",\n \"hcp_date_of_birth_10\",\n \"sof_previous_claims_yes\",\n \"sof_previous_claims_no\",\n \"sof_claims_yes\",\n \"sof_claims_no\",\n \"sof_property_claims_in_the_last_5_years_yes\",\n \"sof_property_claims_in_the_last_5_years_no\",\n \"sof_property_claims_in_the_last_0_to_4_years_yes\",\n \"sof_property_claims_in_the_last_0_to_4_years_no\",\n \"claim_count\",\n \"sof_number_of_claims\",\n \"number_of_claims_in_last_5_years\",\n \"number_of_claims_in_time_owned\",\n \"date_of_incident_1\",\n \"date_of_incident_2\",\n \"date_of_incident_3\",\n \"date_of_incident_4\",\n \"date_of_incident_5\",\n \"type_of_incident_1\",\n \"type_of_incident_2\",\n \"type_of_incident_3\",\n \"type_of_incident_4\",\n \"type_of_incident_5\",\n \"incident_value_1\",\n \"incident_value_2\",\n \"incident_value_3\",\n \"incident_value_4\",\n \"incident_value_5\",\n \"sof_pollution_disease_claims_yes\",\n \"sof_pollution_disease_claims_no\",\n \"sof_potential_claims_yes\",\n \"sof_potential_claims_no\",\n \"sof_previous_circumstances_yes\",\n \"sof_previous_circumstances_no\",\n \"sof_possible_claims_yes\",\n \"sof_possible_claims_no\",\n \"date_of_possible_incident\",\n \"type_of_possible_incident\",\n \"possible_incident_value\",\n \"sof_property_claims_yes\",\n \"sof_property_claims_no\",\n \"sof_liability_claims_yes\",\n \"sof_liability_claims_no\",\n \"van_registration\",\n \"sof_disqualified_director_yes\",\n \"sof_disqualified_director_no\",\n \"sof_insurance_refused_yes\",\n \"sof_insurance_refused_no\",\n \"sof_insurance_declined_yes\",\n \"sof_insurance_declined_no\",\n \"insurance_refused\",\n];\n\nconst RADIO_ANSWER_FROM_QUESTIONS = [\n \"have_secondary_trade_yes\",\n \"have_secondary_trade_no\",\n];\n\nconst ANSWER_SUFFIX_PATTERN = /_(yes|no)$/;\n\nexport const redact = (params: ParamsType) => {\n let { question, answer } = params as ParamsType;\n\n const piiAnswer = new Set(PII_ANSWER);\n const radioAnswerFromQuestions = new Set(RADIO_ANSWER_FROM_QUESTIONS);\n\n if (piiAnswer.has(question)) {\n answer = \"REDACTED\";\n question = question?.replace(ANSWER_SUFFIX_PATTERN, \"\");\n } else if (radioAnswerFromQuestions.has(question)) {\n question = question?.replace(ANSWER_SUFFIX_PATTERN, \"\");\n }\n return { question, answer };\n};\n"],"names":["PII_ANSWER","RADIO_ANSWER_FROM_QUESTIONS","ANSWER_SUFFIX_PATTERN","redact","params","question","answer","piiAnswer","Set","radioAnswerFromQuestions","has","replace"],"mappings":"AAEA,MAAMA,aAAa;IACjB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,8BAA8B;IAClC;IACA;CACD;AAED,MAAMC,wBAAwB;AAE9B,OAAO,MAAMC,SAAS,CAACC;IACrB,IAAI,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGF;IAE3B,MAAMG,YAAY,IAAIC,IAAIR;IAC1B,MAAMS,2BAA2B,IAAID,IAAIP;IAEzC,IAAIM,UAAUG,GAAG,CAACL,WAAW;QAC3BC,SAAS;QACTD,WAAWA,qBAAAA,+BAAAA,SAAUM,OAAO,CAACT,uBAAuB;IACtD,OAAO,IAAIO,yBAAyBC,GAAG,CAACL,WAAW;QACjDA,WAAWA,qBAAAA,+BAAAA,SAAUM,OAAO,CAACT,uBAAuB;IACtD;IACA,OAAO;QAAEG;QAAUC;IAAO;AAC5B,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/snowplow/types.ts"],"sourcesContent":["import {\n EventMethod,\n SelfDescribingJson,\n StructuredEvent,\n} from \"@snowplow/browser-tracker\";\n\ntype BaseConfig = {\n appId: string;\n avalancheCollector: string;\n eventMethod: EventMethod;\n trackPageView: boolean;\n includeGAContext: boolean;\n uid?: string;\n postPath?: string;\n};\n\nexport type EnvConfig = BaseConfig & {\n cookieDomain: Record<string, string>;\n};\n\nexport type TrackingProps = BaseConfig & {\n eventMethod: EventMethod;\n cookieDomain?: string;\n};\n\nexport type ChannelContext = {\n schema: string;\n data: Record<string, string | number>;\n};\n\nexport type ChannelContexts = Record<string, ChannelContext>;\n\nexport type ArrayOneOrMore<T> = [T, ...T[]];\n\nexport type ParamsType = Record<\n | \"label\"\n | \"deviceType\"\n | \"category\"\n | \"product\"\n | \"title\"\n | \"label\"\n | \"name\"\n | \"fromValue\"\n | \"toValue\"\n | \"url\"\n | \"journeyId\"\n | \"vertical\",\n string\n>;\n\nexport type EventDefinition = {\n name: string;\n type: \"structured\" | \"unstructured\";\n makePayload: (\n params?: Record<string, unknown>,\n ) => StructuredEvent | SelfDescribingJson<Record<string, unknown>>;\n};\n\nexport interface PageDataProps\n extends Partial<\n Record<\n \"scripts\",\n Array<{\n metadata: { name: string };\n props?: Record<string, unknown>;\n }>\n >\n > {}\n"],"names":[],"mappings":"AA0DA,WASM"}
1
+ {"version":3,"sources":["../../../src/snowplow/types.ts"],"sourcesContent":["import {\n EventMethod,\n SelfDescribingJson,\n StructuredEvent,\n} from \"@snowplow/browser-tracker\";\n\ntype BaseConfig = {\n appId: string;\n avalancheCollector: string;\n eventMethod: EventMethod;\n trackPageView: boolean;\n includeGAContext: boolean;\n uid?: string;\n postPath?: string;\n};\n\nexport type EnvConfig = BaseConfig & {\n cookieDomain: Record<string, string>;\n};\n\nexport type TrackingProps = BaseConfig & {\n eventMethod: EventMethod;\n cookieDomain?: string;\n pageViewContext?: ChannelContext;\n};\n\nexport type ChannelContext = {\n schema: string;\n data: Record<string, string | number>;\n};\n\nexport type ChannelContexts = Record<string, ChannelContext>;\n\nexport type ArrayOneOrMore<T> = [T, ...T[]];\n\nexport type ParamsType = Record<string, string> & {\n context: ServerContext;\n};\n\ntype ServerContext = {\n site: string;\n vertical: string;\n primary_detail: string;\n journey_name: string;\n journey_id: string;\n};\n\nexport type LinkType = Record<string, string> & {\n targetUrl: string;\n elementContent: string;\n};\n\nexport type EventDefinition = {\n name: string;\n type: \"structured\" | \"unstructured\";\n makePayload: (\n params?: Record<string, unknown>,\n ) => StructuredEvent | SelfDescribingJson<Record<string, unknown>>;\n};\n\nexport interface PageDataProps\n extends Partial<\n Record<\n \"scripts\",\n Array<{\n metadata: { name: string };\n props?: Record<string, unknown>;\n }>\n >\n > {}\n"],"names":[],"mappings":"AA4DA,WASM"}
@@ -1,3 +1,4 @@
1
+ import { ParamsType } from "../snowplow";
1
2
  declare const _default: ({
2
3
  name: string;
3
4
  type: string;
@@ -28,5 +29,34 @@ declare const _default: ({
28
29
  answer: string | undefined;
29
30
  };
30
31
  };
32
+ } | {
33
+ name: string;
34
+ type: string;
35
+ makePayload: (params: ParamsType) => {
36
+ schema: string;
37
+ data: {
38
+ site: string;
39
+ page_index: number;
40
+ page_name: string;
41
+ submitted_from: string;
42
+ section_name: string;
43
+ question: string;
44
+ answer: string;
45
+ vertical: string;
46
+ };
47
+ };
48
+ } | {
49
+ name: string;
50
+ type: string;
51
+ makePayload: (params: ParamsType) => {
52
+ schema: string;
53
+ data: {
54
+ vertical: string;
55
+ site: string;
56
+ primary_text: string;
57
+ label: string;
58
+ page_name: string;
59
+ };
60
+ };
31
61
  })[];
32
62
  export default _default;
@@ -16,6 +16,7 @@ export declare class Snowplow {
16
16
  uid: unknown;
17
17
  trackPageView: boolean;
18
18
  contexts: SelfDescribingJson<Record<string, unknown>>[];
19
+ serverData: Record<string, unknown>;
19
20
  eventHandlers: Record<string, (params?: Record<string, unknown>) => void>;
20
21
  constructor(props?: TrackingProps);
21
22
  setContexts(contexts: SelfDescribingJson<Record<string, unknown>>[]): this;
@@ -3,3 +3,4 @@ export declare const qcpPageEvents: import("..").EventDefinition[];
3
3
  export declare const referralPageEvents: import("..").EventDefinition[];
4
4
  export declare const interventionPageEvents: import("..").EventDefinition[];
5
5
  export type { InterventionPayload } from "./intervention";
6
+ export declare const questionnairePageEvents: import("..").EventDefinition[];
@@ -0,0 +1,2 @@
1
+ import { EventDefinition } from "../types";
2
+ export declare const questionnaireEventDefinitions: EventDefinition[];
@@ -0,0 +1,5 @@
1
+ import { ParamsType } from "../types";
2
+ export declare const redact: (params: ParamsType) => {
3
+ question: string;
4
+ answer: string;
5
+ };
@@ -14,6 +14,7 @@ export type EnvConfig = BaseConfig & {
14
14
  export type TrackingProps = BaseConfig & {
15
15
  eventMethod: EventMethod;
16
16
  cookieDomain?: string;
17
+ pageViewContext?: ChannelContext;
17
18
  };
18
19
  export type ChannelContext = {
19
20
  schema: string;
@@ -21,7 +22,20 @@ export type ChannelContext = {
21
22
  };
22
23
  export type ChannelContexts = Record<string, ChannelContext>;
23
24
  export type ArrayOneOrMore<T> = [T, ...T[]];
24
- export type ParamsType = Record<"label" | "deviceType" | "category" | "product" | "title" | "label" | "name" | "fromValue" | "toValue" | "url" | "journeyId" | "vertical", string>;
25
+ export type ParamsType = Record<string, string> & {
26
+ context: ServerContext;
27
+ };
28
+ type ServerContext = {
29
+ site: string;
30
+ vertical: string;
31
+ primary_detail: string;
32
+ journey_name: string;
33
+ journey_id: string;
34
+ };
35
+ export type LinkType = Record<string, string> & {
36
+ targetUrl: string;
37
+ elementContent: string;
38
+ };
25
39
  export type EventDefinition = {
26
40
  name: string;
27
41
  type: "structured" | "unstructured";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simplybusiness/services",
3
3
  "license": "UNLICENSED",
4
- "version": "0.8.0",
4
+ "version": "0.13.0",
5
5
  "description": "Internal library for services",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,3 +1,6 @@
1
+ import { ParamsType } from "../snowplow";
2
+ import { redact } from "../snowplow/event-definitions/redaction";
3
+
1
4
  export default [
2
5
  {
3
6
  name: "navButtonClicked",
@@ -36,4 +39,45 @@ export default [
36
39
  };
37
40
  },
38
41
  },
42
+ {
43
+ name: "questionAnswered",
44
+ type: "unstructured",
45
+ makePayload: (params: ParamsType) => {
46
+ const { section, context } = params as ParamsType;
47
+ const { question, answer } = redact(params as ParamsType);
48
+
49
+ return {
50
+ schema:
51
+ "iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-3",
52
+ data: {
53
+ site: context.site,
54
+ page_index: 1,
55
+ page_name: "quick_to_quote",
56
+ submitted_from: "quick_to_quote_experiment",
57
+ section_name: section,
58
+ question,
59
+ answer,
60
+ vertical: context.vertical,
61
+ },
62
+ };
63
+ },
64
+ },
65
+ {
66
+ name: "helpTextOpened",
67
+ type: "unstructured",
68
+ makePayload: (params: ParamsType) => {
69
+ const { primaryText, label, context } = params as ParamsType;
70
+
71
+ return {
72
+ schema: "iglu:com.simplybusiness/help_text_opened/jsonschema/1-1-0",
73
+ data: {
74
+ vertical: context.vertical,
75
+ site: context.site,
76
+ primary_text: primaryText,
77
+ label,
78
+ page_name: "quick_to_quote",
79
+ },
80
+ };
81
+ },
82
+ },
39
83
  ];
@@ -34,6 +34,8 @@ export class Snowplow {
34
34
 
35
35
  contexts: SelfDescribingJson<Record<string, unknown>>[] = [];
36
36
 
37
+ serverData: Record<string, unknown> = {};
38
+
37
39
  eventHandlers: Record<string, (params?: Record<string, unknown>) => void> =
38
40
  {};
39
41
 
@@ -53,6 +55,7 @@ export class Snowplow {
53
55
  } = props;
54
56
  this.uid = uid;
55
57
  this.trackPageView = tpv;
58
+ this.serverData = props?.pageViewContext?.data || {};
56
59
 
57
60
  // Set options
58
61
  const stateStorageStrategy = "cookieAndLocalStorage";
@@ -124,16 +127,27 @@ export class Snowplow {
124
127
  }
125
128
 
126
129
  addEventHandlers(eventDefinitions: EventDefinition[]) {
130
+ // Add server context to makePayload functions
131
+ const context = this.serverData;
132
+
127
133
  eventDefinitions.forEach(({ name, type, makePayload }) => {
128
134
  // Convert type into relevant function
129
135
  if (type === "structured") {
130
136
  this.addEventHandler(name, (params?: Record<string, unknown>) => {
131
- this.trackEvent(makePayload(params) as StructuredEvent);
137
+ this.trackEvent(
138
+ makePayload({
139
+ ...params,
140
+ context,
141
+ }) as StructuredEvent,
142
+ );
132
143
  });
133
144
  } else {
134
145
  this.addEventHandler(name, (params?: Record<string, unknown>) => {
135
146
  this.trackUnstructEvent(
136
- makePayload(params) as SelfDescribingJson<Record<string, unknown>>,
147
+ makePayload({
148
+ ...params,
149
+ context,
150
+ }) as SelfDescribingJson<Record<string, unknown>>,
137
151
  );
138
152
  });
139
153
  }
@@ -1,5 +1,5 @@
1
- import { EventDefinition } from "../types";
2
-
1
+ import { EventDefinition, ParamsType } from "../types";
2
+ import { redact } from "./redaction";
3
3
  /**
4
4
  * Event definitions for Snowplow
5
5
  * @type {EventDefinition[]}
@@ -48,4 +48,45 @@ export const baseEventDefinitions: EventDefinition[] = [
48
48
  },
49
49
  }),
50
50
  },
51
+ {
52
+ name: "questionAnswered",
53
+ type: "unstructured",
54
+ makePayload: params => {
55
+ const { section, context } = params as ParamsType;
56
+ const { question, answer } = redact(params as ParamsType);
57
+
58
+ return {
59
+ schema:
60
+ "iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-3",
61
+ data: {
62
+ site: context.site,
63
+ page_index: 1,
64
+ page_name: "quick_to_quote",
65
+ submitted_from: "quick_to_quote_experiment",
66
+ section_name: section,
67
+ question,
68
+ answer,
69
+ vertical: context.vertical,
70
+ },
71
+ };
72
+ },
73
+ },
74
+ {
75
+ name: "helpTextOpened",
76
+ type: "unstructured",
77
+ makePayload: params => {
78
+ const { primaryText, label, context } = params as ParamsType;
79
+
80
+ return {
81
+ schema: "iglu:com.simplybusiness/help_text_opened/jsonschema/1-1-0",
82
+ data: {
83
+ vertical: context.vertical,
84
+ site: context.site,
85
+ primary_text: primaryText,
86
+ label,
87
+ page_name: "quick_to_quote",
88
+ },
89
+ };
90
+ },
91
+ },
51
92
  ];
@@ -2,6 +2,7 @@ import { baseEventDefinitions } from "./base";
2
2
  import { qcpEventDefinitions } from "./qcp";
3
3
  import { referralEventDefinitions } from "./referral";
4
4
  import { interventionEventDefinitions } from "./intervention";
5
+ import { questionnaireEventDefinitions } from "./questionnaire";
5
6
 
6
7
  // All events (keep up to date with new files)
7
8
  export const eventDefinitions = [
@@ -9,6 +10,7 @@ export const eventDefinitions = [
9
10
  ...qcpEventDefinitions,
10
11
  ...referralEventDefinitions,
11
12
  ...interventionEventDefinitions,
13
+ ...questionnaireEventDefinitions,
12
14
  ];
13
15
 
14
16
  export const qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];
@@ -22,5 +24,7 @@ export const interventionPageEvents = [...interventionEventDefinitions];
22
24
 
23
25
  export type { InterventionPayload } from "./intervention";
24
26
 
27
+ export const questionnairePageEvents = [...questionnaireEventDefinitions];
28
+
25
29
  // Create a new export for each kind of page below
26
30
  // containing just the subset needed for that page
@@ -1,5 +1,5 @@
1
1
  import { snakeCase } from "../../utils";
2
- import { EventDefinition, ParamsType } from "../types";
2
+ import { EventDefinition, LinkType, ParamsType } from "../types";
3
3
 
4
4
  /**
5
5
  * Event definitions for Snowplow
@@ -281,4 +281,20 @@ export const qcpEventDefinitions: EventDefinition[] = [
281
281
  property: window.location.href,
282
282
  }),
283
283
  },
284
+ {
285
+ name: "linkClicked",
286
+ type: "unstructured",
287
+ makePayload: params => {
288
+ const { targetUrl, elementContent } = params as LinkType;
289
+
290
+ return {
291
+ schema:
292
+ "iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",
293
+ data: {
294
+ targetUrl,
295
+ elementContent,
296
+ },
297
+ };
298
+ },
299
+ },
284
300
  ];
@@ -0,0 +1,43 @@
1
+ import { EventDefinition, ParamsType } from "../types";
2
+
3
+ // Questionnaire events
4
+ export const questionnaireEventDefinitions: EventDefinition[] = [
5
+ {
6
+ name: "assumptionsButtonClicked",
7
+ type: "structured",
8
+ makePayload: params => {
9
+ const { source, presentationGroup } = params as ParamsType;
10
+
11
+ return {
12
+ action: source,
13
+ category: presentationGroup,
14
+ };
15
+ },
16
+ },
17
+ {
18
+ name: "navButtonClicked",
19
+ type: "structured",
20
+ makePayload: params => {
21
+ const { label, category } = params as ParamsType;
22
+
23
+ return {
24
+ label,
25
+ action: "link_click",
26
+ category,
27
+ };
28
+ },
29
+ },
30
+ {
31
+ name: "manualAddressClicked",
32
+ type: "structured",
33
+ makePayload: params => {
34
+ const { category } = params as ParamsType;
35
+
36
+ return {
37
+ action: "link_click",
38
+ category,
39
+ label: "Enter address manually",
40
+ };
41
+ },
42
+ },
43
+ ];