@nosto/nosto-react 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +13 -16
- package/dist/index.es.js +257 -866
- package/dist/index.umd.js +1 -25
- package/package.json +3 -3
- package/src/components/Nosto404.tsx +2 -25
- package/src/components/NostoCategory.tsx +2 -30
- package/src/components/NostoCheckout.tsx +2 -25
- package/src/components/NostoHome.tsx +2 -26
- package/src/components/NostoOrder.tsx +2 -33
- package/src/components/NostoOther.tsx +2 -25
- package/src/components/NostoPlacement.tsx +1 -1
- package/src/components/NostoProduct.tsx +2 -32
- package/src/components/NostoProvider.tsx +11 -10
- package/src/components/NostoSearch.tsx +2 -30
- package/src/components/NostoSession.tsx +2 -43
- package/src/components/helpers.ts +2 -2
- package/src/context.ts +0 -1
- package/src/hooks/scriptLoader.ts +4 -4
- package/src/hooks/useDeepCompareEffect.ts +4 -7
- package/src/hooks/useLoadClientScript.ts +9 -4
- package/src/hooks/useNosto404.tsx +25 -0
- package/src/hooks/useNostoApi.ts +4 -11
- package/src/hooks/useNostoCategory.tsx +31 -0
- package/src/hooks/useNostoCheckout.tsx +25 -0
- package/src/hooks/useNostoContext.ts +2 -3
- package/src/hooks/useNostoHome.tsx +25 -0
- package/src/hooks/useNostoOrder.tsx +35 -0
- package/src/hooks/useNostoOther.tsx +25 -0
- package/src/hooks/useNostoProduct.tsx +37 -0
- package/src/hooks/useNostoSearch.tsx +31 -0
- package/src/hooks/useNostoSession.tsx +33 -0
- package/src/hooks/useRenderCampaigns.tsx +10 -8
- package/src/index.ts +21 -2
- package/src/types.ts +775 -733
- package/src/utils/types.ts +5 -3
- package/src/components/index.ts +0 -11
- package/src/hooks/index.ts +0 -5
package/src/types.ts
CHANGED
|
@@ -6,7 +6,6 @@ declare global {
|
|
|
6
6
|
nostojs: {
|
|
7
7
|
(callback: (api: NostoClient) => void): void
|
|
8
8
|
q?: unknown[]
|
|
9
|
-
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
}
|
|
@@ -77,10 +76,9 @@ export interface PushedProduct {
|
|
|
77
76
|
variations: { [index: string]: PushedVariation }
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
export interface PushedProductSKU extends NostoSku {
|
|
81
|
-
|
|
82
|
-
export interface PushedVariation extends NostoVariant { }
|
|
79
|
+
export interface PushedProductSKU extends NostoSku {}
|
|
83
80
|
|
|
81
|
+
export interface PushedVariation extends NostoVariant {}
|
|
84
82
|
|
|
85
83
|
export interface NostoSku extends Sku {
|
|
86
84
|
inventory_level?: number
|
|
@@ -109,828 +107,872 @@ export interface Sku {
|
|
|
109
107
|
}
|
|
110
108
|
|
|
111
109
|
// copied from client script d.ts export
|
|
112
|
-
declare const eventTypes: readonly [
|
|
113
|
-
|
|
110
|
+
declare const eventTypes: readonly [
|
|
111
|
+
"vp",
|
|
112
|
+
"lp",
|
|
113
|
+
"dp",
|
|
114
|
+
"rp",
|
|
115
|
+
"bp",
|
|
116
|
+
"vc",
|
|
117
|
+
"or",
|
|
118
|
+
"is",
|
|
119
|
+
"cp",
|
|
120
|
+
"ec",
|
|
121
|
+
"es",
|
|
122
|
+
"gc",
|
|
123
|
+
"src",
|
|
124
|
+
"cpr",
|
|
125
|
+
"pl",
|
|
126
|
+
"cc",
|
|
127
|
+
"con"
|
|
128
|
+
]
|
|
129
|
+
declare type EventType = (typeof eventTypes)[number]
|
|
114
130
|
|
|
115
131
|
/**
|
|
116
132
|
* @group Types
|
|
117
133
|
*/
|
|
118
134
|
export interface CartItem {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
135
|
+
name: string
|
|
136
|
+
price_currency_code: string
|
|
137
|
+
product_id: string
|
|
138
|
+
quantity: number
|
|
139
|
+
sku_id?: string
|
|
140
|
+
unit_price: number
|
|
125
141
|
}
|
|
126
142
|
|
|
127
143
|
/**
|
|
128
144
|
* @group Types
|
|
129
145
|
*/
|
|
130
146
|
export interface ConversionItem {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
name: string
|
|
148
|
+
price_currency_code: string
|
|
149
|
+
product_id: string
|
|
150
|
+
quantity?: number
|
|
151
|
+
sku_id?: string
|
|
152
|
+
unit_price?: number
|
|
137
153
|
}
|
|
138
154
|
|
|
139
155
|
/**
|
|
140
156
|
* @group Types
|
|
141
157
|
*/
|
|
142
158
|
export interface CustomerAffinityResponse {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
discount: number
|
|
160
|
+
top_brands: CustomerAffinityResponseItem[]
|
|
161
|
+
top_categories: CustomerAffinityResponseItem[]
|
|
162
|
+
top_product_types: CustomerAffinityResponseItem[]
|
|
163
|
+
top_skus: {
|
|
164
|
+
[index: string]: CustomerAffinityResponseItem[]
|
|
165
|
+
}
|
|
150
166
|
}
|
|
151
167
|
|
|
152
168
|
/**
|
|
153
169
|
* @group Types
|
|
154
170
|
*/
|
|
155
171
|
export interface CustomerAffinityResponseItem {
|
|
156
|
-
|
|
157
|
-
|
|
172
|
+
name: string
|
|
173
|
+
score: number
|
|
158
174
|
}
|
|
159
175
|
|
|
160
176
|
/**
|
|
161
177
|
* @group Types
|
|
162
178
|
*/
|
|
163
179
|
export interface OrderCustomer {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
180
|
+
country: string
|
|
181
|
+
email?: string
|
|
182
|
+
first_name?: string
|
|
183
|
+
last_name?: string
|
|
184
|
+
newsletter: string
|
|
185
|
+
order_number: string
|
|
186
|
+
phone: string
|
|
187
|
+
post_code: string
|
|
188
|
+
type: string
|
|
173
189
|
}
|
|
174
190
|
|
|
175
191
|
/**
|
|
176
192
|
* @group Types
|
|
177
193
|
*/
|
|
178
194
|
export interface Customer {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
customer_reference?: string
|
|
196
|
+
email: string
|
|
197
|
+
first_name: string
|
|
198
|
+
hcid?: string
|
|
199
|
+
last_name: string
|
|
200
|
+
newsletter?: boolean
|
|
201
|
+
order_number?: string
|
|
202
|
+
source?: string
|
|
203
|
+
source_id?: string
|
|
204
|
+
type?: string
|
|
189
205
|
}
|
|
190
206
|
|
|
191
207
|
/**
|
|
192
208
|
* @group Types
|
|
193
209
|
*/
|
|
194
210
|
export interface Order {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
211
|
+
created_at?: Date
|
|
212
|
+
external_order_ref: string
|
|
213
|
+
info?: OrderCustomer
|
|
214
|
+
items: ConversionItem[]
|
|
215
|
+
order_status?: string
|
|
216
|
+
order_status_label?: string
|
|
217
|
+
payment_provider: string
|
|
202
218
|
}
|
|
203
219
|
|
|
204
220
|
/**
|
|
205
221
|
* @group Types
|
|
206
222
|
*/
|
|
207
|
-
export type PageType =
|
|
223
|
+
export type PageType =
|
|
224
|
+
| "front"
|
|
225
|
+
| "category"
|
|
226
|
+
| "product"
|
|
227
|
+
| "cart"
|
|
228
|
+
| "search"
|
|
229
|
+
| "notfound"
|
|
230
|
+
| "order"
|
|
231
|
+
| "other"
|
|
232
|
+
| "checkout"
|
|
208
233
|
|
|
209
234
|
/**
|
|
210
235
|
* @group Types
|
|
211
236
|
*/
|
|
212
|
-
export type RenderMode =
|
|
237
|
+
export type RenderMode =
|
|
238
|
+
| "HTML"
|
|
239
|
+
| "SIMPLE"
|
|
240
|
+
| "JSON_170x170"
|
|
241
|
+
| "JSON_100_X_100"
|
|
242
|
+
| "JSON_90x70"
|
|
243
|
+
| "JSON_50x50"
|
|
244
|
+
| "JSON_30x30"
|
|
245
|
+
| "JSON_100x140"
|
|
246
|
+
| "JSON_200x200"
|
|
247
|
+
| "JSON_400x400"
|
|
248
|
+
| "JSON_750x750"
|
|
249
|
+
| "JSON_10_MAX_SQUARE"
|
|
250
|
+
| "JSON_200x200_SQUARE"
|
|
251
|
+
| "JSON_400x400_SQUARE"
|
|
252
|
+
| "JSON_750x750_SQUARE"
|
|
253
|
+
| "JSON_ORIGINAL"
|
|
254
|
+
| "VERSION_SOURCE"
|
|
213
255
|
|
|
214
256
|
/**
|
|
215
257
|
* @group Types
|
|
216
258
|
*/
|
|
217
259
|
interface PluginMetadata {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
260
|
+
mainModule?: string
|
|
261
|
+
cmpModule?: string
|
|
262
|
+
msiModule?: string
|
|
221
263
|
}
|
|
222
264
|
|
|
223
265
|
/**
|
|
224
266
|
* @group Types
|
|
225
267
|
*/
|
|
226
268
|
export interface Cart {
|
|
227
|
-
|
|
228
|
-
|
|
269
|
+
hcid?: string
|
|
270
|
+
items: CartItem[]
|
|
229
271
|
}
|
|
230
272
|
|
|
231
273
|
/**
|
|
232
274
|
* @group Types
|
|
233
275
|
*/
|
|
234
276
|
export type Product = {
|
|
235
|
-
|
|
236
|
-
|
|
277
|
+
product_id: string
|
|
278
|
+
selected_sku_id?: string
|
|
237
279
|
}
|
|
238
280
|
|
|
239
281
|
/**
|
|
240
282
|
* @group Types
|
|
241
283
|
*/
|
|
242
284
|
export interface Data<ProductType extends Product = Product> {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
285
|
+
cart: Cart | undefined
|
|
286
|
+
customer: Customer | undefined
|
|
287
|
+
variation: string | undefined
|
|
288
|
+
restoreLink: string | undefined
|
|
289
|
+
products: ProductType[]
|
|
290
|
+
order: Order | undefined
|
|
291
|
+
searchTerms: string[] | undefined
|
|
292
|
+
categories: string[] | undefined
|
|
293
|
+
categoryIds: string[] | undefined
|
|
294
|
+
parentCategoryIds: string[] | undefined
|
|
295
|
+
tags: string[] | undefined
|
|
296
|
+
customFields: Record<string, string[]> | undefined
|
|
297
|
+
elements: string[] | undefined
|
|
298
|
+
pageType: PageType | undefined
|
|
299
|
+
sortOrder: string | undefined
|
|
300
|
+
pluginVersion: PluginMetadata | undefined
|
|
259
301
|
}
|
|
260
302
|
|
|
261
303
|
/**
|
|
262
304
|
* @group Types
|
|
263
305
|
*/
|
|
264
306
|
export interface RecommendationRequestFlags {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
307
|
+
skipPageViews?: boolean
|
|
308
|
+
trackEvents?: boolean
|
|
309
|
+
skipEvents?: boolean
|
|
310
|
+
reloadCart?: boolean
|
|
269
311
|
}
|
|
270
312
|
|
|
271
313
|
/**
|
|
272
314
|
* @group Types
|
|
273
315
|
*/
|
|
274
316
|
export interface Session {
|
|
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
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Sets the information about the user's current shopping cart. It the user
|
|
319
|
+
* does not have any items in his shopping cart, you can pass <code>null<code>.
|
|
320
|
+
* Passing <code>null<code> will nullify the user's shopping cart on Nosto's
|
|
321
|
+
* end. You must also pass in the shopping cart content in it's entirety as
|
|
322
|
+
* partial content are not supported.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* nostojs(api => api
|
|
326
|
+
* .defaultSession()
|
|
327
|
+
* .setCart({
|
|
328
|
+
* items: [
|
|
329
|
+
* product_id: "101",
|
|
330
|
+
* sku_id: "101-S",
|
|
331
|
+
* name: "Shoe",
|
|
332
|
+
* unit_price: 34.99
|
|
333
|
+
* price_currency_code: "EUR"
|
|
334
|
+
* ]
|
|
335
|
+
* })
|
|
336
|
+
* .viewCart()
|
|
337
|
+
* .setPlacements(["free-shipper"])
|
|
338
|
+
* .update()
|
|
339
|
+
* .then(data => console.log(data)))
|
|
340
|
+
*
|
|
341
|
+
* @public
|
|
342
|
+
* @param {Cart|undefined} cart the details of the user's shopping cart contents
|
|
343
|
+
* @returns {Session} the current session
|
|
344
|
+
*/
|
|
345
|
+
setCart(cart: Cart | undefined): Session
|
|
346
|
+
/**
|
|
347
|
+
* Sets the information about the currently logged in customer. If the current
|
|
348
|
+
* customer is not provided, you will not be able to leverage features such as
|
|
349
|
+
* triggered emails. While it is recommended to always provide the details of
|
|
350
|
+
* the currently logged in customer, it may be omitted if there are concerns
|
|
351
|
+
* about privacy or compliance.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* nostojs(api => api
|
|
355
|
+
* .defaultSession()
|
|
356
|
+
* .setCustomer({
|
|
357
|
+
* first_name: "Mridang",
|
|
358
|
+
* last_name: "Agarwalla",
|
|
359
|
+
* email: "mridang@nosto.com",
|
|
360
|
+
* newsletter: false,
|
|
361
|
+
* customer_reference: "5e3d4a9c-cf58-11ea-87d0-0242ac130003"
|
|
362
|
+
* })
|
|
363
|
+
* .viewCart()
|
|
364
|
+
* .setPlacements(["free-shipper"])
|
|
365
|
+
* .load()
|
|
366
|
+
* .then(data => console.log(data)))
|
|
367
|
+
*
|
|
368
|
+
* @public
|
|
369
|
+
* @param {Customer} customer the details of the currently logged in customer
|
|
370
|
+
* @returns {Session} the current session
|
|
371
|
+
*/
|
|
372
|
+
setCustomer(customer: Customer | undefined): Session
|
|
373
|
+
/**
|
|
374
|
+
* Sets the current variation identifier for the session. A variation identifier
|
|
375
|
+
* identifies the current currency (or the current customer group). If your site
|
|
376
|
+
* uses multi-currency, you must provide the ISO code current currency being viewed.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* nostojs(api => api
|
|
380
|
+
* .defaultSession()
|
|
381
|
+
* .setVariation("GBP")
|
|
382
|
+
* .viewCart()
|
|
383
|
+
* .setPlacements(["free-shipper"])
|
|
384
|
+
* .load()
|
|
385
|
+
* .then(data => console.log(data)))
|
|
386
|
+
*
|
|
387
|
+
* @public
|
|
388
|
+
* @param {String} variation the case-sensitive identifier of the current variation
|
|
389
|
+
* @returns {Session} the current session
|
|
390
|
+
*/
|
|
391
|
+
setVariation(variation: string): Session
|
|
392
|
+
/**
|
|
393
|
+
* Sets the restore link for the current session. Restore links can be leveraged
|
|
394
|
+
* in email campaigns. Restore links allow the the user to restore the cart
|
|
395
|
+
* contents in a single click.
|
|
396
|
+
* <br/><br/>
|
|
397
|
+
* Read more about
|
|
398
|
+
* {@link https://help.nosto.com/en/articles/664692|how to leverage the restore cart link}
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* nostojs(api => api
|
|
402
|
+
* .defaultSession()
|
|
403
|
+
* .setRestoreLink("https://jeans.com/session/restore?sid=6bdb69d5-ed15-4d92")
|
|
404
|
+
* .viewCart()
|
|
405
|
+
* .setPlacements(["free-shipper"])
|
|
406
|
+
* .load()
|
|
407
|
+
* .then(data => console.log(data)))
|
|
408
|
+
*
|
|
409
|
+
* @public
|
|
410
|
+
* @param {String} restoreLink the secure URL to restore the user's current session
|
|
411
|
+
* @returns {Session} the current session
|
|
412
|
+
*/
|
|
413
|
+
setRestoreLink(restoreLink: string): Session
|
|
414
|
+
/**
|
|
415
|
+
* Sets the response type to HTML or JSON_ORIGINAL. This denotes the preferred
|
|
416
|
+
* response type of the recommendation result.
|
|
417
|
+
* If you would like to access the raw recommendation data in <code>JSON</code> form, specify
|
|
418
|
+
* <code>JSON</code>. When you specify JSON, you will need to template the result yourself.
|
|
419
|
+
* If you require a more simplified approach, specify <code>HTML</code>. When you specify
|
|
420
|
+
* <code>HTML</code>, you get back HTML blobs, that you may simply inject into
|
|
421
|
+
* you placements.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* nostojs(api => api
|
|
425
|
+
* .defaultSession()
|
|
426
|
+
* .setResponseMode("HTML")
|
|
427
|
+
* .viewCart()
|
|
428
|
+
* .setPlacements(["free-shipper"])
|
|
429
|
+
* .load()
|
|
430
|
+
* .then(data => console.log(data)))
|
|
431
|
+
*
|
|
432
|
+
* @public
|
|
433
|
+
* @param {String} mode the response mode for the recommendation data
|
|
434
|
+
* @returns {Session} the current session
|
|
435
|
+
*/
|
|
436
|
+
setResponseMode(mode: RenderMode): Session
|
|
437
|
+
/**
|
|
438
|
+
* Create a new action for a front page. This should be used when the user
|
|
439
|
+
* visits the home page.
|
|
440
|
+
* <br/><br/>
|
|
441
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
442
|
+
* action in order for the request to be made.
|
|
443
|
+
* <br/><br/>
|
|
444
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
445
|
+
* from the action.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* nostojs(api => api
|
|
449
|
+
* .defaultSession()
|
|
450
|
+
* .viewFrontPage()
|
|
451
|
+
* .setPlacements(["best-seller"])
|
|
452
|
+
* .load()
|
|
453
|
+
* .then(data => console.log(data)))
|
|
454
|
+
*
|
|
455
|
+
*
|
|
456
|
+
* @public
|
|
457
|
+
* @returns {Action} the action instance to load content or track events.
|
|
458
|
+
*/
|
|
459
|
+
viewFrontPage(): Action
|
|
460
|
+
/**
|
|
461
|
+
* Create a new action for a cart page. This should be used on all cart and
|
|
462
|
+
* checkout pages. If your site has a multi-step checkout, it is recommended
|
|
463
|
+
* that you send this event on each checkout page.
|
|
464
|
+
* <br/><br/>
|
|
465
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
466
|
+
* action in order for the request to be made.
|
|
467
|
+
* <br/><br/>
|
|
468
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
469
|
+
* from the action.
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* nostojs(api => api
|
|
473
|
+
* .defaultSession()
|
|
474
|
+
* .viewCart()
|
|
475
|
+
* .setPlacements(["free-shipper"])
|
|
476
|
+
* .load()
|
|
477
|
+
* .then(data => console.log(data)))
|
|
478
|
+
*
|
|
479
|
+
* @public
|
|
480
|
+
* @returns {Action} the action instance to load content or track events.
|
|
481
|
+
*/
|
|
482
|
+
viewCart(): Action
|
|
483
|
+
/**
|
|
484
|
+
* Create a new action for a not found page. This should be used only on 404
|
|
485
|
+
* pages.
|
|
486
|
+
* <br/><br/>
|
|
487
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
488
|
+
* action in order for the request to be made.
|
|
489
|
+
* <br/><br/>
|
|
490
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
491
|
+
* from the action.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* nostojs(api => api
|
|
495
|
+
* .defaultSession()
|
|
496
|
+
* .viewNotFound()
|
|
497
|
+
* .setPlacements(["best-seller"])
|
|
498
|
+
* .load()
|
|
499
|
+
* .then(data => console.log(data)))
|
|
500
|
+
*
|
|
501
|
+
* @public
|
|
502
|
+
* @returns {Action} the action instance to load content or track events.
|
|
503
|
+
*/
|
|
504
|
+
viewNotFound(): Action
|
|
505
|
+
/**
|
|
506
|
+
* Create a new action for a product page. This must be used only when a
|
|
507
|
+
* product is being viewed. In case a specific SKU of the product is being viewed, use viewProductSku instead.
|
|
508
|
+
* <br/><br/>
|
|
509
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
510
|
+
* action in order for the request to be made.
|
|
511
|
+
* <br/><br/>
|
|
512
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
513
|
+
* from the action.
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* nostojs(api => api
|
|
517
|
+
* .defaultSession()
|
|
518
|
+
* .viewProduct("101")
|
|
519
|
+
* .setCategories(["/men/trousers"])
|
|
520
|
+
* .setRef("123", "example_reco_id")
|
|
521
|
+
* .setPlacements(["cross-seller"])
|
|
522
|
+
* .load()
|
|
523
|
+
* .then(data => console.log(data)))
|
|
524
|
+
*
|
|
525
|
+
* @public
|
|
526
|
+
* @param product
|
|
527
|
+
* @returns {Action} the action instance to load content or track events.
|
|
528
|
+
*/
|
|
529
|
+
viewProduct(product: string | Product): Action
|
|
530
|
+
/**
|
|
531
|
+
* Create a new action for a product page when a specific SKU has been chosen. This must be used only when a
|
|
532
|
+
* product and specific SKU is being viewed.
|
|
533
|
+
* <br/><br/>
|
|
534
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
535
|
+
* action in order for the request to be made.
|
|
536
|
+
* <br/><br/>
|
|
537
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
538
|
+
* from the action.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* nostojs(api => api
|
|
542
|
+
* .defaultSession()
|
|
543
|
+
* .viewProductSku("101", "101-sku-1")
|
|
544
|
+
* .setCategories(["/men/trousers"])
|
|
545
|
+
* .setRef("123", "example_reco_id")
|
|
546
|
+
* .setPlacements(["cross-seller"])
|
|
547
|
+
* .load()
|
|
548
|
+
* .then(data => console.log(data)))
|
|
549
|
+
*
|
|
550
|
+
* @public
|
|
551
|
+
* @param productId
|
|
552
|
+
* @param skuId
|
|
553
|
+
* @returns {Action} the action instance to load content or track events.
|
|
554
|
+
*/
|
|
555
|
+
viewProductSku(productId: string, skuId: string): Action
|
|
556
|
+
/**
|
|
557
|
+
* Create a new action for a category page. This should be used on all
|
|
558
|
+
* category, collection of brand pages.
|
|
559
|
+
* <br/><br/>
|
|
560
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
561
|
+
* action in order for the request to be made.
|
|
562
|
+
* <br/><br/>
|
|
563
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
564
|
+
* from the action.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* nostojs(api => api
|
|
568
|
+
* .defaultSession()
|
|
569
|
+
* .viewCategory("/men/shoes")
|
|
570
|
+
* .setPlacements(["category123"])
|
|
571
|
+
* .load()
|
|
572
|
+
* .then(data => console.log(data)))
|
|
573
|
+
*
|
|
574
|
+
* @public
|
|
575
|
+
* @param {Array<String>} categories
|
|
576
|
+
* @returns {Action} the action instance to load content or track events.
|
|
577
|
+
*/
|
|
578
|
+
viewCategory(...categories: string[]): Action
|
|
579
|
+
/**
|
|
580
|
+
* Create a new action for a tag page. This should be used only on tag pages.
|
|
581
|
+
* <br/><br/>
|
|
582
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
583
|
+
* action in order for the request to be made.
|
|
584
|
+
* <br/><br/>
|
|
585
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
586
|
+
* from the action.
|
|
587
|
+
* Note: tags are not case-sensitive.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* nostojs(api => api
|
|
591
|
+
* .defaultSession()
|
|
592
|
+
* .viewTag("colourful")
|
|
593
|
+
* .load()
|
|
594
|
+
* .then(data => console.log(data)))
|
|
595
|
+
*
|
|
596
|
+
* @public
|
|
597
|
+
* @deprecated as this is an advanced action with a limited a use case
|
|
598
|
+
* @param {Array<String>} tags the set of the tags being viewed.
|
|
599
|
+
* @returns {Action} the action instance to load content or track events.
|
|
600
|
+
*/
|
|
601
|
+
viewTag(...tags: string[]): Action
|
|
602
|
+
/**
|
|
603
|
+
* Create a new action with custom fields.
|
|
604
|
+
* <br/><br/>
|
|
605
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
606
|
+
* action in order for the request to be made.
|
|
607
|
+
* <br/><br/>
|
|
608
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
609
|
+
* from the action.
|
|
610
|
+
* Note: tags are not case-sensitive.
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* nostojs(api => api
|
|
614
|
+
* .defaultSession()
|
|
615
|
+
* .viewCustomField({material: "cotton"})
|
|
616
|
+
* .load()
|
|
617
|
+
* .then(data => console.log(data)))
|
|
618
|
+
*
|
|
619
|
+
* @public
|
|
620
|
+
* @deprecated as this is an advanced action with a limited a use case
|
|
621
|
+
* @param {Object} customFields custom fields being viewed.
|
|
622
|
+
* @returns {Action} the action instance to load content or track events.
|
|
623
|
+
*/
|
|
624
|
+
viewCustomField(customFields: Record<string, string[]>): Action
|
|
625
|
+
/**
|
|
626
|
+
* Create a new action for a search page. This should be used only
|
|
627
|
+
* on search pages. A search page action requires you to pass the search
|
|
628
|
+
* term. For example, if the user search for "black shoes", you must pass
|
|
629
|
+
* in "black shoes" and not an encoded version such as "black+shoes".
|
|
630
|
+
* <br/><br/>
|
|
631
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
632
|
+
* action in order for the request to be made.
|
|
633
|
+
* <br/><br/>
|
|
634
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
635
|
+
* from the action.
|
|
636
|
+
* Search terms are not case-sensitive.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* nostojs(api => api
|
|
640
|
+
* .defaultSession()
|
|
641
|
+
* .viewSearch("black shoes")
|
|
642
|
+
* .load()
|
|
643
|
+
* .then(data => console.log(data)))
|
|
644
|
+
*
|
|
645
|
+
* @public
|
|
646
|
+
* @param {Array.<String>} searchTerms the non-encoded search terms
|
|
647
|
+
* @returns {Action} the action instance to load content or track events.
|
|
648
|
+
*/
|
|
649
|
+
viewSearch(...searchTerms: string[]): Action
|
|
650
|
+
/**
|
|
651
|
+
* Create a new action for a general page. This should be used only on
|
|
652
|
+
* pages that don't have a corresponding action. For example, if the user
|
|
653
|
+
* is viewing a page such as a "Contact Us" page, you should use the viewOther
|
|
654
|
+
* action.
|
|
655
|
+
* <br/><br/>
|
|
656
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
657
|
+
* action in order for the request to be made.
|
|
658
|
+
* <br/><br/>
|
|
659
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
660
|
+
* from the action.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* nostojs(api => api
|
|
664
|
+
* .defaultSession()
|
|
665
|
+
* .viewOther()
|
|
666
|
+
* .load()
|
|
667
|
+
* .then(data => console.log(data)))
|
|
668
|
+
*
|
|
669
|
+
* @public
|
|
670
|
+
* @returns {Action} the action instance to load content or track events.
|
|
671
|
+
*/
|
|
672
|
+
viewOther(): Action
|
|
673
|
+
/**
|
|
674
|
+
* Create a new action for an order page. This should only be used on order
|
|
675
|
+
* confirmation / thank you pages.
|
|
676
|
+
* <br/><br/>
|
|
677
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
678
|
+
* from the action.
|
|
679
|
+
* <br/><br/>
|
|
680
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
681
|
+
* action in order for the request to be made.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* nostojs(api => {
|
|
685
|
+
* api.defaultSession()
|
|
686
|
+
* .addOrder({
|
|
687
|
+
* external_order_ref: "145000006",
|
|
688
|
+
* info: {
|
|
689
|
+
* order_number: "195",
|
|
690
|
+
* email: "mridang@nosto.com",
|
|
691
|
+
* first_name: "Mridang",
|
|
692
|
+
* last_name: "Agarwalla",
|
|
693
|
+
* type: "order",
|
|
694
|
+
* newsletter: true
|
|
695
|
+
* },
|
|
696
|
+
* items: [{
|
|
697
|
+
* product_id: "406",
|
|
698
|
+
* sku_id: "243",
|
|
699
|
+
* name: "Linen Blazer (White, S)",
|
|
700
|
+
* quantity: 1,
|
|
701
|
+
* unit_price: 455,
|
|
702
|
+
* price_currency_code: "EUR"
|
|
703
|
+
* }]
|
|
704
|
+
* })
|
|
705
|
+
* .setPlacements(["order-related"])
|
|
706
|
+
* .load()
|
|
707
|
+
* .then(data => {
|
|
708
|
+
* console.log(data.recommendations)
|
|
709
|
+
* })
|
|
710
|
+
* })
|
|
711
|
+
* @public
|
|
712
|
+
* @param {Order} order the information about the order that was placed
|
|
713
|
+
* @returns {Action} the action instance to load content or track events.
|
|
714
|
+
*/
|
|
715
|
+
addOrder(order: Order): Action
|
|
716
|
+
/**
|
|
717
|
+
* Creates an action to report that product was added to the shopping cart,
|
|
718
|
+
* e.g. from the recommendation slot with "Add to cart" button.
|
|
719
|
+
* <p>
|
|
720
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
721
|
+
* action in order for the request to be made.
|
|
722
|
+
*
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* nostojs(api => api
|
|
726
|
+
* .defaultSession()
|
|
727
|
+
* .reportAddToCart("123", "reco-slot-1")
|
|
728
|
+
* .load()
|
|
729
|
+
* .then(data => console.log(data)))
|
|
730
|
+
*
|
|
731
|
+
* @public
|
|
732
|
+
* @param product
|
|
733
|
+
* @param element
|
|
734
|
+
* @returns {Action} the action instance to load content or track events.
|
|
735
|
+
*/
|
|
736
|
+
reportAddToCart(product: string, element: string): Action
|
|
737
|
+
/**
|
|
738
|
+
* @example
|
|
739
|
+
* nostojs(api => api
|
|
740
|
+
* .defaultSession()
|
|
741
|
+
* .recordAttribution("vp", "12345678", "123456")
|
|
742
|
+
* .done()
|
|
743
|
+
* .then(data => console.log(data))
|
|
744
|
+
* @param { EventType } type
|
|
745
|
+
* @param { String } target
|
|
746
|
+
* @param { String | undefined } [ref]
|
|
747
|
+
* @param { String | undefined } [refSrc]
|
|
748
|
+
* @return { Object }
|
|
749
|
+
*
|
|
750
|
+
*/
|
|
751
|
+
recordAttribution(type: EventType, target: string, ref: string, refSrc: string): object
|
|
710
752
|
}
|
|
711
753
|
|
|
712
754
|
/**
|
|
713
755
|
* @group Types
|
|
714
756
|
*/
|
|
715
757
|
export interface Action {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
758
|
+
/**
|
|
759
|
+
* Handles click attribution for product recommendations.
|
|
760
|
+
* This can be called when reporting a product view
|
|
761
|
+
* to signal that the view is a result of a click on a recommendation.
|
|
762
|
+
*
|
|
763
|
+
* @public
|
|
764
|
+
* @param {String} productId currently viewed product's product id
|
|
765
|
+
* @param {String} reference value of result_id from the recommendation response that was clicked
|
|
766
|
+
* @return {Action}
|
|
767
|
+
*/
|
|
768
|
+
setRef(productId: string, reference: string): Action
|
|
769
|
+
/**
|
|
770
|
+
* Allows you to provide an additional recommender hint that a product is being
|
|
771
|
+
* viewed.
|
|
772
|
+
* <br/><br/>
|
|
773
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
774
|
+
* action in order for the request to be made.
|
|
775
|
+
*
|
|
776
|
+
* @public
|
|
777
|
+
* @param {String} product the identifier of the product being viewed
|
|
778
|
+
* @return {Action} the instance of the action
|
|
779
|
+
*/
|
|
780
|
+
setProduct(product: string | Product): Action
|
|
781
|
+
/**
|
|
782
|
+
* @deprecated
|
|
783
|
+
* @param {Array<String>} products
|
|
784
|
+
* @return {Action}
|
|
785
|
+
*/
|
|
786
|
+
setProducts(products: (string | Product)[]): Action
|
|
787
|
+
/**
|
|
788
|
+
* Sets the information about the user's current shopping cart. It the user
|
|
789
|
+
* does not have any items in his shopping cart, you can pass <code>null<code>.
|
|
790
|
+
* Passing <code>null<code> will nullify the user's shopping cart on Nosto's
|
|
791
|
+
* end. You must also pass in the shopping cart content in it's entirety as
|
|
792
|
+
* partial content are not supported.
|
|
793
|
+
* <br/><br/>
|
|
794
|
+
* It is not recommended to pass the current cart contents to an action but
|
|
795
|
+
* instead use the the session
|
|
796
|
+
* <br/><br/>
|
|
797
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
798
|
+
* action in order for the request to be made.
|
|
799
|
+
*
|
|
800
|
+
* @see {@link Session#setCart}
|
|
801
|
+
* @return {Action}
|
|
802
|
+
*/
|
|
803
|
+
setCart(cart: Cart): Action
|
|
804
|
+
/**
|
|
805
|
+
* Sets the information about the currently logged in customer. If the current
|
|
806
|
+
* customer is not provided, you will not be able to leverage features such as
|
|
807
|
+
* triggered emails. While it is recommended to always provide the details of
|
|
808
|
+
* the currently logged in customer, it may be omitted if there are concerns
|
|
809
|
+
* about privacy or compliance.
|
|
810
|
+
* <br/><br/>
|
|
811
|
+
* It is not recommended to pass the current customer details to an action but
|
|
812
|
+
* instead use the the session
|
|
813
|
+
* <br/><br/>
|
|
814
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
815
|
+
* action in order for the request to be made.
|
|
816
|
+
*
|
|
817
|
+
* @see {@link Session#setCustomer}
|
|
818
|
+
* @public
|
|
819
|
+
* @param {Customer} customer the details of the currently logged in customer
|
|
820
|
+
* @return {Action}
|
|
821
|
+
*/
|
|
822
|
+
setCustomer(customer: Customer): Action
|
|
823
|
+
/**
|
|
824
|
+
* @param {Order} order
|
|
825
|
+
* @return {Action}
|
|
826
|
+
*/
|
|
827
|
+
setOrder(order: Order): Action
|
|
828
|
+
/**
|
|
829
|
+
* <br/><br/>
|
|
830
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
831
|
+
* action in order for the request to be made.
|
|
832
|
+
*
|
|
833
|
+
* @public
|
|
834
|
+
* @param searchTerms
|
|
835
|
+
* @return {Action}
|
|
836
|
+
*/
|
|
837
|
+
setSearchTerms(searchTerms: string[]): Action
|
|
838
|
+
/**
|
|
839
|
+
* <br/><br/>
|
|
840
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
841
|
+
* action in order for the request to be made.
|
|
842
|
+
*
|
|
843
|
+
* @public
|
|
844
|
+
* @param {Array<String>} categories
|
|
845
|
+
* @return {Action}
|
|
846
|
+
*/
|
|
847
|
+
setCategories(categories: string[]): Action
|
|
848
|
+
/**
|
|
849
|
+
* <br/><br/>
|
|
850
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
851
|
+
* action in order for the request to be made.
|
|
852
|
+
*
|
|
853
|
+
* @public
|
|
854
|
+
* @param {Array<String>} categoryIds
|
|
855
|
+
* @return {Action}
|
|
856
|
+
*/
|
|
857
|
+
setCategoryIds(categoryIds: string[]): Action
|
|
858
|
+
/**
|
|
859
|
+
* <br/><br/>
|
|
860
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
861
|
+
* action in order for the request to be made.
|
|
862
|
+
*
|
|
863
|
+
* @public
|
|
864
|
+
* @param {Array<String>} parentCategoryIds
|
|
865
|
+
* @return {Action}
|
|
866
|
+
*/
|
|
867
|
+
setParentCategoryIds(parentCategoryIds: string[]): Action
|
|
868
|
+
/**
|
|
869
|
+
* <br/><br/>
|
|
870
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
871
|
+
* action in order for the request to be made.
|
|
872
|
+
*
|
|
873
|
+
* @public
|
|
874
|
+
* @param tags
|
|
875
|
+
* @return {Action}
|
|
876
|
+
*/
|
|
877
|
+
setTags(tags: string[]): Action
|
|
878
|
+
/**
|
|
879
|
+
* <br/><br/>
|
|
880
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
881
|
+
* action in order for the request to be made.
|
|
882
|
+
*
|
|
883
|
+
* @public
|
|
884
|
+
* @param customFields
|
|
885
|
+
* @return {Action}
|
|
886
|
+
*/
|
|
887
|
+
setCustomFields(customFields: Record<string, string[]>): Action
|
|
888
|
+
/**
|
|
889
|
+
* Sets the current variation identifier for the session. A variation identifier
|
|
890
|
+
* identifies the current currency (or the current customer group). If your site
|
|
891
|
+
* uses multi-currency, you must provide the ISO code current currency being viewed.
|
|
892
|
+
* <br/><br/>
|
|
893
|
+
* It is not recommended to pass the variation identifier to an action but
|
|
894
|
+
* instead use the the session.
|
|
895
|
+
* <br/><br/>
|
|
896
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
897
|
+
* action in order for the request to be made.
|
|
898
|
+
*
|
|
899
|
+
* @see {@link Session#setVariation}
|
|
900
|
+
* @public
|
|
901
|
+
* @param {String} variation the case-sensitive identifier of the current variation
|
|
902
|
+
* @return {Action}
|
|
903
|
+
*/
|
|
904
|
+
setVariation(variation: string): Action
|
|
905
|
+
/**
|
|
906
|
+
* <br/><br/>
|
|
907
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
908
|
+
* action in order for the request to be made.
|
|
909
|
+
*
|
|
910
|
+
* @public
|
|
911
|
+
* @param {Array.<String>} placements
|
|
912
|
+
* @return {Action}
|
|
913
|
+
*/
|
|
914
|
+
setPlacements(placements: string[]): Action
|
|
915
|
+
/**
|
|
916
|
+
* Sets the restore link for the current session. Restore links can be leveraged
|
|
917
|
+
* in email campaigns. Restore links allow the the user to restore the cart
|
|
918
|
+
* contents in a single click.
|
|
919
|
+
* <br/><br/>
|
|
920
|
+
* Read more about
|
|
921
|
+
* {@link https://help.nosto.com/en/articles/664692|how to leverage the restore cart link}
|
|
922
|
+
* <br/><br/>
|
|
923
|
+
* It is not recommended to pass the restore link to an action but instead use the the
|
|
924
|
+
* session.
|
|
925
|
+
* <br/><br/>
|
|
926
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
927
|
+
* action in order for the request to be made.
|
|
928
|
+
*
|
|
929
|
+
* @see {@link Session#setRestoreLink}
|
|
930
|
+
* @public
|
|
931
|
+
* @param {String} restoreLink the secure URL to restore the user's current session
|
|
932
|
+
* @return {Action}
|
|
933
|
+
*/
|
|
934
|
+
setRestoreLink(restoreLink: string): Action
|
|
935
|
+
/**
|
|
936
|
+
* Sets the identifier of the current page type to the current request. The different
|
|
937
|
+
* page types are product, front, search, cart, order, category, notfound and other.
|
|
938
|
+
* <br/><br/>
|
|
939
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
940
|
+
* action in order for the request to be made.
|
|
941
|
+
* <br/><br/>
|
|
942
|
+
* It is not recommended to pass the page type to an action but instead use the the
|
|
943
|
+
* session.
|
|
944
|
+
* <br/><br/>
|
|
945
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
946
|
+
* action in order for the request to be made.
|
|
947
|
+
*
|
|
948
|
+
* @see {@link Session#viewFrontPage} for when a front or home page is being viewed
|
|
949
|
+
* @see {@link Session#viewCart} for when a cart or checkout page is being viewed
|
|
950
|
+
* @see {@link Session#viewNotFound} for when a not-found or 404 page is being viewed
|
|
951
|
+
* @see {@link Session#viewProduct} for when a product page is being viewed
|
|
952
|
+
* @see {@link Session#viewCategory} for when a category, collection or brand page is being viewed
|
|
953
|
+
* @see {@link Session#viewTag} for when a tag page is being viewed
|
|
954
|
+
* @see {@link Session#viewSearch} for when a search page is being viewed
|
|
955
|
+
* @see {@link Session#viewOther} for when a miscellaneous page is being viewed
|
|
956
|
+
* @public
|
|
957
|
+
*/
|
|
958
|
+
setPageType(pageType: PageType): Action
|
|
959
|
+
/**
|
|
960
|
+
* @public
|
|
961
|
+
* @return {Object}
|
|
962
|
+
*/
|
|
963
|
+
dumpData(): Data
|
|
964
|
+
update(): unknown
|
|
965
|
+
load(flags?: RecommendationRequestFlags): Promise<ActionResponse>
|
|
924
966
|
}
|
|
925
967
|
|
|
926
968
|
export interface ActionResponse {
|
|
969
|
+
recommendations: Record<string, unknown>
|
|
970
|
+
campaigns?: {
|
|
927
971
|
recommendations: Record<string, unknown>
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
affinities: CustomerAffinityResponse
|
|
935
|
-
cmpid: string
|
|
972
|
+
content: Record<string, unknown>
|
|
973
|
+
}
|
|
974
|
+
page_views: number
|
|
975
|
+
geo_location: string[]
|
|
976
|
+
affinities: CustomerAffinityResponse
|
|
977
|
+
cmpid: string
|
|
936
978
|
}
|