@simplybusiness/services 1.7.3 → 2.0.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.
- package/CHANGELOG.md +17 -0
- package/package.json +23 -9
- package/dist/cjs/index.js +0 -1404
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/meta.json +0 -401
package/dist/cjs/index.js
DELETED
|
@@ -1,1404 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// index.tsx
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
AddressLookup: () => AddressLookup,
|
|
24
|
-
Snowplow: () => Snowplow,
|
|
25
|
-
SnowplowProvider: () => SnowplowProvider,
|
|
26
|
-
coverageSelectionPageEvents: () => coverageSelectionPageEvents,
|
|
27
|
-
eventDefinitions: () => eventDefinitions,
|
|
28
|
-
getAirbrake: () => getAirbrake,
|
|
29
|
-
getAirbrakeEnvironment: () => getAirbrakeEnvironment,
|
|
30
|
-
getContexts: () => getContexts,
|
|
31
|
-
getSnowplowConfig: () => getSnowplowConfig,
|
|
32
|
-
interventionPageEvents: () => interventionPageEvents,
|
|
33
|
-
makeContexts: () => makeContexts,
|
|
34
|
-
personalisedCoverPageEvents: () => personalisedCoverPageEvents,
|
|
35
|
-
qcpPageEvents: () => qcpPageEvents,
|
|
36
|
-
questionnairePageEvents: () => questionnairePageEvents,
|
|
37
|
-
referralPageEvents: () => referralPageEvents,
|
|
38
|
-
updateIdentityContext: () => updateIdentityContext,
|
|
39
|
-
useSnowplowContext: () => useSnowplowContext
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(index_exports);
|
|
42
|
-
|
|
43
|
-
// src/address-lookup/index.ts
|
|
44
|
-
var BASE_URL = "https://api.addressy.com/Capture/Interactive";
|
|
45
|
-
var FIND_URL = `${BASE_URL}/Find/v1.00/json3.ws`;
|
|
46
|
-
var RETRIEVE_URL = `${BASE_URL}/Retrieve/v1.2/json3.ws`;
|
|
47
|
-
var COUNTRIES = ["GB"];
|
|
48
|
-
var LIMIT = 20;
|
|
49
|
-
var AddressLookup = class _AddressLookup {
|
|
50
|
-
constructor({ apiKey, limit, countries }) {
|
|
51
|
-
this.apiKey = apiKey;
|
|
52
|
-
this.limit = limit || LIMIT;
|
|
53
|
-
this.countries = countries || COUNTRIES;
|
|
54
|
-
const countriesParam = this.countries.join(",");
|
|
55
|
-
this.findUrl = `${FIND_URL}?Key=${this.apiKey}&Limit=${this.limit}&Countries=${countriesParam}`;
|
|
56
|
-
this.retrieveUrl = `${RETRIEVE_URL}?Key=${this.apiKey}`;
|
|
57
|
-
}
|
|
58
|
-
static async fetchFromApi(url, handleResponse) {
|
|
59
|
-
return new Promise((resolve, reject) => {
|
|
60
|
-
fetch(url).then((response) => response.json()).then((data) => resolve(handleResponse(data))).catch((error) => reject(Error(String(error))));
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
find(partialAddress) {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
fetch(`${this.findUrl}&Text=${partialAddress}`).then((response) => response.json()).then((data) => resolve(this.formatItems(data))).catch((error) => reject(Error(String(error))));
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
findById(id) {
|
|
69
|
-
return new Promise((resolve, reject) => {
|
|
70
|
-
fetch(`${this.findUrl}&Container=${id}`).then((response) => response.json()).then((data) => resolve(this.formatItems(data))).catch((error) => reject(Error(String(error))));
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
get(id) {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
fetch(`${this.retrieveUrl}&Id=${id}`).then((response) => response.json()).then((data) => resolve(_AddressLookup.formatUkAddress(data))).catch((error) => reject(Error(String(error))));
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
formatItems({ Items }) {
|
|
79
|
-
if (!Items || !Array.isArray(Items)) {
|
|
80
|
-
throw Error("No address found");
|
|
81
|
-
}
|
|
82
|
-
if (Items[0].Error) {
|
|
83
|
-
throw Error(Items[0].Description);
|
|
84
|
-
}
|
|
85
|
-
return Items.map(
|
|
86
|
-
(item) => ({
|
|
87
|
-
id: item.Id,
|
|
88
|
-
label: `${item.Text}, ${item.Description}`,
|
|
89
|
-
value: item.Text,
|
|
90
|
-
// Add a callback to trigger secondary search
|
|
91
|
-
// if the address type is not "Address"
|
|
92
|
-
callback: item.Type === "Address" ? void 0 : () => this.findById(item.Id)
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
static formatUkAddress({ Items }) {
|
|
97
|
-
if (!Items || !Array.isArray(Items)) {
|
|
98
|
-
throw Error("No address found");
|
|
99
|
-
}
|
|
100
|
-
if (Items[0].Error) {
|
|
101
|
-
throw Error(Items[0].Description);
|
|
102
|
-
}
|
|
103
|
-
const { Line1, Line2, City, PostalCode } = Items[0];
|
|
104
|
-
return {
|
|
105
|
-
address_1: Line1,
|
|
106
|
-
address_2: Line2,
|
|
107
|
-
town: City,
|
|
108
|
-
uk_postcode: PostalCode
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// src/airbrake/index.ts
|
|
114
|
-
var import_browser = require("@airbrake/browser");
|
|
115
|
-
var defaultProjectId = 512949;
|
|
116
|
-
var defaultProjectKey = "4e25197d8faea61c10fbb97702200780";
|
|
117
|
-
var notifierInstances = /* @__PURE__ */ new Map();
|
|
118
|
-
var fakeAirbrake = {
|
|
119
|
-
notify: globalThis.process?.env?.NODE_ENV === "test" ? jest.fn() : console.error.bind(console)
|
|
120
|
-
};
|
|
121
|
-
var getAirbrakeEnvironment = () => globalThis.process?.env?.AIRBRAKE_ENV ?? "development";
|
|
122
|
-
var shouldUseAirbrake = () => {
|
|
123
|
-
const env = getAirbrakeEnvironment();
|
|
124
|
-
return env === "staging" || env === "production";
|
|
125
|
-
};
|
|
126
|
-
function getAirbrake(options = {}) {
|
|
127
|
-
const {
|
|
128
|
-
projectId = defaultProjectId,
|
|
129
|
-
projectKey = defaultProjectKey,
|
|
130
|
-
forceSend
|
|
131
|
-
} = options;
|
|
132
|
-
if (!forceSend && !shouldUseAirbrake()) {
|
|
133
|
-
return fakeAirbrake;
|
|
134
|
-
}
|
|
135
|
-
let notifierInstance = notifierInstances.get(projectId);
|
|
136
|
-
if (!notifierInstance) {
|
|
137
|
-
notifierInstance = new import_browser.Notifier({
|
|
138
|
-
projectId,
|
|
139
|
-
projectKey,
|
|
140
|
-
environment: getAirbrakeEnvironment(),
|
|
141
|
-
instrumentation: {
|
|
142
|
-
onerror: false,
|
|
143
|
-
unhandledrejection: false
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
notifierInstances.set(projectId, notifierInstance);
|
|
147
|
-
}
|
|
148
|
-
return notifierInstance;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// src/utils/text.ts
|
|
152
|
-
var snakeCaseKeys = (object) => Object.entries(object || {}).reduce(
|
|
153
|
-
(acc, [key, value]) => {
|
|
154
|
-
const newKey = camelToSnakeCase(key);
|
|
155
|
-
if (Array.isArray(value) && value.every(isObject)) {
|
|
156
|
-
return {
|
|
157
|
-
...acc,
|
|
158
|
-
[newKey]: value.map((v) => snakeCaseKeys(v))
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
if (isObject(value)) {
|
|
162
|
-
return {
|
|
163
|
-
...acc,
|
|
164
|
-
[newKey]: snakeCaseKeys(value)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
...acc,
|
|
169
|
-
[newKey]: value
|
|
170
|
-
};
|
|
171
|
-
},
|
|
172
|
-
{}
|
|
173
|
-
);
|
|
174
|
-
var snakeCase = (text = "") => text.toLowerCase().replace(/ /g, "_");
|
|
175
|
-
var camelToSnakeCase = (text) => text.charAt(0).toLowerCase() + text.slice(1).replace(
|
|
176
|
-
/(\[.*?\])|[A-Z]/g,
|
|
177
|
-
(match, group) => group ? match : `_${match.toLowerCase()}`
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
// src/utils/isObject.tsx
|
|
181
|
-
function isObject(value) {
|
|
182
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// src/snowplow/contexts.ts
|
|
186
|
-
var getContexts = (config) => {
|
|
187
|
-
const contextEntries = Object.entries(config || {}).filter(([key]) => key.includes("Context") && key !== "includeGAContext").reduce((acc, [key, value]) => {
|
|
188
|
-
if (typeof value === "object") {
|
|
189
|
-
return { ...acc, [key]: snakeCaseKeys({ ...value }) };
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
...acc,
|
|
193
|
-
[key]: snakeCaseKeys({ data: { service_channel_identifier: value } })
|
|
194
|
-
};
|
|
195
|
-
}, {});
|
|
196
|
-
return contextEntries;
|
|
197
|
-
};
|
|
198
|
-
var updateIdentityContext = (contexts, uid) => {
|
|
199
|
-
const index = Object.keys(contexts).findIndex(
|
|
200
|
-
(ctx) => contexts[ctx].schema?.includes("identity_context")
|
|
201
|
-
);
|
|
202
|
-
if (index > -1) {
|
|
203
|
-
const key = Object.keys(contexts)[index];
|
|
204
|
-
return {
|
|
205
|
-
...contexts,
|
|
206
|
-
[key]: {
|
|
207
|
-
...contexts[key],
|
|
208
|
-
data: {
|
|
209
|
-
...contexts[key].data,
|
|
210
|
-
domain_userid: uid
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
return contexts;
|
|
216
|
-
};
|
|
217
|
-
var makeContexts = (keys, config) => (keys || []).map((key) => config[key]);
|
|
218
|
-
|
|
219
|
-
// src/snowplow/event-definitions/base.ts
|
|
220
|
-
var baseEventDefinitions = [
|
|
221
|
-
// Mobile link in header
|
|
222
|
-
{
|
|
223
|
-
name: "mobileLinkClick",
|
|
224
|
-
type: "structured",
|
|
225
|
-
makePayload: () => ({
|
|
226
|
-
category: "marketing",
|
|
227
|
-
action: "link-click",
|
|
228
|
-
label: "mobile_call_button",
|
|
229
|
-
property: window.location.href
|
|
230
|
-
})
|
|
231
|
-
},
|
|
232
|
-
// Operating hours link in footer
|
|
233
|
-
{
|
|
234
|
-
name: "operatingHoursClick",
|
|
235
|
-
type: "unstructured",
|
|
236
|
-
makePayload: () => ({
|
|
237
|
-
schema: "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
|
|
238
|
-
data: {
|
|
239
|
-
schema: "iglu:com.simplybusiness/operating_hours_clicked/jsonschema/1-0-2",
|
|
240
|
-
data: {}
|
|
241
|
-
}
|
|
242
|
-
})
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
name: "progressbarClicked",
|
|
246
|
-
type: "unstructured",
|
|
247
|
-
makePayload: (params) => {
|
|
248
|
-
const {
|
|
249
|
-
section,
|
|
250
|
-
context,
|
|
251
|
-
fromStepIndex,
|
|
252
|
-
fromStepName,
|
|
253
|
-
stepIndex,
|
|
254
|
-
stepName
|
|
255
|
-
} = params;
|
|
256
|
-
return {
|
|
257
|
-
schema: "iglu:com.simplybusiness/progressbar_clicked/jsonschema/1-1-0",
|
|
258
|
-
data: {
|
|
259
|
-
source_page_index: fromStepIndex,
|
|
260
|
-
source_page_name: fromStepName,
|
|
261
|
-
page_index: stepIndex,
|
|
262
|
-
page_name: stepName,
|
|
263
|
-
site: context.site,
|
|
264
|
-
section_name: section,
|
|
265
|
-
vertical: context.vertical
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
// Zendesk help chat link
|
|
271
|
-
{
|
|
272
|
-
name: "helpChatLinkClicked",
|
|
273
|
-
type: "structured",
|
|
274
|
-
makePayload: (params) => {
|
|
275
|
-
const { label } = params;
|
|
276
|
-
return {
|
|
277
|
-
category: "help chat for question",
|
|
278
|
-
action: "help_chat_for_question_clicked",
|
|
279
|
-
label,
|
|
280
|
-
property: window.location.href
|
|
281
|
-
};
|
|
282
|
-
},
|
|
283
|
-
contexts: ["serviceChannelContext"]
|
|
284
|
-
}
|
|
285
|
-
];
|
|
286
|
-
|
|
287
|
-
// src/snowplow/event-definitions/intervention.ts
|
|
288
|
-
var interventionEventDefinitions = [
|
|
289
|
-
{
|
|
290
|
-
name: "interventionInteractionCompleted",
|
|
291
|
-
type: "unstructured",
|
|
292
|
-
makePayload: (params) => {
|
|
293
|
-
const {
|
|
294
|
-
interventionName,
|
|
295
|
-
userUniqueIdentifier,
|
|
296
|
-
userUniqueIdentifierType,
|
|
297
|
-
action,
|
|
298
|
-
site
|
|
299
|
-
} = params;
|
|
300
|
-
return {
|
|
301
|
-
schema: "iglu:com.simplybusiness/intervention_interaction_completed/jsonschema/2-1-0",
|
|
302
|
-
data: {
|
|
303
|
-
intervention_name: interventionName,
|
|
304
|
-
user_unique_identifier: userUniqueIdentifier,
|
|
305
|
-
user_unique_identifier_type: userUniqueIdentifierType,
|
|
306
|
-
action,
|
|
307
|
-
site
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
name: "iaLiveChatInterventionClosed",
|
|
314
|
-
type: "structured",
|
|
315
|
-
makePayload: (_) => ({
|
|
316
|
-
category: "insurance_assistant",
|
|
317
|
-
action: "ia_live_chat_intervention_closed"
|
|
318
|
-
})
|
|
319
|
-
}
|
|
320
|
-
];
|
|
321
|
-
|
|
322
|
-
// src/snowplow/constants.ts
|
|
323
|
-
var DELIMITER = "|";
|
|
324
|
-
|
|
325
|
-
// src/snowplow/event-definitions/questionnaire/redaction.ts
|
|
326
|
-
var PII_ANSWER = [
|
|
327
|
-
"customer_title",
|
|
328
|
-
"customer_first_name",
|
|
329
|
-
"customer_last_name",
|
|
330
|
-
"customer_email_address",
|
|
331
|
-
"preapp_email_address",
|
|
332
|
-
"customer_telephone_number",
|
|
333
|
-
"customer_alternative_telephone_number",
|
|
334
|
-
"uk_address_lookup",
|
|
335
|
-
"uk_correspondence_address_lookup",
|
|
336
|
-
"customer_address_1_pre_quote",
|
|
337
|
-
"customer_address_2_pre_quote",
|
|
338
|
-
"customer_town_pre_quote",
|
|
339
|
-
"customer_postcode_pre_quote",
|
|
340
|
-
"customer_address_1",
|
|
341
|
-
"customer_address_2",
|
|
342
|
-
"customer_town",
|
|
343
|
-
"customer_postcode",
|
|
344
|
-
"address_1_pre_quote",
|
|
345
|
-
"address_2_pre_quote",
|
|
346
|
-
"uk_postcode_pre_quote",
|
|
347
|
-
"town_pre_quote",
|
|
348
|
-
"owner_first_name",
|
|
349
|
-
"owner_last_name",
|
|
350
|
-
"beneficiary_first_name",
|
|
351
|
-
"beneficiary_last_name",
|
|
352
|
-
"gender",
|
|
353
|
-
"dynamic_ssn_fein",
|
|
354
|
-
"ssn",
|
|
355
|
-
"fein",
|
|
356
|
-
"sof_county_court_judgement_online_yes",
|
|
357
|
-
"sof_county_court_judgement_online_no",
|
|
358
|
-
"sof_ccj_count",
|
|
359
|
-
"sof_ccj_value",
|
|
360
|
-
"sof_ccj_date",
|
|
361
|
-
"sof_court_judgement_yes",
|
|
362
|
-
"sof_court_judgement_no",
|
|
363
|
-
"ccj_date",
|
|
364
|
-
"sof_single_ccj_no",
|
|
365
|
-
"sof_single_ccj_yes",
|
|
366
|
-
"sof_ccj_yes",
|
|
367
|
-
"sof_ccj_no",
|
|
368
|
-
"ccj_count",
|
|
369
|
-
"sof_bankrupt_yes",
|
|
370
|
-
"sof_bankrupt_no",
|
|
371
|
-
"sof_multiple_bankruptcies_yes",
|
|
372
|
-
"sof_multiple_bankruptcies_no",
|
|
373
|
-
"bankruptcy_date",
|
|
374
|
-
"sof_single_bankruptcy_no",
|
|
375
|
-
"sof_single_bankruptcy_yes",
|
|
376
|
-
"sof_bankruptcy_yes",
|
|
377
|
-
"sof_bankruptcy_no",
|
|
378
|
-
"bankruptcy_discharged",
|
|
379
|
-
"sof_liquidation_yes",
|
|
380
|
-
"sof_liquidation_no",
|
|
381
|
-
"sof_multiple_liquidations",
|
|
382
|
-
"liquidation_date",
|
|
383
|
-
"sof_criminal_offence_yes",
|
|
384
|
-
"sof_criminal_offence_no",
|
|
385
|
-
"sof_criminal_yes",
|
|
386
|
-
"sof_criminal_no",
|
|
387
|
-
"hcp_date_of_birth_1",
|
|
388
|
-
"hcp_date_of_birth_2",
|
|
389
|
-
"hcp_date_of_birth_3",
|
|
390
|
-
"hcp_date_of_birth_4",
|
|
391
|
-
"hcp_date_of_birth_5",
|
|
392
|
-
"hcp_date_of_birth_6",
|
|
393
|
-
"hcp_date_of_birth_7",
|
|
394
|
-
"hcp_date_of_birth_8",
|
|
395
|
-
"hcp_date_of_birth_9",
|
|
396
|
-
"hcp_date_of_birth_10",
|
|
397
|
-
"sof_previous_claims_yes",
|
|
398
|
-
"sof_previous_claims_no",
|
|
399
|
-
"sof_claims_yes",
|
|
400
|
-
"sof_claims_no",
|
|
401
|
-
"sof_property_claims_in_the_last_5_years_yes",
|
|
402
|
-
"sof_property_claims_in_the_last_5_years_no",
|
|
403
|
-
"sof_property_claims_in_the_last_0_to_4_years_yes",
|
|
404
|
-
"sof_property_claims_in_the_last_0_to_4_years_no",
|
|
405
|
-
"claim_count",
|
|
406
|
-
"sof_number_of_claims",
|
|
407
|
-
"number_of_claims_in_last_5_years",
|
|
408
|
-
"number_of_claims_in_time_owned",
|
|
409
|
-
"date_of_incident_1",
|
|
410
|
-
"date_of_incident_2",
|
|
411
|
-
"date_of_incident_3",
|
|
412
|
-
"date_of_incident_4",
|
|
413
|
-
"date_of_incident_5",
|
|
414
|
-
"type_of_incident_1",
|
|
415
|
-
"type_of_incident_2",
|
|
416
|
-
"type_of_incident_3",
|
|
417
|
-
"type_of_incident_4",
|
|
418
|
-
"type_of_incident_5",
|
|
419
|
-
"incident_value_1",
|
|
420
|
-
"incident_value_2",
|
|
421
|
-
"incident_value_3",
|
|
422
|
-
"incident_value_4",
|
|
423
|
-
"incident_value_5",
|
|
424
|
-
"sof_pollution_disease_claims_yes",
|
|
425
|
-
"sof_pollution_disease_claims_no",
|
|
426
|
-
"sof_potential_claims_yes",
|
|
427
|
-
"sof_potential_claims_no",
|
|
428
|
-
"sof_previous_circumstances_yes",
|
|
429
|
-
"sof_previous_circumstances_no",
|
|
430
|
-
"sof_possible_claims_yes",
|
|
431
|
-
"sof_possible_claims_no",
|
|
432
|
-
"date_of_possible_incident",
|
|
433
|
-
"type_of_possible_incident",
|
|
434
|
-
"possible_incident_value",
|
|
435
|
-
"sof_property_claims_yes",
|
|
436
|
-
"sof_property_claims_no",
|
|
437
|
-
"sof_liability_claims_yes",
|
|
438
|
-
"sof_liability_claims_no",
|
|
439
|
-
"van_registration",
|
|
440
|
-
"sof_disqualified_director_yes",
|
|
441
|
-
"sof_disqualified_director_no",
|
|
442
|
-
"sof_insurance_refused_yes",
|
|
443
|
-
"sof_insurance_refused_no",
|
|
444
|
-
"sof_insurance_declined_yes",
|
|
445
|
-
"sof_insurance_declined_no",
|
|
446
|
-
"insurance_refused"
|
|
447
|
-
];
|
|
448
|
-
var RADIO_ANSWER_FROM_QUESTIONS = [
|
|
449
|
-
"have_secondary_trade_yes",
|
|
450
|
-
"have_secondary_trade_no"
|
|
451
|
-
];
|
|
452
|
-
var ANSWER_SUFFIX_PATTERN = /_(yes|no)$/;
|
|
453
|
-
var redact = (params) => {
|
|
454
|
-
let { question, answer } = params;
|
|
455
|
-
const piiAnswer = new Set(PII_ANSWER);
|
|
456
|
-
const radioAnswerFromQuestions = new Set(RADIO_ANSWER_FROM_QUESTIONS);
|
|
457
|
-
if (piiAnswer.has(question)) {
|
|
458
|
-
answer = "REDACTED";
|
|
459
|
-
question = question?.replace(ANSWER_SUFFIX_PATTERN, "");
|
|
460
|
-
} else if (radioAnswerFromQuestions.has(question)) {
|
|
461
|
-
question = question?.replace(ANSWER_SUFFIX_PATTERN, "");
|
|
462
|
-
}
|
|
463
|
-
return { question, answer };
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
// src/snowplow/event-definitions/personalised_cover.ts
|
|
467
|
-
var personalisedCoverEventDefinitions = [
|
|
468
|
-
{
|
|
469
|
-
name: "seeMoreClicked",
|
|
470
|
-
type: "structured",
|
|
471
|
-
makePayload: (_) => ({
|
|
472
|
-
category: "personalised_cover",
|
|
473
|
-
action: "see_more_clicked",
|
|
474
|
-
label: "page",
|
|
475
|
-
property: "personalised_cover"
|
|
476
|
-
})
|
|
477
|
-
},
|
|
478
|
-
{
|
|
479
|
-
name: "selectPackageClicked",
|
|
480
|
-
type: "structured",
|
|
481
|
-
makePayload: (_) => ({
|
|
482
|
-
category: "personalised_cover",
|
|
483
|
-
action: "select_package_clicked",
|
|
484
|
-
label: "page",
|
|
485
|
-
property: "personalised_cover"
|
|
486
|
-
})
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
name: "validationShown",
|
|
490
|
-
type: "structured",
|
|
491
|
-
makePayload: (params) => {
|
|
492
|
-
const { cover, question } = params;
|
|
493
|
-
return {
|
|
494
|
-
category: "personalised_cover",
|
|
495
|
-
action: "validation_shown",
|
|
496
|
-
label: "cover_question",
|
|
497
|
-
property: `${snakeCase(cover)}_${snakeCase(question)}`
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
name: "coverQuestionAnswered",
|
|
503
|
-
type: "unstructured",
|
|
504
|
-
makePayload: (params) => {
|
|
505
|
-
const { context } = params;
|
|
506
|
-
const { question, answer } = redact(params);
|
|
507
|
-
const flatAnswer = Array.isArray(answer) ? answer.join(DELIMITER) : answer;
|
|
508
|
-
return {
|
|
509
|
-
schema: "iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-1",
|
|
510
|
-
data: {
|
|
511
|
-
site: context.site,
|
|
512
|
-
page_name: "personalised_cover",
|
|
513
|
-
section_name: "Personalised Cover Questions",
|
|
514
|
-
question,
|
|
515
|
-
answer: flatAnswer
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
name: "limitLinkClicked",
|
|
522
|
-
type: "structured",
|
|
523
|
-
makePayload: (params) => {
|
|
524
|
-
const { label } = params;
|
|
525
|
-
return {
|
|
526
|
-
category: "personalised_cover",
|
|
527
|
-
action: "limit_link_clicked",
|
|
528
|
-
label,
|
|
529
|
-
property: "link_clicked"
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
name: "limitChanged",
|
|
535
|
-
type: "structured",
|
|
536
|
-
makePayload: (params) => {
|
|
537
|
-
const { label, limit } = params;
|
|
538
|
-
return {
|
|
539
|
-
category: "personalised_cover",
|
|
540
|
-
action: "limit_changed",
|
|
541
|
-
label,
|
|
542
|
-
property: limit
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
},
|
|
546
|
-
{
|
|
547
|
-
name: "coverPresented",
|
|
548
|
-
type: "structured",
|
|
549
|
-
makePayload: (params) => {
|
|
550
|
-
const { property } = params;
|
|
551
|
-
return {
|
|
552
|
-
category: "personalised_cover",
|
|
553
|
-
action: "cover_presented",
|
|
554
|
-
label: "cover_name",
|
|
555
|
-
property
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
name: "coverDetailsClicked",
|
|
561
|
-
type: "structured",
|
|
562
|
-
makePayload: (params) => {
|
|
563
|
-
const { property } = params;
|
|
564
|
-
return {
|
|
565
|
-
category: "personalised_cover",
|
|
566
|
-
action: "cover_details_clicked",
|
|
567
|
-
label: "cover_name",
|
|
568
|
-
property
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
name: "additionalQuestionsClicked",
|
|
574
|
-
type: "structured",
|
|
575
|
-
makePayload: (params) => {
|
|
576
|
-
const { property } = params;
|
|
577
|
-
return {
|
|
578
|
-
category: "personalised_cover",
|
|
579
|
-
action: "cover_details_clicked",
|
|
580
|
-
label: "cover_name",
|
|
581
|
-
property
|
|
582
|
-
};
|
|
583
|
-
}
|
|
584
|
-
},
|
|
585
|
-
{
|
|
586
|
-
name: "chatbotPromptClicked",
|
|
587
|
-
type: "structured",
|
|
588
|
-
makePayload: (params) => {
|
|
589
|
-
const { label, property } = params;
|
|
590
|
-
return {
|
|
591
|
-
category: "personalised_cover",
|
|
592
|
-
action: "chatbot_prompt_clicked",
|
|
593
|
-
label: property,
|
|
594
|
-
property: label
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
];
|
|
599
|
-
|
|
600
|
-
// src/snowplow/event-definitions/qcp.ts
|
|
601
|
-
var qcpEventDefinitions = [
|
|
602
|
-
{
|
|
603
|
-
// QDP details button
|
|
604
|
-
name: "detailsClicked",
|
|
605
|
-
type: "structured",
|
|
606
|
-
makePayload: () => ({
|
|
607
|
-
category: "comparison_cta",
|
|
608
|
-
action: "link_click",
|
|
609
|
-
label: "Details"
|
|
610
|
-
})
|
|
611
|
-
},
|
|
612
|
-
{
|
|
613
|
-
// Buy button
|
|
614
|
-
name: "selectClicked",
|
|
615
|
-
type: "structured",
|
|
616
|
-
makePayload: () => ({
|
|
617
|
-
category: "comparison_cta",
|
|
618
|
-
action: "link_click",
|
|
619
|
-
label: "Buy"
|
|
620
|
-
})
|
|
621
|
-
},
|
|
622
|
-
{
|
|
623
|
-
// Quote Details Slider Next steps button
|
|
624
|
-
name: "nextStepsClicked",
|
|
625
|
-
type: "structured",
|
|
626
|
-
makePayload: () => ({
|
|
627
|
-
category: "quote_details_slider_next_step_cta",
|
|
628
|
-
action: "link_click",
|
|
629
|
-
label: "Next steps"
|
|
630
|
-
})
|
|
631
|
-
},
|
|
632
|
-
{
|
|
633
|
-
// Toggle deductibles accordion
|
|
634
|
-
name: "deductiblesClicked",
|
|
635
|
-
type: "structured",
|
|
636
|
-
makePayload: () => ({
|
|
637
|
-
category: "us-qcp-react",
|
|
638
|
-
action: "view_deductables_clicked",
|
|
639
|
-
label: "view_deductables_clicked",
|
|
640
|
-
property: window.location.href
|
|
641
|
-
})
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
name: "deductiblesClickedUk",
|
|
645
|
-
type: "structured",
|
|
646
|
-
makePayload: (params) => {
|
|
647
|
-
const { label, deviceType } = params;
|
|
648
|
-
const urlFriendlyLabel = label.replace(/ /g, "-").toLowerCase();
|
|
649
|
-
return {
|
|
650
|
-
category: `uk-qcp-react-${deviceType}-${urlFriendlyLabel}-view-excess-toggle`,
|
|
651
|
-
action: "view_excess_clicked",
|
|
652
|
-
label,
|
|
653
|
-
property: window.location.href
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
},
|
|
657
|
-
{
|
|
658
|
-
// Quote Details Slider opened
|
|
659
|
-
name: "sliderOpened",
|
|
660
|
-
type: "structured",
|
|
661
|
-
makePayload: (params) => {
|
|
662
|
-
const { label } = params;
|
|
663
|
-
return {
|
|
664
|
-
category: "comparison_cta",
|
|
665
|
-
action: "quote_details_slider_opened",
|
|
666
|
-
label
|
|
667
|
-
};
|
|
668
|
-
}
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
// Coverage modal opened
|
|
672
|
-
name: "coverageModalOpened",
|
|
673
|
-
type: "structured",
|
|
674
|
-
makePayload: (params) => {
|
|
675
|
-
const {
|
|
676
|
-
category,
|
|
677
|
-
product = "extra_coverage",
|
|
678
|
-
title
|
|
679
|
-
} = params;
|
|
680
|
-
const productLabel = snakeCase(product);
|
|
681
|
-
return {
|
|
682
|
-
category,
|
|
683
|
-
action: `${productLabel}_${snakeCase(title)}_popup_opened`,
|
|
684
|
-
label: productLabel,
|
|
685
|
-
property: window.location.href
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
},
|
|
689
|
-
{
|
|
690
|
-
// Toggle cover select
|
|
691
|
-
name: "coverChanged",
|
|
692
|
-
type: "unstructured",
|
|
693
|
-
makePayload: (params) => {
|
|
694
|
-
const { name = "", fromValue = "", toValue = "" } = params;
|
|
695
|
-
let action = "change";
|
|
696
|
-
if (fromValue === "0") {
|
|
697
|
-
action = "add";
|
|
698
|
-
}
|
|
699
|
-
if (toValue === "0") {
|
|
700
|
-
action = "remove";
|
|
701
|
-
}
|
|
702
|
-
return {
|
|
703
|
-
schema: "iglu:com.simplybusiness/comparison_page_cover_changed/jsonschema/1-0-0",
|
|
704
|
-
data: {
|
|
705
|
-
name,
|
|
706
|
-
action,
|
|
707
|
-
from_value: fromValue,
|
|
708
|
-
to_value: toValue
|
|
709
|
-
}
|
|
710
|
-
};
|
|
711
|
-
},
|
|
712
|
-
contexts: ["distributionChannelContext"]
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
name: "ratingsModalOpened",
|
|
716
|
-
type: "structured",
|
|
717
|
-
makePayload: (params) => {
|
|
718
|
-
const { category, label } = params;
|
|
719
|
-
return {
|
|
720
|
-
category,
|
|
721
|
-
action: "insurer_rating_help_popup_triggered",
|
|
722
|
-
label,
|
|
723
|
-
property: window.location.href
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
},
|
|
727
|
-
{
|
|
728
|
-
name: "coverToggleOpened",
|
|
729
|
-
type: "structured",
|
|
730
|
-
makePayload: () => ({
|
|
731
|
-
category: "qcp_limit_interaction",
|
|
732
|
-
label: "limit_interaction",
|
|
733
|
-
action: "limit_interaction_clicked",
|
|
734
|
-
property: window.location.href
|
|
735
|
-
})
|
|
736
|
-
},
|
|
737
|
-
{
|
|
738
|
-
name: "paymentToggleClicked",
|
|
739
|
-
type: "structured",
|
|
740
|
-
makePayload: (params) => {
|
|
741
|
-
const { category, label } = params;
|
|
742
|
-
return {
|
|
743
|
-
category,
|
|
744
|
-
action: "button_click",
|
|
745
|
-
label,
|
|
746
|
-
property: window.location.href
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
name: "insurerDetailsAccordionClicked",
|
|
752
|
-
type: "structured",
|
|
753
|
-
makePayload: () => ({
|
|
754
|
-
category: "quote_details_slider_insurer_details_description",
|
|
755
|
-
action: "accordion_clicked",
|
|
756
|
-
label: "accordion_clicked",
|
|
757
|
-
property: window.location.href
|
|
758
|
-
})
|
|
759
|
-
},
|
|
760
|
-
{
|
|
761
|
-
name: "priceDetailsPopUpOpened",
|
|
762
|
-
type: "structured",
|
|
763
|
-
makePayload: () => ({
|
|
764
|
-
category: "price_details",
|
|
765
|
-
action: "price_details_popup_opened",
|
|
766
|
-
label: "Price details",
|
|
767
|
-
property: window.location.href
|
|
768
|
-
})
|
|
769
|
-
},
|
|
770
|
-
{
|
|
771
|
-
name: "editLimitButtonClicked",
|
|
772
|
-
type: "structured",
|
|
773
|
-
makePayload: () => ({
|
|
774
|
-
category: "cover_limit_changes",
|
|
775
|
-
action: "edit_limit_button_clicked",
|
|
776
|
-
label: "Edit Limit",
|
|
777
|
-
property: window.location.href
|
|
778
|
-
})
|
|
779
|
-
},
|
|
780
|
-
{
|
|
781
|
-
name: "applyButtonClicked",
|
|
782
|
-
type: "structured",
|
|
783
|
-
makePayload: () => ({
|
|
784
|
-
category: "cover_limit_changes",
|
|
785
|
-
action: "apply_button_clicked",
|
|
786
|
-
label: "Apply Button Clicked",
|
|
787
|
-
property: window.location.href
|
|
788
|
-
})
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
name: "coverageInfoClicked",
|
|
792
|
-
type: "structured",
|
|
793
|
-
makePayload: (params) => {
|
|
794
|
-
const { deviceType, open = true } = params;
|
|
795
|
-
return {
|
|
796
|
-
action: "show_coverage_info_clicked",
|
|
797
|
-
category: `uk-qcp-react-${deviceType}-show-coverage-info-toggle`,
|
|
798
|
-
label: `${open ? "show" : "hide"}_coverage_info_clicked`,
|
|
799
|
-
property: window.location.href
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
},
|
|
803
|
-
{
|
|
804
|
-
name: "backToApplication",
|
|
805
|
-
type: "unstructured",
|
|
806
|
-
makePayload: (params) => {
|
|
807
|
-
const { journeyId, vertical } = params;
|
|
808
|
-
return {
|
|
809
|
-
schema: "iglu:com.simplybusiness/qcp_back_to_application/jsonschema/1-0-0",
|
|
810
|
-
data: {
|
|
811
|
-
journey_id: journeyId,
|
|
812
|
-
vertical
|
|
813
|
-
}
|
|
814
|
-
};
|
|
815
|
-
},
|
|
816
|
-
contexts: ["serviceChannelContext"]
|
|
817
|
-
},
|
|
818
|
-
// No quotes referral
|
|
819
|
-
{
|
|
820
|
-
name: "coverOptionsLinkClicked",
|
|
821
|
-
type: "structured",
|
|
822
|
-
makePayload: () => ({
|
|
823
|
-
category: "uk-qcp-react-cover-options-link",
|
|
824
|
-
action: "cover_options_link_clicked",
|
|
825
|
-
label: "cover_options_link_clicked",
|
|
826
|
-
property: window.location.href
|
|
827
|
-
})
|
|
828
|
-
},
|
|
829
|
-
{
|
|
830
|
-
name: "referralReasonsVariantBCoverOptionsLinkClicked",
|
|
831
|
-
type: "structured",
|
|
832
|
-
makePayload: () => ({
|
|
833
|
-
category: "uk-24-12-qcp-mvt-referral-reasons",
|
|
834
|
-
action: "cover_options_link_clicked_variant_b",
|
|
835
|
-
label: "cover_options_link_clicked_variant_b",
|
|
836
|
-
property: window.location.href
|
|
837
|
-
})
|
|
838
|
-
},
|
|
839
|
-
{
|
|
840
|
-
name: "referralReasonsVariantCCoverOptionsLinkClicked",
|
|
841
|
-
type: "structured",
|
|
842
|
-
makePayload: () => ({
|
|
843
|
-
category: "uk-24-12-qcp-mvt-referral-reasons",
|
|
844
|
-
action: "cover_options_link_clicked_variant_c",
|
|
845
|
-
label: "cover_options_link_clicked_variant_c",
|
|
846
|
-
property: window.location.href
|
|
847
|
-
})
|
|
848
|
-
},
|
|
849
|
-
{
|
|
850
|
-
name: "phoneNumberLinkClicked",
|
|
851
|
-
type: "structured",
|
|
852
|
-
makePayload: () => ({
|
|
853
|
-
category: "uk-qcp-react-phone-number-link",
|
|
854
|
-
action: "phone_number_link_clicked",
|
|
855
|
-
label: "phone_number_link_clicked",
|
|
856
|
-
property: window.location.href
|
|
857
|
-
})
|
|
858
|
-
},
|
|
859
|
-
{
|
|
860
|
-
name: "linkClicked",
|
|
861
|
-
type: "unstructured",
|
|
862
|
-
makePayload: (params) => {
|
|
863
|
-
const { targetUrl, elementContent } = params;
|
|
864
|
-
return {
|
|
865
|
-
schema: "iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",
|
|
866
|
-
data: {
|
|
867
|
-
targetUrl,
|
|
868
|
-
elementContent
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
},
|
|
873
|
-
{
|
|
874
|
-
name: "qcpUpsellAccordionClicked",
|
|
875
|
-
type: "structured",
|
|
876
|
-
makePayload: (params) => ({
|
|
877
|
-
category: "us-qcp-upsells",
|
|
878
|
-
action: "accordion_clicked_qcp",
|
|
879
|
-
label: params?.label,
|
|
880
|
-
property: window.location.href
|
|
881
|
-
})
|
|
882
|
-
},
|
|
883
|
-
{
|
|
884
|
-
name: "qdsUpsellAccordionClicked",
|
|
885
|
-
type: "structured",
|
|
886
|
-
makePayload: (params) => ({
|
|
887
|
-
category: "us-qcp-upsells",
|
|
888
|
-
action: "accordion_clicked_slider",
|
|
889
|
-
label: params?.label,
|
|
890
|
-
property: window.location.href
|
|
891
|
-
})
|
|
892
|
-
},
|
|
893
|
-
{
|
|
894
|
-
name: "qcpUpsellTooltipHelperClicked",
|
|
895
|
-
type: "structured",
|
|
896
|
-
makePayload: (params) => ({
|
|
897
|
-
category: "us-qcp-upsells",
|
|
898
|
-
action: "tooltip_helper_clicked_qcp",
|
|
899
|
-
label: params?.label,
|
|
900
|
-
property: window.location.href
|
|
901
|
-
})
|
|
902
|
-
},
|
|
903
|
-
{
|
|
904
|
-
name: "qdsUpsellTooltipHelperClicked",
|
|
905
|
-
type: "structured",
|
|
906
|
-
makePayload: (params) => ({
|
|
907
|
-
category: "us-qcp-upsells",
|
|
908
|
-
action: "tooltip_helper_clicked_slider",
|
|
909
|
-
label: params?.label,
|
|
910
|
-
property: window.location.href
|
|
911
|
-
})
|
|
912
|
-
},
|
|
913
|
-
{
|
|
914
|
-
name: "qcpQuoteButtonClicked",
|
|
915
|
-
type: "structured",
|
|
916
|
-
makePayload: (payload) => ({
|
|
917
|
-
category: "quote-buttons",
|
|
918
|
-
action: "button-clicked",
|
|
919
|
-
label: payload?.label,
|
|
920
|
-
property: window.location.href
|
|
921
|
-
})
|
|
922
|
-
},
|
|
923
|
-
{
|
|
924
|
-
name: "layoutToggleClickedExperiment",
|
|
925
|
-
type: "structured",
|
|
926
|
-
makePayload: (params) => {
|
|
927
|
-
const { layout } = params;
|
|
928
|
-
return {
|
|
929
|
-
category: "uk-25-04-16-gridview_layout",
|
|
930
|
-
action: "layout_toggle_clicked",
|
|
931
|
-
label: layout,
|
|
932
|
-
property: window.location.href
|
|
933
|
-
};
|
|
934
|
-
}
|
|
935
|
-
},
|
|
936
|
-
{
|
|
937
|
-
name: "selectCoverOptionsClicked",
|
|
938
|
-
type: "structured",
|
|
939
|
-
makePayload: (payload) => {
|
|
940
|
-
return {
|
|
941
|
-
category: "uk-25-09-qcp-covers-demand-test",
|
|
942
|
-
action: "cover_options_clicked",
|
|
943
|
-
label: payload?.label,
|
|
944
|
-
property: window.location.href
|
|
945
|
-
};
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
];
|
|
949
|
-
|
|
950
|
-
// src/snowplow/event-definitions/questionnaire/questionnaire.ts
|
|
951
|
-
var questionnaireEventDefinitions = [
|
|
952
|
-
{
|
|
953
|
-
name: "questionAnswered",
|
|
954
|
-
type: "unstructured",
|
|
955
|
-
makePayload: (params) => {
|
|
956
|
-
const { section, context } = params;
|
|
957
|
-
const { question, answer } = redact(params);
|
|
958
|
-
const flatAnswer = Array.isArray(answer) ? answer.join(DELIMITER) : answer;
|
|
959
|
-
return {
|
|
960
|
-
schema: "iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-4",
|
|
961
|
-
data: {
|
|
962
|
-
site: context.site,
|
|
963
|
-
page_index: 1,
|
|
964
|
-
page_name: "quick_to_quote",
|
|
965
|
-
submitted_from: "quick_to_quote_experiment",
|
|
966
|
-
section_name: section,
|
|
967
|
-
question,
|
|
968
|
-
answer: flatAnswer,
|
|
969
|
-
vertical: context.vertical
|
|
970
|
-
}
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
},
|
|
974
|
-
{
|
|
975
|
-
name: "primaryDetailSelected",
|
|
976
|
-
type: "unstructured",
|
|
977
|
-
makePayload: (params) => {
|
|
978
|
-
const {
|
|
979
|
-
context,
|
|
980
|
-
answer,
|
|
981
|
-
vertical,
|
|
982
|
-
searchId,
|
|
983
|
-
selectedListPosition,
|
|
984
|
-
selectionMethod
|
|
985
|
-
} = params;
|
|
986
|
-
const { site } = context;
|
|
987
|
-
const isUSPage = site === "simplybusiness_us";
|
|
988
|
-
let verticalName = vertical || context.vertical;
|
|
989
|
-
if (verticalName.toLowerCase().indexOf("landlord") > -1) {
|
|
990
|
-
verticalName = answer === "residential" ? "Landlord" : "Commercial landlord";
|
|
991
|
-
}
|
|
992
|
-
const data = {
|
|
993
|
-
site,
|
|
994
|
-
vertical: verticalName,
|
|
995
|
-
primary_detail: answer,
|
|
996
|
-
selected_type: "trade_selector",
|
|
997
|
-
location: window?.location?.pathname ?? ""
|
|
998
|
-
};
|
|
999
|
-
if (searchId) {
|
|
1000
|
-
data.search_id = searchId;
|
|
1001
|
-
}
|
|
1002
|
-
if (selectionMethod) {
|
|
1003
|
-
data.selection_method = selectionMethod;
|
|
1004
|
-
}
|
|
1005
|
-
if (isUSPage) {
|
|
1006
|
-
data.selected_list_position = selectedListPosition !== void 0 ? (selectedListPosition + 1).toString() : null;
|
|
1007
|
-
data.selected_location = "trade_selector_vertical";
|
|
1008
|
-
data.business_unit = site;
|
|
1009
|
-
}
|
|
1010
|
-
return {
|
|
1011
|
-
schema: "iglu:com.simplybusiness/primary_detail_selected/jsonschema/1-4-0",
|
|
1012
|
-
data
|
|
1013
|
-
};
|
|
1014
|
-
},
|
|
1015
|
-
contexts: ["distributionChannelContext", "serviceChannelContext"]
|
|
1016
|
-
},
|
|
1017
|
-
{
|
|
1018
|
-
name: "helpTextOpened",
|
|
1019
|
-
type: "unstructured",
|
|
1020
|
-
makePayload: (params) => {
|
|
1021
|
-
const { primaryText, label, context, helpText } = params;
|
|
1022
|
-
return {
|
|
1023
|
-
schema: "iglu:com.simplybusiness/help_text_opened/jsonschema/1-1-0",
|
|
1024
|
-
data: {
|
|
1025
|
-
vertical: context.vertical,
|
|
1026
|
-
site: context.site,
|
|
1027
|
-
primary_text: primaryText,
|
|
1028
|
-
help_text: helpText,
|
|
1029
|
-
label,
|
|
1030
|
-
page_name: "quick_to_quote"
|
|
1031
|
-
}
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
},
|
|
1035
|
-
{
|
|
1036
|
-
name: "assumptionsButtonClicked",
|
|
1037
|
-
type: "structured",
|
|
1038
|
-
makePayload: (params) => {
|
|
1039
|
-
const { source, presentationGroup } = params;
|
|
1040
|
-
return {
|
|
1041
|
-
action: source,
|
|
1042
|
-
category: presentationGroup
|
|
1043
|
-
};
|
|
1044
|
-
}
|
|
1045
|
-
},
|
|
1046
|
-
{
|
|
1047
|
-
name: "navButtonClicked",
|
|
1048
|
-
type: "structured",
|
|
1049
|
-
makePayload: (params) => {
|
|
1050
|
-
const { label, category } = params;
|
|
1051
|
-
return {
|
|
1052
|
-
label,
|
|
1053
|
-
action: "link_click",
|
|
1054
|
-
category
|
|
1055
|
-
};
|
|
1056
|
-
}
|
|
1057
|
-
},
|
|
1058
|
-
{
|
|
1059
|
-
name: "manualAddressClicked",
|
|
1060
|
-
type: "structured",
|
|
1061
|
-
makePayload: (params) => {
|
|
1062
|
-
const { category } = params;
|
|
1063
|
-
return {
|
|
1064
|
-
action: "link_click",
|
|
1065
|
-
category,
|
|
1066
|
-
label: "Enter address manually"
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
},
|
|
1070
|
-
{
|
|
1071
|
-
name: "assumptionLinkClicked",
|
|
1072
|
-
type: "structured",
|
|
1073
|
-
makePayload: (params) => {
|
|
1074
|
-
const { label, category, property } = params;
|
|
1075
|
-
return {
|
|
1076
|
-
action: "assumption_link_click",
|
|
1077
|
-
category,
|
|
1078
|
-
label,
|
|
1079
|
-
property
|
|
1080
|
-
};
|
|
1081
|
-
}
|
|
1082
|
-
},
|
|
1083
|
-
{
|
|
1084
|
-
name: "addressLookupFocused",
|
|
1085
|
-
type: "structured",
|
|
1086
|
-
makePayload: (params) => {
|
|
1087
|
-
const { label, category } = params;
|
|
1088
|
-
return {
|
|
1089
|
-
action: "address_lookup_focused",
|
|
1090
|
-
category,
|
|
1091
|
-
label
|
|
1092
|
-
};
|
|
1093
|
-
}
|
|
1094
|
-
},
|
|
1095
|
-
{
|
|
1096
|
-
name: "addressLookupTypedIn",
|
|
1097
|
-
type: "structured",
|
|
1098
|
-
makePayload: (params) => {
|
|
1099
|
-
const { label, category } = params;
|
|
1100
|
-
return {
|
|
1101
|
-
action: "address_lookup_typed_in",
|
|
1102
|
-
category,
|
|
1103
|
-
label
|
|
1104
|
-
};
|
|
1105
|
-
}
|
|
1106
|
-
},
|
|
1107
|
-
{
|
|
1108
|
-
name: "addressOptionsDisplayed",
|
|
1109
|
-
type: "structured",
|
|
1110
|
-
makePayload: (params) => {
|
|
1111
|
-
const { label, category } = params;
|
|
1112
|
-
return {
|
|
1113
|
-
action: "address_options_displayed",
|
|
1114
|
-
category,
|
|
1115
|
-
label
|
|
1116
|
-
};
|
|
1117
|
-
}
|
|
1118
|
-
},
|
|
1119
|
-
{
|
|
1120
|
-
name: "tradeChanged",
|
|
1121
|
-
type: "structured",
|
|
1122
|
-
makePayload: (params) => {
|
|
1123
|
-
const { label, property } = params;
|
|
1124
|
-
return {
|
|
1125
|
-
action: "change_your_selected_profession_button_clicked",
|
|
1126
|
-
category: "change_your_selected_profession_button",
|
|
1127
|
-
label: `Question: ${label}`,
|
|
1128
|
-
property
|
|
1129
|
-
// Answer before change
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
},
|
|
1133
|
-
{
|
|
1134
|
-
name: "stateQuestionAnswered",
|
|
1135
|
-
type: "unstructured",
|
|
1136
|
-
makePayload: (params) => {
|
|
1137
|
-
const { context, answer, selectedCoverages } = params;
|
|
1138
|
-
const data = {
|
|
1139
|
-
vertical: context.vertical,
|
|
1140
|
-
selected_type: context.journeyName ?? "usa",
|
|
1141
|
-
location: window?.location?.pathname ?? "",
|
|
1142
|
-
url: window?.location?.href ?? "",
|
|
1143
|
-
state: answer,
|
|
1144
|
-
selection_method: "dropdown"
|
|
1145
|
-
};
|
|
1146
|
-
if (selectedCoverages?.length) {
|
|
1147
|
-
data.products = selectedCoverages.join(",");
|
|
1148
|
-
}
|
|
1149
|
-
return {
|
|
1150
|
-
schema: "iglu:com.simplybusiness/state_question_answered/jsonschema/1-0-0",
|
|
1151
|
-
data
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
];
|
|
1156
|
-
|
|
1157
|
-
// src/snowplow/event-definitions/coverage-selection.ts
|
|
1158
|
-
var coverageSelectionEventDefinitions = [
|
|
1159
|
-
{
|
|
1160
|
-
name: "checkboxFormQuestionAnswered",
|
|
1161
|
-
type: "unstructured",
|
|
1162
|
-
makePayload: (params) => {
|
|
1163
|
-
const { context, pageIndex, pageName, sectionName, question, answer } = params;
|
|
1164
|
-
return {
|
|
1165
|
-
schema: "iglu:com.simplybusiness/checkbox_form_question_answered/jsonschema/1-0-1",
|
|
1166
|
-
data: {
|
|
1167
|
-
site: context.site,
|
|
1168
|
-
vertical: context.vertical ?? "",
|
|
1169
|
-
journey_id: context.journeyId,
|
|
1170
|
-
page_index: pageIndex,
|
|
1171
|
-
page_name: pageName,
|
|
1172
|
-
section_name: sectionName,
|
|
1173
|
-
question,
|
|
1174
|
-
answer
|
|
1175
|
-
}
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
];
|
|
1180
|
-
|
|
1181
|
-
// src/snowplow/event-definitions/referral.ts
|
|
1182
|
-
var referralEventDefinitions = [
|
|
1183
|
-
{
|
|
1184
|
-
name: "nextCoverageClicked",
|
|
1185
|
-
type: "structured",
|
|
1186
|
-
makePayload: (params) => {
|
|
1187
|
-
const { url } = params;
|
|
1188
|
-
const eventName = "post_referral_workers_compensation_continuation_link";
|
|
1189
|
-
return {
|
|
1190
|
-
category: eventName,
|
|
1191
|
-
action: "link_click",
|
|
1192
|
-
label: eventName,
|
|
1193
|
-
property: url
|
|
1194
|
-
};
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
];
|
|
1198
|
-
|
|
1199
|
-
// src/snowplow/event-definitions/index.ts
|
|
1200
|
-
var eventDefinitions = [
|
|
1201
|
-
...baseEventDefinitions,
|
|
1202
|
-
...qcpEventDefinitions,
|
|
1203
|
-
...referralEventDefinitions,
|
|
1204
|
-
...interventionEventDefinitions,
|
|
1205
|
-
...questionnaireEventDefinitions,
|
|
1206
|
-
...personalisedCoverEventDefinitions,
|
|
1207
|
-
...coverageSelectionEventDefinitions
|
|
1208
|
-
];
|
|
1209
|
-
var qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];
|
|
1210
|
-
var referralPageEvents = [
|
|
1211
|
-
...baseEventDefinitions,
|
|
1212
|
-
...referralEventDefinitions
|
|
1213
|
-
];
|
|
1214
|
-
var personalisedCoverPageEvents = [
|
|
1215
|
-
...baseEventDefinitions,
|
|
1216
|
-
...personalisedCoverEventDefinitions
|
|
1217
|
-
];
|
|
1218
|
-
var interventionPageEvents = [...interventionEventDefinitions];
|
|
1219
|
-
var questionnairePageEvents = [...questionnaireEventDefinitions];
|
|
1220
|
-
var coverageSelectionPageEvents = [
|
|
1221
|
-
...baseEventDefinitions,
|
|
1222
|
-
...coverageSelectionEventDefinitions
|
|
1223
|
-
];
|
|
1224
|
-
|
|
1225
|
-
// src/snowplow/getSnowplowConfig.ts
|
|
1226
|
-
var getSnowplowConfig = (pageData) => pageData.scripts?.find(({ metadata }) => metadata.name === "snowplow")?.props;
|
|
1227
|
-
|
|
1228
|
-
// src/snowplow/Snowplow.ts
|
|
1229
|
-
var import_browser_tracker = require("@snowplow/browser-tracker");
|
|
1230
|
-
var Snowplow = class _Snowplow {
|
|
1231
|
-
constructor(props) {
|
|
1232
|
-
this.avalancheTrackerName = "sb-ava";
|
|
1233
|
-
this.bronzeAvalancheTrackerName = "sb-ava-br";
|
|
1234
|
-
this.pvAvalancheTrackerName = "sb-ava-pv";
|
|
1235
|
-
this.uid = "";
|
|
1236
|
-
this.trackPageView = false;
|
|
1237
|
-
this.contexts = {};
|
|
1238
|
-
this.pvContext = [];
|
|
1239
|
-
this.structContext = [];
|
|
1240
|
-
this.serverData = {};
|
|
1241
|
-
this.eventHandlers = {};
|
|
1242
|
-
if (!props) return;
|
|
1243
|
-
const {
|
|
1244
|
-
appId,
|
|
1245
|
-
cookieDomain,
|
|
1246
|
-
avalancheCollector,
|
|
1247
|
-
eventMethod,
|
|
1248
|
-
uid,
|
|
1249
|
-
postPath,
|
|
1250
|
-
trackPageView: tpv
|
|
1251
|
-
} = props;
|
|
1252
|
-
this.uid = uid;
|
|
1253
|
-
this.trackPageView = tpv;
|
|
1254
|
-
this.serverData = props?.pageViewContext?.data || {};
|
|
1255
|
-
const stateStorageStrategy = "cookieAndLocalStorage";
|
|
1256
|
-
const baseOptions = {
|
|
1257
|
-
appId,
|
|
1258
|
-
cookieDomain,
|
|
1259
|
-
eventMethod,
|
|
1260
|
-
stateStorageStrategy,
|
|
1261
|
-
postPath
|
|
1262
|
-
};
|
|
1263
|
-
(0, import_browser_tracker.newTracker)(this.avalancheTrackerName, avalancheCollector, baseOptions);
|
|
1264
|
-
(0, import_browser_tracker.newTracker)(
|
|
1265
|
-
this.bronzeAvalancheTrackerName,
|
|
1266
|
-
avalancheCollector,
|
|
1267
|
-
baseOptions
|
|
1268
|
-
);
|
|
1269
|
-
(0, import_browser_tracker.newTracker)(this.pvAvalancheTrackerName, avalancheCollector, {
|
|
1270
|
-
...baseOptions,
|
|
1271
|
-
eventMethod: eventMethod === "post" ? "beacon" : eventMethod
|
|
1272
|
-
});
|
|
1273
|
-
(0, import_browser_tracker.setCookiePath)("/");
|
|
1274
|
-
if (uid) {
|
|
1275
|
-
(0, import_browser_tracker.setUserId)(uid);
|
|
1276
|
-
}
|
|
1277
|
-
_Snowplow.instance = this;
|
|
1278
|
-
}
|
|
1279
|
-
setContexts(contexts) {
|
|
1280
|
-
this.contexts = updateIdentityContext(contexts, this.uid);
|
|
1281
|
-
this.pvContext = Object.values(this.contexts);
|
|
1282
|
-
this.structContext = makeContexts(
|
|
1283
|
-
["distributionChannelContext", "serviceChannelContext"],
|
|
1284
|
-
this.contexts
|
|
1285
|
-
);
|
|
1286
|
-
return this;
|
|
1287
|
-
}
|
|
1288
|
-
// Send a page view event
|
|
1289
|
-
trackView(event) {
|
|
1290
|
-
if (this.trackPageView) {
|
|
1291
|
-
(0, import_browser_tracker.trackPageView)({ ...event, context: this.pvContext }, [
|
|
1292
|
-
this.avalancheTrackerName
|
|
1293
|
-
]);
|
|
1294
|
-
}
|
|
1295
|
-
return this;
|
|
1296
|
-
}
|
|
1297
|
-
// Send a structured event with contexts
|
|
1298
|
-
trackEvent(event) {
|
|
1299
|
-
(0, import_browser_tracker.trackStructEvent)({ ...event, context: this.structContext }, [
|
|
1300
|
-
this.bronzeAvalancheTrackerName
|
|
1301
|
-
]);
|
|
1302
|
-
return this;
|
|
1303
|
-
}
|
|
1304
|
-
// Send a custom event with defined schema and optional contexts
|
|
1305
|
-
trackUnstructEvent(event, contexts) {
|
|
1306
|
-
if (!event) {
|
|
1307
|
-
return this;
|
|
1308
|
-
}
|
|
1309
|
-
if (contexts && Array.isArray(contexts) && contexts.length > 0) {
|
|
1310
|
-
const context = makeContexts(contexts, this.contexts);
|
|
1311
|
-
(0, import_browser_tracker.trackSelfDescribingEvent)({ event, context }, [this.avalancheTrackerName]);
|
|
1312
|
-
} else {
|
|
1313
|
-
(0, import_browser_tracker.trackSelfDescribingEvent)({ event }, [this.avalancheTrackerName]);
|
|
1314
|
-
}
|
|
1315
|
-
return this;
|
|
1316
|
-
}
|
|
1317
|
-
addEventHandlers(eventDefinitions2) {
|
|
1318
|
-
const context = this.serverData;
|
|
1319
|
-
eventDefinitions2.forEach(({ name, type, makePayload, contexts }) => {
|
|
1320
|
-
if (type === "structured") {
|
|
1321
|
-
this.addEventHandler(name, (params) => {
|
|
1322
|
-
void this.trackEvent(
|
|
1323
|
-
makePayload({
|
|
1324
|
-
...params,
|
|
1325
|
-
context
|
|
1326
|
-
})
|
|
1327
|
-
);
|
|
1328
|
-
});
|
|
1329
|
-
} else {
|
|
1330
|
-
this.addEventHandler(name, (params) => {
|
|
1331
|
-
const payload = makePayload({
|
|
1332
|
-
...params,
|
|
1333
|
-
context
|
|
1334
|
-
});
|
|
1335
|
-
if (contexts && Array.isArray(contexts) && contexts.length > 0) {
|
|
1336
|
-
void this.trackUnstructEvent(payload, contexts);
|
|
1337
|
-
} else {
|
|
1338
|
-
void this.trackUnstructEvent(payload);
|
|
1339
|
-
}
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
|
-
});
|
|
1343
|
-
return this;
|
|
1344
|
-
}
|
|
1345
|
-
addEventHandler(name, handler) {
|
|
1346
|
-
this.eventHandlers[name] = handler;
|
|
1347
|
-
return this;
|
|
1348
|
-
}
|
|
1349
|
-
removeEventHandler(name) {
|
|
1350
|
-
delete this.eventHandlers[name];
|
|
1351
|
-
return this;
|
|
1352
|
-
}
|
|
1353
|
-
trigger(name, params) {
|
|
1354
|
-
const handler = this.eventHandlers[name];
|
|
1355
|
-
if (Object.prototype.hasOwnProperty.call(this.eventHandlers, name) && typeof handler === "function") {
|
|
1356
|
-
handler(params);
|
|
1357
|
-
}
|
|
1358
|
-
return this;
|
|
1359
|
-
}
|
|
1360
|
-
static getInstance(props) {
|
|
1361
|
-
if (!_Snowplow.instance) {
|
|
1362
|
-
_Snowplow.instance = new _Snowplow(props);
|
|
1363
|
-
}
|
|
1364
|
-
return _Snowplow.instance;
|
|
1365
|
-
}
|
|
1366
|
-
};
|
|
1367
|
-
|
|
1368
|
-
// src/snowplow/SnowplowContext.tsx
|
|
1369
|
-
var import_react = require("react");
|
|
1370
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1371
|
-
var SnowplowContext = (0, import_react.createContext)(null);
|
|
1372
|
-
var SnowplowProvider = ({ scripts, children }) => {
|
|
1373
|
-
const [config, _setConfig] = (0, import_react.useState)(scripts);
|
|
1374
|
-
const [snowplowInstance] = (0, import_react.useState)(
|
|
1375
|
-
() => Snowplow.getInstance(config)
|
|
1376
|
-
);
|
|
1377
|
-
(0, import_react.useEffect)(() => {
|
|
1378
|
-
if (snowplowInstance && scripts) {
|
|
1379
|
-
const contexts = getContexts(config);
|
|
1380
|
-
snowplowInstance.setContexts(contexts).addEventHandlers(eventDefinitions);
|
|
1381
|
-
if (config.trackPageView) {
|
|
1382
|
-
void snowplowInstance.trackView();
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
}, [config, snowplowInstance, scripts]);
|
|
1386
|
-
const value = (0, import_react.useMemo)(
|
|
1387
|
-
() => ({
|
|
1388
|
-
config,
|
|
1389
|
-
snowplow: snowplowInstance
|
|
1390
|
-
}),
|
|
1391
|
-
[config, snowplowInstance]
|
|
1392
|
-
);
|
|
1393
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SnowplowContext.Provider, { value, children });
|
|
1394
|
-
};
|
|
1395
|
-
function useSnowplowContext() {
|
|
1396
|
-
const context = (0, import_react.useContext)(SnowplowContext);
|
|
1397
|
-
if (!context) {
|
|
1398
|
-
throw new Error(
|
|
1399
|
-
"useSnowplowContext must be used inside a `SnowplowProvider`"
|
|
1400
|
-
);
|
|
1401
|
-
}
|
|
1402
|
-
return context;
|
|
1403
|
-
}
|
|
1404
|
-
//# sourceMappingURL=index.js.map
|