forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
327 lines (313 loc) · 7.61 KB
/
Copy pathtypes.ts
File metadata and controls
327 lines (313 loc) · 7.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
import { CommonEventProperties } from '@snowplow/tracker-core';
/**
* Type/Schema for an ecommerce Action
*/
export interface Action {
/**
* Standard ecommerce actions
*/
type:
| 'add_to_cart'
| 'remove_from_cart'
| 'product_view'
| 'list_click'
| 'list_view'
| 'promo_click'
| 'promo_view'
| 'checkout_step'
| 'transaction'
| 'refund'
| 'trns_error';
/**
* You can add a name for the list presented to the user.
* E.g. product list, search results, shop the look, frequently bought with
*/
name?: string;
}
/**
* Type/Schema for a checkout_step event in Ecommerce
*/
export interface CheckoutStep {
/* Checkout step index */
step: number;
/* Shipping address postcode */
shipping_postcode?: string;
/* Billing address postcode */
billing_postcode?: string;
/* Full shipping address */
shipping_full_address?: string;
/* Full billing address */
billing_full_address?: string;
/* Can be used to discern delivery providers DHL, PostNL etc. */
delivery_provider?: string;
/* Store pickup, standard delivery, express delivery, international */
delivery_method?: string;
/* Coupon applied at checkout */
coupon_code?: string;
/* Selection of 'existing user' or 'guest checkout' */
account_type?: string;
/* Any kind of payment method the user selected to proceed. Card, PayPal, Alipay etc. */
payment_method?: string;
/* Invoice or receipt */
proof_of_payment?: string;
/* If opted in to marketing campaigns to the email address */
marketing_opt_in?: boolean;
}
/**
* Type for a cart entity in Ecommerce
*/
export interface Cart {
/**
* The unique ID representing this cart
*/
cart_id?: string;
/**
* The total value of the cart after this interaction
*/
total_value: number;
/**
* The currency used for this cart (ISO 4217)
*/
currency: string;
/**
* Array of products added/removed from cart
*/
products?: Product[];
}
/**
* Type/Schema for a page entity in Ecommerce
*/
export interface Page {
/**
* The type of the page that was visited (e.g. homepage, product page, cart,checkout page, etc)
*/
type: string;
/**
* The language that the web page is based in
*/
language?: string;
/**
* The locale version of the site that is running
*/
locale?: string;
}
/**
* Type/Schema for a product entity in Ecommerce
*/
export type Product = {
/**
* The SKU or product ID
*/
id: string;
/**
* The name or title of the product
*/
name?: string;
/**
* The category the product belongs to.
* Use a consistent separator to express multiple levels. E.g. Woman/Shoes/Sneakers
*/
category?: string;
/**
* The price of the product at the current time.
*/
price: number;
/**
* The recommended or list price of a product
*/
list_price?: number;
/**
* The quantity of the product taking part in the action. Used for Cart events.
*/
quantity?: number;
/**
* The size of the product
*/
size?: string;
/**
* The variant of the product
*/
variant?: string;
/**
* The brand of the product
*/
brand?: string;
/**
* The inventory status of the product (e.g. in stock, out of stock, preorder, backorder, etc)
*/
inventory_status?: string;
/**
* The position the product was presented in a list of products (search results, product list page, etc)
*/
position?: number;
/**
* The currency in which the product is being priced (ISO 4217)
*/
currency: string;
/**
* Identifier/Name/Url for the creative presented on a list or product view.
*/
creative_id?: string;
};
/**
* Type/Schema for a promotion entity in Ecommerce
*/
export interface SPPromotion {
/**
* The ID of the promotion.
*/
id: string;
/**
* The name of the promotion.
*/
name?: string | null;
/**
* Array of SKUs or product IDs showcased in the promotion.
*/
product_ids?: string[] | null;
/**
* The position the promotion was presented in a list of promotions E.g. banner, slider.
*/
position?: number | null;
/**
* Identifier/Name/Url for the creative presented on the promotion.
*/
creative_id?: string | null;
/**
* Type of the promotion delivery mechanism. E.g. popup, banner, intra-content
*/
type?: string | null;
/**
* The website slot in which the promotional content was added to.
*/
slot?: string | null;
}
/**
* Type/Schema for a transaction entity in Ecommerce
*/
export interface SPTransaction {
/**
* The ID of the transaction
*/
transaction_id: string;
/**
* The total value of the transaction
*/
revenue: number;
/**
* The currency used for the transaction
*/
currency: string;
/**
* The payment method used for the transaction
*/
payment_method: string;
/**
* Total quantity of items in the transaction
*/
total_quantity?: number;
/**
* Total amount of tax on the transaction
*/
tax?: number;
/**
* Total cost of shipping on the transaction
*/
shipping?: number;
/**
* Discount code used
*/
discount_code?: string;
/**
* Discount amount taken off
*/
discount_amount?: number;
/**
* Whether the transaction is a credit order or not
*/
credit_order?: boolean;
/**
* Array of products on the transaction from cart
*/
products?: Product[];
}
/**
* Type/Schema for a refund entity in Ecommerce
*/
export interface Refund {
/**
* The ID of the transaction.
*/
transaction_id: string;
/**
* The currency in which the product is being priced (ISO 4217).
*/
currency: string;
/**
* The monetary amount refunded.
*/
refund_amount: number;
/**
* Reason for refunding the whole or part of the transaction.
*/
refund_reason?: string | null;
/**
* Array of products on the refund. This is used when specific products are refunded.
* If not present, the whole transaction and products will be marked as refunded.
*/
products?: Product[];
}
/**
* Type/Schema for a transaction error entity in Ecommerce
*/
export interface TransactionError {
/**
* Error-identifying code for the transaction issue. E.g. E522
*/
error_code?: string;
/**
* Shortcode for the error occurred in the transaction. E.g. declined_by_stock_api, declined_by_payment_method, card_declined, pm_card_radarBlock
*/
error_shortcode?: string;
/**
* Longer description for the error occurred in the transaction.
*/
error_description?: string;
/**
* Type of error.
* Hard error types mean the customer must provide another form of payment e.g. an expired card.
* Soft errors can be the result of temporary issues where retrying might be successful e.g. processor declined the transaction.
*/
error_type?: 'hard' | 'soft' | null;
/**
* The resolution selected for the error scenario. E.g. retry_allowed, user_blacklisted, block_gateway, contact_user, default
*/
resolution?: string;
/**
* The transaction object representing the transaction that ended up in an error.
*/
transaction: SPTransaction;
}
/**
* Type/Schema for an user entity in Ecommerce
*/
export interface User {
/**
* The user ID
*/
id: string;
/**
* Whether or not the user is a guest
*/
is_guest?: boolean;
/**
* The user's email address
*/
email?: string;
}
export interface CommonEcommerceEventProperties<T = Record<string, unknown>> extends CommonEventProperties<T> {
/** Add context to an event by setting an Array of Self Describing JSON */
context?: Exclude<CommonEventProperties<T>['context'], null>;
}
export type ListViewEvent = { name: string; products: Product[] };
export type ListClickEvent = { name: string; product: Product };