@buddy-technology/offer-component 0.2.5 → 0.3.2
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/API.md +45 -3
- package/CHANGELOG.md +23 -0
- package/README.md +251 -3
- package/dist/index.js +26 -3
- package/dist/util.js +6 -1
- package/lib/types.d.ts +35 -2
- package/package.json +1 -1
package/API.md
CHANGED
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
<dd></dd>
|
|
21
21
|
<dt><a href="#ThemeObject">ThemeObject</a> : <code>Object</code></dt>
|
|
22
22
|
<dd></dd>
|
|
23
|
+
<dt><a href="#LogoOverride">LogoOverride</a> : <code>Object</code></dt>
|
|
24
|
+
<dd></dd>
|
|
25
|
+
<dt><a href="#EventObject">EventObject</a> : <code>Object</code></dt>
|
|
26
|
+
<dd></dd>
|
|
27
|
+
<dt><a href="#OnUserEventCallback">OnUserEventCallback</a> : <code>function</code></dt>
|
|
28
|
+
<dd></dd>
|
|
23
29
|
<dt><a href="#BuddyOfferElementProps">BuddyOfferElementProps</a> : <code>Object</code></dt>
|
|
24
30
|
<dd></dd>
|
|
25
31
|
</dl>
|
|
@@ -114,6 +120,38 @@ const theme = {
|
|
|
114
120
|
},
|
|
115
121
|
};
|
|
116
122
|
```
|
|
123
|
+
<a name="LogoOverride"></a>
|
|
124
|
+
|
|
125
|
+
## LogoOverride : <code>Object</code>
|
|
126
|
+
**Kind**: global typedef
|
|
127
|
+
**Properties**
|
|
128
|
+
|
|
129
|
+
| Name | Type | Description |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| url | <code>String</code> | destination url when users click the trust badge |
|
|
132
|
+
| src | <code>String</code> | src of the img for displaying the trust badge |
|
|
133
|
+
| [alt] | <code>String</code> | alt text for trust badge image |
|
|
134
|
+
|
|
135
|
+
<a name="EventObject"></a>
|
|
136
|
+
|
|
137
|
+
## EventObject : <code>Object</code>
|
|
138
|
+
**Kind**: global typedef
|
|
139
|
+
|
|
140
|
+
| Param | Type | Description |
|
|
141
|
+
| --- | --- | --- |
|
|
142
|
+
| eventType | <code>string</code> | the type of user event (eg:'onCheckout') |
|
|
143
|
+
| data | <code>object</code> | data object related to the user event. |
|
|
144
|
+
| data.timestamp | <code>object</code> | timestamp of the event. All events have a timestamp property. |
|
|
145
|
+
|
|
146
|
+
<a name="OnUserEventCallback"></a>
|
|
147
|
+
|
|
148
|
+
## OnUserEventCallback : <code>function</code>
|
|
149
|
+
**Kind**: global typedef
|
|
150
|
+
|
|
151
|
+
| Param | Type | Description |
|
|
152
|
+
| --- | --- | --- |
|
|
153
|
+
| type | [<code>EventObject</code>](#EventObject) | the type of user event (eg:'onCheckout') |
|
|
154
|
+
|
|
117
155
|
<a name="BuddyOfferElementProps"></a>
|
|
118
156
|
|
|
119
157
|
## BuddyOfferElementProps : <code>Object</code>
|
|
@@ -124,9 +162,13 @@ const theme = {
|
|
|
124
162
|
| --- | --- | --- | --- |
|
|
125
163
|
| ion | <code>String</code> | | The ion id for the offering. |
|
|
126
164
|
| partnerID | <code>String</code> | | The partner ID required for instantiating the Offer |
|
|
165
|
+
| [stage] | <code>String</code> | <code>"STAGING"</code> | toggle's the environment for the Offer Component. Defaults to STAGING. Must be set to "PRODUCTION" before going live. |
|
|
127
166
|
| [viewType] | <code>String</code> | <code>"paginated"</code> | establishes how the offer should display to the user. One of: 'paginated', 'single-form' or 'offer-only.' |
|
|
167
|
+
| [theme] | [<code>ThemeObject</code>](#ThemeObject) | | theming object for customizing offer component's styles |
|
|
128
168
|
| [data] | [<code>DataObject</code>](#DataObject) | | Any customer or policy data to pre-fill the offer with. Refer to your individual ION for data structure. |
|
|
129
|
-
| [
|
|
130
|
-
| [
|
|
131
|
-
| [
|
|
169
|
+
| [onUserEvent] | [<code>OnUserEventCallback</code>](#OnUserEventCallback) | | callback function for tracking user behavioral data. Triggers on user interactions such as input focus/blur, in-app navigation, etc. Refer to the docs for more details. |
|
|
170
|
+
| [onAddToCart] | [<code>AddToCartFunction</code>](#AddToCartFunction) | | callback function triggered when users opt into an offer-only offer. |
|
|
171
|
+
| [onRemoveFromCart] | [<code>RemoveFromCartFunction</code>](#RemoveFromCartFunction) | | callback function triggered when users opt out of an offer-only offer. |
|
|
172
|
+
| [includeCheckout] | <code>boolean</code> | | toggles whether or not to display the card capture checkout view. Defaults to true. When false, an AddToCart callback must be provided. |
|
|
173
|
+
| [logoOverride] | [<code>LogoOverride</code>](#LogoOverride) | | object for overriding Buddy's trust badge. |
|
|
132
174
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
### v0.3.2
|
|
4
|
+
2023-06-27
|
|
5
|
+
|
|
6
|
+
- fix deploy action :crossed_fingers:
|
|
7
|
+
- fix includeCheckout should be optional
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### v0.3.1
|
|
12
|
+
2023-06-27
|
|
13
|
+
|
|
14
|
+
- add missing props to types file
|
|
15
|
+
- update docs
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### v0.2.6
|
|
20
|
+
2022-11-09
|
|
21
|
+
|
|
22
|
+
- Added testing as an environment
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
|
|
3
26
|
### v0.2.5
|
|
4
27
|
2022-08-09
|
|
5
28
|
|
package/README.md
CHANGED
|
@@ -38,11 +38,12 @@ export default App;
|
|
|
38
38
|
| *ion | string | | The ion ID for the product to be presented |
|
|
39
39
|
| stage | enum | "STAGING" | One of: `"STAGING"`, `"PRODUCTION"`. Set to `"STAGING"` (default) for testing and development. |
|
|
40
40
|
| viewType | enum | `"paginated"` | Sets how the offer element is displayed. One of: `"paginated"`, `"single-form"`, `"offer-only"`. _See [View types](#view-types) for details._|
|
|
41
|
+
| data | object | | Customer or policy data to pre-load the offer with. Refer to specific ION documentation for the data structure. |
|
|
42
|
+
| theme | object | |The [theme](#styling) object for passing in styles and color palettes |
|
|
43
|
+
| onUserEvent | function | | A callback for tracking user behavioral data. See [Capturing Data](#capturing-data) for details. |
|
|
41
44
|
| includeCheckout | boolean | `true` | Toggles whether to render the secure checkout. |
|
|
42
45
|
| onAddToCart | function | | The callback fired when a user opts into an offer. See Buddy's Partner API docs for details on how to complete the transaction.|
|
|
43
46
|
| onRemoveCart | function | | The callback fired when a user opts out of the offer. |
|
|
44
|
-
| data | object | | Customer or policy data to pre-load the offer with. Refer to specific ION documentation for the data structure. |
|
|
45
|
-
| theme | object | |The [theme](#styling) object for passing in styles and color palettes |
|
|
46
47
|
_*required_
|
|
47
48
|
|
|
48
49
|
---
|
|
@@ -292,4 +293,251 @@ Some components can be directly modified by accessing their class names in the t
|
|
|
292
293
|
- field-container
|
|
293
294
|
- view-container
|
|
294
295
|
|
|
295
|
-
---
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
## Capturing data
|
|
301
|
+
You can hook any CRM or analytics platform into the Buddy offer-element using the `onUserEvent` hook.
|
|
302
|
+
|
|
303
|
+
`onUserEvent(eventType: string, data: object) ⇒ void`
|
|
304
|
+
|
|
305
|
+
The `onUserEvent` hook property allows you to pass in a custom function to embed your analytics of choice. Simply pass in a callback to the `onUseEvent` option, and you will get the following 2 parameters:
|
|
306
|
+
|
|
307
|
+
- **eventType:** string denoting the type of event that fired (ex: "onViewChange")
|
|
308
|
+
- **data**: object with internal data regarding the event. All data objects include a timestamp property.
|
|
309
|
+
|
|
310
|
+
### Quick example
|
|
311
|
+
|
|
312
|
+
```javascript
|
|
313
|
+
import React from 'react';
|
|
314
|
+
import BuddyOfferElement from '@buddy-technology/offer-component';
|
|
315
|
+
|
|
316
|
+
function App() {
|
|
317
|
+
const handleUserEvent = (payload) => {
|
|
318
|
+
// logs an object with eventType and data to the console
|
|
319
|
+
console.log(payload)
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
return (
|
|
323
|
+
<div id="app">
|
|
324
|
+
<h1>My App</h1>
|
|
325
|
+
<BuddyOfferElement
|
|
326
|
+
ion="MY_ION"
|
|
327
|
+
partnerID="my-partner-id"
|
|
328
|
+
viewType="offer-only"
|
|
329
|
+
onUserEvent={handleUserEvent}
|
|
330
|
+
stage="PRODUCTION"
|
|
331
|
+
/>
|
|
332
|
+
</div>
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
export default App;
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Event types and data fired:
|
|
339
|
+
We capture several user-driven events and each has different available pieces of data associated with it. Look closely at the list below to determine which events you want to capture and how to use the data.
|
|
340
|
+
|
|
341
|
+
##### `onViewChange`
|
|
342
|
+
|
|
343
|
+
Triggers when users click to a new screen in a paginated view mode.
|
|
344
|
+
|
|
345
|
+
_data returned_
|
|
346
|
+
| Name | Type | Description |
|
|
347
|
+
|-----------|--------|---------------------------------------------------------|
|
|
348
|
+
| `viewId` | string | the id of the current view |
|
|
349
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
##### `onScrollToView`
|
|
353
|
+
|
|
354
|
+
Triggers when or scroll to a section in single-page view mode.
|
|
355
|
+
|
|
356
|
+
_data returned_
|
|
357
|
+
|
|
358
|
+
| Name | Type | Description |
|
|
359
|
+
|-----------|--------|---------------------------------------------------------|
|
|
360
|
+
| `viewId` | string | the id of the current view |
|
|
361
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
362
|
+
|
|
363
|
+
##### `onQuote`
|
|
364
|
+
|
|
365
|
+
Triggers when the app displays retrieves a quote for the policy
|
|
366
|
+
|
|
367
|
+
_data returned_
|
|
368
|
+
|
|
369
|
+
| Name | Type | Description |
|
|
370
|
+
|-----------|--------|-----------------------------------------------------------------------------------|
|
|
371
|
+
| `pricing` | number | if successful, the price of the policy |
|
|
372
|
+
| `error` | string | if unsuccessful, a message explaining the type of error encountered when attempting to quote |
|
|
373
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
##### `onCheckout`
|
|
377
|
+
|
|
378
|
+
Triggers during the check out process
|
|
379
|
+
|
|
380
|
+
_data returned_
|
|
381
|
+
|
|
382
|
+
| Name | Type | Description |
|
|
383
|
+
|--------------------|--------|-----------------------------------------------------------------------------------|
|
|
384
|
+
| `checkoutStatus` | enum | one of `['start', 'success', 'error']` |
|
|
385
|
+
| `premium` | number | the total premium of the purchase |
|
|
386
|
+
| `error` | string | if unsuccessful, a message explaining the type of error encountered |
|
|
387
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
##### `onFocus`
|
|
391
|
+
|
|
392
|
+
Triggers when an input is focused
|
|
393
|
+
|
|
394
|
+
_data returned_
|
|
395
|
+
|
|
396
|
+
| Name | Type | Description |
|
|
397
|
+
|------------------|--------|---------------------------------------------------------|
|
|
398
|
+
| `elementId` | string | the id of the invalid field/input |
|
|
399
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
##### `onBlur`
|
|
403
|
+
|
|
404
|
+
Triggers when an input is blurred
|
|
405
|
+
|
|
406
|
+
_data returned_
|
|
407
|
+
|
|
408
|
+
| Name | Type | Description |
|
|
409
|
+
|------------------|--------|---------------------------------------------------------|
|
|
410
|
+
| `elementId` | string | the id of the invalid field/input |
|
|
411
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
412
|
+
|
|
413
|
+
##### `onRadioSelection`
|
|
414
|
+
|
|
415
|
+
Triggers when a radio button is selected
|
|
416
|
+
|
|
417
|
+
_data returned_
|
|
418
|
+
|
|
419
|
+
| Name | Type | Description |
|
|
420
|
+
|-------------|--------|---------------------------------------------------------|
|
|
421
|
+
| `elementId` | string | the id of the invalid field/input |
|
|
422
|
+
| `value` | any | the value of the selected radio |
|
|
423
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
424
|
+
|
|
425
|
+
##### `onSlide`
|
|
426
|
+
|
|
427
|
+
Triggers when a slider input is changed
|
|
428
|
+
|
|
429
|
+
_data returned_
|
|
430
|
+
|
|
431
|
+
| Name | Type | Description |
|
|
432
|
+
|-------------|--------|---------------------------------------------------------|
|
|
433
|
+
| `elementId` | string | the id of the invalid field/input |
|
|
434
|
+
| `value` | any | the value of the selected radio |
|
|
435
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
436
|
+
|
|
437
|
+
##### `onCheckboxSelection`
|
|
438
|
+
|
|
439
|
+
Triggers when a checkbox is selected
|
|
440
|
+
|
|
441
|
+
_data returned_
|
|
442
|
+
|
|
443
|
+
| Name | Type | Description |
|
|
444
|
+
|--------------|---------|---------------------------------------------------------|
|
|
445
|
+
| `elementId` | string | the id of the invalid field/input |
|
|
446
|
+
| `checked` | boolean | whether the box is checked/unchecked |
|
|
447
|
+
| `value` | string | the label of the selected checkbox |
|
|
448
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
449
|
+
|
|
450
|
+
##### `onBlur`
|
|
451
|
+
|
|
452
|
+
Triggers when an input is blurred
|
|
453
|
+
|
|
454
|
+
_data returned_
|
|
455
|
+
|
|
456
|
+
| Name | Type | Description |
|
|
457
|
+
|------------------|--------|---------------------------------------------------------|
|
|
458
|
+
| `elementId` | string | the id of the invalid field/input |
|
|
459
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
460
|
+
|
|
461
|
+
##### `onValidationError`
|
|
462
|
+
|
|
463
|
+
Triggers when an input is triggered as invalid
|
|
464
|
+
|
|
465
|
+
_data returned_
|
|
466
|
+
|
|
467
|
+
| Name | Type | Description |
|
|
468
|
+
|----------------------|--------|---------------------------------------------------------|
|
|
469
|
+
| `elementId` | string | the id of the invalid field/input |
|
|
470
|
+
| `validationError` | string | the type of validation error encountered |
|
|
471
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
472
|
+
|
|
473
|
+
##### `onExternalLink`
|
|
474
|
+
|
|
475
|
+
Triggers when an input is triggered as invalid
|
|
476
|
+
|
|
477
|
+
_data returned_
|
|
478
|
+
|
|
479
|
+
| Name | Type | Description |
|
|
480
|
+
|----------------------|--------|---------------------------------------------------------|
|
|
481
|
+
| `externalLinkUrl` | string | the url of the link |
|
|
482
|
+
| `timestamp` | number | the timestamp when the event occurred in milliseconds |
|
|
483
|
+
|
|
484
|
+
### Google Analytics example
|
|
485
|
+
|
|
486
|
+
```javascript
|
|
487
|
+
import React from 'react';
|
|
488
|
+
import BuddyOfferElement from '@buddy-technology/offer-component';
|
|
489
|
+
|
|
490
|
+
function App() {
|
|
491
|
+
/* This is an example of how you could use these events
|
|
492
|
+
your usage may vary depending on your analytics systems */
|
|
493
|
+
|
|
494
|
+
const handleUserEvent = (e) => {
|
|
495
|
+
// this block shows a condition looking for checkout and success,
|
|
496
|
+
// this is a completed purchase using the GA 'purchase' event for conversion
|
|
497
|
+
if (e.eventType == "onCheckout" && e.data.checkoutStatus == "success") {
|
|
498
|
+
gtag("event", "purchase", {
|
|
499
|
+
transaction_id: e.data.orderID,
|
|
500
|
+
value: e.data.premium,
|
|
501
|
+
items: [{
|
|
502
|
+
item_id: "SKU_12345",
|
|
503
|
+
item_name: '${ion}',
|
|
504
|
+
currency: "USD",
|
|
505
|
+
price: e.data.premium,
|
|
506
|
+
}]
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// This block tracks which views are displayed
|
|
511
|
+
// this is configured to use the built-in GA event 'screen_view'
|
|
512
|
+
if (e.eventType == "onViewChange") {
|
|
513
|
+
gtag('event', 'screen_view', {
|
|
514
|
+
'app_name': 'in-offer-element',
|
|
515
|
+
'screen_name': e.data.viewID
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
// This block tracks when quotes are made
|
|
519
|
+
// This is configured to use a custom event and captures a custom dimension
|
|
520
|
+
if (e.eventType == "onQuote") {
|
|
521
|
+
gtag('event', 'quote', {
|
|
522
|
+
'app_name': 'in-offer-element',
|
|
523
|
+
'price': e.data.pricing,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
return (
|
|
530
|
+
<div id="app">
|
|
531
|
+
<h1>My App</h1>
|
|
532
|
+
<BuddyOfferElement
|
|
533
|
+
ion="MY_ION"
|
|
534
|
+
partnerID="my-partner-id"
|
|
535
|
+
viewType="offer-only"
|
|
536
|
+
onUserEvent={handleUserEvent}
|
|
537
|
+
stage="PRODUCTION"
|
|
538
|
+
/>
|
|
539
|
+
</div>
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
export default App;
|
|
543
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -81,15 +81,38 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
81
81
|
* };
|
|
82
82
|
*/
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @typedef {Object} LogoOverride
|
|
86
|
+
* @property {String} url - destination url when users click the trust badge
|
|
87
|
+
* @property {String} src - src of the img for displaying the trust badge
|
|
88
|
+
* @property {String} [alt] - alt text for trust badge image
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
*@typedef {Object} EventObject
|
|
93
|
+
*@param {string} eventType - the type of user event (eg:'onCheckout')
|
|
94
|
+
*@param {object} data - data object related to the user event.
|
|
95
|
+
*@param {object} data.timestamp - timestamp of the event. All events have a timestamp property.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
*@typedef {Function} OnUserEventCallback
|
|
100
|
+
*@param {EventObject} type - the type of user event (eg:'onCheckout')
|
|
101
|
+
*/
|
|
102
|
+
|
|
84
103
|
/**
|
|
85
104
|
* @typedef {Object} BuddyOfferElementProps
|
|
86
105
|
* @property {String} ion - The ion id for the offering.
|
|
87
106
|
* @property {String} partnerID - The partner ID required for instantiating the Offer
|
|
107
|
+
* @property {String} [stage="STAGING"] - toggle's the environment for the Offer Component. Defaults to STAGING. Must be set to "PRODUCTION" before going live.
|
|
88
108
|
* @property {String} [viewType="paginated"] - establishes how the offer should display to the user. One of: 'paginated', 'single-form' or 'offer-only.'
|
|
109
|
+
* @property {ThemeObject} [theme] - theming object for customizing offer component's styles
|
|
89
110
|
* @property {DataObject} [data] - Any customer or policy data to pre-fill the offer with. Refer to your individual ION for data structure.
|
|
90
|
-
* @property {
|
|
91
|
-
* @property {
|
|
92
|
-
* @property {
|
|
111
|
+
* @property {OnUserEventCallback} [onUserEvent] - callback function for tracking user behavioral data. Triggers on user interactions such as input focus/blur, in-app navigation, etc. Refer to the docs for more details.
|
|
112
|
+
* @property {AddToCartFunction} [onAddToCart] - callback function triggered when users opt into an offer-only offer.
|
|
113
|
+
* @property {RemoveFromCartFunction} [onRemoveFromCart] - callback function triggered when users opt out of an offer-only offer.
|
|
114
|
+
* @property {boolean} [includeCheckout] - toggles whether or not to display the card capture checkout view. Defaults to true. When false, an AddToCart callback must be provided.
|
|
115
|
+
* @property {LogoOverride} [logoOverride] - object for overriding Buddy's trust badge.
|
|
93
116
|
*/
|
|
94
117
|
|
|
95
118
|
/**
|
package/dist/util.js
CHANGED
|
@@ -31,9 +31,14 @@ const SCRIPTS = {
|
|
|
31
31
|
URL: 'http://localhost:8008/index.js',
|
|
32
32
|
REGEX: /^http:\/\/localhost:8008\/index\.js\/?(\?.*)?$/
|
|
33
33
|
},
|
|
34
|
+
// TODO: Delete this in favor of "testing", once we're sure nothing is using it.
|
|
34
35
|
DEVELOPMENT: {
|
|
35
36
|
URL: 'https://js.buddy.insure/v2/dev/index.js',
|
|
36
|
-
REGEX: /^https:\/\/js\.buddy\.insure\/v2\/
|
|
37
|
+
REGEX: /^https:\/\/js\.buddy\.insure\/v2\/dev\/index\.js\/?(\?.*)?$/
|
|
38
|
+
},
|
|
39
|
+
TESTING: {
|
|
40
|
+
URL: 'https://js.buddy.insure/v2/testing/index.js',
|
|
41
|
+
REGEX: /^https:\/\/js\.buddy\.insure\/v2\/testing\/index\.js\/?(\?.*)?$/
|
|
37
42
|
},
|
|
38
43
|
STAGING: {
|
|
39
44
|
URL: 'https://js.buddy.insure/v2/staging/index.js',
|
package/lib/types.d.ts
CHANGED
|
@@ -70,21 +70,54 @@ declare type ThemeObject = {
|
|
|
70
70
|
overrides?: OverridesObject;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @property url - destination url when users click the trust badge
|
|
75
|
+
* @property src - src of the img for displaying the trust badge
|
|
76
|
+
* @property [alt] - alt text for trust badge image
|
|
77
|
+
*/
|
|
78
|
+
declare type LogoOverride = {
|
|
79
|
+
url: string;
|
|
80
|
+
src: string;
|
|
81
|
+
alt?: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param eventType - the type of user event (eg:'onCheckout')
|
|
86
|
+
* @param data - data object related to the user event.
|
|
87
|
+
* @param data.timestamp - timestamp of the event. All events have a timestamp property.
|
|
88
|
+
*/
|
|
89
|
+
declare type EventObject = any;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param type - the type of user event (eg:'onCheckout')
|
|
93
|
+
*/
|
|
94
|
+
declare type OnUserEventCallback = (type: EventObject) => void;
|
|
95
|
+
|
|
73
96
|
/**
|
|
74
97
|
* @property ion - The ion id for the offering.
|
|
75
98
|
* @property partnerID - The partner ID required for instantiating the Offer
|
|
99
|
+
* @property [stage = STAGING] - toggle's the environment for the Offer Component. Defaults to STAGING. Must be set to PRODUCTION before going live.
|
|
76
100
|
* @property [viewType = paginated] - establishes how the offer should display to the user. One of: 'paginated', 'single-form' or 'offer-only.'
|
|
101
|
+
* @property [theme] - theming object for customizing offer component's styles
|
|
77
102
|
* @property [data] - Any customer or policy data to pre-fill the offer with. Refer to your individual ION for data structure.
|
|
78
|
-
* @property [
|
|
103
|
+
* @property [onUserEvent] - callback function for tracking user behavioral data. Triggers on user interactions such as input focus/blur, in-app navigation, etc. Refer to the docs for more details.
|
|
104
|
+
* @property [onAddToCart] - callback function triggered when users opt into an offer-only offer.
|
|
105
|
+
* @property [onRemoveFromCart] - callback function triggered when users opt out of an offer-only offer.
|
|
106
|
+
* @property [includeCheckout] - toggles whether or not to display the card capture checkout view. Defaults to true. When false, an AddToCart callback must be provided.
|
|
107
|
+
* @property [logoOverride] - object for overriding Buddy's trust badge.
|
|
79
108
|
*/
|
|
80
109
|
declare type BuddyOfferElementProps = {
|
|
81
110
|
ion: string;
|
|
82
111
|
partnerID: string;
|
|
112
|
+
stage?: string;
|
|
83
113
|
viewType?: string;
|
|
114
|
+
theme?: ThemeObject;
|
|
84
115
|
data?: DataObject;
|
|
116
|
+
onUserEvent?: OnUserEventCallback;
|
|
85
117
|
onAddToCart?: AddToCartFunction;
|
|
86
118
|
onRemoveFromCart?: RemoveFromCartFunction;
|
|
87
|
-
|
|
119
|
+
includeCheckout?: boolean;
|
|
120
|
+
logoOverride?: LogoOverride;
|
|
88
121
|
};
|
|
89
122
|
|
|
90
123
|
declare function BuddyOfferElement(options: BuddyOfferElementProps): FunctionComponent<BuddyOfferElementProps>;
|