@simplybusiness/services 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/data/scripts-mock.js +59 -0
- package/dist/cjs/data/scripts-mock.js.map +1 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/mocks/eventDefinitions.js +46 -0
- package/dist/cjs/mocks/eventDefinitions.js.map +1 -0
- package/dist/cjs/services/airbrake/index.js +23 -0
- package/dist/cjs/services/airbrake/index.js.map +1 -0
- package/dist/cjs/services/index.js +25 -0
- package/dist/cjs/services/index.js.map +1 -0
- package/dist/cjs/services/snowplow/SnowplowContext.js +61 -0
- package/dist/cjs/services/snowplow/SnowplowContext.js.map +1 -0
- package/dist/cjs/services/snowplow/contexts.js +18 -0
- package/dist/cjs/services/snowplow/contexts.js.map +1 -0
- package/dist/cjs/services/snowplow/event-definitions.js +235 -0
- package/dist/cjs/services/snowplow/event-definitions.js.map +1 -0
- package/dist/cjs/services/snowplow/getSnowplowConfig.js +16 -0
- package/dist/cjs/services/snowplow/getSnowplowConfig.js.map +1 -0
- package/dist/cjs/services/snowplow/index.js +138 -0
- package/dist/cjs/services/snowplow/index.js.map +1 -0
- package/dist/cjs/services/snowplow/types.js +6 -0
- package/dist/cjs/services/snowplow/types.js.map +1 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -0
- package/dist/cjs/utils/index.js +20 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/testUtils.js +43 -0
- package/dist/cjs/utils/testUtils.js.map +1 -0
- package/dist/cjs/utils/text.js +13 -0
- package/dist/cjs/utils/text.js.map +1 -0
- package/dist/esm/data/scripts-mock.js +49 -0
- package/dist/esm/data/scripts-mock.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/mocks/eventDefinitions.js +36 -0
- package/dist/esm/mocks/eventDefinitions.js.map +1 -0
- package/dist/esm/services/airbrake/index.js +13 -0
- package/dist/esm/services/airbrake/index.js.map +1 -0
- package/dist/esm/services/index.js +8 -0
- package/dist/esm/services/index.js.map +1 -0
- package/dist/esm/services/snowplow/SnowplowContext.js +43 -0
- package/dist/esm/services/snowplow/SnowplowContext.js.map +1 -0
- package/dist/esm/services/snowplow/contexts.js +8 -0
- package/dist/esm/services/snowplow/contexts.js.map +1 -0
- package/dist/esm/services/snowplow/event-definitions.js +240 -0
- package/dist/esm/services/snowplow/event-definitions.js.map +1 -0
- package/dist/esm/services/snowplow/getSnowplowConfig.js +7 -0
- package/dist/esm/services/snowplow/getSnowplowConfig.js.map +1 -0
- package/dist/esm/services/snowplow/index.js +133 -0
- package/dist/esm/services/snowplow/index.js.map +1 -0
- package/dist/esm/services/snowplow/types.js +3 -0
- package/dist/esm/services/snowplow/types.js.map +1 -0
- package/dist/esm/utils/index.js +3 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/testUtils.js +26 -0
- package/dist/esm/utils/testUtils.js.map +1 -0
- package/dist/esm/utils/text.js +3 -0
- package/dist/esm/utils/text.js.map +1 -0
- package/dist/types/data/scripts-mock.d.ts +44 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/mocks/eventDefinitions.d.ts +32 -0
- package/dist/types/services/airbrake/index.d.ts +2 -0
- package/dist/types/services/index.d.ts +5 -0
- package/dist/types/services/snowplow/SnowplowContext.d.ts +14 -0
- package/dist/types/services/snowplow/SnowplowContext.test.d.ts +1 -0
- package/dist/types/services/snowplow/contexts.d.ts +3 -0
- package/dist/types/services/snowplow/contexts.test.d.ts +1 -0
- package/dist/types/services/snowplow/event-definitions.d.ts +18 -0
- package/dist/types/services/snowplow/getSnowplowConfig.d.ts +2 -0
- package/dist/types/services/snowplow/index.d.ts +29 -0
- package/dist/types/services/snowplow/index.test.d.ts +1 -0
- package/dist/types/services/snowplow/types.d.ts +37 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/testUtils.d.ts +7 -0
- package/dist/types/utils/text.d.ts +1 -0
- package/dist/types/utils/text.test.d.ts +1 -0
- package/package.json +86 -0
- package/src/__mocks__/snowplowBrowserTrackerMock.js +6 -0
- package/src/data/scripts-mock.ts +44 -0
- package/src/index.tsx +1 -0
- package/src/mocks/eventDefinitions.ts +39 -0
- package/src/services/airbrake/index.ts +16 -0
- package/src/services/index.tsx +6 -0
- package/src/services/snowplow/SnowplowContext.test.tsx +32 -0
- package/src/services/snowplow/SnowplowContext.tsx +68 -0
- package/src/services/snowplow/contexts.test.ts +42 -0
- package/src/services/snowplow/contexts.ts +14 -0
- package/src/services/snowplow/event-definitions.ts +256 -0
- package/src/services/snowplow/getSnowplowConfig.ts +8 -0
- package/src/services/snowplow/index.test.ts +194 -0
- package/src/services/snowplow/index.ts +163 -0
- package/src/services/snowplow/types.ts +65 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/testUtils.tsx +36 -0
- package/src/utils/text.test.ts +9 -0
- package/src/utils/text.ts +2 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "pageData", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return pageData;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const pageData = {
|
|
12
|
+
scripts: [
|
|
13
|
+
{
|
|
14
|
+
metadata: {
|
|
15
|
+
name: "snowplow"
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
uid: "49a449d8aaa9dd58f90a623d4b9dbcae235bf92a",
|
|
19
|
+
cookieDomain: "",
|
|
20
|
+
// TODO: Change this url to "http://localhost:8000" for local development
|
|
21
|
+
avalancheCollector: "https://snowplow-collector-staging.simplybusiness.com",
|
|
22
|
+
appId: "us-chopin",
|
|
23
|
+
includeGAContext: true,
|
|
24
|
+
eventMethod: "post",
|
|
25
|
+
postPath: "/com.simplybusiness/events",
|
|
26
|
+
trackActivity: true,
|
|
27
|
+
trackPageView: true,
|
|
28
|
+
pageViewContext: {
|
|
29
|
+
schema: "igluuk.co.simplybusiness/journey_context/jsonschema/1-0-0",
|
|
30
|
+
data: {
|
|
31
|
+
site: "simplybusiness_us",
|
|
32
|
+
vertical: "usa",
|
|
33
|
+
super_segment: "Unknown",
|
|
34
|
+
primary_detail: "Lawn care services",
|
|
35
|
+
journey_name: "usa",
|
|
36
|
+
journey_id: "666ff79d90abbc3582e496da",
|
|
37
|
+
page_step_name: "thank_you_ssr",
|
|
38
|
+
page_step_depth: -1
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
distributionChannelContext: {
|
|
42
|
+
schema: "iglucom.simplybusiness/distribution_channel_context/jsonschema/1-0-0",
|
|
43
|
+
data: {
|
|
44
|
+
service_channel_identifier: "simplybusiness_us"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
serviceChannelContext: {
|
|
48
|
+
schema: "iglucom.simplybusiness/service_channel_context/jsonschema/1-0-0",
|
|
49
|
+
data: {
|
|
50
|
+
service_channel_identifier: "simplybusiness_us"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
forceSecureTracker: true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=scripts-mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/data/scripts-mock.ts"],"sourcesContent":["export const pageData = {\n scripts: [\n {\n metadata: { name: \"snowplow\" },\n props: {\n uid: \"49a449d8aaa9dd58f90a623d4b9dbcae235bf92a\",\n cookieDomain: \"\",\n // TODO: Change this url to \"http://localhost:8000\" for local development\n avalancheCollector:\n \"https://snowplow-collector-staging.simplybusiness.com\",\n appId: \"us-chopin\",\n includeGAContext: true,\n eventMethod: \"post\",\n postPath: \"/com.simplybusiness/events\",\n trackActivity: true,\n trackPageView: true,\n pageViewContext: {\n schema: \"igluuk.co.simplybusiness/journey_context/jsonschema/1-0-0\",\n data: {\n site: \"simplybusiness_us\",\n vertical: \"usa\",\n super_segment: \"Unknown\",\n primary_detail: \"Lawn care services\",\n journey_name: \"usa\",\n journey_id: \"666ff79d90abbc3582e496da\",\n page_step_name: \"thank_you_ssr\",\n page_step_depth: -1,\n },\n },\n distributionChannelContext: {\n schema:\n \"iglucom.simplybusiness/distribution_channel_context/jsonschema/1-0-0\",\n data: { service_channel_identifier: \"simplybusiness_us\" },\n },\n serviceChannelContext: {\n schema:\n \"iglucom.simplybusiness/service_channel_context/jsonschema/1-0-0\",\n data: { service_channel_identifier: \"simplybusiness_us\" },\n },\n forceSecureTracker: true,\n },\n },\n ],\n};\n"],"names":["pageData","scripts","metadata","name","props","uid","cookieDomain","avalancheCollector","appId","includeGAContext","eventMethod","postPath","trackActivity","trackPageView","pageViewContext","schema","data","site","vertical","super_segment","primary_detail","journey_name","journey_id","page_step_name","page_step_depth","distributionChannelContext","service_channel_identifier","serviceChannelContext","forceSecureTracker"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,WAAW;IACtBC,SAAS;QACP;YACEC,UAAU;gBAAEC,MAAM;YAAW;YAC7BC,OAAO;gBACLC,KAAK;gBACLC,cAAc;gBACd,yEAAyE;gBACzEC,oBACE;gBACFC,OAAO;gBACPC,kBAAkB;gBAClBC,aAAa;gBACbC,UAAU;gBACVC,eAAe;gBACfC,eAAe;gBACfC,iBAAiB;oBACfC,QAAQ;oBACRC,MAAM;wBACJC,MAAM;wBACNC,UAAU;wBACVC,eAAe;wBACfC,gBAAgB;wBAChBC,cAAc;wBACdC,YAAY;wBACZC,gBAAgB;wBAChBC,iBAAiB,CAAC;oBACpB;gBACF;gBACAC,4BAA4B;oBAC1BV,QACE;oBACFC,MAAM;wBAAEU,4BAA4B;oBAAoB;gBAC1D;gBACAC,uBAAuB;oBACrBZ,QACE;oBACFC,MAAM;wBAAEU,4BAA4B;oBAAoB;gBAC1D;gBACAE,oBAAoB;YACtB;QACF;KACD;AACH"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./services"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.tsx"],"sourcesContent":["export * from \"./services\";\n"],"names":[],"mappings":";;;;qBAAc"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _default = [
|
|
12
|
+
{
|
|
13
|
+
name: "navButtonClicked",
|
|
14
|
+
type: "structured",
|
|
15
|
+
makePayload: (params)=>{
|
|
16
|
+
const { label } = params;
|
|
17
|
+
return {
|
|
18
|
+
category: "navigation",
|
|
19
|
+
action: "thankyou_navigation_button_click",
|
|
20
|
+
label,
|
|
21
|
+
property: "test-property"
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "questionAnswered",
|
|
27
|
+
type: "unstructured",
|
|
28
|
+
makePayload: (params)=>{
|
|
29
|
+
const { vertical, question, answer } = params;
|
|
30
|
+
return {
|
|
31
|
+
schema: "iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-1",
|
|
32
|
+
data: {
|
|
33
|
+
site: "",
|
|
34
|
+
vertical: vertical || "business",
|
|
35
|
+
page_index: 1,
|
|
36
|
+
page_name: "Coverage diagnosis questionnaire",
|
|
37
|
+
section_name: "Coverage diagnosis questionnaire",
|
|
38
|
+
question,
|
|
39
|
+
answer
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=eventDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/mocks/eventDefinitions.ts"],"sourcesContent":["export default [\n {\n name: \"navButtonClicked\",\n type: \"structured\",\n makePayload: (params: { label: \"next\" | \"back\" | \"redirect\" }) => {\n const { label } = params;\n return {\n category: \"navigation\",\n action: \"thankyou_navigation_button_click\",\n label,\n property: \"test-property\",\n };\n },\n },\n {\n name: \"questionAnswered\",\n type: \"unstructured\",\n makePayload: (params: {\n vertical?: string;\n question: string;\n answer?: string;\n }) => {\n const { vertical, question, answer } = params;\n return {\n schema:\n \"iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-1\",\n data: {\n site: \"\",\n vertical: vertical || \"business\",\n page_index: 1,\n page_name: \"Coverage diagnosis questionnaire\",\n section_name: \"Coverage diagnosis questionnaire\",\n question,\n answer,\n },\n };\n },\n },\n];\n"],"names":["name","type","makePayload","params","label","category","action","property","vertical","question","answer","schema","data","site","page_index","page_name","section_name"],"mappings":";;;;+BAAA;;;eAAA;;;MAAA,WAAe;IACb;QACEA,MAAM;QACNC,MAAM;QACNC,aAAa,CAACC;YACZ,MAAM,EAAEC,KAAK,EAAE,GAAGD;YAClB,OAAO;gBACLE,UAAU;gBACVC,QAAQ;gBACRF;gBACAG,UAAU;YACZ;QACF;IACF;IACA;QACEP,MAAM;QACNC,MAAM;QACNC,aAAa,CAACC;YAKZ,MAAM,EAAEK,QAAQ,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGP;YACvC,OAAO;gBACLQ,QACE;gBACFC,MAAM;oBACJC,MAAM;oBACNL,UAAUA,YAAY;oBACtBM,YAAY;oBACZC,WAAW;oBACXC,cAAc;oBACdP;oBACAC;gBACF;YACF;QACF;IACF;CACD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Set Airbrake configuration for embedded-qcp project
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "airbrake", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return airbrake;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const _browser = require("@airbrake/browser");
|
|
13
|
+
const getEnvironment = ()=>process.env.NODE_ENV === "test" ? "test" : "development";
|
|
14
|
+
// https://simplybusiness.airbrake.io/projects/512949/edit#tab-access
|
|
15
|
+
const projectId = 512949;
|
|
16
|
+
const projectKey = "4e25197d8faea61c10fbb97702200780";
|
|
17
|
+
const airbrake = new _browser.Notifier({
|
|
18
|
+
projectId: +projectId,
|
|
19
|
+
projectKey,
|
|
20
|
+
environment: getEnvironment()
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/services/airbrake/index.ts"],"sourcesContent":["// Set Airbrake configuration for embedded-qcp project\n\nimport { Notifier } from \"@airbrake/browser\";\n\nconst getEnvironment = () =>\n process.env.NODE_ENV === \"test\" ? \"test\" : \"development\";\n\n// https://simplybusiness.airbrake.io/projects/512949/edit#tab-access\nconst projectId = 512949;\nconst projectKey = \"4e25197d8faea61c10fbb97702200780\";\n\nexport const airbrake = new Notifier({\n projectId: +projectId,\n projectKey,\n environment: getEnvironment(),\n});\n"],"names":["airbrake","getEnvironment","process","env","NODE_ENV","projectId","projectKey","Notifier","environment"],"mappings":"AAAA,sDAAsD;;;;;+BAWzCA;;;eAAAA;;;yBATY;AAEzB,MAAMC,iBAAiB,IACrBC,QAAQC,GAAG,CAACC,QAAQ,KAAK,SAAS,SAAS;AAE7C,qEAAqE;AACrE,MAAMC,YAAY;AAClB,MAAMC,aAAa;AAEZ,MAAMN,WAAW,IAAIO,iBAAQ,CAAC;IACnCF,WAAW,CAACA;IACZC;IACAE,aAAaP;AACf"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// TODO: move all Snowplow related code to a single index.tsx file
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
_export_star(require("./snowplow"), exports);
|
|
7
|
+
_export_star(require("./snowplow/SnowplowContext"), exports);
|
|
8
|
+
_export_star(require("./snowplow/getSnowplowConfig"), exports);
|
|
9
|
+
_export_star(require("./snowplow/contexts"), exports);
|
|
10
|
+
_export_star(require("./airbrake"), exports);
|
|
11
|
+
function _export_star(from, to) {
|
|
12
|
+
Object.keys(from).forEach(function(k) {
|
|
13
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
14
|
+
Object.defineProperty(to, k, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function() {
|
|
17
|
+
return from[k];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return from;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/services/index.tsx"],"sourcesContent":["// TODO: move all Snowplow related code to a single index.tsx file\nexport * from \"./snowplow\";\nexport * from \"./snowplow/SnowplowContext\";\nexport * from \"./snowplow/getSnowplowConfig\";\nexport * from \"./snowplow/contexts\";\nexport * from \"./airbrake\";\n"],"names":[],"mappings":"AAAA,kEAAkE;;;;;qBACpD;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */ "use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
SnowplowProvider: function() {
|
|
13
|
+
return SnowplowProvider;
|
|
14
|
+
},
|
|
15
|
+
useSnowplowContext: function() {
|
|
16
|
+
return useSnowplowContext;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
20
|
+
const _react = require("react");
|
|
21
|
+
const _ = require(".");
|
|
22
|
+
const _contexts = require("./contexts");
|
|
23
|
+
const _eventdefinitions = require("./event-definitions");
|
|
24
|
+
const SnowplowContext = /*#__PURE__*/ (0, _react.createContext)(null);
|
|
25
|
+
const SnowplowProvider = ({ scripts, children })=>{
|
|
26
|
+
const [config, _setConfig] = (0, _react.useState)(scripts);
|
|
27
|
+
const [snowplow, setSnowplow] = (0, _react.useState)(new _.Snowplow(config));
|
|
28
|
+
// Attach event handlers and set contexts
|
|
29
|
+
(0, _react.useEffect)(()=>{
|
|
30
|
+
if (snowplow && scripts) {
|
|
31
|
+
const contexts = (0, _contexts.getContexts)(config);
|
|
32
|
+
snowplow.setContexts(contexts).addEventHandlers(_eventdefinitions.eventDefinitions);
|
|
33
|
+
// Send page view event
|
|
34
|
+
if (config.trackPageView) snowplow.trackView();
|
|
35
|
+
}
|
|
36
|
+
}, [
|
|
37
|
+
config,
|
|
38
|
+
snowplow,
|
|
39
|
+
scripts
|
|
40
|
+
]);
|
|
41
|
+
const value = (0, _react.useMemo)(()=>({
|
|
42
|
+
config,
|
|
43
|
+
snowplow
|
|
44
|
+
}), [
|
|
45
|
+
config,
|
|
46
|
+
snowplow
|
|
47
|
+
]);
|
|
48
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(SnowplowContext.Provider, {
|
|
49
|
+
value: value,
|
|
50
|
+
children: children
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
function useSnowplowContext() {
|
|
54
|
+
const context = (0, _react.useContext)(SnowplowContext);
|
|
55
|
+
if (!context) {
|
|
56
|
+
throw new Error("useSnowplowContext must be used inside a `SnowplowProvider`");
|
|
57
|
+
}
|
|
58
|
+
return context;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=SnowplowContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/services/snowplow/SnowplowContext.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\nimport { Snowplow } from \".\";\nimport { getContexts } from \"./contexts\";\nimport { eventDefinitions } from \"./event-definitions\";\nimport { EventDefinition, TrackingProps } from \"./types\";\n\nexport interface SnowplowContextInterface {\n config: TrackingProps;\n snowplow?: Snowplow;\n}\n\nconst SnowplowContext = createContext<SnowplowContextInterface | null>(null);\n\ntype ProviderProps = {\n scripts: TrackingProps;\n children: ReactNode;\n};\n\nexport const SnowplowProvider = ({ scripts, children }: ProviderProps) => {\n const [config, _setConfig] = useState<TrackingProps>(scripts);\n const [snowplow, setSnowplow] = useState<Snowplow>(new Snowplow(config));\n\n // Attach event handlers and set contexts\n useEffect(() => {\n if (snowplow && scripts) {\n const contexts = getContexts(config);\n\n snowplow\n .setContexts(contexts)\n .addEventHandlers(eventDefinitions as EventDefinition[]);\n // Send page view event\n if (config.trackPageView) snowplow.trackView();\n }\n }, [config, snowplow, scripts]);\n\n const value: SnowplowContextInterface = useMemo(\n () => ({\n config,\n snowplow,\n }),\n [config, snowplow],\n );\n\n return (\n <SnowplowContext.Provider value={value}>\n {children}\n </SnowplowContext.Provider>\n );\n};\n\nexport function useSnowplowContext() {\n const context = useContext(SnowplowContext);\n\n if (!context) {\n throw new Error(\n \"useSnowplowContext must be used inside a `SnowplowProvider`\",\n );\n }\n return context;\n}\n"],"names":["SnowplowProvider","useSnowplowContext","SnowplowContext","createContext","scripts","children","config","_setConfig","useState","snowplow","setSnowplow","Snowplow","useEffect","contexts","getContexts","setContexts","addEventHandlers","eventDefinitions","trackPageView","trackView","value","useMemo","Provider","context","useContext","Error"],"mappings":"AAAA,oDAAoD;;;;;;;;;;;IA0BvCA,gBAAgB;eAAhBA;;IAgCGC,kBAAkB;eAAlBA;;;;uBAlDT;kBACkB;0BACG;kCACK;AAQjC,MAAMC,gCAAkBC,IAAAA,oBAAa,EAAkC;AAOhE,MAAMH,mBAAmB,CAAC,EAAEI,OAAO,EAAEC,QAAQ,EAAiB;IACnE,MAAM,CAACC,QAAQC,WAAW,GAAGC,IAAAA,eAAQ,EAAgBJ;IACrD,MAAM,CAACK,UAAUC,YAAY,GAAGF,IAAAA,eAAQ,EAAW,IAAIG,UAAQ,CAACL;IAEhE,yCAAyC;IACzCM,IAAAA,gBAAS,EAAC;QACR,IAAIH,YAAYL,SAAS;YACvB,MAAMS,WAAWC,IAAAA,qBAAW,EAACR;YAE7BG,SACGM,WAAW,CAACF,UACZG,gBAAgB,CAACC,kCAAgB;YACpC,uBAAuB;YACvB,IAAIX,OAAOY,aAAa,EAAET,SAASU,SAAS;QAC9C;IACF,GAAG;QAACb;QAAQG;QAAUL;KAAQ;IAE9B,MAAMgB,QAAkCC,IAAAA,cAAO,EAC7C,IAAO,CAAA;YACLf;YACAG;QACF,CAAA,GACA;QAACH;QAAQG;KAAS;IAGpB,qBACE,qBAACP,gBAAgBoB,QAAQ;QAACF,OAAOA;kBAC9Bf;;AAGP;AAEO,SAASJ;IACd,MAAMsB,UAAUC,IAAAA,iBAAU,EAACtB;IAE3B,IAAI,CAACqB,SAAS;QACZ,MAAM,IAAIE,MACR;IAEJ;IACA,OAAOF;AACT"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getContexts", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getContexts;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const getContexts = (config)=>{
|
|
12
|
+
const contexts = config && Object.entries(config).filter(([key])=>key.includes("Context") && key !== "includeGAContext").map(([key, value])=>({
|
|
13
|
+
[key]: value
|
|
14
|
+
}));
|
|
15
|
+
return contexts;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=contexts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/services/snowplow/contexts.ts"],"sourcesContent":["import { SelfDescribingJson } from \"@snowplow/browser-tracker\";\nimport { TrackingProps } from \"./types\";\n\nexport const getContexts = (\n config: TrackingProps,\n): SelfDescribingJson<Record<string, unknown>>[] => {\n const contexts =\n config &&\n Object.entries(config)\n .filter(([key]) => key.includes(\"Context\") && key !== \"includeGAContext\")\n .map(([key, value]) => ({ [key]: value }));\n\n return contexts as unknown as SelfDescribingJson<Record<string, unknown>>[];\n};\n"],"names":["getContexts","config","contexts","Object","entries","filter","key","includes","map","value"],"mappings":";;;;+BAGaA;;;eAAAA;;;AAAN,MAAMA,cAAc,CACzBC;IAEA,MAAMC,WACJD,UACAE,OAAOC,OAAO,CAACH,QACZI,MAAM,CAAC,CAAC,CAACC,IAAI,GAAKA,IAAIC,QAAQ,CAAC,cAAcD,QAAQ,oBACrDE,GAAG,CAAC,CAAC,CAACF,KAAKG,MAAM,GAAM,CAAA;YAAE,CAACH,IAAI,EAAEG;QAAM,CAAA;IAE3C,OAAOP;AACT"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "eventDefinitions", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return eventDefinitions;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _utils = require("../../utils");
|
|
12
|
+
const eventDefinitions = [
|
|
13
|
+
{
|
|
14
|
+
name: "mobileLinkClick",
|
|
15
|
+
type: "structured",
|
|
16
|
+
makePayload: ()=>({
|
|
17
|
+
category: "marketing",
|
|
18
|
+
action: "link-click",
|
|
19
|
+
label: "mobile_call_button",
|
|
20
|
+
property: window.location.href
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "operatingHoursClick",
|
|
25
|
+
type: "unstructured",
|
|
26
|
+
makePayload: ()=>({
|
|
27
|
+
schema: "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
|
|
28
|
+
data: {
|
|
29
|
+
schema: "iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2",
|
|
30
|
+
data: {}
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
// QDP details button
|
|
36
|
+
name: "detailsClicked",
|
|
37
|
+
type: "structured",
|
|
38
|
+
makePayload: ()=>({
|
|
39
|
+
category: "comparison_cta",
|
|
40
|
+
action: "link_click",
|
|
41
|
+
label: "Details"
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
// Buy button
|
|
46
|
+
name: "selectClicked",
|
|
47
|
+
type: "structured",
|
|
48
|
+
makePayload: ()=>({
|
|
49
|
+
category: "comparison_cta",
|
|
50
|
+
action: "link_click",
|
|
51
|
+
label: "Select"
|
|
52
|
+
})
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
// Quote Details Slider Next steps button
|
|
56
|
+
name: "nextStepsClicked",
|
|
57
|
+
type: "structured",
|
|
58
|
+
makePayload: ()=>({
|
|
59
|
+
category: "quote_details_slider_next_step_cta",
|
|
60
|
+
action: "link_click",
|
|
61
|
+
label: "Next steps"
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
// Toggle deductibles accordion
|
|
66
|
+
name: "deductiblesClicked",
|
|
67
|
+
type: "structured",
|
|
68
|
+
makePayload: ()=>({
|
|
69
|
+
category: "us-qcp-react",
|
|
70
|
+
action: "view_deductables_clicked",
|
|
71
|
+
label: "view_deductables_clicked",
|
|
72
|
+
property: window.location.href
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "deductiblesClickedUk",
|
|
77
|
+
type: "structured",
|
|
78
|
+
makePayload: (params)=>{
|
|
79
|
+
const { label, deviceType } = params;
|
|
80
|
+
const urlFriendlyLabel = label.replace(/ /g, "-").toLowerCase();
|
|
81
|
+
return {
|
|
82
|
+
category: `uk-qcp-react-${deviceType}-${urlFriendlyLabel}-view-excess-toggle`,
|
|
83
|
+
action: "view_excess_clicked",
|
|
84
|
+
label,
|
|
85
|
+
property: window.location.href
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
// Quote Details Slider opened
|
|
91
|
+
name: "sliderOpened",
|
|
92
|
+
type: "structured",
|
|
93
|
+
makePayload: (params)=>{
|
|
94
|
+
const { label } = params;
|
|
95
|
+
return {
|
|
96
|
+
category: "comparison_cta",
|
|
97
|
+
action: "quote_details_slider_opened",
|
|
98
|
+
label
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
// Coverage modal opened
|
|
104
|
+
name: "coverageModalOpened",
|
|
105
|
+
type: "structured",
|
|
106
|
+
makePayload: (params)=>{
|
|
107
|
+
const { category, product = "extra_coverage", title } = params;
|
|
108
|
+
const productLabel = (0, _utils.snakeCase)(product);
|
|
109
|
+
return {
|
|
110
|
+
category,
|
|
111
|
+
action: `${productLabel}_${(0, _utils.snakeCase)(title)}_popup_opened`,
|
|
112
|
+
label: productLabel,
|
|
113
|
+
property: window.location.href
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
// Toggle cover select
|
|
119
|
+
name: "coverChanged",
|
|
120
|
+
type: "unstructured",
|
|
121
|
+
makePayload: (params)=>{
|
|
122
|
+
const { name = "", fromValue = "", toValue = "" } = params;
|
|
123
|
+
// Derive data
|
|
124
|
+
let action = "change";
|
|
125
|
+
// This logic is taken directly from Chopin without documentation:
|
|
126
|
+
// If a cover has zero value, then change the action to add or remove
|
|
127
|
+
if (fromValue === "0") {
|
|
128
|
+
action = "add";
|
|
129
|
+
}
|
|
130
|
+
if (toValue === "0") {
|
|
131
|
+
action = "remove";
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
schema: "iglu:com.simplybusiness/comparison_page_cover_changed/jsonschema/1-0-0",
|
|
135
|
+
data: {
|
|
136
|
+
name,
|
|
137
|
+
action,
|
|
138
|
+
from_value: fromValue,
|
|
139
|
+
to_value: toValue
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "ratingsModalOpened",
|
|
146
|
+
type: "structured",
|
|
147
|
+
makePayload: (params)=>{
|
|
148
|
+
const { category, label } = params;
|
|
149
|
+
return {
|
|
150
|
+
category,
|
|
151
|
+
action: "insurer_rating_help_popup_triggered",
|
|
152
|
+
label,
|
|
153
|
+
property: window.location.href
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "coverToggleOpened",
|
|
159
|
+
type: "structured",
|
|
160
|
+
makePayload: ()=>({
|
|
161
|
+
category: "qcp_limit_interaction",
|
|
162
|
+
label: "limit_interaction",
|
|
163
|
+
action: "limit_interaction_clicked",
|
|
164
|
+
property: window.location.href
|
|
165
|
+
})
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "paymentToggleClicked",
|
|
169
|
+
type: "structured",
|
|
170
|
+
makePayload: (params)=>{
|
|
171
|
+
const { category, label } = params;
|
|
172
|
+
return {
|
|
173
|
+
category,
|
|
174
|
+
action: "button_click",
|
|
175
|
+
label,
|
|
176
|
+
property: window.location.href
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "insurerDetailsAccordionClicked",
|
|
182
|
+
type: "structured",
|
|
183
|
+
makePayload: ()=>({
|
|
184
|
+
category: "quote_details_slider_insurer_details_description",
|
|
185
|
+
action: "accordion_clicked",
|
|
186
|
+
label: "accordion_clicked",
|
|
187
|
+
property: window.location.href
|
|
188
|
+
})
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "priceDetailsPopUpOpened",
|
|
192
|
+
type: "structured",
|
|
193
|
+
makePayload: ()=>({
|
|
194
|
+
category: "price_details",
|
|
195
|
+
action: "price_details_popup_opened",
|
|
196
|
+
label: "Price details",
|
|
197
|
+
property: window.location.href
|
|
198
|
+
})
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "editLimitButtonClicked",
|
|
202
|
+
type: "structured",
|
|
203
|
+
makePayload: ()=>({
|
|
204
|
+
category: "cover_limit_changes",
|
|
205
|
+
action: "edit_limit_button_clicked",
|
|
206
|
+
label: "Edit Limit",
|
|
207
|
+
property: window.location.href
|
|
208
|
+
})
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: "applyButtonClicked",
|
|
212
|
+
type: "structured",
|
|
213
|
+
makePayload: ()=>({
|
|
214
|
+
category: "cover_limit_changes",
|
|
215
|
+
action: "apply_button_clicked",
|
|
216
|
+
label: "Apply Button Clicked",
|
|
217
|
+
property: window.location.href
|
|
218
|
+
})
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: "coverageInfoClicked",
|
|
222
|
+
type: "structured",
|
|
223
|
+
makePayload: (params)=>{
|
|
224
|
+
const { deviceType } = params;
|
|
225
|
+
return {
|
|
226
|
+
action: "show_coverage_info_clicked",
|
|
227
|
+
category: `uk-qcp-react-${deviceType}-show-coverage-info-toggle`,
|
|
228
|
+
label: "show_coverage_info_clicked",
|
|
229
|
+
property: window.location.href
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
];
|
|
234
|
+
|
|
235
|
+
//# sourceMappingURL=event-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/services/snowplow/event-definitions.ts"],"sourcesContent":["import { EventDefinition, ParamsType } from \"./types\";\nimport { snakeCase } from \"../../utils\";\n\n/**\n * Event definitions for Snowplow\n * @type {EventDefinition[]}\n * @property {string} name - The name of the event, to use when triggering\n * @property {string} type - The type of the event (structured | unstructured)\n * @property {makePayload} makePayload\n * - Function that creates the payload for the event;\n * - Allows optional params object to be passed in\n *\n * @example\n * import { Snowplow } from \"./Snowplow\";\n * import { eventDefinitions } from \"./event-definitions\";\n *\n * const snowplow = new Snowplow();\n * snowplow.addEventHandlers(eventDefinitions);\n */\nexport const eventDefinitions: EventDefinition[] = [\n {\n name: \"mobileLinkClick\",\n type: \"structured\",\n makePayload: () => ({\n category: \"marketing\",\n action: \"link-click\",\n label: \"mobile_call_button\",\n property: window.location.href,\n }),\n },\n {\n name: \"operatingHoursClick\",\n type: \"unstructured\",\n makePayload: () => ({\n schema:\n \"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0\",\n data: {\n schema:\n \"iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2\",\n data: {},\n },\n }),\n },\n {\n // QDP details button\n name: \"detailsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Details\",\n }),\n },\n {\n // Buy button\n name: \"selectClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"comparison_cta\",\n action: \"link_click\",\n label: \"Select\",\n }),\n },\n {\n // Quote Details Slider Next steps button\n name: \"nextStepsClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_next_step_cta\",\n action: \"link_click\",\n label: \"Next steps\",\n }),\n },\n {\n // Toggle deductibles accordion\n name: \"deductiblesClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"us-qcp-react\",\n action: \"view_deductables_clicked\",\n label: \"view_deductables_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"deductiblesClickedUk\",\n type: \"structured\",\n makePayload: params => {\n const { label, deviceType } = params as ParamsType;\n const urlFriendlyLabel = label.replace(/ /g, \"-\").toLowerCase();\n\n return {\n category: `uk-qcp-react-${deviceType}-${urlFriendlyLabel}-view-excess-toggle`,\n action: \"view_excess_clicked\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n // Quote Details Slider opened\n name: \"sliderOpened\",\n type: \"structured\",\n makePayload: params => {\n const { label } = params as ParamsType;\n\n return {\n category: \"comparison_cta\",\n action: \"quote_details_slider_opened\",\n label,\n };\n },\n },\n {\n // Coverage modal opened\n name: \"coverageModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const {\n category,\n product = \"extra_coverage\",\n title,\n } = params as ParamsType;\n const productLabel = snakeCase(product);\n\n return {\n category,\n action: `${productLabel}_${snakeCase(title)}_popup_opened`,\n label: productLabel,\n property: window.location.href,\n };\n },\n },\n {\n // Toggle cover select\n name: \"coverChanged\",\n type: \"unstructured\",\n makePayload: params => {\n const { name = \"\", fromValue = \"\", toValue = \"\" } = params as ParamsType;\n // Derive data\n let action = \"change\";\n\n // This logic is taken directly from Chopin without documentation:\n // If a cover has zero value, then change the action to add or remove\n if (fromValue === \"0\") {\n action = \"add\";\n }\n if (toValue === \"0\") {\n action = \"remove\";\n }\n\n return {\n schema:\n \"iglu:com.simplybusiness/comparison_page_cover_changed/jsonschema/1-0-0\",\n data: {\n name,\n action,\n from_value: fromValue,\n to_value: toValue,\n },\n };\n },\n },\n {\n name: \"ratingsModalOpened\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"insurer_rating_help_popup_triggered\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"coverToggleOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"qcp_limit_interaction\",\n label: \"limit_interaction\",\n action: \"limit_interaction_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"paymentToggleClicked\",\n type: \"structured\",\n makePayload: params => {\n const { category, label } = params as ParamsType;\n\n return {\n category,\n action: \"button_click\",\n label,\n property: window.location.href,\n };\n },\n },\n {\n name: \"insurerDetailsAccordionClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"quote_details_slider_insurer_details_description\",\n action: \"accordion_clicked\",\n label: \"accordion_clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"priceDetailsPopUpOpened\",\n type: \"structured\",\n makePayload: () => ({\n category: \"price_details\",\n action: \"price_details_popup_opened\",\n label: \"Price details\",\n property: window.location.href,\n }),\n },\n {\n name: \"editLimitButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"edit_limit_button_clicked\",\n label: \"Edit Limit\",\n property: window.location.href,\n }),\n },\n {\n name: \"applyButtonClicked\",\n type: \"structured\",\n makePayload: () => ({\n category: \"cover_limit_changes\",\n action: \"apply_button_clicked\",\n label: \"Apply Button Clicked\",\n property: window.location.href,\n }),\n },\n {\n name: \"coverageInfoClicked\",\n type: \"structured\",\n makePayload: params => {\n const { deviceType } = params as ParamsType;\n\n return {\n action: \"show_coverage_info_clicked\",\n category: `uk-qcp-react-${deviceType}-show-coverage-info-toggle`,\n label: \"show_coverage_info_clicked\",\n property: window.location.href,\n };\n },\n },\n];\n"],"names":["eventDefinitions","name","type","makePayload","category","action","label","property","window","location","href","schema","data","params","deviceType","urlFriendlyLabel","replace","toLowerCase","product","title","productLabel","snakeCase","fromValue","toValue","from_value","to_value"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getSnowplowConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return getSnowplowConfig;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const getSnowplowConfig = (pageData)=>{
|
|
12
|
+
var _pageData_scripts_find, _pageData_scripts;
|
|
13
|
+
return (_pageData_scripts = pageData.scripts) === null || _pageData_scripts === void 0 ? void 0 : (_pageData_scripts_find = _pageData_scripts.find(({ metadata })=>metadata.name === "snowplow")) === null || _pageData_scripts_find === void 0 ? void 0 : _pageData_scripts_find.props;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=getSnowplowConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/services/snowplow/getSnowplowConfig.ts"],"sourcesContent":["import type { TrackingProps, PageDataProps } from \"./types\";\n\n// Get Snowplow config from page data props\nexport const getSnowplowConfig = (\n pageData: PageDataProps,\n): TrackingProps | undefined =>\n pageData.scripts?.find(({ metadata }) => metadata.name === \"snowplow\")\n ?.props as TrackingProps;\n"],"names":["getSnowplowConfig","pageData","scripts","find","metadata","name","props"],"mappings":";;;;+BAGaA;;;eAAAA;;;AAAN,MAAMA,oBAAoB,CAC/BC;QAEAA,wBAAAA;YAAAA,oBAAAA,SAASC,OAAO,cAAhBD,yCAAAA,yBAAAA,kBAAkBE,IAAI,CAAC,CAAC,EAAEC,QAAQ,EAAE,GAAKA,SAASC,IAAI,KAAK,yBAA3DJ,6CAAAA,uBACIK,KAAK"}
|