@chordcommerce/analytics 1.5.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -6
- package/dist/client/index.d.ts +12 -12
- package/dist/types/client.d.ts +9 -31
- package/dist/types/formatters.d.ts +86 -0
- package/dist/types/formatters.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/input.d.ts +27 -27
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @chordcommerce/analytics
|
|
2
2
|
|
|
3
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
4
|
|
|
@@ -6,11 +6,11 @@ The `@chordcommerce/analytics` library provides simple methods for sending track
|
|
|
6
6
|
|
|
7
7
|
Visit [docs.chord.co](https://docs.chord.co/analytics-getting-started) for guides, examples, and an API reference.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Requirements
|
|
10
10
|
|
|
11
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
12
|
|
|
13
|
-
##
|
|
13
|
+
## Installation
|
|
14
14
|
|
|
15
15
|
To install `@chordcommerce/analytics`, run the following command in your project directory:
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ npm install @chordcommerce/analytics
|
|
|
20
20
|
yarn add @chordcommerce/analytics
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## Usage
|
|
24
24
|
|
|
25
25
|
First, ensure that a CDP Javascript library is installed and configured in your project. Then, initialize `@chordcommerce/analytics` as follows:
|
|
26
26
|
|
|
@@ -58,7 +58,7 @@ chord.trackCartViewed({ cart }) // sends a "Cart Viewed" event to the CDP
|
|
|
58
58
|
| `metadata.platform.type` | true | The type of platform where the event originated. Either `web` or `pos`. |
|
|
59
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
60
|
|
|
61
|
-
###
|
|
61
|
+
### Formatters
|
|
62
62
|
|
|
63
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
64
|
|
|
@@ -77,10 +77,40 @@ A formatter must be provided for each of the four core data types that are used
|
|
|
77
77
|
|
|
78
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
79
|
|
|
80
|
+
## Using with Typescript
|
|
81
|
+
|
|
82
|
+
Optionally, you can instantiate `ChordAnalytics` with a custom type argument describing your data to improve type safety for formatters and SDK functions.
|
|
83
|
+
|
|
84
|
+
For instance, if you're working with objects like `cart`, `product`, etc., from a Shopify storefront API query, you might already have types like `StorefrontCart` defined for the response. Instantiate `ChordAnalytics` with a type argument:
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
interface ObjectTypes {
|
|
88
|
+
Cart: StorefrontCart
|
|
89
|
+
Checkout: StorefrontCart
|
|
90
|
+
LineItem: StorefrontLineItem
|
|
91
|
+
Product: StorefrontProduct
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const chord = new ChordAnalytics<ObjectTypes>({ options })
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Now, when you use an SDK method like `chord.trackCartViewed({ cart })`, `cart` has the `StorefrontCart` type.
|
|
98
|
+
|
|
99
|
+
Formatter types also support an optional generic type parameter for the function argument:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import type { CartFormatter } from '@chordcommerce/analytics'
|
|
103
|
+
|
|
104
|
+
export const cartFormatter: CartFormatter<StorefrontCart> = (props) => {
|
|
105
|
+
const { cart } = props // `cart` has type `StorefrontCart`
|
|
106
|
+
return { ... }
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
80
110
|
## API Reference
|
|
81
111
|
|
|
82
112
|
See [Chord’s documentation](https://docs.chord.co/analytics-getting-started) for a full API reference.
|
|
83
113
|
|
|
84
|
-
##
|
|
114
|
+
## Support
|
|
85
115
|
|
|
86
116
|
For support with setup and configuration, please contact Chord directly at **help@chord.co**.
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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';
|
|
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, ObjectTypes } from '../types/index.js';
|
|
2
2
|
export interface ChordAnalyticsSnippet {
|
|
3
|
-
_loadOptions: ChordAnalyticsOptions
|
|
3
|
+
_loadOptions: ChordAnalyticsOptions<ObjectTypes>;
|
|
4
4
|
invoked: boolean;
|
|
5
5
|
methods: string[];
|
|
6
6
|
queue: any[];
|
|
@@ -8,7 +8,7 @@ export interface ChordAnalyticsSnippet {
|
|
|
8
8
|
load: () => void;
|
|
9
9
|
SNIPPET_VERSION: string;
|
|
10
10
|
}
|
|
11
|
-
export declare class ChordAnalytics {
|
|
11
|
+
export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
12
12
|
/**
|
|
13
13
|
* Allows snippet.js to detect whether this library has been initialized yet.
|
|
14
14
|
*/
|
|
@@ -20,8 +20,8 @@ export declare class ChordAnalytics {
|
|
|
20
20
|
/**
|
|
21
21
|
* Options for ChordAnalytics.
|
|
22
22
|
*/
|
|
23
|
-
options: ChordAnalyticsOptions
|
|
24
|
-
constructor(options: ChordAnalyticsOptions);
|
|
23
|
+
options: ChordAnalyticsOptions<T>;
|
|
24
|
+
constructor(options: ChordAnalyticsOptions<T>);
|
|
25
25
|
cdp: () => AnyAnalytics;
|
|
26
26
|
logger: (message?: any, ...optionalParams: any[]) => void;
|
|
27
27
|
/**
|
|
@@ -64,19 +64,19 @@ export declare class ChordAnalytics {
|
|
|
64
64
|
(): void;
|
|
65
65
|
};
|
|
66
66
|
reset: () => void;
|
|
67
|
-
trackCartViewed: (props: CartViewedInput
|
|
68
|
-
trackCheckoutStarted: (props: CheckoutStartedInput
|
|
67
|
+
trackCartViewed: (props: CartViewedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
68
|
+
trackCheckoutStarted: (props: CheckoutStartedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
69
69
|
trackCouponApplied: (props: CouponAppliedInput, options?: AnyOptions) => Promise<void>;
|
|
70
70
|
trackCouponDenied: (props: CouponDeniedInput, options?: AnyOptions) => Promise<void>;
|
|
71
71
|
trackCouponEntered: (props: CouponEnteredInput, options?: AnyOptions) => Promise<void>;
|
|
72
72
|
trackCouponRemoved: (props: CouponRemovedInput, options?: AnyOptions) => Promise<void>;
|
|
73
73
|
trackEmailCaptured: (props: EmailCapturedInput, options?: AnyOptions) => Promise<void>;
|
|
74
|
-
trackProductAdded: (props: ProductAddedInput
|
|
75
|
-
trackProductClicked: (props: ProductClickedInput
|
|
74
|
+
trackProductAdded: (props: ProductAddedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
75
|
+
trackProductClicked: (props: ProductClickedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
76
76
|
trackProductListFiltered: (props: ProductListFilteredInput, options?: AnyOptions) => Promise<void>;
|
|
77
|
-
trackProductListViewed: (props: ProductListViewedInput
|
|
78
|
-
trackProductRemoved: (props: ProductRemovedInput
|
|
79
|
-
trackProductViewed: (props: ProductViewedInput
|
|
77
|
+
trackProductListViewed: (props: ProductListViewedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
78
|
+
trackProductRemoved: (props: ProductRemovedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
79
|
+
trackProductViewed: (props: ProductViewedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
80
80
|
trackProductsSearched: (props: ProductsSearchedInput, options?: AnyOptions) => Promise<void>;
|
|
81
81
|
trackSignedIn: (props: SignedInInput, options?: AnyOptions) => Promise<void>;
|
|
82
82
|
trackSignedOut: (props?: SignedOutInput, options?: AnyOptions) => Promise<void>;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { AnalyticsSnippet, Analytics, AnalyticsBrowser, Options } from '@segment/analytics-next';
|
|
2
|
-
import
|
|
3
|
-
import type { CartViewed, CheckoutStarted, CouponApplied, CouponDenied, CouponEntered, CouponRemoved, EmailCaptured, ProductAdded, ProductClicked, ProductListFiltered, ProductListViewed, ProductRemoved, ProductViewed, ProductsSearched, SignedIn, SignedOut, SignedUp } from './typewriter.js';
|
|
4
|
-
import type { CartViewedInput, CheckoutStartedInput, EmailCapturedInput, ProductAddedInput, ProductClickedInput, ProductListFilteredInput, ProductListViewedInput, ProductRemovedInput, ProductViewedInput, ProductsSearchedInput, ProductInput, CartInput, CheckoutInput, LineItemInput, CouponAppliedInput, CouponDeniedInput, CouponEnteredInput, CouponRemovedInput, SignedInInput, SignedOutInput, SignedUpInput } from './input.js';
|
|
2
|
+
import { ChordAnalyticsFormatters } from './formatters.js';
|
|
5
3
|
export interface ValidateResult {
|
|
6
4
|
success: boolean;
|
|
7
5
|
error?: any[];
|
|
8
6
|
data?: any;
|
|
9
7
|
}
|
|
8
|
+
export interface ObjectTypes {
|
|
9
|
+
Cart: any;
|
|
10
|
+
Checkout: any;
|
|
11
|
+
LineItem: any;
|
|
12
|
+
Product: any;
|
|
13
|
+
}
|
|
10
14
|
export type AnyAnalytics = AnalyticsSnippet | Analytics | AnalyticsBrowser;
|
|
11
15
|
export type AnyOptions = Options;
|
|
12
16
|
export type AnyProduct = {
|
|
@@ -22,37 +26,11 @@ export type AnyId = string | number;
|
|
|
22
26
|
export type AnyLineItem = {
|
|
23
27
|
[key: string]: unknown;
|
|
24
28
|
};
|
|
25
|
-
export interface ChordAnalyticsOptions {
|
|
29
|
+
export interface ChordAnalyticsOptions<T extends ObjectTypes = ObjectTypes> {
|
|
26
30
|
cdp?: AnyAnalytics | (() => AnyAnalytics);
|
|
27
31
|
debug?: boolean;
|
|
28
32
|
enableLogging?: boolean;
|
|
29
|
-
formatters:
|
|
30
|
-
events?: {
|
|
31
|
-
cartViewed?: (props: CartViewedInput, event: CartViewed) => CartViewed;
|
|
32
|
-
checkoutStarted?: (props: CheckoutStartedInput, event: CheckoutStarted) => CheckoutStarted;
|
|
33
|
-
couponApplied?: (props: CouponAppliedInput, event: CouponApplied) => CouponApplied;
|
|
34
|
-
couponDenied?: (props: CouponDeniedInput, event: CouponDenied) => CouponDenied;
|
|
35
|
-
couponEntered?: (props: CouponEnteredInput, event: CouponEntered) => CouponEntered;
|
|
36
|
-
couponRemoved?: (props: CouponRemovedInput, event: CouponRemoved) => CouponRemoved;
|
|
37
|
-
emailCaptured?: (props: EmailCapturedInput, event: EmailCaptured) => EmailCaptured;
|
|
38
|
-
productAdded?: (props: ProductAddedInput, event: ProductAdded) => ProductAdded;
|
|
39
|
-
productClicked?: (props: ProductClickedInput, event: ProductClicked) => ProductClicked;
|
|
40
|
-
productListFiltered?: (props: ProductListFilteredInput, event: ProductListFiltered) => ProductListFiltered;
|
|
41
|
-
productListViewed?: (props: ProductListViewedInput, event: ProductListViewed) => ProductListViewed;
|
|
42
|
-
productRemoved?: (props: ProductRemovedInput, event: ProductRemoved) => ProductRemoved;
|
|
43
|
-
productViewed?: (props: ProductViewedInput, event: ProductViewed) => ProductViewed;
|
|
44
|
-
productsSearched?: (props: ProductsSearchedInput, event: ProductsSearched) => ProductsSearched;
|
|
45
|
-
signedIn?: (props: SignedInInput, event: SignedIn) => SignedIn;
|
|
46
|
-
signedOut?: (props: SignedOutInput, event: SignedOut) => SignedOut;
|
|
47
|
-
signedUp?: (props: SignedUpInput, event: SignedUp) => SignedUp;
|
|
48
|
-
};
|
|
49
|
-
objects: {
|
|
50
|
-
cart: (props: CartInput) => Cart;
|
|
51
|
-
checkout: (props: CheckoutInput) => Checkout;
|
|
52
|
-
lineItem: (props: LineItemInput) => LineItem;
|
|
53
|
-
product: (props: ProductInput) => Product;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
33
|
+
formatters: ChordAnalyticsFormatters<T>;
|
|
56
34
|
stripNull?: boolean;
|
|
57
35
|
metadata: EventMetadata;
|
|
58
36
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { CartViewed, CheckoutStarted, ProductAdded, ProductClicked, ProductViewed, ProductListViewed, CouponApplied, CouponDenied, CouponEntered, CouponRemoved, EmailCaptured, ProductListFiltered, ProductRemoved, ProductsSearched, SignedIn, SignedOut, SignedUp } from './typewriter.js';
|
|
2
|
+
import type { Cart, Checkout, LineItem, Product } from './objects.js';
|
|
3
|
+
import type { CartInput, CheckoutInput, LineItemInput, ProductInput, CartViewedInput, CheckoutStartedInput, ProductAddedInput, ProductClickedInput, ProductViewedInput, ProductListViewedInput, ProductListFilteredInput, ProductRemovedInput, CouponAppliedInput, CouponDeniedInput, CouponEnteredInput, CouponRemovedInput, EmailCapturedInput, ProductsSearchedInput, SignedInInput, SignedOutInput, SignedUpInput } from './input.js';
|
|
4
|
+
import type { ObjectTypes } from './client.js';
|
|
5
|
+
export type CartFormatter<T = ObjectTypes['Cart']> = (props: CartInput<T>) => Cart;
|
|
6
|
+
export type CheckoutFormatter<T = ObjectTypes['Checkout']> = (props: CheckoutInput<T>) => Checkout;
|
|
7
|
+
export type LineItemFormatter<T = ObjectTypes['LineItem']> = (props: LineItemInput<T>) => LineItem;
|
|
8
|
+
export type ProductFormatter<T = ObjectTypes['Product']> = (props: ProductInput<T>) => Product;
|
|
9
|
+
export interface CartViewedFormatter<T extends ObjectTypes = ObjectTypes> {
|
|
10
|
+
(props: CartViewedInput<T>, event: CartViewed): CartViewed;
|
|
11
|
+
}
|
|
12
|
+
export interface CheckoutStartedFormatter<T extends ObjectTypes = ObjectTypes> {
|
|
13
|
+
(props: CheckoutStartedInput<T>, event: CheckoutStarted): CheckoutStarted;
|
|
14
|
+
}
|
|
15
|
+
export interface CouponAppliedFormatter {
|
|
16
|
+
(props: CouponAppliedInput, event: CouponApplied): CouponApplied;
|
|
17
|
+
}
|
|
18
|
+
export interface CouponDeniedFormatter {
|
|
19
|
+
(props: CouponDeniedInput, event: CouponDenied): CouponDenied;
|
|
20
|
+
}
|
|
21
|
+
export interface CouponEnteredFormatter {
|
|
22
|
+
(props: CouponEnteredInput, event: CouponEntered): CouponEntered;
|
|
23
|
+
}
|
|
24
|
+
export interface CouponRemovedFormatter {
|
|
25
|
+
(props: CouponRemovedInput, event: CouponRemoved): CouponRemoved;
|
|
26
|
+
}
|
|
27
|
+
export interface EmailCapturedFormatter {
|
|
28
|
+
(props: EmailCapturedInput, event: EmailCaptured): EmailCaptured;
|
|
29
|
+
}
|
|
30
|
+
export interface ProductAddedFormatter<T extends ObjectTypes = ObjectTypes> {
|
|
31
|
+
(props: ProductAddedInput<T>, event: ProductAdded): ProductAdded;
|
|
32
|
+
}
|
|
33
|
+
export interface ProductClickedFormatter<T extends ObjectTypes = ObjectTypes> {
|
|
34
|
+
(props: ProductClickedInput<T>, event: ProductClicked): ProductClicked;
|
|
35
|
+
}
|
|
36
|
+
export interface ProductListFilteredFormatter {
|
|
37
|
+
(props: ProductListFilteredInput, event: ProductListFiltered): ProductListFiltered;
|
|
38
|
+
}
|
|
39
|
+
export interface ProductListViewedFormatter<T extends ObjectTypes = ObjectTypes> {
|
|
40
|
+
(props: ProductListViewedInput<T>, event: ProductListViewed): ProductListViewed;
|
|
41
|
+
}
|
|
42
|
+
export interface ProductRemovedFormatter<T extends ObjectTypes = ObjectTypes> {
|
|
43
|
+
(props: ProductRemovedInput<T>, event: ProductRemoved): ProductRemoved;
|
|
44
|
+
}
|
|
45
|
+
export interface ProductViewedFormatter<T extends ObjectTypes = ObjectTypes> {
|
|
46
|
+
(props: ProductViewedInput<T>, event: ProductViewed): ProductViewed;
|
|
47
|
+
}
|
|
48
|
+
export interface ProductsSearchedFormatter {
|
|
49
|
+
(props: ProductsSearchedInput, event: ProductsSearched): ProductsSearched;
|
|
50
|
+
}
|
|
51
|
+
export interface SignedInFormatter {
|
|
52
|
+
(props: SignedInInput, event: SignedIn): SignedIn;
|
|
53
|
+
}
|
|
54
|
+
export interface SignedOutFormatter {
|
|
55
|
+
(props: SignedOutInput, event: SignedOut): SignedOut;
|
|
56
|
+
}
|
|
57
|
+
export interface SignedUpFormatter {
|
|
58
|
+
(props: SignedUpInput, event: SignedUp): SignedUp;
|
|
59
|
+
}
|
|
60
|
+
export interface ChordAnalyticsFormatters<T extends ObjectTypes = ObjectTypes> {
|
|
61
|
+
events?: {
|
|
62
|
+
cartViewed?: CartViewedFormatter<T>;
|
|
63
|
+
checkoutStarted?: CheckoutStartedFormatter<T>;
|
|
64
|
+
couponApplied?: CouponAppliedFormatter;
|
|
65
|
+
couponDenied?: CouponDeniedFormatter;
|
|
66
|
+
couponEntered?: CouponEnteredFormatter;
|
|
67
|
+
couponRemoved?: CouponRemovedFormatter;
|
|
68
|
+
emailCaptured?: EmailCapturedFormatter;
|
|
69
|
+
productAdded?: ProductAddedFormatter<T>;
|
|
70
|
+
productClicked?: ProductClickedFormatter<T>;
|
|
71
|
+
productListFiltered?: ProductListFilteredFormatter;
|
|
72
|
+
productListViewed?: ProductListViewedFormatter<T>;
|
|
73
|
+
productRemoved?: ProductRemovedFormatter<T>;
|
|
74
|
+
productViewed?: ProductViewedFormatter<T>;
|
|
75
|
+
productsSearched?: ProductsSearchedFormatter;
|
|
76
|
+
signedIn?: SignedInFormatter;
|
|
77
|
+
signedOut?: SignedOutFormatter;
|
|
78
|
+
signedUp?: SignedUpFormatter;
|
|
79
|
+
};
|
|
80
|
+
objects: {
|
|
81
|
+
cart: CartFormatter<T['Cart']>;
|
|
82
|
+
checkout: CheckoutFormatter<T['Checkout']>;
|
|
83
|
+
lineItem: LineItemFormatter<T['LineItem']>;
|
|
84
|
+
product: ProductFormatter<T['Product']>;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/dist/types/input.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyId, ObjectTypes } from './client.js';
|
|
2
2
|
import type { Filter, Sort } from './typewriter.js';
|
|
3
|
-
export interface ProductInput {
|
|
3
|
+
export interface ProductInput<ProductType extends ObjectTypes['Product'] = ObjectTypes['Product']> {
|
|
4
4
|
/**
|
|
5
5
|
* The position in a list of the product that was added, if relevant.
|
|
6
6
|
*/
|
|
@@ -8,7 +8,7 @@ export interface ProductInput {
|
|
|
8
8
|
/**
|
|
9
9
|
* Product and variant details, like product name and variant SKUs.
|
|
10
10
|
*/
|
|
11
|
-
product:
|
|
11
|
+
product: ProductType;
|
|
12
12
|
/**
|
|
13
13
|
* The quantity of the product involved in the tracking event. Sometimes quantity might
|
|
14
14
|
* not be relevant to an event, and can be either omitted or defaulted to `1`.
|
|
@@ -22,35 +22,35 @@ export interface ProductInput {
|
|
|
22
22
|
*/
|
|
23
23
|
variantId?: AnyId;
|
|
24
24
|
}
|
|
25
|
-
export interface CartInput {
|
|
25
|
+
export interface CartInput<CartType extends ObjectTypes['Cart'] = ObjectTypes['Cart']> {
|
|
26
26
|
/**
|
|
27
27
|
* The current cart.
|
|
28
28
|
*/
|
|
29
|
-
cart:
|
|
29
|
+
cart: CartType;
|
|
30
30
|
}
|
|
31
|
-
export interface CheckoutInput {
|
|
31
|
+
export interface CheckoutInput<CheckoutType extends ObjectTypes['Checkout'] = ObjectTypes['Checkout']> {
|
|
32
32
|
/**
|
|
33
33
|
* The current checkout.
|
|
34
34
|
*/
|
|
35
|
-
checkout:
|
|
35
|
+
checkout: CheckoutType;
|
|
36
36
|
}
|
|
37
|
-
export interface LineItemInput {
|
|
37
|
+
export interface LineItemInput<LineItemType extends ObjectTypes['LineItem'] = ObjectTypes['LineItem']> {
|
|
38
38
|
/**
|
|
39
39
|
* The line item before it was removed.
|
|
40
40
|
*/
|
|
41
|
-
lineItem:
|
|
41
|
+
lineItem: LineItemType;
|
|
42
42
|
}
|
|
43
|
-
export interface CartViewedInput {
|
|
43
|
+
export interface CartViewedInput<T extends ObjectTypes = ObjectTypes> {
|
|
44
44
|
/**
|
|
45
45
|
* The current cart.
|
|
46
46
|
*/
|
|
47
|
-
cart:
|
|
47
|
+
cart: T['Cart'];
|
|
48
48
|
}
|
|
49
|
-
export interface CheckoutStartedInput {
|
|
49
|
+
export interface CheckoutStartedInput<T extends ObjectTypes = ObjectTypes> {
|
|
50
50
|
/**
|
|
51
51
|
* The current checkout.
|
|
52
52
|
*/
|
|
53
|
-
checkout:
|
|
53
|
+
checkout: T['Checkout'];
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Coupon was applied on a user's shopping cart or order
|
|
@@ -154,21 +154,21 @@ export interface EmailCapturedInput {
|
|
|
154
154
|
placementComponent?: string;
|
|
155
155
|
placementPage?: string;
|
|
156
156
|
}
|
|
157
|
-
export interface ProductAddedInput {
|
|
157
|
+
export interface ProductAddedInput<T extends ObjectTypes = ObjectTypes> {
|
|
158
158
|
/**
|
|
159
159
|
* The current cart, after the product is added.
|
|
160
160
|
*/
|
|
161
|
-
cart:
|
|
162
|
-
product: ProductInput
|
|
161
|
+
cart: T['Cart'];
|
|
162
|
+
product: ProductInput<T['Product']>;
|
|
163
163
|
}
|
|
164
|
-
export interface ProductClickedInput {
|
|
164
|
+
export interface ProductClickedInput<T extends ObjectTypes = ObjectTypes> {
|
|
165
165
|
/**
|
|
166
166
|
* The current cart.
|
|
167
167
|
*/
|
|
168
|
-
cart:
|
|
168
|
+
cart: T['Cart'];
|
|
169
169
|
listId?: AnyId;
|
|
170
170
|
listName?: string;
|
|
171
|
-
product: ProductInput
|
|
171
|
+
product: ProductInput<T['Product']>;
|
|
172
172
|
}
|
|
173
173
|
export interface ProductListFilteredInput {
|
|
174
174
|
category?: string;
|
|
@@ -177,31 +177,31 @@ export interface ProductListFilteredInput {
|
|
|
177
177
|
filters?: Filter[];
|
|
178
178
|
sorts?: Sort[];
|
|
179
179
|
}
|
|
180
|
-
export interface ProductListViewedInput {
|
|
180
|
+
export interface ProductListViewedInput<T extends ObjectTypes = ObjectTypes> {
|
|
181
181
|
category?: string;
|
|
182
182
|
listId?: string;
|
|
183
183
|
listName?: string;
|
|
184
|
-
products: ProductInput[];
|
|
184
|
+
products: ProductInput<T['Product']>[];
|
|
185
185
|
}
|
|
186
|
-
export interface ProductRemovedInput {
|
|
186
|
+
export interface ProductRemovedInput<T extends ObjectTypes = ObjectTypes> {
|
|
187
187
|
/**
|
|
188
188
|
* The current cart.
|
|
189
189
|
*/
|
|
190
|
-
cart:
|
|
190
|
+
cart: T['Cart'];
|
|
191
191
|
/**
|
|
192
192
|
* The line item before it was removed.
|
|
193
193
|
*/
|
|
194
|
-
lineItem:
|
|
194
|
+
lineItem: T['LineItem'];
|
|
195
195
|
}
|
|
196
|
-
export interface ProductViewedInput {
|
|
196
|
+
export interface ProductViewedInput<T extends ObjectTypes = ObjectTypes> {
|
|
197
197
|
/**
|
|
198
198
|
* The current cart.
|
|
199
199
|
*/
|
|
200
|
-
cart:
|
|
200
|
+
cart: T['Cart'];
|
|
201
201
|
/**
|
|
202
202
|
* The product being viewed.
|
|
203
203
|
*/
|
|
204
|
-
product: ProductInput
|
|
204
|
+
product: ProductInput<T['Product']>;
|
|
205
205
|
}
|
|
206
206
|
export interface ProductsSearchedInput {
|
|
207
207
|
currency?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chordcommerce/analytics",
|
|
3
3
|
"description": "Chord Commerce event tracking",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.7.0",
|
|
5
5
|
"author": "Chord Commerce <help@chord.co> (https://www.chord.co)",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"zod": "^3.22.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@chordcommerce/eslint-config": "^1.0.1",
|
|
31
30
|
"@types/jest": "^29.5.11",
|
|
32
31
|
"jest": "^29.7.0",
|
|
33
32
|
"jest-environment-jsdom": "^29.7.0",
|