@insure-os/client 0.0.3
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/CDN_SETUP.md +332 -0
- package/DEPLOYMENT.md +192 -0
- package/NPM_PUBLISHING.md +379 -0
- package/README.md +299 -0
- package/dist/bundle-sizes.json +26 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1099 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +137 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1099 @@
|
|
|
1
|
+
import { QuoteIntentResponse, CalculationResponse, PaymentInitiationRequest, PaymentGateway, FormDefinition, FormData, FormField, FormPage, PaymentOption, CalculationExcessOption } from '@insure-os/types';
|
|
2
|
+
export { FieldValidation, FormData, FormDefinition, FormError, FormErrorType, FormField, FormPage, FormSettings, PageValidation, SelectOption } from '@insure-os/types';
|
|
3
|
+
import * as Sentry from '@sentry/browser';
|
|
4
|
+
|
|
5
|
+
interface RetryConfig {
|
|
6
|
+
maxRetries: number;
|
|
7
|
+
baseDelay: number;
|
|
8
|
+
maxDelay: number;
|
|
9
|
+
retryableStatusCodes: number[];
|
|
10
|
+
}
|
|
11
|
+
interface HttpClientConfig {
|
|
12
|
+
orgId: string;
|
|
13
|
+
apiBaseUrl?: string;
|
|
14
|
+
timeout: number;
|
|
15
|
+
retryConfig: RetryConfig;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Enhanced HTTP client with retry logic and better error handling
|
|
19
|
+
*/
|
|
20
|
+
declare class EnhancedHttpClient {
|
|
21
|
+
private config;
|
|
22
|
+
private retryStrategy;
|
|
23
|
+
constructor(config: HttpClientConfig);
|
|
24
|
+
getBaseUrl(): string;
|
|
25
|
+
private makeRequest;
|
|
26
|
+
getQuoteIntent(url: string): Promise<QuoteIntentResponse>;
|
|
27
|
+
createQuoteIntent(body: any): Promise<QuoteIntentResponse>;
|
|
28
|
+
updateQuoteIntent(url: string, data: any): Promise<QuoteIntentResponse>;
|
|
29
|
+
deleteQuoteIntent(url: string): Promise<void>;
|
|
30
|
+
calculateQuoteIntent(url: string): Promise<CalculationResponse>;
|
|
31
|
+
initiatePayment(request: PaymentInitiationRequest, gateway: PaymentGateway): Promise<any>;
|
|
32
|
+
getPaymentStatus(transactionId: string, gateway: PaymentGateway): Promise<any>;
|
|
33
|
+
private executeWithRetry;
|
|
34
|
+
private handleApiError;
|
|
35
|
+
/**
|
|
36
|
+
* Capture API error to Sentry
|
|
37
|
+
*/
|
|
38
|
+
private captureApiErrorToSentry;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface PolyfillConfig {
|
|
42
|
+
fetch: boolean;
|
|
43
|
+
promise: boolean;
|
|
44
|
+
url: boolean;
|
|
45
|
+
}
|
|
46
|
+
interface FeatureDetectionResult {
|
|
47
|
+
fetch: boolean;
|
|
48
|
+
promise: boolean;
|
|
49
|
+
url: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Polyfill manager for loading polyfills conditionally based on browser support
|
|
53
|
+
* Provides feature detection and conditional loading to avoid conflicts with existing implementations
|
|
54
|
+
*/
|
|
55
|
+
declare class PolyfillManager {
|
|
56
|
+
private config;
|
|
57
|
+
private detectionResults;
|
|
58
|
+
constructor(config?: Partial<PolyfillConfig>);
|
|
59
|
+
/**
|
|
60
|
+
* Load polyfills based on feature detection and configuration
|
|
61
|
+
*/
|
|
62
|
+
loadPolyfills(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Get the results of feature detection
|
|
65
|
+
*/
|
|
66
|
+
getDetectionResults(): FeatureDetectionResult | null;
|
|
67
|
+
/**
|
|
68
|
+
* Detect which features need polyfills
|
|
69
|
+
*/
|
|
70
|
+
private detectFeatures;
|
|
71
|
+
/**
|
|
72
|
+
* Check if fetch polyfill is needed
|
|
73
|
+
*/
|
|
74
|
+
private needsFetchPolyfill;
|
|
75
|
+
/**
|
|
76
|
+
* Check if Promise polyfill is needed
|
|
77
|
+
*/
|
|
78
|
+
private needsPromisePolyfill;
|
|
79
|
+
/**
|
|
80
|
+
* Check if URL polyfill is needed
|
|
81
|
+
*/
|
|
82
|
+
private needsUrlPolyfill;
|
|
83
|
+
/**
|
|
84
|
+
* Load fetch polyfill if not already present
|
|
85
|
+
*/
|
|
86
|
+
private loadFetchPolyfill;
|
|
87
|
+
/**
|
|
88
|
+
* Load Promise polyfill if not already present
|
|
89
|
+
*/
|
|
90
|
+
private loadPromisePolyfill;
|
|
91
|
+
/**
|
|
92
|
+
* Load URL polyfill if not already present
|
|
93
|
+
*/
|
|
94
|
+
private loadUrlPolyfill;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Analytics and GTM Data Layer Types
|
|
99
|
+
*
|
|
100
|
+
* Provides type-safe event tracking for Google Tag Manager / Google Analytics
|
|
101
|
+
* integration throughout the quote journey lifecycle.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Configuration for analytics tracking
|
|
106
|
+
*/
|
|
107
|
+
interface AnalyticsConfig {
|
|
108
|
+
/** Enable or disable analytics tracking (default: true if dataLayer exists) */
|
|
109
|
+
enabled?: boolean;
|
|
110
|
+
/** Custom data layer variable name (default: 'dataLayer') */
|
|
111
|
+
customDataLayer?: string;
|
|
112
|
+
/** Include personally identifiable information in events (default: false) */
|
|
113
|
+
includePersonalData?: boolean;
|
|
114
|
+
/** Enable debug logging to console (default: false) */
|
|
115
|
+
debug?: boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Base properties included in all analytics events
|
|
119
|
+
*/
|
|
120
|
+
interface BaseAnalyticsEvent {
|
|
121
|
+
/** Event name for GTM trigger */
|
|
122
|
+
event: string;
|
|
123
|
+
/** Quote intent ID */
|
|
124
|
+
quote_id: string;
|
|
125
|
+
/** Product code (versioned) */
|
|
126
|
+
product_code?: string;
|
|
127
|
+
/** Product name */
|
|
128
|
+
product_name?: string;
|
|
129
|
+
/** Organisation slug */
|
|
130
|
+
organisation_slug?: string;
|
|
131
|
+
/** Organisation name */
|
|
132
|
+
organisation_name?: string;
|
|
133
|
+
/** Event timestamp (ISO 8601) */
|
|
134
|
+
timestamp: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Event: quote_started
|
|
138
|
+
* Triggered when a new quote intent is created
|
|
139
|
+
*/
|
|
140
|
+
interface QuoteStartedEvent extends BaseAnalyticsEvent {
|
|
141
|
+
event: 'quote_started';
|
|
142
|
+
/** Quote status */
|
|
143
|
+
quote_status: QuoteIntentState['status'];
|
|
144
|
+
/** Total number of form pages */
|
|
145
|
+
total_pages?: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Event: quote_form_progress
|
|
149
|
+
* Triggered when user completes a form page
|
|
150
|
+
*/
|
|
151
|
+
interface QuoteFormProgressEvent extends BaseAnalyticsEvent {
|
|
152
|
+
event: 'quote_form_progress';
|
|
153
|
+
/** Current page index (0-based) */
|
|
154
|
+
current_page: number;
|
|
155
|
+
/** Total number of pages */
|
|
156
|
+
total_pages: number;
|
|
157
|
+
/** Number of completed pages */
|
|
158
|
+
completed_pages: number;
|
|
159
|
+
/** Form completion percentage (0-100) */
|
|
160
|
+
completion_percentage: number;
|
|
161
|
+
/** Page title that was just completed */
|
|
162
|
+
page_title?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Event: quote_calculated
|
|
166
|
+
* Triggered when quote calculation completes successfully
|
|
167
|
+
*/
|
|
168
|
+
interface QuoteCalculatedEvent extends BaseAnalyticsEvent {
|
|
169
|
+
event: 'quote_calculated';
|
|
170
|
+
/** Selected excess option ID */
|
|
171
|
+
excess_id?: string;
|
|
172
|
+
/** Selected excess amount */
|
|
173
|
+
excess_amount?: number;
|
|
174
|
+
/** Premium subtotal (before fees) */
|
|
175
|
+
premium_subtotal?: number;
|
|
176
|
+
/** Premium total (including fees) */
|
|
177
|
+
premium_total?: number;
|
|
178
|
+
/** Number of excess options available */
|
|
179
|
+
excess_options_count: number;
|
|
180
|
+
/** Number of payment options available */
|
|
181
|
+
payment_options_count: number;
|
|
182
|
+
/** Whether installment payments are available */
|
|
183
|
+
has_installments?: boolean;
|
|
184
|
+
/** Lowest available premium */
|
|
185
|
+
min_premium?: number;
|
|
186
|
+
/** Highest available premium */
|
|
187
|
+
max_premium?: number;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Event: quote_at_checkout
|
|
191
|
+
* Triggered when user reaches the checkout page
|
|
192
|
+
*/
|
|
193
|
+
interface QuoteAtCheckoutEvent extends BaseAnalyticsEvent {
|
|
194
|
+
event: 'quote_at_checkout';
|
|
195
|
+
/** Selected excess option ID */
|
|
196
|
+
excess_id: string;
|
|
197
|
+
/** Selected excess amount */
|
|
198
|
+
excess_amount: number;
|
|
199
|
+
/** Premium subtotal (before fees) */
|
|
200
|
+
premium_subtotal: number;
|
|
201
|
+
/** Premium total (including fees) */
|
|
202
|
+
premium_total: number;
|
|
203
|
+
/** Number of payment options available */
|
|
204
|
+
payment_options_count: number;
|
|
205
|
+
/** Whether installment payments are available */
|
|
206
|
+
has_installments: boolean;
|
|
207
|
+
/** Form completion percentage (should be 100) */
|
|
208
|
+
form_completion: number;
|
|
209
|
+
/** Fees breakdown */
|
|
210
|
+
fees?: Array<{
|
|
211
|
+
name: string;
|
|
212
|
+
type: string;
|
|
213
|
+
amount: number;
|
|
214
|
+
}>;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Event: quote_referred
|
|
218
|
+
* Triggered when a quote is referred and cannot proceed
|
|
219
|
+
*/
|
|
220
|
+
interface QuoteReferredEvent extends BaseAnalyticsEvent {
|
|
221
|
+
event: 'quote_referred';
|
|
222
|
+
/** Referral reason/message */
|
|
223
|
+
referral_reason?: string;
|
|
224
|
+
/** Number of referrals */
|
|
225
|
+
referrals_count: number;
|
|
226
|
+
/** Referral IDs */
|
|
227
|
+
referral_ids?: string[];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Event: payment_initiated
|
|
231
|
+
* Triggered when user clicks "Pay Now" and payment process begins
|
|
232
|
+
*/
|
|
233
|
+
interface PaymentInitiatedEvent extends BaseAnalyticsEvent {
|
|
234
|
+
event: 'payment_initiated';
|
|
235
|
+
/** Payment amount */
|
|
236
|
+
payment_amount: number;
|
|
237
|
+
/** Payment gateway code */
|
|
238
|
+
payment_gateway: string;
|
|
239
|
+
/** Payment gateway name */
|
|
240
|
+
payment_gateway_name?: string;
|
|
241
|
+
/** Selected excess amount */
|
|
242
|
+
excess_amount: number;
|
|
243
|
+
/** Payment frequency (monthly vs one-time) */
|
|
244
|
+
payment_frequency?: 'monthly' | 'one-time';
|
|
245
|
+
/** Amount due today */
|
|
246
|
+
amount_due_today?: number;
|
|
247
|
+
/** Number of installments (if applicable) */
|
|
248
|
+
installments_count?: number;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Event: payment_completed
|
|
252
|
+
* Triggered when payment is successfully completed
|
|
253
|
+
*/
|
|
254
|
+
interface PaymentCompletedEvent extends BaseAnalyticsEvent {
|
|
255
|
+
event: 'payment_completed';
|
|
256
|
+
/** Payment transaction ID */
|
|
257
|
+
transaction_id: string;
|
|
258
|
+
/** Payment amount */
|
|
259
|
+
payment_amount: number;
|
|
260
|
+
/** Payment gateway used */
|
|
261
|
+
payment_gateway?: string;
|
|
262
|
+
/** Premium total */
|
|
263
|
+
premium_total: number;
|
|
264
|
+
/** Excess amount */
|
|
265
|
+
excess_amount: number;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Event: payment_failed
|
|
269
|
+
* Triggered when payment fails or is declined
|
|
270
|
+
*/
|
|
271
|
+
interface PaymentFailedEvent extends BaseAnalyticsEvent {
|
|
272
|
+
event: 'payment_failed';
|
|
273
|
+
/** Payment transaction ID (if available) */
|
|
274
|
+
transaction_id?: string;
|
|
275
|
+
/** Payment amount attempted */
|
|
276
|
+
payment_amount?: number;
|
|
277
|
+
/** Payment gateway used */
|
|
278
|
+
payment_gateway?: string;
|
|
279
|
+
/** Payment status */
|
|
280
|
+
payment_status?: string;
|
|
281
|
+
/** Failure reason (if available) */
|
|
282
|
+
failure_reason?: string;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Union type of all possible analytics events
|
|
286
|
+
*/
|
|
287
|
+
type AnalyticsEvent = QuoteStartedEvent | QuoteFormProgressEvent | QuoteCalculatedEvent | QuoteAtCheckoutEvent | QuoteReferredEvent | PaymentInitiatedEvent | PaymentCompletedEvent | PaymentFailedEvent;
|
|
288
|
+
/**
|
|
289
|
+
* Type for the global dataLayer array
|
|
290
|
+
*/
|
|
291
|
+
type DataLayer = Array<Record<string, any>>;
|
|
292
|
+
/**
|
|
293
|
+
* Window interface extension for dataLayer
|
|
294
|
+
*/
|
|
295
|
+
declare global {
|
|
296
|
+
interface Window {
|
|
297
|
+
dataLayer?: DataLayer;
|
|
298
|
+
[key: string]: any;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Storage abstraction layer for browser storage APIs
|
|
304
|
+
*/
|
|
305
|
+
interface StorageAdapter {
|
|
306
|
+
/**
|
|
307
|
+
* Get a value from storage
|
|
308
|
+
*/
|
|
309
|
+
get(key: string): string | null;
|
|
310
|
+
/**
|
|
311
|
+
* Set a value in storage
|
|
312
|
+
*/
|
|
313
|
+
set(key: string, value: string): void;
|
|
314
|
+
/**
|
|
315
|
+
* Remove a value from storage
|
|
316
|
+
*/
|
|
317
|
+
remove(key: string): void;
|
|
318
|
+
/**
|
|
319
|
+
* Check if storage is available
|
|
320
|
+
*/
|
|
321
|
+
isAvailable(): boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Clear all storage
|
|
324
|
+
*/
|
|
325
|
+
clear(): void;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* localStorage implementation of StorageAdapter
|
|
329
|
+
*/
|
|
330
|
+
declare class LocalStorageAdapter implements StorageAdapter {
|
|
331
|
+
private available;
|
|
332
|
+
constructor();
|
|
333
|
+
get(key: string): string | null;
|
|
334
|
+
set(key: string, value: string): void;
|
|
335
|
+
remove(key: string): void;
|
|
336
|
+
clear(): void;
|
|
337
|
+
isAvailable(): boolean;
|
|
338
|
+
private checkAvailability;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* sessionStorage implementation of StorageAdapter
|
|
342
|
+
*/
|
|
343
|
+
declare class SessionStorageAdapter implements StorageAdapter {
|
|
344
|
+
private available;
|
|
345
|
+
constructor();
|
|
346
|
+
get(key: string): string | null;
|
|
347
|
+
set(key: string, value: string): void;
|
|
348
|
+
remove(key: string): void;
|
|
349
|
+
clear(): void;
|
|
350
|
+
isAvailable(): boolean;
|
|
351
|
+
private checkAvailability;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* In-memory fallback implementation when storage is not available
|
|
355
|
+
*/
|
|
356
|
+
declare class MemoryStorageAdapter implements StorageAdapter {
|
|
357
|
+
private storage;
|
|
358
|
+
get(key: string): string | null;
|
|
359
|
+
set(key: string, value: string): void;
|
|
360
|
+
remove(key: string): void;
|
|
361
|
+
clear(): void;
|
|
362
|
+
isAvailable(): boolean;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Local state management for quote intents
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Configuration for LocalStateManager
|
|
371
|
+
*/
|
|
372
|
+
interface StateManagerConfig {
|
|
373
|
+
/** Default expiration time in milliseconds (default: 24 hours) */
|
|
374
|
+
defaultExpirationMs?: number;
|
|
375
|
+
/** Storage namespace (default: 'quote_intent') */
|
|
376
|
+
namespace?: string;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Local state manager for persisting quote intent data
|
|
380
|
+
*/
|
|
381
|
+
declare class LocalStateManager {
|
|
382
|
+
private static readonly DEFAULT_EXPIRATION_MS;
|
|
383
|
+
private static readonly DEFAULT_NAMESPACE;
|
|
384
|
+
private storageAdapter;
|
|
385
|
+
private config;
|
|
386
|
+
constructor(storageAdapter: StorageAdapter, config?: StateManagerConfig);
|
|
387
|
+
/**
|
|
388
|
+
* Save quote intent state for an organization
|
|
389
|
+
*/
|
|
390
|
+
saveQuoteIntent(orgId: string, state: QuoteIntentState): void;
|
|
391
|
+
/**
|
|
392
|
+
* Get quote intent state for an organization
|
|
393
|
+
*/
|
|
394
|
+
getQuoteIntent(orgId: string): QuoteIntentState | null;
|
|
395
|
+
/**
|
|
396
|
+
* Remove quote intent state for an organization
|
|
397
|
+
*/
|
|
398
|
+
removeQuoteIntent(orgId: string): void;
|
|
399
|
+
/**
|
|
400
|
+
* Check if quote intent state is valid (not expired and has required fields)
|
|
401
|
+
*/
|
|
402
|
+
isQuoteIntentValid(state: QuoteIntentState): boolean;
|
|
403
|
+
/**
|
|
404
|
+
* Get all quote intent states (for cleanup purposes)
|
|
405
|
+
*/
|
|
406
|
+
getAllQuoteIntents(): Record<string, QuoteIntentState>;
|
|
407
|
+
/**
|
|
408
|
+
* Clean up expired quote intents
|
|
409
|
+
*/
|
|
410
|
+
cleanupExpiredQuoteIntents(): void;
|
|
411
|
+
/**
|
|
412
|
+
* Check if storage is available
|
|
413
|
+
*/
|
|
414
|
+
isStorageAvailable(): boolean;
|
|
415
|
+
/**
|
|
416
|
+
* Generate storage key for organization
|
|
417
|
+
*/
|
|
418
|
+
private generateStorageKey;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Quote intent specific storage operations
|
|
422
|
+
*/
|
|
423
|
+
declare class QuoteIntentStore {
|
|
424
|
+
private stateManager;
|
|
425
|
+
constructor(stateManager: LocalStateManager);
|
|
426
|
+
/**
|
|
427
|
+
* Get existing quote intent or create a new one
|
|
428
|
+
*/
|
|
429
|
+
getOrCreateQuoteIntent(orgId: string, createQuoteIntent: () => Promise<QuoteIntentState>, getQuoteIntent: (url: string) => Promise<QuoteIntentState>): Promise<QuoteIntentState>;
|
|
430
|
+
/**
|
|
431
|
+
* Update existing quote intent state
|
|
432
|
+
*/
|
|
433
|
+
updateQuoteIntent(orgId: string, updates: Partial<QuoteIntentState>): QuoteIntentState | null;
|
|
434
|
+
/**
|
|
435
|
+
* Clear quote intent for organization
|
|
436
|
+
*/
|
|
437
|
+
clearQuoteIntent(orgId: string): void;
|
|
438
|
+
/**
|
|
439
|
+
* Clear all expired quote intents
|
|
440
|
+
*/
|
|
441
|
+
clearExpiredQuoteIntents(): void;
|
|
442
|
+
/**
|
|
443
|
+
* Check if quote intent exists and is valid
|
|
444
|
+
*/
|
|
445
|
+
hasValidQuoteIntent(orgId: string): boolean;
|
|
446
|
+
/**
|
|
447
|
+
* Get quote intent URL if available
|
|
448
|
+
*/
|
|
449
|
+
getQuoteIntentUrl(orgId: string): string | null;
|
|
450
|
+
/**
|
|
451
|
+
* Check if storage is available
|
|
452
|
+
*/
|
|
453
|
+
isStorageAvailable(): boolean;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
interface PerformanceMetrics {
|
|
457
|
+
bundleSize: {
|
|
458
|
+
esm: number;
|
|
459
|
+
umd: number;
|
|
460
|
+
cjs: number;
|
|
461
|
+
gzipped: {
|
|
462
|
+
esm: number;
|
|
463
|
+
umd: number;
|
|
464
|
+
cjs: number;
|
|
465
|
+
};
|
|
466
|
+
};
|
|
467
|
+
runtime: {
|
|
468
|
+
initializationTime: number;
|
|
469
|
+
apiCallTime: number;
|
|
470
|
+
memoryUsage: number;
|
|
471
|
+
averageApiCallTime: number;
|
|
472
|
+
totalApiCalls: number;
|
|
473
|
+
};
|
|
474
|
+
measurements: Record<string, number[]>;
|
|
475
|
+
}
|
|
476
|
+
interface MemoryInfo {
|
|
477
|
+
usedJSHeapSize: number;
|
|
478
|
+
totalJSHeapSize: number;
|
|
479
|
+
jsHeapSizeLimit: number;
|
|
480
|
+
}
|
|
481
|
+
interface ApiCallMetrics {
|
|
482
|
+
operation: string;
|
|
483
|
+
duration: number;
|
|
484
|
+
timestamp: number;
|
|
485
|
+
success: boolean;
|
|
486
|
+
error?: string;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Performance monitoring class for tracking metrics
|
|
490
|
+
*/
|
|
491
|
+
declare class PerformanceMonitor {
|
|
492
|
+
private measurements;
|
|
493
|
+
private completedMeasurements;
|
|
494
|
+
private apiCallMetrics;
|
|
495
|
+
private initializationTime;
|
|
496
|
+
private static instance;
|
|
497
|
+
constructor();
|
|
498
|
+
/**
|
|
499
|
+
* Start measuring performance for a named operation
|
|
500
|
+
*/
|
|
501
|
+
startMeasurement(name: string): void;
|
|
502
|
+
/**
|
|
503
|
+
* End measurement and return duration in milliseconds
|
|
504
|
+
*/
|
|
505
|
+
endMeasurement(name: string): number;
|
|
506
|
+
/**
|
|
507
|
+
* Measure and record API call performance
|
|
508
|
+
*/
|
|
509
|
+
measureApiCall<T>(operation: string, apiCall: () => Promise<T>): Promise<T>;
|
|
510
|
+
/**
|
|
511
|
+
* Get current memory usage information
|
|
512
|
+
*/
|
|
513
|
+
measureMemoryUsage(): number;
|
|
514
|
+
/**
|
|
515
|
+
* Get detailed memory information if available
|
|
516
|
+
*/
|
|
517
|
+
getDetailedMemoryInfo(): MemoryInfo | null;
|
|
518
|
+
/**
|
|
519
|
+
* Get all collected performance metrics
|
|
520
|
+
*/
|
|
521
|
+
getMetrics(): PerformanceMetrics;
|
|
522
|
+
/**
|
|
523
|
+
* Get API call metrics for analysis
|
|
524
|
+
*/
|
|
525
|
+
getApiCallMetrics(): ApiCallMetrics[];
|
|
526
|
+
/**
|
|
527
|
+
* Clear all collected metrics
|
|
528
|
+
*/
|
|
529
|
+
clearMetrics(): void;
|
|
530
|
+
/**
|
|
531
|
+
* Generate performance report
|
|
532
|
+
*/
|
|
533
|
+
generateReport(): string;
|
|
534
|
+
/**
|
|
535
|
+
* Get bundle sizes from build artifacts
|
|
536
|
+
*/
|
|
537
|
+
static getBundleSizes(): Promise<PerformanceMetrics["bundleSize"]>;
|
|
538
|
+
private now;
|
|
539
|
+
static startMeasurement(name: string): void;
|
|
540
|
+
static endMeasurement(name: string): number;
|
|
541
|
+
static measureMemoryUsage(): number;
|
|
542
|
+
static measureApiCall<T>(operation: string, apiCall: () => Promise<T>): Promise<T>;
|
|
543
|
+
static getMetrics(): PerformanceMetrics;
|
|
544
|
+
static generateReport(): string;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
declare enum ErrorType {
|
|
548
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
549
|
+
API_ERROR = "API_ERROR",
|
|
550
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
551
|
+
STORAGE_ERROR = "STORAGE_ERROR",
|
|
552
|
+
TIMEOUT_ERROR = "TIMEOUT_ERROR",
|
|
553
|
+
MAINTENANCE_ERROR = "MAINTENANCE_ERROR"
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Custom error class for InsureOS operations
|
|
557
|
+
*/
|
|
558
|
+
declare class InsureOSError extends Error {
|
|
559
|
+
type: ErrorType;
|
|
560
|
+
retryable: boolean;
|
|
561
|
+
statusCode?: number | undefined;
|
|
562
|
+
retryAfter?: string | undefined;
|
|
563
|
+
validationErrors?: Record<string, any> | undefined;
|
|
564
|
+
constructor(type: ErrorType, message: string, retryable?: boolean, statusCode?: number | undefined, retryAfter?: string | undefined, validationErrors?: Record<string, any> | undefined);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Error handling strategy for different error types
|
|
568
|
+
*/
|
|
569
|
+
declare class ErrorHandlingStrategy {
|
|
570
|
+
handleNetworkError(error: Error): InsureOSError;
|
|
571
|
+
handleApiError(response: Response): InsureOSError;
|
|
572
|
+
handleStorageError(error: Error): InsureOSError;
|
|
573
|
+
shouldRetry(error: InsureOSError): boolean;
|
|
574
|
+
getUserFriendlyMessage(error: InsureOSError): string;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
type FixedVersionStrategyConfig = {
|
|
578
|
+
versionStrategy?: "fixed";
|
|
579
|
+
code: string;
|
|
580
|
+
};
|
|
581
|
+
type LatestVersionStrategyConfig = {
|
|
582
|
+
versionStrategy?: "latest";
|
|
583
|
+
code: string;
|
|
584
|
+
};
|
|
585
|
+
type VersionStrategyConfig = FixedVersionStrategyConfig | LatestVersionStrategyConfig;
|
|
586
|
+
/** Version strategies for InsureOS products */
|
|
587
|
+
declare enum VersionStrategy {
|
|
588
|
+
/** Gets the product based on an exact versioned code */
|
|
589
|
+
FIXED = "fixed",
|
|
590
|
+
/** Gets the latest active version of the product */
|
|
591
|
+
LATEST = "latest"
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Enhanced configuration for mounting InsureOS quote functionality
|
|
595
|
+
*/
|
|
596
|
+
type ClientConfig = {
|
|
597
|
+
/** Org UUID */
|
|
598
|
+
orgId: string;
|
|
599
|
+
/** API URL */
|
|
600
|
+
apiBaseUrl?: string;
|
|
601
|
+
/** HTTP client configuration */
|
|
602
|
+
httpConfig?: Partial<HttpClientConfig>;
|
|
603
|
+
};
|
|
604
|
+
type MountConfig = ClientConfig & {
|
|
605
|
+
/** Existing quote intent url for loading (omit for new quote intents) */
|
|
606
|
+
quoteIntentUrl?: string;
|
|
607
|
+
/** Version strategy configuration */
|
|
608
|
+
product: VersionStrategyConfig;
|
|
609
|
+
/** Storage type preference */
|
|
610
|
+
storageType?: "localStorage" | "sessionStorage";
|
|
611
|
+
/** Polyfill configuration */
|
|
612
|
+
polyfillConfig?: Partial<PolyfillConfig>;
|
|
613
|
+
/** Analytics/GTM data layer configuration */
|
|
614
|
+
analyticsConfig?: AnalyticsConfig;
|
|
615
|
+
/** Enable debug mode for enhanced logging */
|
|
616
|
+
debug?: boolean;
|
|
617
|
+
/** Disable style injection */
|
|
618
|
+
disableStyles?: boolean;
|
|
619
|
+
/** Enable local state persistence (default: true) */
|
|
620
|
+
enableLocalState?: boolean;
|
|
621
|
+
/** Enable polyfills for older browsers (default: true) */
|
|
622
|
+
enablePolyfills?: boolean;
|
|
623
|
+
/** Enable performance monitoring (default: false) */
|
|
624
|
+
enablePerformanceMonitoring?: boolean;
|
|
625
|
+
};
|
|
626
|
+
type QuoteIntentState = {
|
|
627
|
+
id: string;
|
|
628
|
+
created_at: number;
|
|
629
|
+
updated_at: number;
|
|
630
|
+
expires_at: number;
|
|
631
|
+
org_id: string;
|
|
632
|
+
url: string;
|
|
633
|
+
calculate_url: string;
|
|
634
|
+
status: string;
|
|
635
|
+
product_id?: string;
|
|
636
|
+
form_definition?: FormDefinition;
|
|
637
|
+
form_data?: FormData;
|
|
638
|
+
organisation?: {
|
|
639
|
+
id: string;
|
|
640
|
+
created_at: string;
|
|
641
|
+
updated_at: string;
|
|
642
|
+
deleted_at: string | null;
|
|
643
|
+
name: string;
|
|
644
|
+
slug: string;
|
|
645
|
+
admin_email?: string | null;
|
|
646
|
+
phone?: string | null;
|
|
647
|
+
theme: {
|
|
648
|
+
css_url: string;
|
|
649
|
+
} | null;
|
|
650
|
+
};
|
|
651
|
+
payment_return?: {
|
|
652
|
+
paymentTransactionId: string | null;
|
|
653
|
+
paymentStatus: string | null;
|
|
654
|
+
transactionStatus?: any;
|
|
655
|
+
};
|
|
656
|
+
cached_result?: CalculationResponse;
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
declare class InsureOSQuoteWrapperClient {
|
|
660
|
+
private httpClient;
|
|
661
|
+
response: QuoteIntentResponse;
|
|
662
|
+
constructor(httpClient: EnhancedHttpClient, response: QuoteIntentResponse);
|
|
663
|
+
get(): Promise<QuoteIntentResponse>;
|
|
664
|
+
update(data: Record<string, any>): Promise<QuoteIntentResponse>;
|
|
665
|
+
}
|
|
666
|
+
declare class InsureOSWrapperClient {
|
|
667
|
+
private httpClient;
|
|
668
|
+
constructor(httpClient: EnhancedHttpClient);
|
|
669
|
+
createQuoteIntent(productCode: string, options?: {
|
|
670
|
+
cover_start_date?: string;
|
|
671
|
+
}): Promise<InsureOSQuoteWrapperClient>;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Enhanced InsureOS client with feature integration
|
|
676
|
+
*/
|
|
677
|
+
declare class InsureOSClient {
|
|
678
|
+
private sentryInitialized;
|
|
679
|
+
private analyticsManager;
|
|
680
|
+
constructor();
|
|
681
|
+
/**
|
|
682
|
+
* Initialize Sentry on first mount (only once)
|
|
683
|
+
*/
|
|
684
|
+
private initializeSentryOnce;
|
|
685
|
+
private validateConfig;
|
|
686
|
+
/**
|
|
687
|
+
* Initialize analytics on first mount (only once)
|
|
688
|
+
*/
|
|
689
|
+
private initializeAnalyticsOnce;
|
|
690
|
+
/**
|
|
691
|
+
* Mount enhanced InsureOS quote functionality to a DOM element
|
|
692
|
+
*/
|
|
693
|
+
mount(element: HTMLElement, config: MountConfig): Promise<void>;
|
|
694
|
+
private createHttpClient;
|
|
695
|
+
createClient(config: ClientConfig): InsureOSWrapperClient;
|
|
696
|
+
private initializeFormContext;
|
|
697
|
+
/**
|
|
698
|
+
* Check if all form pages are completed and trigger calculation automatically
|
|
699
|
+
*/
|
|
700
|
+
private handleAutoCalculationIfComplete;
|
|
701
|
+
}
|
|
702
|
+
declare const InsureOS: InsureOSClient;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Retry strategy implementation with exponential backoff
|
|
706
|
+
*/
|
|
707
|
+
declare class RetryStrategy {
|
|
708
|
+
private config;
|
|
709
|
+
constructor(config: RetryConfig);
|
|
710
|
+
shouldRetry(error: Error, attempt: number): boolean;
|
|
711
|
+
getDelay(attempt: number, retryAfterHeader?: string): number;
|
|
712
|
+
isRetryableError(error: Error): boolean;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
type ValidationError = {
|
|
716
|
+
field: string;
|
|
717
|
+
message: string;
|
|
718
|
+
};
|
|
719
|
+
type ValidationResult = {
|
|
720
|
+
isValid: boolean;
|
|
721
|
+
errors: ValidationError[];
|
|
722
|
+
};
|
|
723
|
+
type ServerValidationResponse = {
|
|
724
|
+
message?: string;
|
|
725
|
+
validation_errors?: Record<string, string[]>;
|
|
726
|
+
errors?: Record<string, string[]>;
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* Validates a single field value against its field definition
|
|
730
|
+
*/
|
|
731
|
+
declare function validateField(field: FormField, value: string | number | boolean | undefined): ValidationError[];
|
|
732
|
+
/**
|
|
733
|
+
* Validates all fields on a page
|
|
734
|
+
*/
|
|
735
|
+
declare function validatePage(page: FormPage, formData: Record<string, any>): ValidationResult;
|
|
736
|
+
/**
|
|
737
|
+
* Converts server validation response to our ValidationError format
|
|
738
|
+
* Supports both 'validation_errors' (422) and 'errors' (400) formats
|
|
739
|
+
*/
|
|
740
|
+
declare function parseServerValidationErrors(response: ServerValidationResponse | Record<string, string[]>): ValidationError[];
|
|
741
|
+
/**
|
|
742
|
+
* Groups validation errors by field ID
|
|
743
|
+
*/
|
|
744
|
+
declare function groupErrorsByField(errors: ValidationError[]): Record<string, ValidationError[]>;
|
|
745
|
+
|
|
746
|
+
type AppErrorType = "initialization" | "calculation" | "network" | "validation" | "maintenance" | "unknown";
|
|
747
|
+
type AppErrorSeverity = "warning" | "error" | "critical";
|
|
748
|
+
interface AppError {
|
|
749
|
+
id: string;
|
|
750
|
+
type: AppErrorType;
|
|
751
|
+
severity: AppErrorSeverity;
|
|
752
|
+
title: string;
|
|
753
|
+
message: string;
|
|
754
|
+
details?: string;
|
|
755
|
+
statusCode?: number;
|
|
756
|
+
retryable: boolean;
|
|
757
|
+
timestamp: number;
|
|
758
|
+
dismissed?: boolean;
|
|
759
|
+
trackingId?: string;
|
|
760
|
+
}
|
|
761
|
+
interface ServerErrorResponse {
|
|
762
|
+
statusCode: number;
|
|
763
|
+
message: string;
|
|
764
|
+
error?: string;
|
|
765
|
+
details?: any;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Creates a standardized app error from various error sources
|
|
769
|
+
*/
|
|
770
|
+
declare function createAppError(type: AppErrorType, error: any, customMessage?: string): AppError;
|
|
771
|
+
/**
|
|
772
|
+
* Checks if an error indicates the app should show a fallback error page
|
|
773
|
+
*/
|
|
774
|
+
declare function shouldShowErrorPage(error: AppError): boolean;
|
|
775
|
+
/**
|
|
776
|
+
* Checks if an error indicates the app should show the maintenance page
|
|
777
|
+
*/
|
|
778
|
+
declare function shouldShowMaintenancePage(error: AppError): boolean;
|
|
779
|
+
/**
|
|
780
|
+
* Generates a user-friendly support message
|
|
781
|
+
*/
|
|
782
|
+
declare function getSupportMessage(error: AppError): string;
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Configuration for FormStateManager
|
|
786
|
+
*/
|
|
787
|
+
interface FormStateManagerConfig {
|
|
788
|
+
/** Auto-save interval in milliseconds (default: 1000) */
|
|
789
|
+
autoSaveInterval?: number;
|
|
790
|
+
/** Whether to enable auto-save (default: true) */
|
|
791
|
+
autoSave?: boolean;
|
|
792
|
+
/** Maximum retry attempts for failed saves (default: 3) */
|
|
793
|
+
maxRetryAttempts?: number;
|
|
794
|
+
/** Retry delay in milliseconds (default: 2000) */
|
|
795
|
+
retryDelay?: number;
|
|
796
|
+
}
|
|
797
|
+
type SaveType = "page" | "auto-save" | "full";
|
|
798
|
+
type SubscriptionCallback = (state: FormStateManager) => void;
|
|
799
|
+
declare class FormStateManager {
|
|
800
|
+
private quoteIntent;
|
|
801
|
+
httpClient: EnhancedHttpClient;
|
|
802
|
+
private subscribers;
|
|
803
|
+
private formData;
|
|
804
|
+
private pendingChanges;
|
|
805
|
+
private config;
|
|
806
|
+
private isCalculating;
|
|
807
|
+
private selectedExcessId;
|
|
808
|
+
private selectedPaymentOption;
|
|
809
|
+
private calculationResult;
|
|
810
|
+
private validationErrors;
|
|
811
|
+
private serverValidationErrors;
|
|
812
|
+
private generalErrors;
|
|
813
|
+
private lastCalculationFailed;
|
|
814
|
+
private autoSaveManager;
|
|
815
|
+
private persistenceManager;
|
|
816
|
+
private navigationManager;
|
|
817
|
+
private calculationManager;
|
|
818
|
+
private quoteIntentStore?;
|
|
819
|
+
constructor(quoteIntent: QuoteIntentState, httpClient: EnhancedHttpClient, quoteIntentStore?: QuoteIntentStore, config?: FormStateManagerConfig);
|
|
820
|
+
subscribe(callback: SubscriptionCallback): () => boolean;
|
|
821
|
+
loadFormProgress(): Promise<FormData>;
|
|
822
|
+
updatePageData(pageId: string, data: Record<string, any>): void;
|
|
823
|
+
updateFieldValue(pageId: string, fieldId: string, value: any): void;
|
|
824
|
+
updateFieldAnswer(pageId: string, fieldId: string, answer: string): void;
|
|
825
|
+
restoreFormProgress(data: FormData): void;
|
|
826
|
+
restoreCalculationResult(result: CalculationResponse): void;
|
|
827
|
+
private processRatingFactorMappings;
|
|
828
|
+
private applyDerivationRule;
|
|
829
|
+
private calculateAge;
|
|
830
|
+
saveFormData(force?: boolean, saveType?: SaveType): Promise<void>;
|
|
831
|
+
canNavigateToPage(pageIndex: number): boolean;
|
|
832
|
+
navigateToPage(pageIndex: number): Promise<boolean>;
|
|
833
|
+
navigateToNextPage(): Promise<boolean>;
|
|
834
|
+
navigateToPreviousPage(): Promise<boolean>;
|
|
835
|
+
getPageCompletionStatus(): {
|
|
836
|
+
totalPages: number;
|
|
837
|
+
currentPage: number;
|
|
838
|
+
completedPages: number[];
|
|
839
|
+
percentComplete: number;
|
|
840
|
+
};
|
|
841
|
+
getFormProgress(): FormData;
|
|
842
|
+
getFormDefinition(): FormDefinition;
|
|
843
|
+
getTotalPages(): number;
|
|
844
|
+
getCurrentPageIndex(): number;
|
|
845
|
+
isAutoSavePaused(): boolean;
|
|
846
|
+
isUserTyping(): boolean;
|
|
847
|
+
getIsCalculating(): boolean;
|
|
848
|
+
hasCalculationResponse(): boolean;
|
|
849
|
+
getCalculationResult(): CalculationResponse | undefined;
|
|
850
|
+
getConsecutiveFailures(): number;
|
|
851
|
+
getSelectedExcessId(): string | null;
|
|
852
|
+
setSelectedExcessId(excessId: string | null): void;
|
|
853
|
+
getSelectedPaymentOption(): PaymentOption | null;
|
|
854
|
+
setSelectedPaymentOption(paymentOption: PaymentOption | null): void;
|
|
855
|
+
hasPendingChanges(): boolean;
|
|
856
|
+
validateCurrentPage(): ValidationError[];
|
|
857
|
+
validateField(pageId: string, fieldId: string, value: any): ValidationError[];
|
|
858
|
+
getValidationErrors(): ValidationError[];
|
|
859
|
+
getFieldErrors(fieldId: string): ValidationError[];
|
|
860
|
+
hasErrors(): boolean;
|
|
861
|
+
hasFieldErrors(fieldId: string): boolean;
|
|
862
|
+
clearValidationErrors(): void;
|
|
863
|
+
setServerValidationErrors(errors: ValidationError[]): void;
|
|
864
|
+
clearServerValidationErrors(): void;
|
|
865
|
+
getGeneralErrors(): AppError[];
|
|
866
|
+
addGeneralError(error: AppError): void;
|
|
867
|
+
dismissGeneralError(errorId: string): void;
|
|
868
|
+
clearGeneralErrors(): void;
|
|
869
|
+
hasGeneralErrors(): boolean;
|
|
870
|
+
hasLastCalculationFailed(): boolean;
|
|
871
|
+
dispose(): void;
|
|
872
|
+
/**
|
|
873
|
+
* Filter out hidden field values before calculation
|
|
874
|
+
* This ensures hidden fields don't affect calculations
|
|
875
|
+
*/
|
|
876
|
+
private filterHiddenFieldsAndSave;
|
|
877
|
+
calculateQuote(): Promise<CalculationResponse | undefined>;
|
|
878
|
+
private notify;
|
|
879
|
+
private updateFormDataInternal;
|
|
880
|
+
private createEmptyFormData;
|
|
881
|
+
private getPersistedCalculationFailureState;
|
|
882
|
+
private persistCalculationFailureState;
|
|
883
|
+
reset(): void;
|
|
884
|
+
getQuoteIntent(): QuoteIntentState;
|
|
885
|
+
updateQuoteIntent(updates: Partial<QuoteIntentState>): void;
|
|
886
|
+
clearStoredQuoteIntent(): void;
|
|
887
|
+
initiatePayment(paymentRequest: PaymentInitiationRequest): Promise<any>;
|
|
888
|
+
getPaymentStatus(transactionId: string): Promise<any>;
|
|
889
|
+
startPaymentStatusPolling(transactionId: string, onStatusUpdate: (status: any) => void, maxPolls?: number): () => void;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
interface SentryConfig {
|
|
893
|
+
dsn: string;
|
|
894
|
+
environment?: string;
|
|
895
|
+
release?: string;
|
|
896
|
+
enabled?: boolean;
|
|
897
|
+
sampleRate?: number;
|
|
898
|
+
tracesSampleRate?: number;
|
|
899
|
+
bundleUrlPatterns?: RegExp[];
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Initialize Sentry with isolated configuration for embedded widget use
|
|
903
|
+
*
|
|
904
|
+
* IMPORTANT: This is configured to ONLY capture errors from our widget code,
|
|
905
|
+
* not from the host page. This prevents conflicts with host page Sentry installations.
|
|
906
|
+
*/
|
|
907
|
+
declare function initializeSentry(config: SentryConfig): void;
|
|
908
|
+
/**
|
|
909
|
+
* Capture an exception to Sentry
|
|
910
|
+
*/
|
|
911
|
+
declare function captureException(error: Error | unknown, context?: Record<string, any>): void;
|
|
912
|
+
/**
|
|
913
|
+
* Capture a message to Sentry
|
|
914
|
+
*/
|
|
915
|
+
declare function captureMessage(message: string, level?: Sentry.SeverityLevel, context?: Record<string, any>): void;
|
|
916
|
+
/**
|
|
917
|
+
* Set user context for Sentry
|
|
918
|
+
*/
|
|
919
|
+
declare function setUser(user: {
|
|
920
|
+
id?: string;
|
|
921
|
+
email?: string;
|
|
922
|
+
username?: string;
|
|
923
|
+
} | null): void;
|
|
924
|
+
/**
|
|
925
|
+
* Add a breadcrumb to Sentry
|
|
926
|
+
*/
|
|
927
|
+
declare function addBreadcrumb(breadcrumb: {
|
|
928
|
+
message: string;
|
|
929
|
+
category?: string;
|
|
930
|
+
level?: Sentry.SeverityLevel;
|
|
931
|
+
data?: Record<string, any>;
|
|
932
|
+
}): void;
|
|
933
|
+
/**
|
|
934
|
+
* Set a custom tag in Sentry
|
|
935
|
+
*/
|
|
936
|
+
declare function setTag(key: string, value: string): void;
|
|
937
|
+
/**
|
|
938
|
+
* Check if Sentry is initialized
|
|
939
|
+
*/
|
|
940
|
+
declare function isSentryInitialized(): boolean;
|
|
941
|
+
|
|
942
|
+
interface ThemeConfig {
|
|
943
|
+
slug: string;
|
|
944
|
+
theme_url: string;
|
|
945
|
+
}
|
|
946
|
+
interface ParsedTheme {
|
|
947
|
+
variables: Record<string, string>;
|
|
948
|
+
classRules: string;
|
|
949
|
+
mappedVariables: Record<string, string>;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Theme loader utility for loading organization-specific CSS themes
|
|
953
|
+
*/
|
|
954
|
+
declare class ThemeLoader {
|
|
955
|
+
private static loadedThemes;
|
|
956
|
+
/**
|
|
957
|
+
* Mapping from organization theme variables to InsureOS prefixed variables
|
|
958
|
+
*/
|
|
959
|
+
private static variableMapping;
|
|
960
|
+
/**
|
|
961
|
+
* Load theme CSS from organization configuration
|
|
962
|
+
*/
|
|
963
|
+
static loadTheme(themeConfig: ThemeConfig): Promise<void>;
|
|
964
|
+
/**
|
|
965
|
+
* Parse CSS content to extract variables and class rules
|
|
966
|
+
*/
|
|
967
|
+
private static parseCSSContent;
|
|
968
|
+
/**
|
|
969
|
+
* Apply parsed theme to document and update base variables
|
|
970
|
+
*/
|
|
971
|
+
private static applyParsedTheme;
|
|
972
|
+
/**
|
|
973
|
+
* Apply class rules to document
|
|
974
|
+
*/
|
|
975
|
+
private static applyClassRules;
|
|
976
|
+
/**
|
|
977
|
+
* Inject original CSS for unmapped variables and additional styles
|
|
978
|
+
*/
|
|
979
|
+
private static injectOriginalCSS;
|
|
980
|
+
/**
|
|
981
|
+
* Remove theme CSS from document
|
|
982
|
+
*/
|
|
983
|
+
static removeTheme(slug: string): void;
|
|
984
|
+
/**
|
|
985
|
+
* Check if theme is loaded
|
|
986
|
+
*/
|
|
987
|
+
static isThemeLoaded(slug: string): boolean;
|
|
988
|
+
/**
|
|
989
|
+
* Get list of loaded themes
|
|
990
|
+
*/
|
|
991
|
+
static getLoadedThemes(): string[];
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* Data Layer Helper
|
|
996
|
+
*
|
|
997
|
+
* Provides safe, type-safe access to the GTM/GA data layer for analytics tracking.
|
|
998
|
+
* Gracefully degrades if data layer is not present on the page.
|
|
999
|
+
*/
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Data Layer Manager
|
|
1003
|
+
*
|
|
1004
|
+
* Handles pushing events to the GTM/GA data layer with proper error handling
|
|
1005
|
+
* and optional debug logging.
|
|
1006
|
+
*/
|
|
1007
|
+
declare class DataLayerManager {
|
|
1008
|
+
private config;
|
|
1009
|
+
private dataLayerAvailable;
|
|
1010
|
+
constructor(config?: AnalyticsConfig);
|
|
1011
|
+
/**
|
|
1012
|
+
* Initialize the data layer if it doesn't exist
|
|
1013
|
+
*/
|
|
1014
|
+
private initializeDataLayer;
|
|
1015
|
+
/**
|
|
1016
|
+
* Check if analytics is enabled and data layer is available
|
|
1017
|
+
*/
|
|
1018
|
+
isEnabled(): boolean;
|
|
1019
|
+
/**
|
|
1020
|
+
* Get the data layer array
|
|
1021
|
+
*/
|
|
1022
|
+
private getDataLayer;
|
|
1023
|
+
/**
|
|
1024
|
+
* Push an event to the data layer
|
|
1025
|
+
*/
|
|
1026
|
+
push(event: AnalyticsEvent): void;
|
|
1027
|
+
/**
|
|
1028
|
+
* Remove personally identifiable information from event
|
|
1029
|
+
*/
|
|
1030
|
+
private removePII;
|
|
1031
|
+
/**
|
|
1032
|
+
* Log debug messages if debug mode is enabled
|
|
1033
|
+
*/
|
|
1034
|
+
private logDebug;
|
|
1035
|
+
/**
|
|
1036
|
+
* Reset/clear the data layer (useful for testing)
|
|
1037
|
+
*/
|
|
1038
|
+
clear(): void;
|
|
1039
|
+
/**
|
|
1040
|
+
* Get current configuration
|
|
1041
|
+
*/
|
|
1042
|
+
getConfig(): Readonly<Required<AnalyticsConfig>>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Update configuration
|
|
1045
|
+
*/
|
|
1046
|
+
updateConfig(config: Partial<AnalyticsConfig>): void;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Analytics Event Tracking Functions
|
|
1051
|
+
*
|
|
1052
|
+
* Provides high-level functions to track specific events throughout the quote
|
|
1053
|
+
* journey lifecycle. These functions extract relevant data from quote intents,
|
|
1054
|
+
* calculations, and payments to create rich, structured analytics events.
|
|
1055
|
+
*/
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Initialize analytics with configuration
|
|
1059
|
+
*/
|
|
1060
|
+
declare function initializeAnalytics(manager: DataLayerManager): void;
|
|
1061
|
+
/**
|
|
1062
|
+
* Get the analytics instance
|
|
1063
|
+
*/
|
|
1064
|
+
declare function getAnalytics(): DataLayerManager | null;
|
|
1065
|
+
/**
|
|
1066
|
+
* Track quote started event
|
|
1067
|
+
*/
|
|
1068
|
+
declare function trackQuoteStarted(quoteIntent: QuoteIntentState): void;
|
|
1069
|
+
/**
|
|
1070
|
+
* Track form progress event
|
|
1071
|
+
*/
|
|
1072
|
+
declare function trackFormProgress(quoteIntent: QuoteIntentState, currentPage: number, completedPages: number[], pageTitle?: string): void;
|
|
1073
|
+
/**
|
|
1074
|
+
* Track quote calculated event
|
|
1075
|
+
*/
|
|
1076
|
+
declare function trackQuoteCalculated(quoteIntent: QuoteIntentState, calculationResponse: CalculationResponse): void;
|
|
1077
|
+
/**
|
|
1078
|
+
* Track quote at checkout event
|
|
1079
|
+
*/
|
|
1080
|
+
declare function trackQuoteAtCheckout(quoteIntent: QuoteIntentState, selectedExcess: CalculationExcessOption, paymentOptionsCount: number, hasInstallments: boolean, formCompletion: number): void;
|
|
1081
|
+
/**
|
|
1082
|
+
* Track quote referred event
|
|
1083
|
+
*/
|
|
1084
|
+
declare function trackQuoteReferred(quoteIntent: QuoteIntentState, calculationResponse: CalculationResponse): void;
|
|
1085
|
+
/**
|
|
1086
|
+
* Track payment initiated event
|
|
1087
|
+
*/
|
|
1088
|
+
declare function trackPaymentInitiated(quoteIntent: QuoteIntentState, paymentOption: PaymentOption, gatewayName?: string, excessAmount?: number): void;
|
|
1089
|
+
/**
|
|
1090
|
+
* Track payment completed event
|
|
1091
|
+
*/
|
|
1092
|
+
declare function trackPaymentCompleted(quoteIntent: QuoteIntentState, transactionId: string, paymentAmount: number, paymentGateway?: string, premiumTotal?: number, excessAmount?: number): void;
|
|
1093
|
+
/**
|
|
1094
|
+
* Track payment failed event
|
|
1095
|
+
*/
|
|
1096
|
+
declare function trackPaymentFailed(quoteIntent: QuoteIntentState, transactionId?: string, paymentAmount?: number, paymentGateway?: string, paymentStatus?: string, failureReason?: string): void;
|
|
1097
|
+
|
|
1098
|
+
export { DataLayerManager, EnhancedHttpClient, ErrorHandlingStrategy, ErrorType, FormStateManager, InsureOS, InsureOSClient, InsureOSError, LocalStateManager, LocalStorageAdapter, MemoryStorageAdapter, PerformanceMonitor, PolyfillManager, RetryStrategy, SessionStorageAdapter, ThemeLoader, VersionStrategy, addBreadcrumb, captureException, captureMessage, createAppError, getAnalytics, getSupportMessage, groupErrorsByField, initializeAnalytics, initializeSentry, isSentryInitialized, parseServerValidationErrors, setTag, setUser, shouldShowErrorPage, shouldShowMaintenancePage, trackFormProgress, trackPaymentCompleted, trackPaymentFailed, trackPaymentInitiated, trackQuoteAtCheckout, trackQuoteCalculated, trackQuoteReferred, trackQuoteStarted, validateField, validatePage };
|
|
1099
|
+
export type { AnalyticsConfig, AnalyticsEvent, ApiCallMetrics, AppError, AppErrorSeverity, AppErrorType, BaseAnalyticsEvent, DataLayer, FormStateManagerConfig, HttpClientConfig, MemoryInfo, MountConfig, ParsedTheme, PaymentCompletedEvent, PaymentFailedEvent, PaymentInitiatedEvent, PerformanceMetrics, PolyfillConfig, QuoteAtCheckoutEvent, QuoteCalculatedEvent, QuoteFormProgressEvent, QuoteIntentState, QuoteReferredEvent, QuoteStartedEvent, RetryConfig, SentryConfig, ServerErrorResponse, ServerValidationResponse, StorageAdapter, ThemeConfig, ValidationError, ValidationResult, VersionStrategyConfig };
|