@chordcommerce/analytics 1.7.0 → 1.9.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.
@@ -11,7 +11,7 @@ export interface ObjectTypes {
11
11
  LineItem: any;
12
12
  Product: any;
13
13
  }
14
- export type AnyAnalytics = AnalyticsSnippet | Analytics | AnalyticsBrowser;
14
+ export type AnyAnalytics = AnalyticsSnippet | Analytics | AnalyticsBrowser | ChordAnalyticsQueue;
15
15
  export type AnyOptions = Options;
16
16
  export type AnyProduct = {
17
17
  [key: string]: unknown;
@@ -28,9 +28,12 @@ export type AnyLineItem = {
28
28
  };
29
29
  export interface ChordAnalyticsOptions<T extends ObjectTypes = ObjectTypes> {
30
30
  cdp?: AnyAnalytics | (() => AnyAnalytics);
31
+ cdpDomain?: string;
32
+ cdpWriteKey?: string;
31
33
  debug?: boolean;
32
34
  enableLogging?: boolean;
33
35
  formatters: ChordAnalyticsFormatters<T>;
36
+ namespace?: string;
34
37
  stripNull?: boolean;
35
38
  metadata: EventMetadata;
36
39
  }
@@ -62,3 +65,9 @@ export interface versionMetadata {
62
65
  export interface storeMetadata {
63
66
  domain: string;
64
67
  }
68
+ export type ChordAnalyticsQueue = {
69
+ track: (...args: any[]) => void;
70
+ identify: (...args: any[]) => void;
71
+ page: (...args: any[]) => void;
72
+ reset: (...args: any[]) => void;
73
+ };
@@ -1,6 +1,6 @@
1
- import type { CartViewed, CheckoutStarted, ProductAdded, ProductClicked, ProductViewed, ProductListViewed, CouponApplied, CouponDenied, CouponEntered, CouponRemoved, EmailCaptured, ProductListFiltered, ProductRemoved, ProductsSearched, SignedIn, SignedOut, SignedUp } from './typewriter.js';
1
+ import type { CartViewed, CheckoutStarted, CheckoutStepCompleted, CheckoutStepViewed, ProductAdded, ProductClicked, VariantClicked, ProductViewed, ProductListViewed, CouponApplied, CouponDenied, CouponEntered, CouponRemoved, EmailCaptured, ProductListFiltered, ProductRemoved, ProductsSearched, SignedIn, SignedOut, SignedUp, LoginStarted, SubscriptionCancelled, NavigationClicked, PaymentInfoEntered } from './typewriter.js';
2
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';
3
+ import type { CartInput, CheckoutInput, CheckoutStepCompletedInput, CheckoutStepViewedInput, LineItemInput, ProductInput, CartViewedInput, CheckoutStartedInput, ProductAddedInput, ProductClickedInput, VariantClickedInput, ProductViewedInput, ProductListViewedInput, ProductListFilteredInput, ProductRemovedInput, CouponAppliedInput, CouponDeniedInput, CouponEnteredInput, CouponRemovedInput, EmailCapturedInput, ProductsSearchedInput, SignedInInput, SignedOutInput, SignedUpInput, LoginStartedInput, SubscriptionCancelledInput, NavigationClickedInput, PaymentInfoEnteredInput } from './input.js';
4
4
  import type { ObjectTypes } from './client.js';
5
5
  export type CartFormatter<T = ObjectTypes['Cart']> = (props: CartInput<T>) => Cart;
6
6
  export type CheckoutFormatter<T = ObjectTypes['Checkout']> = (props: CheckoutInput<T>) => Checkout;
@@ -12,6 +12,12 @@ export interface CartViewedFormatter<T extends ObjectTypes = ObjectTypes> {
12
12
  export interface CheckoutStartedFormatter<T extends ObjectTypes = ObjectTypes> {
13
13
  (props: CheckoutStartedInput<T>, event: CheckoutStarted): CheckoutStarted;
14
14
  }
15
+ export interface CheckoutStepCompletedFormatter {
16
+ (props: CheckoutStepCompletedInput, event: CheckoutStepCompleted): CheckoutStepCompleted;
17
+ }
18
+ export interface CheckoutStepViewedFormatter {
19
+ (props: CheckoutStepViewedInput, event: CheckoutStepViewed): CheckoutStepViewed;
20
+ }
15
21
  export interface CouponAppliedFormatter {
16
22
  (props: CouponAppliedInput, event: CouponApplied): CouponApplied;
17
23
  }
@@ -33,6 +39,9 @@ export interface ProductAddedFormatter<T extends ObjectTypes = ObjectTypes> {
33
39
  export interface ProductClickedFormatter<T extends ObjectTypes = ObjectTypes> {
34
40
  (props: ProductClickedInput<T>, event: ProductClicked): ProductClicked;
35
41
  }
42
+ export interface VariantClickedFormatter<T extends ObjectTypes = ObjectTypes> {
43
+ (props: VariantClickedInput<T>, event: VariantClicked): VariantClicked;
44
+ }
36
45
  export interface ProductListFilteredFormatter {
37
46
  (props: ProductListFilteredInput, event: ProductListFiltered): ProductListFiltered;
38
47
  }
@@ -57,10 +66,24 @@ export interface SignedOutFormatter {
57
66
  export interface SignedUpFormatter {
58
67
  (props: SignedUpInput, event: SignedUp): SignedUp;
59
68
  }
69
+ export interface LoginStartedFormatter {
70
+ (props: LoginStartedInput, event: LoginStarted): LoginStarted;
71
+ }
72
+ export interface SubscriptionCancelledFormatter {
73
+ (props: SubscriptionCancelledInput, event: SubscriptionCancelled): SubscriptionCancelled;
74
+ }
75
+ export interface NavigationClickedFormatter {
76
+ (props: NavigationClickedInput, event: NavigationClicked): NavigationClicked;
77
+ }
78
+ export interface PaymentInfoEnteredFormatter {
79
+ (props: PaymentInfoEnteredInput, event: PaymentInfoEntered): PaymentInfoEntered;
80
+ }
60
81
  export interface ChordAnalyticsFormatters<T extends ObjectTypes = ObjectTypes> {
61
82
  events?: {
62
83
  cartViewed?: CartViewedFormatter<T>;
63
84
  checkoutStarted?: CheckoutStartedFormatter<T>;
85
+ checkoutStepCompleted?: CheckoutStepCompletedFormatter;
86
+ checkoutStepViewed?: CheckoutStepViewedFormatter;
64
87
  couponApplied?: CouponAppliedFormatter;
65
88
  couponDenied?: CouponDeniedFormatter;
66
89
  couponEntered?: CouponEnteredFormatter;
@@ -68,6 +91,7 @@ export interface ChordAnalyticsFormatters<T extends ObjectTypes = ObjectTypes> {
68
91
  emailCaptured?: EmailCapturedFormatter;
69
92
  productAdded?: ProductAddedFormatter<T>;
70
93
  productClicked?: ProductClickedFormatter<T>;
94
+ variantClicked?: VariantClickedFormatter<T>;
71
95
  productListFiltered?: ProductListFilteredFormatter;
72
96
  productListViewed?: ProductListViewedFormatter<T>;
73
97
  productRemoved?: ProductRemovedFormatter<T>;
@@ -76,6 +100,10 @@ export interface ChordAnalyticsFormatters<T extends ObjectTypes = ObjectTypes> {
76
100
  signedIn?: SignedInFormatter;
77
101
  signedOut?: SignedOutFormatter;
78
102
  signedUp?: SignedUpFormatter;
103
+ loginStarted?: LoginStartedFormatter;
104
+ subscriptionCancelled?: SubscriptionCancelledFormatter;
105
+ navigationClicked?: NavigationClickedFormatter;
106
+ paymentInfoEntered?: PaymentInfoEnteredFormatter;
79
107
  };
80
108
  objects: {
81
109
  cart: CartFormatter<T['Cart']>;
@@ -1,5 +1,5 @@
1
1
  import type { AnyId, ObjectTypes } from './client.js';
2
- import type { Filter, Sort } from './typewriter.js';
2
+ import type { Filter, Sort, SubscriptionCancelledAddress } from './typewriter.js';
3
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.
@@ -52,6 +52,42 @@ export interface CheckoutStartedInput<T extends ObjectTypes = ObjectTypes> {
52
52
  */
53
53
  checkout: T['Checkout'];
54
54
  }
55
+ export interface CheckoutStepCompletedInput {
56
+ /**
57
+ * The current checkout.
58
+ */
59
+ checkoutId: string;
60
+ /**
61
+ * The step that was completed.
62
+ */
63
+ step: number;
64
+ /**
65
+ * String representing the payment method chosen
66
+ */
67
+ paymentMethod?: string;
68
+ /**
69
+ * String representing the shipping the method chosen
70
+ */
71
+ shippingMethod?: string;
72
+ }
73
+ export interface CheckoutStepViewedInput {
74
+ /**
75
+ * The current checkout.
76
+ */
77
+ checkoutId: string;
78
+ /**
79
+ * The step that was completed.
80
+ */
81
+ step: number;
82
+ /**
83
+ * String representing the payment method chosen
84
+ */
85
+ paymentMethod?: string;
86
+ /**
87
+ * String representing the shipping the method chosen
88
+ */
89
+ shippingMethod?: string;
90
+ }
55
91
  /**
56
92
  * Coupon was applied on a user's shopping cart or order
57
93
  */
@@ -170,6 +206,16 @@ export interface ProductClickedInput<T extends ObjectTypes = ObjectTypes> {
170
206
  listName?: string;
171
207
  product: ProductInput<T['Product']>;
172
208
  }
209
+ export interface VariantClickedInput<T extends ObjectTypes = ObjectTypes> {
210
+ /**
211
+ * The current cart.
212
+ */
213
+ cart: T['Cart'];
214
+ coupon?: string;
215
+ lineItemId?: string;
216
+ product: ProductInput<T['Product']>;
217
+ couponId?: string;
218
+ }
173
219
  export interface ProductListFilteredInput {
174
220
  category?: string;
175
221
  listId?: string;
@@ -211,13 +257,140 @@ export interface ProductsSearchedInput {
211
257
  query?: string;
212
258
  }
213
259
  export interface SignedInInput {
260
+ /**
261
+ * The email of the user
262
+ */
214
263
  email?: string;
264
+ /**
265
+ * The method used to login
266
+ */
215
267
  method?: string;
216
268
  }
217
269
  export interface SignedOutInput {
270
+ /**
271
+ * The email of the user
272
+ */
218
273
  email?: string;
219
274
  }
220
275
  export interface SignedUpInput {
276
+ /**
277
+ * The email of the user
278
+ */
221
279
  email?: string;
280
+ /**
281
+ * The method used to login
282
+ */
222
283
  method?: string;
223
284
  }
285
+ export interface LoginStartedInput {
286
+ /**
287
+ * The email of the user
288
+ */
289
+ email?: string;
290
+ }
291
+ export interface SubscriptionCancelledInput<T extends ObjectTypes = ObjectTypes> {
292
+ /**
293
+ * Next date when this subscription will be actionable (renewed, expired, etc.)
294
+ */
295
+ actionableDate?: string;
296
+ /**
297
+ * Shipping address for the subscription
298
+ */
299
+ address?: SubscriptionCancelledAddress;
300
+ /**
301
+ * Brand associated with the subscription
302
+ */
303
+ brand?: string;
304
+ /**
305
+ * Currency code of the transaction (for example, "USD")
306
+ */
307
+ currency?: string;
308
+ /**
309
+ * Email address associated with the subscription
310
+ */
311
+ email?: string;
312
+ /**
313
+ * Subscription will stop auto-renewing after this date
314
+ */
315
+ endDate?: string;
316
+ /**
317
+ * Interval number at which the subscription renews
318
+ */
319
+ intervalLength?: number;
320
+ /**
321
+ * Interval unit at which the subscription renews (for example, "month")
322
+ */
323
+ intervalUnits?: string;
324
+ /**
325
+ * Products in the subscription
326
+ */
327
+ products?: ProductInput<T['Product']>[];
328
+ /**
329
+ * The state of the subscription (for example, "active")
330
+ */
331
+ state?: string;
332
+ /**
333
+ * ID of the subscription
334
+ */
335
+ subscriptionId?: string;
336
+ }
337
+ export interface NavigationClickedInput {
338
+ /**
339
+ * Name of menu or category where navigation link was clicked (for example, "Support")
340
+ */
341
+ category?: string;
342
+ /**
343
+ * Navigation label clicked (for example, "Contact")
344
+ */
345
+ label?: string;
346
+ /**
347
+ * Navigation HTML component within the UX (for example, "footer")
348
+ */
349
+ navigationPlacement?: string;
350
+ /**
351
+ * Navigation label clicked (for example, "Contact")
352
+ */
353
+ navigationTitle?: string;
354
+ /**
355
+ * URL of navigation link destination
356
+ */
357
+ navigationUrl?: string;
358
+ }
359
+ export interface PaymentInfoEnteredInput<T extends ObjectTypes = ObjectTypes> {
360
+ /**
361
+ * Checkout transaction ID
362
+ */
363
+ checkoutId?: string;
364
+ /**
365
+ * Transaction coupon redeemed with the transaction
366
+ */
367
+ coupon?: string;
368
+ /**
369
+ * Currency code of the transaction (for example, "USD")
370
+ */
371
+ currency?: string;
372
+ /**
373
+ * Order ID
374
+ */
375
+ orderId?: string;
376
+ /**
377
+ * String representing the payment method chosen
378
+ */
379
+ paymentMethod?: string;
380
+ /**
381
+ * Products in the order
382
+ */
383
+ products: ProductInput<T['Product']>[];
384
+ /**
385
+ * String representing the shipping the method chosen
386
+ */
387
+ shippingMethod?: string;
388
+ /**
389
+ * Number representing a step in the checkout process
390
+ */
391
+ step: number;
392
+ /**
393
+ * Revenue ($) with discounts and coupons added in
394
+ */
395
+ value?: number;
396
+ }
@@ -1,113 +1,113 @@
1
1
  import { z } from 'zod';
2
2
  export declare const identifyTraitsSchema: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
3
- address: z.ZodOptional<z.ZodObject<{
3
+ address: z.ZodOptional<z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
4
4
  city: z.ZodOptional<z.ZodString>;
5
5
  country: z.ZodOptional<z.ZodString>;
6
- postal_code: z.ZodOptional<z.ZodString>;
6
+ postalCode: z.ZodOptional<z.ZodString>;
7
7
  state: z.ZodOptional<z.ZodString>;
8
8
  street: z.ZodOptional<z.ZodString>;
9
9
  }, "strip", z.ZodTypeAny, {
10
10
  city?: string;
11
11
  country?: string;
12
- postal_code?: string;
12
+ postalCode?: string;
13
13
  state?: string;
14
14
  street?: string;
15
15
  }, {
16
16
  city?: string;
17
17
  country?: string;
18
- postal_code?: string;
18
+ postalCode?: string;
19
19
  state?: string;
20
20
  street?: string;
21
- }>>;
21
+ }>>>;
22
22
  age: z.ZodOptional<z.ZodNumber>;
23
23
  avatar: z.ZodOptional<z.ZodString>;
24
24
  birthday: z.ZodOptional<z.ZodString>;
25
- company: z.ZodOptional<z.ZodObject<{
25
+ company: z.ZodOptional<z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodObject<{
26
26
  name: z.ZodOptional<z.ZodString>;
27
27
  id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
28
28
  industry: z.ZodOptional<z.ZodString>;
29
- employee_count: z.ZodOptional<z.ZodNumber>;
29
+ employeeCount: z.ZodOptional<z.ZodNumber>;
30
30
  plan: z.ZodOptional<z.ZodString>;
31
31
  }, "strip", z.ZodTypeAny, {
32
32
  name?: string;
33
33
  id?: string | number;
34
34
  industry?: string;
35
- employee_count?: number;
35
+ employeeCount?: number;
36
36
  plan?: string;
37
37
  }, {
38
38
  name?: string;
39
39
  id?: string | number;
40
40
  industry?: string;
41
- employee_count?: number;
41
+ employeeCount?: number;
42
42
  plan?: string;
43
- }>>;
44
- created_at: z.ZodOptional<z.ZodString>;
43
+ }>>>;
44
+ createdAt: z.ZodOptional<z.ZodString>;
45
45
  description: z.ZodOptional<z.ZodString>;
46
46
  email: z.ZodOptional<z.ZodString>;
47
- first_name: z.ZodOptional<z.ZodString>;
47
+ firstName: z.ZodOptional<z.ZodString>;
48
48
  gender: z.ZodOptional<z.ZodString>;
49
49
  id: z.ZodOptional<z.ZodString>;
50
- last_name: z.ZodOptional<z.ZodString>;
50
+ lastName: z.ZodOptional<z.ZodString>;
51
51
  name: z.ZodOptional<z.ZodString>;
52
52
  phone: z.ZodOptional<z.ZodString>;
53
53
  title: z.ZodOptional<z.ZodString>;
54
54
  username: z.ZodOptional<z.ZodString>;
55
55
  website: z.ZodOptional<z.ZodString>;
56
56
  }, "strip", z.ZodTypeAny, {
57
- address?: {
57
+ address?: Record<string, any> & {
58
58
  city?: string;
59
59
  country?: string;
60
- postal_code?: string;
60
+ postalCode?: string;
61
61
  state?: string;
62
62
  street?: string;
63
63
  };
64
64
  age?: number;
65
65
  avatar?: string;
66
66
  birthday?: string;
67
- company?: {
67
+ company?: Record<string, any> & {
68
68
  name?: string;
69
69
  id?: string | number;
70
70
  industry?: string;
71
- employee_count?: number;
71
+ employeeCount?: number;
72
72
  plan?: string;
73
73
  };
74
- created_at?: string;
74
+ createdAt?: string;
75
75
  description?: string;
76
76
  email?: string;
77
- first_name?: string;
77
+ firstName?: string;
78
78
  gender?: string;
79
79
  id?: string;
80
- last_name?: string;
80
+ lastName?: string;
81
81
  name?: string;
82
82
  phone?: string;
83
83
  title?: string;
84
84
  username?: string;
85
85
  website?: string;
86
86
  }, {
87
- address?: {
87
+ address?: Record<string, any> & {
88
88
  city?: string;
89
89
  country?: string;
90
- postal_code?: string;
90
+ postalCode?: string;
91
91
  state?: string;
92
92
  street?: string;
93
93
  };
94
94
  age?: number;
95
95
  avatar?: string;
96
96
  birthday?: string;
97
- company?: {
97
+ company?: Record<string, any> & {
98
98
  name?: string;
99
99
  id?: string | number;
100
100
  industry?: string;
101
- employee_count?: number;
101
+ employeeCount?: number;
102
102
  plan?: string;
103
103
  };
104
- created_at?: string;
104
+ createdAt?: string;
105
105
  description?: string;
106
106
  email?: string;
107
- first_name?: string;
107
+ firstName?: string;
108
108
  gender?: string;
109
109
  id?: string;
110
- last_name?: string;
110
+ lastName?: string;
111
111
  name?: string;
112
112
  phone?: string;
113
113
  title?: string;
@@ -515,6 +515,7 @@ export declare const checkoutSchema: z.ZodObject<{
515
515
  shipping: z.ZodOptional<z.ZodNumber>;
516
516
  tax: z.ZodOptional<z.ZodNumber>;
517
517
  value: z.ZodOptional<z.ZodNumber>;
518
+ step: z.ZodOptional<z.ZodNumber>;
518
519
  }, "strip", z.ZodTypeAny, {
519
520
  affiliation?: string;
520
521
  checkout_type?: string;
@@ -547,6 +548,7 @@ export declare const checkoutSchema: z.ZodObject<{
547
548
  shipping?: number;
548
549
  tax?: number;
549
550
  value?: number;
551
+ step?: number;
550
552
  }, {
551
553
  affiliation?: string;
552
554
  checkout_type?: string;
@@ -579,6 +581,7 @@ export declare const checkoutSchema: z.ZodObject<{
579
581
  shipping?: number;
580
582
  tax?: number;
581
583
  value?: number;
584
+ step?: number;
582
585
  }>;
583
586
  export declare const cartSchema: z.ZodObject<{
584
587
  cart_id: z.ZodOptional<z.ZodString>;
@@ -2,33 +2,35 @@
2
2
  import { z } from 'zod';
3
3
  export const identifyTraitsSchema = z.record(z.any()).and(z.object({
4
4
  address: z
5
- .object({
5
+ .record(z.any())
6
+ .and(z.object({
6
7
  city: z.string().optional(),
7
8
  country: z.string().optional(),
8
- postal_code: z.string().optional(),
9
+ postalCode: z.string().optional(),
9
10
  state: z.string().optional(),
10
11
  street: z.string().optional(),
11
- })
12
+ }))
12
13
  .optional(),
13
14
  age: z.number().optional(),
14
15
  avatar: z.string().optional(),
15
16
  birthday: z.string().optional(),
16
17
  company: z
17
- .object({
18
+ .record(z.any())
19
+ .and(z.object({
18
20
  name: z.string().optional(),
19
21
  id: z.union([z.string(), z.number()]).optional(),
20
22
  industry: z.string().optional(),
21
- employee_count: z.number().optional(),
23
+ employeeCount: z.number().optional(),
22
24
  plan: z.string().optional(),
23
- })
25
+ }))
24
26
  .optional(),
25
- created_at: z.string().optional(),
27
+ createdAt: z.string().optional(),
26
28
  description: z.string().optional(),
27
29
  email: z.string().optional(),
28
- first_name: z.string().optional(),
30
+ firstName: z.string().optional(),
29
31
  gender: z.string().optional(),
30
32
  id: z.string().optional(),
31
- last_name: z.string().optional(),
33
+ lastName: z.string().optional(),
32
34
  name: z.string().optional(),
33
35
  phone: z.string().optional(),
34
36
  title: z.string().optional(),
@@ -113,6 +115,7 @@ export const checkoutSchema = z.object({
113
115
  shipping: z.number().optional(),
114
116
  tax: z.number().optional(),
115
117
  value: z.number().optional(),
118
+ step: z.number().optional(),
116
119
  });
117
120
  export const cartSchema = z.object({
118
121
  cart_id: z.string().optional(),