@simplybusiness/services 2.0.1 → 2.1.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.
@@ -0,0 +1,1407 @@
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-4",
510
+ data: {
511
+ site: context.site,
512
+ page_name: "personalised_cover",
513
+ section_name: "Personalised Cover Questions",
514
+ question,
515
+ answer: flatAnswer,
516
+ vertical: context.vertical,
517
+ journey_id: context.journeyId
518
+ }
519
+ };
520
+ }
521
+ },
522
+ {
523
+ name: "limitLinkClicked",
524
+ type: "structured",
525
+ makePayload: (params) => {
526
+ const { label } = params;
527
+ return {
528
+ category: "personalised_cover",
529
+ action: "limit_link_clicked",
530
+ label,
531
+ property: "link_clicked"
532
+ };
533
+ }
534
+ },
535
+ {
536
+ name: "limitChanged",
537
+ type: "structured",
538
+ makePayload: (params) => {
539
+ const { label, limit } = params;
540
+ return {
541
+ category: "personalised_cover",
542
+ action: "limit_changed",
543
+ label,
544
+ property: limit
545
+ };
546
+ }
547
+ },
548
+ {
549
+ name: "coverPresented",
550
+ type: "structured",
551
+ makePayload: (params) => {
552
+ const { property } = params;
553
+ return {
554
+ category: "personalised_cover",
555
+ action: "cover_presented",
556
+ label: "cover_name",
557
+ property
558
+ };
559
+ }
560
+ },
561
+ {
562
+ name: "coverDetailsClicked",
563
+ type: "structured",
564
+ makePayload: (params) => {
565
+ const { property } = params;
566
+ return {
567
+ category: "personalised_cover",
568
+ action: "cover_details_clicked",
569
+ label: "cover_name",
570
+ property
571
+ };
572
+ }
573
+ },
574
+ {
575
+ name: "additionalQuestionsClicked",
576
+ type: "structured",
577
+ makePayload: (params) => {
578
+ const { property } = params;
579
+ return {
580
+ category: "personalised_cover",
581
+ action: "cover_details_clicked",
582
+ label: "cover_name",
583
+ property
584
+ };
585
+ }
586
+ },
587
+ {
588
+ name: "chatbotPromptClicked",
589
+ type: "structured",
590
+ makePayload: (params) => {
591
+ const { label, property } = params;
592
+ return {
593
+ category: "personalised_cover",
594
+ action: "chatbot_prompt_clicked",
595
+ label: property,
596
+ property: label
597
+ };
598
+ }
599
+ }
600
+ ];
601
+
602
+ // src/snowplow/event-definitions/qcp.ts
603
+ var qcpEventDefinitions = [
604
+ {
605
+ // QDP details button
606
+ name: "detailsClicked",
607
+ type: "structured",
608
+ makePayload: () => ({
609
+ category: "comparison_cta",
610
+ action: "link_click",
611
+ label: "Details"
612
+ })
613
+ },
614
+ {
615
+ // Buy button
616
+ name: "selectClicked",
617
+ type: "structured",
618
+ makePayload: () => ({
619
+ category: "comparison_cta",
620
+ action: "link_click",
621
+ label: "Buy"
622
+ })
623
+ },
624
+ {
625
+ // Quote Details Slider Next steps button
626
+ name: "nextStepsClicked",
627
+ type: "structured",
628
+ makePayload: () => ({
629
+ category: "quote_details_slider_next_step_cta",
630
+ action: "link_click",
631
+ label: "Next steps"
632
+ })
633
+ },
634
+ {
635
+ // Toggle deductibles accordion
636
+ name: "deductiblesClicked",
637
+ type: "structured",
638
+ makePayload: () => ({
639
+ category: "us-qcp-react",
640
+ action: "view_deductables_clicked",
641
+ label: "view_deductables_clicked",
642
+ property: window.location.href
643
+ })
644
+ },
645
+ {
646
+ name: "deductiblesClickedUk",
647
+ type: "structured",
648
+ makePayload: (params) => {
649
+ const { label, deviceType } = params;
650
+ const urlFriendlyLabel = label.replace(/ /g, "-").toLowerCase();
651
+ return {
652
+ category: `uk-qcp-react-${deviceType}-${urlFriendlyLabel}-view-excess-toggle`,
653
+ action: "view_excess_clicked",
654
+ label,
655
+ property: window.location.href
656
+ };
657
+ }
658
+ },
659
+ {
660
+ // Quote Details Slider opened
661
+ name: "sliderOpened",
662
+ type: "structured",
663
+ makePayload: (params) => {
664
+ const { label } = params;
665
+ return {
666
+ category: "comparison_cta",
667
+ action: "quote_details_slider_opened",
668
+ label
669
+ };
670
+ }
671
+ },
672
+ {
673
+ // Coverage modal opened
674
+ name: "coverageModalOpened",
675
+ type: "structured",
676
+ makePayload: (params) => {
677
+ const {
678
+ category,
679
+ product = "extra_coverage",
680
+ title
681
+ } = params;
682
+ const productLabel = snakeCase(product);
683
+ return {
684
+ category,
685
+ action: `${productLabel}_${snakeCase(title)}_popup_opened`,
686
+ label: productLabel,
687
+ property: window.location.href
688
+ };
689
+ }
690
+ },
691
+ {
692
+ // Toggle cover select
693
+ name: "coverChanged",
694
+ type: "unstructured",
695
+ makePayload: (params) => {
696
+ const { name = "", fromValue = "", toValue = "" } = params;
697
+ let action = "change";
698
+ if (fromValue === "0") {
699
+ action = "add";
700
+ }
701
+ if (toValue === "0") {
702
+ action = "remove";
703
+ }
704
+ return {
705
+ schema: "iglu:com.simplybusiness/comparison_page_cover_changed/jsonschema/1-0-0",
706
+ data: {
707
+ name,
708
+ action,
709
+ from_value: fromValue,
710
+ to_value: toValue
711
+ }
712
+ };
713
+ },
714
+ contexts: ["distributionChannelContext"]
715
+ },
716
+ {
717
+ name: "ratingsModalOpened",
718
+ type: "structured",
719
+ makePayload: (params) => {
720
+ const { category, label } = params;
721
+ return {
722
+ category,
723
+ action: "insurer_rating_help_popup_triggered",
724
+ label,
725
+ property: window.location.href
726
+ };
727
+ }
728
+ },
729
+ {
730
+ name: "coverToggleOpened",
731
+ type: "structured",
732
+ makePayload: () => ({
733
+ category: "qcp_limit_interaction",
734
+ label: "limit_interaction",
735
+ action: "limit_interaction_clicked",
736
+ property: window.location.href
737
+ })
738
+ },
739
+ {
740
+ name: "paymentToggleClicked",
741
+ type: "structured",
742
+ makePayload: (params) => {
743
+ const { category, label } = params;
744
+ return {
745
+ category,
746
+ action: "button_click",
747
+ label,
748
+ property: window.location.href
749
+ };
750
+ }
751
+ },
752
+ {
753
+ name: "insurerDetailsAccordionClicked",
754
+ type: "structured",
755
+ makePayload: () => ({
756
+ category: "quote_details_slider_insurer_details_description",
757
+ action: "accordion_clicked",
758
+ label: "accordion_clicked",
759
+ property: window.location.href
760
+ })
761
+ },
762
+ {
763
+ name: "priceDetailsPopUpOpened",
764
+ type: "structured",
765
+ makePayload: () => ({
766
+ category: "price_details",
767
+ action: "price_details_popup_opened",
768
+ label: "Price details",
769
+ property: window.location.href
770
+ })
771
+ },
772
+ {
773
+ name: "editLimitButtonClicked",
774
+ type: "structured",
775
+ makePayload: () => ({
776
+ category: "cover_limit_changes",
777
+ action: "edit_limit_button_clicked",
778
+ label: "Edit Limit",
779
+ property: window.location.href
780
+ })
781
+ },
782
+ {
783
+ name: "applyButtonClicked",
784
+ type: "structured",
785
+ makePayload: () => ({
786
+ category: "cover_limit_changes",
787
+ action: "apply_button_clicked",
788
+ label: "Apply Button Clicked",
789
+ property: window.location.href
790
+ })
791
+ },
792
+ {
793
+ name: "coverageInfoClicked",
794
+ type: "structured",
795
+ makePayload: (params) => {
796
+ const { deviceType, open = true } = params;
797
+ return {
798
+ action: "show_coverage_info_clicked",
799
+ category: `uk-qcp-react-${deviceType}-show-coverage-info-toggle`,
800
+ label: `${open ? "show" : "hide"}_coverage_info_clicked`,
801
+ property: window.location.href
802
+ };
803
+ }
804
+ },
805
+ {
806
+ name: "backToApplication",
807
+ type: "unstructured",
808
+ makePayload: (params) => {
809
+ const { journeyId, vertical } = params;
810
+ return {
811
+ schema: "iglu:com.simplybusiness/qcp_back_to_application/jsonschema/1-0-0",
812
+ data: {
813
+ journey_id: journeyId,
814
+ vertical
815
+ }
816
+ };
817
+ },
818
+ contexts: ["serviceChannelContext"]
819
+ },
820
+ // No quotes referral
821
+ {
822
+ name: "coverOptionsLinkClicked",
823
+ type: "structured",
824
+ makePayload: () => ({
825
+ category: "uk-qcp-react-cover-options-link",
826
+ action: "cover_options_link_clicked",
827
+ label: "cover_options_link_clicked",
828
+ property: window.location.href
829
+ })
830
+ },
831
+ {
832
+ name: "referralReasonsVariantBCoverOptionsLinkClicked",
833
+ type: "structured",
834
+ makePayload: () => ({
835
+ category: "uk-24-12-qcp-mvt-referral-reasons",
836
+ action: "cover_options_link_clicked_variant_b",
837
+ label: "cover_options_link_clicked_variant_b",
838
+ property: window.location.href
839
+ })
840
+ },
841
+ {
842
+ name: "referralReasonsVariantCCoverOptionsLinkClicked",
843
+ type: "structured",
844
+ makePayload: () => ({
845
+ category: "uk-24-12-qcp-mvt-referral-reasons",
846
+ action: "cover_options_link_clicked_variant_c",
847
+ label: "cover_options_link_clicked_variant_c",
848
+ property: window.location.href
849
+ })
850
+ },
851
+ {
852
+ name: "phoneNumberLinkClicked",
853
+ type: "structured",
854
+ makePayload: () => ({
855
+ category: "uk-qcp-react-phone-number-link",
856
+ action: "phone_number_link_clicked",
857
+ label: "phone_number_link_clicked",
858
+ property: window.location.href
859
+ })
860
+ },
861
+ {
862
+ name: "linkClicked",
863
+ type: "unstructured",
864
+ makePayload: (params) => {
865
+ const { targetUrl, elementContent } = params;
866
+ return {
867
+ schema: "iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",
868
+ data: {
869
+ targetUrl,
870
+ elementContent
871
+ }
872
+ };
873
+ }
874
+ },
875
+ {
876
+ name: "qcpUpsellAccordionClicked",
877
+ type: "structured",
878
+ makePayload: (params) => ({
879
+ category: "us-qcp-upsells",
880
+ action: "accordion_clicked_qcp",
881
+ label: params?.label,
882
+ property: window.location.href
883
+ })
884
+ },
885
+ {
886
+ name: "qdsUpsellAccordionClicked",
887
+ type: "structured",
888
+ makePayload: (params) => ({
889
+ category: "us-qcp-upsells",
890
+ action: "accordion_clicked_slider",
891
+ label: params?.label,
892
+ property: window.location.href
893
+ })
894
+ },
895
+ {
896
+ name: "qcpUpsellTooltipHelperClicked",
897
+ type: "structured",
898
+ makePayload: (params) => ({
899
+ category: "us-qcp-upsells",
900
+ action: "tooltip_helper_clicked_qcp",
901
+ label: params?.label,
902
+ property: window.location.href
903
+ })
904
+ },
905
+ {
906
+ name: "qdsUpsellTooltipHelperClicked",
907
+ type: "structured",
908
+ makePayload: (params) => ({
909
+ category: "us-qcp-upsells",
910
+ action: "tooltip_helper_clicked_slider",
911
+ label: params?.label,
912
+ property: window.location.href
913
+ })
914
+ },
915
+ {
916
+ name: "qcpQuoteButtonClicked",
917
+ type: "structured",
918
+ makePayload: (payload) => ({
919
+ category: "quote-buttons",
920
+ action: "button-clicked",
921
+ label: payload?.label,
922
+ property: window.location.href
923
+ })
924
+ },
925
+ {
926
+ name: "layoutToggleClickedExperiment",
927
+ type: "structured",
928
+ makePayload: (params) => {
929
+ const { layout } = params;
930
+ return {
931
+ category: "uk-25-04-16-gridview_layout",
932
+ action: "layout_toggle_clicked",
933
+ label: layout,
934
+ property: window.location.href
935
+ };
936
+ }
937
+ },
938
+ {
939
+ name: "selectCoverOptionsClicked",
940
+ type: "structured",
941
+ makePayload: (payload) => {
942
+ return {
943
+ category: "uk-25-09-qcp-covers-demand-test",
944
+ action: "cover_options_clicked",
945
+ label: payload?.label,
946
+ property: window.location.href
947
+ };
948
+ }
949
+ }
950
+ ];
951
+
952
+ // src/snowplow/event-definitions/questionnaire/questionnaire.ts
953
+ var questionnaireEventDefinitions = [
954
+ {
955
+ name: "questionAnswered",
956
+ type: "unstructured",
957
+ makePayload: (params) => {
958
+ const { section, context } = params;
959
+ const { question, answer } = redact(params);
960
+ const flatAnswer = Array.isArray(answer) ? answer.join(DELIMITER) : answer;
961
+ return {
962
+ schema: "iglu:com.simplybusiness/form_question_answered/jsonschema/1-0-4",
963
+ data: {
964
+ site: context.site,
965
+ page_index: 1,
966
+ page_name: "quick_to_quote",
967
+ submitted_from: "quick_to_quote_experiment",
968
+ section_name: section,
969
+ question,
970
+ answer: flatAnswer,
971
+ vertical: context.vertical,
972
+ journey_id: context.journeyId
973
+ }
974
+ };
975
+ }
976
+ },
977
+ {
978
+ name: "primaryDetailSelected",
979
+ type: "unstructured",
980
+ makePayload: (params) => {
981
+ const {
982
+ context,
983
+ answer,
984
+ vertical,
985
+ searchId,
986
+ selectedListPosition,
987
+ selectionMethod
988
+ } = params;
989
+ const { site } = context;
990
+ const isUSPage = site === "simplybusiness_us";
991
+ let verticalName = vertical || context.vertical;
992
+ if (verticalName.toLowerCase().indexOf("landlord") > -1) {
993
+ verticalName = answer === "residential" ? "Landlord" : "Commercial landlord";
994
+ }
995
+ const data = {
996
+ site,
997
+ vertical: verticalName,
998
+ primary_detail: answer,
999
+ selected_type: "trade_selector",
1000
+ location: window?.location?.pathname ?? ""
1001
+ };
1002
+ if (searchId) {
1003
+ data.search_id = searchId;
1004
+ }
1005
+ if (selectionMethod) {
1006
+ data.selection_method = selectionMethod;
1007
+ }
1008
+ if (isUSPage) {
1009
+ data.selected_list_position = selectedListPosition !== void 0 ? (selectedListPosition + 1).toString() : null;
1010
+ data.selected_location = "trade_selector_vertical";
1011
+ data.business_unit = site;
1012
+ }
1013
+ return {
1014
+ schema: "iglu:com.simplybusiness/primary_detail_selected/jsonschema/1-4-0",
1015
+ data
1016
+ };
1017
+ },
1018
+ contexts: ["distributionChannelContext", "serviceChannelContext"]
1019
+ },
1020
+ {
1021
+ name: "helpTextOpened",
1022
+ type: "unstructured",
1023
+ makePayload: (params) => {
1024
+ const { primaryText, label, context, helpText } = params;
1025
+ return {
1026
+ schema: "iglu:com.simplybusiness/help_text_opened/jsonschema/1-1-0",
1027
+ data: {
1028
+ vertical: context.vertical,
1029
+ site: context.site,
1030
+ primary_text: primaryText,
1031
+ help_text: helpText,
1032
+ label,
1033
+ page_name: "quick_to_quote"
1034
+ }
1035
+ };
1036
+ }
1037
+ },
1038
+ {
1039
+ name: "assumptionsButtonClicked",
1040
+ type: "structured",
1041
+ makePayload: (params) => {
1042
+ const { source, presentationGroup } = params;
1043
+ return {
1044
+ action: source,
1045
+ category: presentationGroup
1046
+ };
1047
+ }
1048
+ },
1049
+ {
1050
+ name: "navButtonClicked",
1051
+ type: "structured",
1052
+ makePayload: (params) => {
1053
+ const { label, category } = params;
1054
+ return {
1055
+ label,
1056
+ action: "link_click",
1057
+ category
1058
+ };
1059
+ }
1060
+ },
1061
+ {
1062
+ name: "manualAddressClicked",
1063
+ type: "structured",
1064
+ makePayload: (params) => {
1065
+ const { category } = params;
1066
+ return {
1067
+ action: "link_click",
1068
+ category,
1069
+ label: "Enter address manually"
1070
+ };
1071
+ }
1072
+ },
1073
+ {
1074
+ name: "assumptionLinkClicked",
1075
+ type: "structured",
1076
+ makePayload: (params) => {
1077
+ const { label, category, property } = params;
1078
+ return {
1079
+ action: "assumption_link_click",
1080
+ category,
1081
+ label,
1082
+ property
1083
+ };
1084
+ }
1085
+ },
1086
+ {
1087
+ name: "addressLookupFocused",
1088
+ type: "structured",
1089
+ makePayload: (params) => {
1090
+ const { label, category } = params;
1091
+ return {
1092
+ action: "address_lookup_focused",
1093
+ category,
1094
+ label
1095
+ };
1096
+ }
1097
+ },
1098
+ {
1099
+ name: "addressLookupTypedIn",
1100
+ type: "structured",
1101
+ makePayload: (params) => {
1102
+ const { label, category } = params;
1103
+ return {
1104
+ action: "address_lookup_typed_in",
1105
+ category,
1106
+ label
1107
+ };
1108
+ }
1109
+ },
1110
+ {
1111
+ name: "addressOptionsDisplayed",
1112
+ type: "structured",
1113
+ makePayload: (params) => {
1114
+ const { label, category } = params;
1115
+ return {
1116
+ action: "address_options_displayed",
1117
+ category,
1118
+ label
1119
+ };
1120
+ }
1121
+ },
1122
+ {
1123
+ name: "tradeChanged",
1124
+ type: "structured",
1125
+ makePayload: (params) => {
1126
+ const { label, property } = params;
1127
+ return {
1128
+ action: "change_your_selected_profession_button_clicked",
1129
+ category: "change_your_selected_profession_button",
1130
+ label: `Question: ${label}`,
1131
+ property
1132
+ // Answer before change
1133
+ };
1134
+ }
1135
+ },
1136
+ {
1137
+ name: "stateQuestionAnswered",
1138
+ type: "unstructured",
1139
+ makePayload: (params) => {
1140
+ const { context, answer, selectedCoverages } = params;
1141
+ const data = {
1142
+ vertical: context.vertical,
1143
+ selected_type: context.journeyName ?? "usa",
1144
+ location: window?.location?.pathname ?? "",
1145
+ url: window?.location?.href ?? "",
1146
+ state: answer,
1147
+ selection_method: "dropdown"
1148
+ };
1149
+ if (selectedCoverages?.length) {
1150
+ data.products = selectedCoverages.join(",");
1151
+ }
1152
+ return {
1153
+ schema: "iglu:com.simplybusiness/state_question_answered/jsonschema/1-0-0",
1154
+ data
1155
+ };
1156
+ }
1157
+ }
1158
+ ];
1159
+
1160
+ // src/snowplow/event-definitions/coverage-selection.ts
1161
+ var coverageSelectionEventDefinitions = [
1162
+ {
1163
+ name: "checkboxFormQuestionAnswered",
1164
+ type: "unstructured",
1165
+ makePayload: (params) => {
1166
+ const { context, pageIndex, pageName, sectionName, question, answer } = params;
1167
+ return {
1168
+ schema: "iglu:com.simplybusiness/checkbox_form_question_answered/jsonschema/1-0-1",
1169
+ data: {
1170
+ site: context.site,
1171
+ vertical: context.vertical ?? "",
1172
+ journey_id: context.journeyId,
1173
+ page_index: pageIndex,
1174
+ page_name: pageName,
1175
+ section_name: sectionName,
1176
+ question,
1177
+ answer
1178
+ }
1179
+ };
1180
+ }
1181
+ }
1182
+ ];
1183
+
1184
+ // src/snowplow/event-definitions/referral.ts
1185
+ var referralEventDefinitions = [
1186
+ {
1187
+ name: "nextCoverageClicked",
1188
+ type: "structured",
1189
+ makePayload: (params) => {
1190
+ const { url } = params;
1191
+ const eventName = "post_referral_workers_compensation_continuation_link";
1192
+ return {
1193
+ category: eventName,
1194
+ action: "link_click",
1195
+ label: eventName,
1196
+ property: url
1197
+ };
1198
+ }
1199
+ }
1200
+ ];
1201
+
1202
+ // src/snowplow/event-definitions/index.ts
1203
+ var eventDefinitions = [
1204
+ ...baseEventDefinitions,
1205
+ ...qcpEventDefinitions,
1206
+ ...referralEventDefinitions,
1207
+ ...interventionEventDefinitions,
1208
+ ...questionnaireEventDefinitions,
1209
+ ...personalisedCoverEventDefinitions,
1210
+ ...coverageSelectionEventDefinitions
1211
+ ];
1212
+ var qcpPageEvents = [...baseEventDefinitions, ...qcpEventDefinitions];
1213
+ var referralPageEvents = [
1214
+ ...baseEventDefinitions,
1215
+ ...referralEventDefinitions
1216
+ ];
1217
+ var personalisedCoverPageEvents = [
1218
+ ...baseEventDefinitions,
1219
+ ...personalisedCoverEventDefinitions
1220
+ ];
1221
+ var interventionPageEvents = [...interventionEventDefinitions];
1222
+ var questionnairePageEvents = [...questionnaireEventDefinitions];
1223
+ var coverageSelectionPageEvents = [
1224
+ ...baseEventDefinitions,
1225
+ ...coverageSelectionEventDefinitions
1226
+ ];
1227
+
1228
+ // src/snowplow/getSnowplowConfig.ts
1229
+ var getSnowplowConfig = (pageData) => pageData.scripts?.find(({ metadata }) => metadata.name === "snowplow")?.props;
1230
+
1231
+ // src/snowplow/Snowplow.ts
1232
+ var import_browser_tracker = require("@snowplow/browser-tracker");
1233
+ var Snowplow = class _Snowplow {
1234
+ constructor(props) {
1235
+ this.avalancheTrackerName = "sb-ava";
1236
+ this.bronzeAvalancheTrackerName = "sb-ava-br";
1237
+ this.pvAvalancheTrackerName = "sb-ava-pv";
1238
+ this.uid = "";
1239
+ this.trackPageView = false;
1240
+ this.contexts = {};
1241
+ this.pvContext = [];
1242
+ this.structContext = [];
1243
+ this.serverData = {};
1244
+ this.eventHandlers = {};
1245
+ if (!props) return;
1246
+ const {
1247
+ appId,
1248
+ cookieDomain,
1249
+ avalancheCollector,
1250
+ eventMethod,
1251
+ uid,
1252
+ postPath,
1253
+ trackPageView: tpv
1254
+ } = props;
1255
+ this.uid = uid;
1256
+ this.trackPageView = tpv;
1257
+ this.serverData = props?.pageViewContext?.data || {};
1258
+ const stateStorageStrategy = "cookieAndLocalStorage";
1259
+ const baseOptions = {
1260
+ appId,
1261
+ cookieDomain,
1262
+ eventMethod,
1263
+ stateStorageStrategy,
1264
+ postPath
1265
+ };
1266
+ (0, import_browser_tracker.newTracker)(this.avalancheTrackerName, avalancheCollector, baseOptions);
1267
+ (0, import_browser_tracker.newTracker)(
1268
+ this.bronzeAvalancheTrackerName,
1269
+ avalancheCollector,
1270
+ baseOptions
1271
+ );
1272
+ (0, import_browser_tracker.newTracker)(this.pvAvalancheTrackerName, avalancheCollector, {
1273
+ ...baseOptions,
1274
+ eventMethod: eventMethod === "post" ? "beacon" : eventMethod
1275
+ });
1276
+ (0, import_browser_tracker.setCookiePath)("/");
1277
+ if (uid) {
1278
+ (0, import_browser_tracker.setUserId)(uid);
1279
+ }
1280
+ _Snowplow.instance = this;
1281
+ }
1282
+ setContexts(contexts) {
1283
+ this.contexts = updateIdentityContext(contexts, this.uid);
1284
+ this.pvContext = Object.values(this.contexts);
1285
+ this.structContext = makeContexts(
1286
+ ["distributionChannelContext", "serviceChannelContext"],
1287
+ this.contexts
1288
+ );
1289
+ return this;
1290
+ }
1291
+ // Send a page view event
1292
+ trackView(event) {
1293
+ if (this.trackPageView) {
1294
+ (0, import_browser_tracker.trackPageView)({ ...event, context: this.pvContext }, [
1295
+ this.avalancheTrackerName
1296
+ ]);
1297
+ }
1298
+ return this;
1299
+ }
1300
+ // Send a structured event with contexts
1301
+ trackEvent(event) {
1302
+ (0, import_browser_tracker.trackStructEvent)({ ...event, context: this.structContext }, [
1303
+ this.bronzeAvalancheTrackerName
1304
+ ]);
1305
+ return this;
1306
+ }
1307
+ // Send a custom event with defined schema and optional contexts
1308
+ trackUnstructEvent(event, contexts) {
1309
+ if (!event) {
1310
+ return this;
1311
+ }
1312
+ if (contexts && Array.isArray(contexts) && contexts.length > 0) {
1313
+ const context = makeContexts(contexts, this.contexts);
1314
+ (0, import_browser_tracker.trackSelfDescribingEvent)({ event, context }, [this.avalancheTrackerName]);
1315
+ } else {
1316
+ (0, import_browser_tracker.trackSelfDescribingEvent)({ event }, [this.avalancheTrackerName]);
1317
+ }
1318
+ return this;
1319
+ }
1320
+ addEventHandlers(eventDefinitions2) {
1321
+ const context = this.serverData;
1322
+ eventDefinitions2.forEach(({ name, type, makePayload, contexts }) => {
1323
+ if (type === "structured") {
1324
+ this.addEventHandler(name, (params) => {
1325
+ void this.trackEvent(
1326
+ makePayload({
1327
+ ...params,
1328
+ context
1329
+ })
1330
+ );
1331
+ });
1332
+ } else {
1333
+ this.addEventHandler(name, (params) => {
1334
+ const payload = makePayload({
1335
+ ...params,
1336
+ context
1337
+ });
1338
+ if (contexts && Array.isArray(contexts) && contexts.length > 0) {
1339
+ void this.trackUnstructEvent(payload, contexts);
1340
+ } else {
1341
+ void this.trackUnstructEvent(payload);
1342
+ }
1343
+ });
1344
+ }
1345
+ });
1346
+ return this;
1347
+ }
1348
+ addEventHandler(name, handler) {
1349
+ this.eventHandlers[name] = handler;
1350
+ return this;
1351
+ }
1352
+ removeEventHandler(name) {
1353
+ delete this.eventHandlers[name];
1354
+ return this;
1355
+ }
1356
+ trigger(name, params) {
1357
+ const handler = this.eventHandlers[name];
1358
+ if (Object.prototype.hasOwnProperty.call(this.eventHandlers, name) && typeof handler === "function") {
1359
+ handler(params);
1360
+ }
1361
+ return this;
1362
+ }
1363
+ static getInstance(props) {
1364
+ if (!_Snowplow.instance) {
1365
+ _Snowplow.instance = new _Snowplow(props);
1366
+ }
1367
+ return _Snowplow.instance;
1368
+ }
1369
+ };
1370
+
1371
+ // src/snowplow/SnowplowContext.tsx
1372
+ var import_react = require("react");
1373
+ var import_jsx_runtime = require("react/jsx-runtime");
1374
+ var SnowplowContext = (0, import_react.createContext)(null);
1375
+ var SnowplowProvider = ({ scripts, children }) => {
1376
+ const [config, _setConfig] = (0, import_react.useState)(scripts);
1377
+ const [snowplowInstance] = (0, import_react.useState)(
1378
+ () => Snowplow.getInstance(config)
1379
+ );
1380
+ (0, import_react.useEffect)(() => {
1381
+ if (snowplowInstance && scripts) {
1382
+ const contexts = getContexts(config);
1383
+ snowplowInstance.setContexts(contexts).addEventHandlers(eventDefinitions);
1384
+ if (config.trackPageView) {
1385
+ void snowplowInstance.trackView();
1386
+ }
1387
+ }
1388
+ }, [config, snowplowInstance, scripts]);
1389
+ const value = (0, import_react.useMemo)(
1390
+ () => ({
1391
+ config,
1392
+ snowplow: snowplowInstance
1393
+ }),
1394
+ [config, snowplowInstance]
1395
+ );
1396
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SnowplowContext.Provider, { value, children });
1397
+ };
1398
+ function useSnowplowContext() {
1399
+ const context = (0, import_react.useContext)(SnowplowContext);
1400
+ if (!context) {
1401
+ throw new Error(
1402
+ "useSnowplowContext must be used inside a `SnowplowProvider`"
1403
+ );
1404
+ }
1405
+ return context;
1406
+ }
1407
+ //# sourceMappingURL=index.js.map