@chordcommerce/analytics 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +86 -0
- package/dist/client/index.d.ts +84 -0
- package/dist/client/index.js +412 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types/client.d.ts +86 -0
- package/dist/types/client.js +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +4 -0
- package/dist/types/input.d.ts +223 -0
- package/dist/types/input.js +1 -0
- package/dist/types/objects.d.ts +379 -0
- package/dist/types/objects.js +1 -0
- package/dist/types/typewriter.d.ts +6502 -0
- package/dist/types/typewriter.js +4 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +21 -0
- package/dist/validators/custom.d.ts +43 -0
- package/dist/validators/custom.js +15 -0
- package/dist/validators/index.d.ts +4 -0
- package/dist/validators/index.js +4 -0
- package/dist/validators/objects.d.ts +693 -0
- package/dist/validators/objects.js +122 -0
- package/dist/validators/tracking-plan-map.d.ts +6386 -0
- package/dist/validators/tracking-plan-map.js +69 -0
- package/dist/validators/tracking-plan.d.ts +8942 -0
- package/dist/validators/tracking-plan.js +1628 -0
- package/package.json +38 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Chord Commerce
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# `@chordcommerce/analytics`
|
|
2
|
+
|
|
3
|
+
The `@chordcommerce/analytics` library provides simple methods for sending tracking events to Chord from your website, with an optional debugging mode to validate event properties.
|
|
4
|
+
|
|
5
|
+
`@chordcommerce/analytics` is intended to be installed alongside a customer data platform (CDP) tracking library like Segment's [analytics.js](https://www.npmjs.com/package/@segment/analytics-next). `@chordcommerce/analytics` sends Chord tracking events to the CDP tracking library, so they’re available for all connected integrations.
|
|
6
|
+
|
|
7
|
+
Visit [docs.chord.co](https://docs.chord.co/analytics-getting-started) for guides, examples, and an API reference.
|
|
8
|
+
|
|
9
|
+
## **Requirements**
|
|
10
|
+
|
|
11
|
+
A CDP Javascript library must be installed in your project. Currently, only Segment's [analytics.js](https://www.npmjs.com/package/@segment/analytics-next) library is supported.
|
|
12
|
+
|
|
13
|
+
## **Installation**
|
|
14
|
+
|
|
15
|
+
To install `@chordcommerce/analytics`, run the following command in your project directory:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @chordcommerce/analytics
|
|
19
|
+
# or
|
|
20
|
+
yarn add @chordcommerce/analytics
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## **Usage**
|
|
24
|
+
|
|
25
|
+
First, ensure that a CDP Javascript library is installed and configured in your project. Then, initialize `@chordcommerce/analytics` as follows:
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
import ChordAnalytics from '@chordcommerce/analytics'
|
|
29
|
+
|
|
30
|
+
const chord = new ChordAnalytics(options) // see below for configuration options
|
|
31
|
+
|
|
32
|
+
chord.trackCartViewed({ cart }) // sends a "Cart Viewed" event to the CDP
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
`@chordcommerce/analytics` can be initialized with the following options:
|
|
38
|
+
|
|
39
|
+
| Property | Required | Description |
|
|
40
|
+
| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `cdp` | true | A reference to the CDP library, or a function that returns a reference to the CDP library. For example, if using Segment's [analytics.js](https://www.npmjs.com/package/@segment/analytics-next) library, this could be `window.analytics` or `() => window.analytics`. If omitted, no tracking events are sent. |
|
|
42
|
+
| `debug` | false | Defaults to `false`. When set to `true`, events are validated against Chord's tracking plan and errors are logged. We recommend enabling this for development and disabling for production. |
|
|
43
|
+
| `enableLogging` | false | Defaults to `true`. When set to `true`, errors are logged using `console.log`. |
|
|
44
|
+
| `formatters` | true | Functions that are used to construct tracking events. There are two types of formatters, objects and events. `formatters.objects` is required. See below for details. |
|
|
45
|
+
| `metadata` | true | Event metadata. See below for details. |
|
|
46
|
+
| `stripNull` | false | Defaults to `true`. When set to `true`, event properties with a `null` value are removed. CDPs typically treat `null` and `undefined` as separate values, so be sure you intend to send `null` values before setting to false. |
|
|
47
|
+
|
|
48
|
+
**Metadata**
|
|
49
|
+
|
|
50
|
+
| Property | Required | Description |
|
|
51
|
+
| ----------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
|
+
| `metadata.i18n.currency` | true | The order currency in ISO 4217 currency code, uppercase. For example, `USD`. |
|
|
53
|
+
| `metadata.i18n.locale` | true | The order locale. For example, `en-US`. |
|
|
54
|
+
| `metadata.ownership.omsId` | true | A UUID assigned by Chord. |
|
|
55
|
+
| `metadata.ownership.storeId` | true | A UUID assigned by Chord. |
|
|
56
|
+
| `metadata.ownership.tenantId` | true | A UUID assigned by Chord. |
|
|
57
|
+
| `metadata.platform.name` | true | The e-commerce platform used. For example, `Shopify`. |
|
|
58
|
+
| `metadata.platform.type` | true | The type of platform where the event originated. Either `web` or `pos`. |
|
|
59
|
+
| `metadata.store.domain` | true | The domain of the site where the event originated. For Shopify, this should be the store slug that comes before `.myshopify.com`. |
|
|
60
|
+
|
|
61
|
+
### **Formatters**
|
|
62
|
+
|
|
63
|
+
Formatters are Javascript functions that are used to construct tracking event properties. There are two types of formatters, objects and events. You must define object formatters. Event formatters are optional. See [Chord’s documentation](https://docs.chord.co/analytics-getting-started#fgWx7) for more details and example formatters.
|
|
64
|
+
|
|
65
|
+
**Object Formatters**
|
|
66
|
+
|
|
67
|
+
A formatter must be provided for each of the four core data types that are used in Chord events. This formatter function transforms input data into the type Chord expects. See [Chord’s documentation](https://docs.chord.co/analytics-getting-started#XhUB5) for more details on object formatters.
|
|
68
|
+
|
|
69
|
+
| Property | Required | Description |
|
|
70
|
+
| ----------------------------- | -------- | ------------------------------------------- |
|
|
71
|
+
| `formatters.objects.cart` | true | A function that creates a cart object. |
|
|
72
|
+
| `formatters.objects.checkout` | true | A function that creates a checkout object. |
|
|
73
|
+
| `formatters.objects.lineItem` | true | A function that creates a line item object. |
|
|
74
|
+
| `formatters.objects.product` | true | A function that creates a product object. |
|
|
75
|
+
|
|
76
|
+
**Event Formatters**
|
|
77
|
+
|
|
78
|
+
A formatter can be provided for each event. This formatter is used to transform the event properties of a specific event after Chord constructs the event, just before it's sent to the CDP. See [Chord’s documentation](https://docs.chord.co/analytics-getting-started#jquZe) for more details on event formatters.
|
|
79
|
+
|
|
80
|
+
## API Reference
|
|
81
|
+
|
|
82
|
+
See [Chord’s documentation](https://docs.chord.co/analytics-getting-started) for a full API reference.
|
|
83
|
+
|
|
84
|
+
## **Support**
|
|
85
|
+
|
|
86
|
+
For support with setup and configuration, please contact Chord directly at **help@chord.co**.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { AnyAnalytics, EventProperties, Options, ValidateResult, ChordAnalyticsOptions, AnyOptions, CartViewedInput, IdentifyTraits, CheckoutStartedInput, EmailCapturedInput, ProductListViewedInput, ProductListFilteredInput, ProductAddedInput, ProductClickedInput, ProductRemovedInput, ProductViewedInput, ProductsSearchedInput, CouponAppliedInput, CouponDeniedInput, CouponEnteredInput, CouponRemovedInput, SignedInInput, SignedOutInput, SignedUpInput } from '../types/index.js';
|
|
2
|
+
export interface ChordAnalyticsSnippet {
|
|
3
|
+
_loadOptions: ChordAnalyticsOptions;
|
|
4
|
+
invoked: boolean;
|
|
5
|
+
methods: string[];
|
|
6
|
+
queue: any[];
|
|
7
|
+
factory: (method: string) => () => ChordAnalytics;
|
|
8
|
+
load: () => void;
|
|
9
|
+
SNIPPET_VERSION: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class ChordAnalytics {
|
|
12
|
+
/**
|
|
13
|
+
* Allows snippet.js to detect whether this library has been initialized yet.
|
|
14
|
+
*/
|
|
15
|
+
initialize: true;
|
|
16
|
+
/**
|
|
17
|
+
* Allows snippet.js to detect whether the snippet has started running yet.
|
|
18
|
+
*/
|
|
19
|
+
invoked: true;
|
|
20
|
+
/**
|
|
21
|
+
* Options for ChordAnalytics.
|
|
22
|
+
*/
|
|
23
|
+
options: ChordAnalyticsOptions;
|
|
24
|
+
constructor(options: ChordAnalyticsOptions);
|
|
25
|
+
cdp: () => AnyAnalytics;
|
|
26
|
+
logger: (message?: any, ...optionalParams: any[]) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Validate the body of a `track` event against the Chord tracking plan.
|
|
29
|
+
*/
|
|
30
|
+
validate: (event: string, props: EventProperties) => ValidateResult[];
|
|
31
|
+
/**
|
|
32
|
+
* Generate the event `meta` property.
|
|
33
|
+
*/
|
|
34
|
+
meta: () => {
|
|
35
|
+
ownership: {
|
|
36
|
+
oms_id: string;
|
|
37
|
+
store_id: string;
|
|
38
|
+
tenant_id: string;
|
|
39
|
+
};
|
|
40
|
+
version: {
|
|
41
|
+
major: number;
|
|
42
|
+
minor: number;
|
|
43
|
+
patch: number;
|
|
44
|
+
};
|
|
45
|
+
i18n: import("../types/client.js").i18nMetadata;
|
|
46
|
+
platform: import("../types/client.js").platformMetadata;
|
|
47
|
+
store: import("../types/client.js").storeMetadata;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Send a `track` event to the CDP with any event name and properties.
|
|
51
|
+
*/
|
|
52
|
+
track: (event: string, props?: EventProperties, options?: Options) => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Send an `identify` event to the CDP with user id and traits.
|
|
55
|
+
*/
|
|
56
|
+
identify: {
|
|
57
|
+
(userId?: string, traits?: IdentifyTraits, options?: AnyOptions): void;
|
|
58
|
+
(traits?: IdentifyTraits, options?: AnyOptions): void;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Send a `page` event to the CDP.
|
|
62
|
+
*/
|
|
63
|
+
page: {
|
|
64
|
+
(): void;
|
|
65
|
+
};
|
|
66
|
+
reset: () => void;
|
|
67
|
+
trackCartViewed: (props: CartViewedInput, options?: AnyOptions) => Promise<void>;
|
|
68
|
+
trackCheckoutStarted: (props: CheckoutStartedInput, options?: AnyOptions) => Promise<void>;
|
|
69
|
+
trackCouponApplied: (props: CouponAppliedInput, options?: AnyOptions) => Promise<void>;
|
|
70
|
+
trackCouponDenied: (props: CouponDeniedInput, options?: AnyOptions) => Promise<void>;
|
|
71
|
+
trackCouponEntered: (props: CouponEnteredInput, options?: AnyOptions) => Promise<void>;
|
|
72
|
+
trackCouponRemoved: (props: CouponRemovedInput, options?: AnyOptions) => Promise<void>;
|
|
73
|
+
trackEmailCaptured: (props: EmailCapturedInput, options?: AnyOptions) => Promise<void>;
|
|
74
|
+
trackProductAdded: (props: ProductAddedInput, options?: AnyOptions) => Promise<void>;
|
|
75
|
+
trackProductClicked: (props: ProductClickedInput, options?: AnyOptions) => Promise<void>;
|
|
76
|
+
trackProductListFiltered: (props: ProductListFilteredInput, options?: AnyOptions) => Promise<void>;
|
|
77
|
+
trackProductListViewed: (props: ProductListViewedInput, options?: AnyOptions) => Promise<void>;
|
|
78
|
+
trackProductRemoved: (props: ProductRemovedInput, options?: AnyOptions) => Promise<void>;
|
|
79
|
+
trackProductViewed: (props: ProductViewedInput, options?: AnyOptions) => Promise<void>;
|
|
80
|
+
trackProductsSearched: (props: ProductsSearchedInput, options?: AnyOptions) => Promise<void>;
|
|
81
|
+
trackSignedIn: (props: SignedInInput, options?: AnyOptions) => Promise<void>;
|
|
82
|
+
trackSignedOut: (props?: SignedOutInput, options?: AnyOptions) => Promise<void>;
|
|
83
|
+
trackSignedUp: (props?: SignedUpInput, options?: AnyOptions) => Promise<void>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { eventSchemas } from '../validators/index.js';
|
|
11
|
+
import { pruneNullValues } from '../utils.js';
|
|
12
|
+
export class ChordAnalytics {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
/**
|
|
15
|
+
* Allows snippet.js to detect whether this library has been initialized yet.
|
|
16
|
+
*/
|
|
17
|
+
this.initialize = true;
|
|
18
|
+
/**
|
|
19
|
+
* Allows snippet.js to detect whether the snippet has started running yet.
|
|
20
|
+
*/
|
|
21
|
+
this.invoked = true;
|
|
22
|
+
/*
|
|
23
|
+
* Return the CDP instance provided in `options.cdp`.
|
|
24
|
+
*/
|
|
25
|
+
this.cdp = () => {
|
|
26
|
+
var _a;
|
|
27
|
+
const a = (_a = this.options) === null || _a === void 0 ? void 0 : _a.cdp;
|
|
28
|
+
if (typeof a === 'function')
|
|
29
|
+
return a();
|
|
30
|
+
return a;
|
|
31
|
+
};
|
|
32
|
+
/*
|
|
33
|
+
* Log a message to the console if `options.enableLogging` is true.
|
|
34
|
+
*/
|
|
35
|
+
this.logger = (message, ...optionalParams) => {
|
|
36
|
+
if (!this.options.enableLogging)
|
|
37
|
+
return;
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
console.log(message, ...optionalParams);
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Validate the body of a `track` event against the Chord tracking plan.
|
|
43
|
+
*/
|
|
44
|
+
this.validate = (event, props) => {
|
|
45
|
+
if (!event) {
|
|
46
|
+
this.logger('No event name provided');
|
|
47
|
+
return [{ success: false }];
|
|
48
|
+
}
|
|
49
|
+
const schema = event && eventSchemas[event];
|
|
50
|
+
if (!schema)
|
|
51
|
+
return [{ success: true, data: props }];
|
|
52
|
+
return schema.map((s) => s.safeParse(props));
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Generate the event `meta` property.
|
|
56
|
+
*/
|
|
57
|
+
this.meta = () => {
|
|
58
|
+
var _a, _b, _c, _d, _e, _f;
|
|
59
|
+
return Object.assign(Object.assign({}, this.options.metadata), { ownership: {
|
|
60
|
+
oms_id: (_b = (_a = this.options.metadata) === null || _a === void 0 ? void 0 : _a.ownership) === null || _b === void 0 ? void 0 : _b.omsId,
|
|
61
|
+
store_id: (_d = (_c = this.options.metadata) === null || _c === void 0 ? void 0 : _c.ownership) === null || _d === void 0 ? void 0 : _d.storeId,
|
|
62
|
+
tenant_id: (_f = (_e = this.options.metadata) === null || _e === void 0 ? void 0 : _e.ownership) === null || _f === void 0 ? void 0 : _f.tenantId,
|
|
63
|
+
}, version: {
|
|
64
|
+
// TODO: make this dynamic
|
|
65
|
+
major: 3,
|
|
66
|
+
minor: 0,
|
|
67
|
+
patch: 0,
|
|
68
|
+
} });
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Send a `track` event to the CDP with any event name and properties.
|
|
72
|
+
*/
|
|
73
|
+
this.track = (event, props, options) => {
|
|
74
|
+
if (!event)
|
|
75
|
+
this.logger('No event name provided');
|
|
76
|
+
const formattedProps = this.options.stripNull && props ? pruneNullValues(props) : props;
|
|
77
|
+
const finalEventProps = Object.assign(Object.assign({}, formattedProps), { meta: this.meta() });
|
|
78
|
+
if (this.options.debug) {
|
|
79
|
+
this.validate(event, finalEventProps).forEach((valid) => {
|
|
80
|
+
if (!valid.success) {
|
|
81
|
+
this.logger('Chord tracking plan violation', valid.error);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return new Promise((resolve) => {
|
|
86
|
+
try {
|
|
87
|
+
const a = this.cdp();
|
|
88
|
+
if (a && typeof a.track === 'function') {
|
|
89
|
+
a.track(event, finalEventProps, options, () => resolve());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.logger(error);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Send an `identify` event to the CDP with user id and traits.
|
|
99
|
+
*/
|
|
100
|
+
this.identify = (...props) => {
|
|
101
|
+
try {
|
|
102
|
+
const a = this.cdp();
|
|
103
|
+
if (a && typeof a.identify === 'function') {
|
|
104
|
+
a.identify(...props);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
this.logger(error);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Send a `page` event to the CDP.
|
|
113
|
+
*/
|
|
114
|
+
this.page = () => {
|
|
115
|
+
try {
|
|
116
|
+
const a = this.cdp();
|
|
117
|
+
if (a && typeof a.page === 'function') {
|
|
118
|
+
a.page({ meta: this.meta() });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
this.logger(error);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
this.reset = () => {
|
|
126
|
+
try {
|
|
127
|
+
const a = this.cdp();
|
|
128
|
+
if (a && typeof a.reset === 'function') {
|
|
129
|
+
a.reset();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
this.logger(error);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
// TODO: Add support for props.products
|
|
137
|
+
this.trackCartViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
139
|
+
const cart = (_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.cart) === null || _d === void 0 ? void 0 : _d.call(_c, {
|
|
140
|
+
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
141
|
+
});
|
|
142
|
+
const payload = {
|
|
143
|
+
cart_id: cart === null || cart === void 0 ? void 0 : cart.cart_id,
|
|
144
|
+
currency: cart === null || cart === void 0 ? void 0 : cart.currency,
|
|
145
|
+
products: cart === null || cart === void 0 ? void 0 : cart.products,
|
|
146
|
+
value: cart === null || cart === void 0 ? void 0 : cart.value,
|
|
147
|
+
};
|
|
148
|
+
if ((_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.formatters) === null || _f === void 0 ? void 0 : _f.events) === null || _g === void 0 ? void 0 : _g.cartViewed) {
|
|
149
|
+
const formattedPayload = (_k = (_j = (_h = this.options) === null || _h === void 0 ? void 0 : _h.formatters) === null || _j === void 0 ? void 0 : _j.events) === null || _k === void 0 ? void 0 : _k.cartViewed(props, payload);
|
|
150
|
+
return this.track('Cart Viewed', formattedPayload, options);
|
|
151
|
+
}
|
|
152
|
+
return this.track('Cart Viewed', payload, options);
|
|
153
|
+
});
|
|
154
|
+
// TODO: Add support for props.products
|
|
155
|
+
this.trackCheckoutStarted = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
var _l, _m, _o, _p, _q, _r, _s;
|
|
157
|
+
const formatter = (_o = (_m = (_l = this.options) === null || _l === void 0 ? void 0 : _l.formatters) === null || _m === void 0 ? void 0 : _m.events) === null || _o === void 0 ? void 0 : _o.checkoutStarted;
|
|
158
|
+
const checkout = (_s = (_r = (_q = (_p = this.options) === null || _p === void 0 ? void 0 : _p.formatters) === null || _q === void 0 ? void 0 : _q.objects) === null || _r === void 0 ? void 0 : _r.checkout) === null || _s === void 0 ? void 0 : _s.call(_r, {
|
|
159
|
+
checkout: props === null || props === void 0 ? void 0 : props.checkout,
|
|
160
|
+
});
|
|
161
|
+
const payload = checkout;
|
|
162
|
+
if (typeof formatter === 'function') {
|
|
163
|
+
const formattedPayload = formatter(props, payload);
|
|
164
|
+
return this.track('Checkout Started', formattedPayload, options);
|
|
165
|
+
}
|
|
166
|
+
return this.track('Checkout Started', payload, options);
|
|
167
|
+
});
|
|
168
|
+
this.trackCouponApplied = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
var _t, _u, _v;
|
|
170
|
+
const formatter = (_v = (_u = (_t = this.options) === null || _t === void 0 ? void 0 : _t.formatters) === null || _u === void 0 ? void 0 : _u.events) === null || _v === void 0 ? void 0 : _v.couponApplied;
|
|
171
|
+
const payload = {
|
|
172
|
+
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
173
|
+
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
174
|
+
coupon_name: props === null || props === void 0 ? void 0 : props.couponName,
|
|
175
|
+
discount: props === null || props === void 0 ? void 0 : props.discount,
|
|
176
|
+
order_id: props === null || props === void 0 ? void 0 : props.orderId,
|
|
177
|
+
};
|
|
178
|
+
if (typeof formatter === 'function') {
|
|
179
|
+
const formattedPayload = formatter(props, payload);
|
|
180
|
+
return this.track('Coupon Applied', formattedPayload, options);
|
|
181
|
+
}
|
|
182
|
+
return this.track('Coupon Applied', payload, options);
|
|
183
|
+
});
|
|
184
|
+
this.trackCouponDenied = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
var _w, _x, _y;
|
|
186
|
+
const formatter = (_y = (_x = (_w = this.options) === null || _w === void 0 ? void 0 : _w.formatters) === null || _x === void 0 ? void 0 : _x.events) === null || _y === void 0 ? void 0 : _y.couponDenied;
|
|
187
|
+
const payload = {
|
|
188
|
+
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
189
|
+
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
190
|
+
coupon_name: props === null || props === void 0 ? void 0 : props.couponName,
|
|
191
|
+
order_id: props === null || props === void 0 ? void 0 : props.orderId,
|
|
192
|
+
reason: props === null || props === void 0 ? void 0 : props.reason,
|
|
193
|
+
};
|
|
194
|
+
if (typeof formatter === 'function') {
|
|
195
|
+
const formattedPayload = formatter(props, payload);
|
|
196
|
+
return this.track('Coupon Denied', formattedPayload, options);
|
|
197
|
+
}
|
|
198
|
+
return this.track('Coupon Denied', payload, options);
|
|
199
|
+
});
|
|
200
|
+
this.trackCouponEntered = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
var _z, _0, _1;
|
|
202
|
+
const formatter = (_1 = (_0 = (_z = this.options) === null || _z === void 0 ? void 0 : _z.formatters) === null || _0 === void 0 ? void 0 : _0.events) === null || _1 === void 0 ? void 0 : _1.couponEntered;
|
|
203
|
+
const payload = {
|
|
204
|
+
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
205
|
+
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
206
|
+
coupon_name: props === null || props === void 0 ? void 0 : props.couponName,
|
|
207
|
+
order_id: props === null || props === void 0 ? void 0 : props.orderId,
|
|
208
|
+
};
|
|
209
|
+
if (typeof formatter === 'function') {
|
|
210
|
+
const formattedPayload = formatter(props, payload);
|
|
211
|
+
return this.track('Coupon Entered', formattedPayload, options);
|
|
212
|
+
}
|
|
213
|
+
return this.track('Coupon Entered', payload, options);
|
|
214
|
+
});
|
|
215
|
+
this.trackCouponRemoved = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
var _2, _3, _4;
|
|
217
|
+
const formatter = (_4 = (_3 = (_2 = this.options) === null || _2 === void 0 ? void 0 : _2.formatters) === null || _3 === void 0 ? void 0 : _3.events) === null || _4 === void 0 ? void 0 : _4.couponRemoved;
|
|
218
|
+
const payload = {
|
|
219
|
+
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
220
|
+
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
221
|
+
coupon_name: props === null || props === void 0 ? void 0 : props.couponName,
|
|
222
|
+
discount: props === null || props === void 0 ? void 0 : props.discount,
|
|
223
|
+
order_id: props === null || props === void 0 ? void 0 : props.orderId,
|
|
224
|
+
};
|
|
225
|
+
if (typeof formatter === 'function') {
|
|
226
|
+
const formattedPayload = formatter(props, payload);
|
|
227
|
+
return this.track('Coupon Removed', formattedPayload, options);
|
|
228
|
+
}
|
|
229
|
+
return this.track('Coupon Removed', payload, options);
|
|
230
|
+
});
|
|
231
|
+
this.trackEmailCaptured = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
var _5, _6, _7;
|
|
233
|
+
const formatter = (_7 = (_6 = (_5 = this.options) === null || _5 === void 0 ? void 0 : _5.formatters) === null || _6 === void 0 ? void 0 : _6.events) === null || _7 === void 0 ? void 0 : _7.emailCaptured;
|
|
234
|
+
const payload = {
|
|
235
|
+
email: props === null || props === void 0 ? void 0 : props.email,
|
|
236
|
+
placement_component: props === null || props === void 0 ? void 0 : props.placementComponent,
|
|
237
|
+
placement_page: props === null || props === void 0 ? void 0 : props.placementPage,
|
|
238
|
+
};
|
|
239
|
+
if (typeof formatter === 'function') {
|
|
240
|
+
const formattedPayload = formatter(props, payload);
|
|
241
|
+
return this.track('Email Captured', formattedPayload, options);
|
|
242
|
+
}
|
|
243
|
+
return this.track('Email Captured', payload, options);
|
|
244
|
+
});
|
|
245
|
+
this.trackProductAdded = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
var _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
247
|
+
const formatter = (_10 = (_9 = (_8 = this.options) === null || _8 === void 0 ? void 0 : _8.formatters) === null || _9 === void 0 ? void 0 : _9.events) === null || _10 === void 0 ? void 0 : _10.productAdded;
|
|
248
|
+
const product = (_14 = (_13 = (_12 = (_11 = this.options) === null || _11 === void 0 ? void 0 : _11.formatters) === null || _12 === void 0 ? void 0 : _12.objects) === null || _13 === void 0 ? void 0 : _13.product) === null || _14 === void 0 ? void 0 : _14.call(_13, props === null || props === void 0 ? void 0 : props.product);
|
|
249
|
+
const cart = (_18 = (_17 = (_16 = (_15 = this.options) === null || _15 === void 0 ? void 0 : _15.formatters) === null || _16 === void 0 ? void 0 : _16.objects) === null || _17 === void 0 ? void 0 : _17.cart) === null || _18 === void 0 ? void 0 : _18.call(_17, {
|
|
250
|
+
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
251
|
+
});
|
|
252
|
+
const quantity = ((_19 = props === null || props === void 0 ? void 0 : props.product) === null || _19 === void 0 ? void 0 : _19.quantity) || 1;
|
|
253
|
+
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, products: [Object.assign(Object.assign({}, product), { quantity })], total: product.price * (quantity || 1), value: product.price * (quantity || 1) });
|
|
254
|
+
if (typeof formatter === 'function') {
|
|
255
|
+
const formattedPayload = formatter(props, payload);
|
|
256
|
+
return this.track('Product Added', formattedPayload, options);
|
|
257
|
+
}
|
|
258
|
+
return this.track('Product Added', payload, options);
|
|
259
|
+
});
|
|
260
|
+
this.trackProductClicked = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
var _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32;
|
|
262
|
+
const formatter = (_22 = (_21 = (_20 = this.options) === null || _20 === void 0 ? void 0 : _20.formatters) === null || _21 === void 0 ? void 0 : _21.events) === null || _22 === void 0 ? void 0 : _22.productClicked;
|
|
263
|
+
const product = (_26 = (_25 = (_24 = (_23 = this.options) === null || _23 === void 0 ? void 0 : _23.formatters) === null || _24 === void 0 ? void 0 : _24.objects) === null || _25 === void 0 ? void 0 : _25.product) === null || _26 === void 0 ? void 0 : _26.call(_25, props === null || props === void 0 ? void 0 : props.product);
|
|
264
|
+
const cart = (_30 = (_29 = (_28 = (_27 = this.options) === null || _27 === void 0 ? void 0 : _27.formatters) === null || _28 === void 0 ? void 0 : _28.objects) === null || _29 === void 0 ? void 0 : _29.cart) === null || _30 === void 0 ? void 0 : _30.call(_29, {
|
|
265
|
+
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
266
|
+
});
|
|
267
|
+
const quantity = ((_31 = props === null || props === void 0 ? void 0 : props.product) === null || _31 === void 0 ? void 0 : _31.quantity) || 1;
|
|
268
|
+
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, item_list_id: (_32 = props === null || props === void 0 ? void 0 : props.listId) === null || _32 === void 0 ? void 0 : _32.toString(), item_list_name: props === null || props === void 0 ? void 0 : props.listName, products: [Object.assign(Object.assign({}, product), { quantity })] });
|
|
269
|
+
if (typeof formatter === 'function') {
|
|
270
|
+
const formattedPayload = formatter(props, payload);
|
|
271
|
+
return this.track('Product Clicked', formattedPayload, options);
|
|
272
|
+
}
|
|
273
|
+
return this.track('Product Clicked', payload, options);
|
|
274
|
+
});
|
|
275
|
+
this.trackProductListFiltered = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
var _33, _34, _35, _36, _37;
|
|
277
|
+
const formatter = (_35 = (_34 = (_33 = this.options) === null || _33 === void 0 ? void 0 : _33.formatters) === null || _34 === void 0 ? void 0 : _34.events) === null || _35 === void 0 ? void 0 : _35.productListFiltered;
|
|
278
|
+
const payload = {
|
|
279
|
+
category: props === null || props === void 0 ? void 0 : props.category,
|
|
280
|
+
filters: props === null || props === void 0 ? void 0 : props.filters,
|
|
281
|
+
list_id: (_36 = props === null || props === void 0 ? void 0 : props.listId) === null || _36 === void 0 ? void 0 : _36.toString(),
|
|
282
|
+
item_list_id: (_37 = props === null || props === void 0 ? void 0 : props.listId) === null || _37 === void 0 ? void 0 : _37.toString(),
|
|
283
|
+
item_list_name: props === null || props === void 0 ? void 0 : props.listName,
|
|
284
|
+
sorts: props === null || props === void 0 ? void 0 : props.sorts,
|
|
285
|
+
};
|
|
286
|
+
if (typeof formatter === 'function') {
|
|
287
|
+
const formattedPayload = formatter(props, payload);
|
|
288
|
+
return this.track('Product List Filtered', formattedPayload, options);
|
|
289
|
+
}
|
|
290
|
+
return this.track('Product List Filtered', payload, options);
|
|
291
|
+
});
|
|
292
|
+
this.trackProductListViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
293
|
+
var _38, _39, _40, _41, _42, _43;
|
|
294
|
+
const formatter = (_40 = (_39 = (_38 = this.options) === null || _38 === void 0 ? void 0 : _38.formatters) === null || _39 === void 0 ? void 0 : _39.events) === null || _40 === void 0 ? void 0 : _40.productListViewed;
|
|
295
|
+
const payload = {
|
|
296
|
+
category: props === null || props === void 0 ? void 0 : props.category,
|
|
297
|
+
list_id: (_41 = props === null || props === void 0 ? void 0 : props.listId) === null || _41 === void 0 ? void 0 : _41.toString(),
|
|
298
|
+
item_list_id: (_42 = props === null || props === void 0 ? void 0 : props.listId) === null || _42 === void 0 ? void 0 : _42.toString(),
|
|
299
|
+
item_list_name: props === null || props === void 0 ? void 0 : props.listName,
|
|
300
|
+
products: (_43 = props === null || props === void 0 ? void 0 : props.products) === null || _43 === void 0 ? void 0 : _43.map((p, i) => {
|
|
301
|
+
var _a, _b, _c, _d;
|
|
302
|
+
return (_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.product) === null || _d === void 0 ? void 0 : _d.call(_c, Object.assign(Object.assign({}, p), { position: i + 1 }));
|
|
303
|
+
}),
|
|
304
|
+
value: 0, // TODO: remove from tracking plan
|
|
305
|
+
};
|
|
306
|
+
if (typeof formatter === 'function') {
|
|
307
|
+
const formattedPayload = formatter(props, payload);
|
|
308
|
+
return this.track('Product List Viewed', formattedPayload, options);
|
|
309
|
+
}
|
|
310
|
+
return this.track('Product List Viewed', payload, options);
|
|
311
|
+
});
|
|
312
|
+
this.trackProductRemoved = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
313
|
+
var _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58;
|
|
314
|
+
const formatter = (_46 = (_45 = (_44 = this.options) === null || _44 === void 0 ? void 0 : _44.formatters) === null || _45 === void 0 ? void 0 : _45.events) === null || _46 === void 0 ? void 0 : _46.productRemoved;
|
|
315
|
+
/*
|
|
316
|
+
const product = this.options?.formatters?.objects?.product?.({
|
|
317
|
+
position: props?.position,
|
|
318
|
+
product: props?.product,
|
|
319
|
+
quantity: props?.quantity,
|
|
320
|
+
variantId: props?.variantId,
|
|
321
|
+
})
|
|
322
|
+
*/
|
|
323
|
+
const lineItem = (_50 = (_49 = (_48 = (_47 = this.options) === null || _47 === void 0 ? void 0 : _47.formatters) === null || _48 === void 0 ? void 0 : _48.objects) === null || _49 === void 0 ? void 0 : _49.lineItem) === null || _50 === void 0 ? void 0 : _50.call(_49, {
|
|
324
|
+
lineItem: props === null || props === void 0 ? void 0 : props.lineItem,
|
|
325
|
+
});
|
|
326
|
+
const cart = (_54 = (_53 = (_52 = (_51 = this.options) === null || _51 === void 0 ? void 0 : _51.formatters) === null || _52 === void 0 ? void 0 : _52.objects) === null || _53 === void 0 ? void 0 : _53.cart) === null || _54 === void 0 ? void 0 : _54.call(_53, {
|
|
327
|
+
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
328
|
+
});
|
|
329
|
+
const payload = Object.assign(Object.assign({}, lineItem), { cart_id: cart.cart_id, currency: cart.currency, products: [lineItem], total: ((_55 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.price) !== null && _55 !== void 0 ? _55 : 0) * ((_56 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.quantity) !== null && _56 !== void 0 ? _56 : 1), value: ((_57 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.price) !== null && _57 !== void 0 ? _57 : 0) * ((_58 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.quantity) !== null && _58 !== void 0 ? _58 : 1) });
|
|
330
|
+
if (typeof formatter === 'function') {
|
|
331
|
+
const formattedPayload = formatter(props, payload);
|
|
332
|
+
return this.track('Product Removed', formattedPayload, options);
|
|
333
|
+
}
|
|
334
|
+
return this.track('Product Removed', payload, options);
|
|
335
|
+
});
|
|
336
|
+
this.trackProductViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
337
|
+
var _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71;
|
|
338
|
+
const formatter = (_61 = (_60 = (_59 = this.options) === null || _59 === void 0 ? void 0 : _59.formatters) === null || _60 === void 0 ? void 0 : _60.events) === null || _61 === void 0 ? void 0 : _61.productViewed;
|
|
339
|
+
const product = (_65 = (_64 = (_63 = (_62 = this.options) === null || _62 === void 0 ? void 0 : _62.formatters) === null || _63 === void 0 ? void 0 : _63.objects) === null || _64 === void 0 ? void 0 : _64.product) === null || _65 === void 0 ? void 0 : _65.call(_64, props === null || props === void 0 ? void 0 : props.product);
|
|
340
|
+
const cart = (_69 = (_68 = (_67 = (_66 = this.options) === null || _66 === void 0 ? void 0 : _66.formatters) === null || _67 === void 0 ? void 0 : _67.objects) === null || _68 === void 0 ? void 0 : _68.cart) === null || _69 === void 0 ? void 0 : _69.call(_68, {
|
|
341
|
+
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
342
|
+
});
|
|
343
|
+
const quantity = ((_70 = props === null || props === void 0 ? void 0 : props.product) === null || _70 === void 0 ? void 0 : _70.quantity) || 1;
|
|
344
|
+
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, products: [Object.assign(Object.assign({}, product), { quantity })], value: product.price * (((_71 = props === null || props === void 0 ? void 0 : props.product) === null || _71 === void 0 ? void 0 : _71.quantity) || 1) });
|
|
345
|
+
if (typeof formatter === 'function') {
|
|
346
|
+
const formattedPayload = formatter(props, payload);
|
|
347
|
+
return this.track('Product Viewed', formattedPayload, options);
|
|
348
|
+
}
|
|
349
|
+
return this.track('Product Viewed', payload, options);
|
|
350
|
+
});
|
|
351
|
+
this.trackProductsSearched = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
352
|
+
var _72, _73, _74, _75;
|
|
353
|
+
const formatter = (_74 = (_73 = (_72 = this.options) === null || _72 === void 0 ? void 0 : _72.formatters) === null || _73 === void 0 ? void 0 : _73.events) === null || _74 === void 0 ? void 0 : _74.productsSearched;
|
|
354
|
+
const payload = {
|
|
355
|
+
currency: props === null || props === void 0 ? void 0 : props.currency,
|
|
356
|
+
price: typeof (props === null || props === void 0 ? void 0 : props.price) !== 'undefined' ? Number(props === null || props === void 0 ? void 0 : props.price) : undefined,
|
|
357
|
+
product_id: (_75 = props === null || props === void 0 ? void 0 : props.productId) === null || _75 === void 0 ? void 0 : _75.toString(),
|
|
358
|
+
quantity: props === null || props === void 0 ? void 0 : props.quantity,
|
|
359
|
+
query: props === null || props === void 0 ? void 0 : props.query,
|
|
360
|
+
};
|
|
361
|
+
if (typeof formatter === 'function') {
|
|
362
|
+
const formattedPayload = formatter(props, payload);
|
|
363
|
+
return this.track('Products Searched', formattedPayload, options);
|
|
364
|
+
}
|
|
365
|
+
return this.track('Products Searched', payload, options);
|
|
366
|
+
});
|
|
367
|
+
this.trackSignedIn = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
368
|
+
var _76, _77, _78;
|
|
369
|
+
const formatter = (_78 = (_77 = (_76 = this.options) === null || _76 === void 0 ? void 0 : _76.formatters) === null || _77 === void 0 ? void 0 : _77.events) === null || _78 === void 0 ? void 0 : _78.signedIn;
|
|
370
|
+
const payload = {
|
|
371
|
+
email: props === null || props === void 0 ? void 0 : props.email,
|
|
372
|
+
method: props === null || props === void 0 ? void 0 : props.method,
|
|
373
|
+
};
|
|
374
|
+
if (typeof formatter === 'function') {
|
|
375
|
+
const formattedPayload = formatter(props, payload);
|
|
376
|
+
return this.track('Signed In', formattedPayload, options);
|
|
377
|
+
}
|
|
378
|
+
return this.track('Signed In', payload, options);
|
|
379
|
+
});
|
|
380
|
+
this.trackSignedOut = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
381
|
+
var _79, _80, _81;
|
|
382
|
+
const formatter = (_81 = (_80 = (_79 = this.options) === null || _79 === void 0 ? void 0 : _79.formatters) === null || _80 === void 0 ? void 0 : _80.events) === null || _81 === void 0 ? void 0 : _81.signedOut;
|
|
383
|
+
const payload = {
|
|
384
|
+
email: props === null || props === void 0 ? void 0 : props.email,
|
|
385
|
+
};
|
|
386
|
+
if (typeof formatter === 'function') {
|
|
387
|
+
const formattedPayload = formatter(props || {}, payload);
|
|
388
|
+
return this.track('Signed Out', formattedPayload, options);
|
|
389
|
+
}
|
|
390
|
+
return this.track('Signed Out', payload, options);
|
|
391
|
+
});
|
|
392
|
+
this.trackSignedUp = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
393
|
+
var _82, _83, _84;
|
|
394
|
+
const formatter = (_84 = (_83 = (_82 = this.options) === null || _82 === void 0 ? void 0 : _82.formatters) === null || _83 === void 0 ? void 0 : _83.events) === null || _84 === void 0 ? void 0 : _84.signedUp;
|
|
395
|
+
const payload = {
|
|
396
|
+
email: props === null || props === void 0 ? void 0 : props.email,
|
|
397
|
+
method: props === null || props === void 0 ? void 0 : props.method,
|
|
398
|
+
};
|
|
399
|
+
if (typeof formatter === 'function') {
|
|
400
|
+
const formattedPayload = formatter(props || {}, payload);
|
|
401
|
+
return this.track('Signed Up', formattedPayload, options);
|
|
402
|
+
}
|
|
403
|
+
return this.track('Signed Up', payload, options);
|
|
404
|
+
});
|
|
405
|
+
const defaults = {
|
|
406
|
+
debug: false,
|
|
407
|
+
enableLogging: true,
|
|
408
|
+
stripNull: true,
|
|
409
|
+
};
|
|
410
|
+
this.options = Object.assign(Object.assign({}, defaults), options);
|
|
411
|
+
}
|
|
412
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED