@nosto/nosto-react 0.5.0 → 1.0.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 +1 -6
- package/dist/index.d.ts +793 -111
- package/dist/index.es.js +562 -752
- package/dist/index.umd.js +9 -9
- package/package.json +1 -1
- package/src/components/Nosto404.tsx +1 -8
- package/src/components/NostoCategory.tsx +1 -11
- package/src/components/NostoCheckout.tsx +1 -9
- package/src/components/NostoHome.tsx +1 -8
- package/src/components/NostoOrder.tsx +3 -13
- package/src/components/NostoOther.tsx +1 -8
- package/src/components/NostoProduct.tsx +3 -95
- package/src/components/NostoSearch.tsx +1 -11
- package/src/components/NostoSession.tsx +2 -2
- package/src/components/context.ts +2 -2
- package/src/index.ts +1 -2
- package/src/types.ts +792 -101
- package/src/utils/hooks.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,227 @@ import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
|
5
5
|
/**
|
|
6
6
|
* @group Types
|
|
7
7
|
*/
|
|
8
|
-
declare interface
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
declare interface Action {
|
|
9
|
+
/**
|
|
10
|
+
* Handles click attribution for product recommendations.
|
|
11
|
+
* This can be called when reporting a product view
|
|
12
|
+
* to signal that the view is a result of a click on a recommendation.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @param {String} productId currently viewed product's product id
|
|
16
|
+
* @param {String} reference value of result_id from the recommendation response that was clicked
|
|
17
|
+
* @return {Action}
|
|
18
|
+
*/
|
|
19
|
+
setRef(productId: string, reference: string): Action;
|
|
20
|
+
/**
|
|
21
|
+
* Allows you to provide an additional recommender hint that a product is being
|
|
22
|
+
* viewed.
|
|
23
|
+
* <br/><br/>
|
|
24
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
25
|
+
* action in order for the request to be made.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
* @param {String} product the identifier of the product being viewed
|
|
29
|
+
* @return {Action} the instance of the action
|
|
30
|
+
*/
|
|
31
|
+
setProduct(product: string | Product): Action;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated
|
|
34
|
+
* @param {Array<String>} products
|
|
35
|
+
* @return {Action}
|
|
36
|
+
*/
|
|
37
|
+
setProducts(products: (string | Product)[]): Action;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the information about the user's current shopping cart. It the user
|
|
40
|
+
* does not have any items in his shopping cart, you can pass <code>null<code>.
|
|
41
|
+
* Passing <code>null<code> will nullify the user's shopping cart on Nosto's
|
|
42
|
+
* end. You must also pass in the shopping cart content in it's entirety as
|
|
43
|
+
* partial content are not supported.
|
|
44
|
+
* <br/><br/>
|
|
45
|
+
* It is not recommended to pass the current cart contents to an action but
|
|
46
|
+
* instead use the the session
|
|
47
|
+
* <br/><br/>
|
|
48
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
49
|
+
* action in order for the request to be made.
|
|
50
|
+
*
|
|
51
|
+
* @see {@link Session#setCart}
|
|
52
|
+
* @return {Action}
|
|
53
|
+
*/
|
|
54
|
+
setCart(cart: Cart): Action;
|
|
55
|
+
/**
|
|
56
|
+
* Sets the information about the currently logged in customer. If the current
|
|
57
|
+
* customer is not provided, you will not be able to leverage features such as
|
|
58
|
+
* triggered emails. While it is recommended to always provide the details of
|
|
59
|
+
* the currently logged in customer, it may be omitted if there are concerns
|
|
60
|
+
* about privacy or compliance.
|
|
61
|
+
* <br/><br/>
|
|
62
|
+
* It is not recommended to pass the current customer details to an action but
|
|
63
|
+
* instead use the the session
|
|
64
|
+
* <br/><br/>
|
|
65
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
66
|
+
* action in order for the request to be made.
|
|
67
|
+
*
|
|
68
|
+
* @see {@link Session#setCustomer}
|
|
69
|
+
* @public
|
|
70
|
+
* @param {Customer} customer the details of the currently logged in customer
|
|
71
|
+
* @return {Action}
|
|
72
|
+
*/
|
|
73
|
+
setCustomer(customer: Customer): Action;
|
|
74
|
+
/**
|
|
75
|
+
* @param {Order} order
|
|
76
|
+
* @return {Action}
|
|
77
|
+
*/
|
|
78
|
+
setOrder(order: Order): Action;
|
|
79
|
+
/**
|
|
80
|
+
* <br/><br/>
|
|
81
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
82
|
+
* action in order for the request to be made.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
* @param searchTerms
|
|
86
|
+
* @return {Action}
|
|
87
|
+
*/
|
|
88
|
+
setSearchTerms(searchTerms: string[]): Action;
|
|
89
|
+
/**
|
|
90
|
+
* <br/><br/>
|
|
91
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
92
|
+
* action in order for the request to be made.
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
* @param {Array<String>} categories
|
|
96
|
+
* @return {Action}
|
|
97
|
+
*/
|
|
98
|
+
setCategories(categories: string[]): Action;
|
|
99
|
+
/**
|
|
100
|
+
* <br/><br/>
|
|
101
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
102
|
+
* action in order for the request to be made.
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
* @param {Array<String>} categoryIds
|
|
106
|
+
* @return {Action}
|
|
107
|
+
*/
|
|
108
|
+
setCategoryIds(categoryIds: string[]): Action;
|
|
109
|
+
/**
|
|
110
|
+
* <br/><br/>
|
|
111
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
112
|
+
* action in order for the request to be made.
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
* @param {Array<String>} parentCategoryIds
|
|
116
|
+
* @return {Action}
|
|
117
|
+
*/
|
|
118
|
+
setParentCategoryIds(parentCategoryIds: string[]): Action;
|
|
119
|
+
/**
|
|
120
|
+
* <br/><br/>
|
|
121
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
122
|
+
* action in order for the request to be made.
|
|
123
|
+
*
|
|
124
|
+
* @public
|
|
125
|
+
* @param tags
|
|
126
|
+
* @return {Action}
|
|
127
|
+
*/
|
|
128
|
+
setTags(tags: string[]): Action;
|
|
129
|
+
/**
|
|
130
|
+
* <br/><br/>
|
|
131
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
132
|
+
* action in order for the request to be made.
|
|
133
|
+
*
|
|
134
|
+
* @public
|
|
135
|
+
* @param customFields
|
|
136
|
+
* @return {Action}
|
|
137
|
+
*/
|
|
138
|
+
setCustomFields(customFields: Record<string, string[]>): Action;
|
|
139
|
+
/**
|
|
140
|
+
* Sets the current variation identifier for the session. A variation identifier
|
|
141
|
+
* identifies the current currency (or the current customer group). If your site
|
|
142
|
+
* uses multi-currency, you must provide the ISO code current currency being viewed.
|
|
143
|
+
* <br/><br/>
|
|
144
|
+
* It is not recommended to pass the variation identifier to an action but
|
|
145
|
+
* instead use the the session.
|
|
146
|
+
* <br/><br/>
|
|
147
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
148
|
+
* action in order for the request to be made.
|
|
149
|
+
*
|
|
150
|
+
* @see {@link Session#setVariation}
|
|
151
|
+
* @public
|
|
152
|
+
* @param {String} variation the case-sensitive identifier of the current variation
|
|
153
|
+
* @return {Action}
|
|
154
|
+
*/
|
|
155
|
+
setVariation(variation: string): Action;
|
|
156
|
+
/**
|
|
157
|
+
* <br/><br/>
|
|
158
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
159
|
+
* action in order for the request to be made.
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
* @param {Array.<String>} placements
|
|
163
|
+
* @return {Action}
|
|
164
|
+
*/
|
|
165
|
+
setPlacements(placements: string[]): Action;
|
|
166
|
+
/**
|
|
167
|
+
* Sets the restore link for the current session. Restore links can be leveraged
|
|
168
|
+
* in email campaigns. Restore links allow the the user to restore the cart
|
|
169
|
+
* contents in a single click.
|
|
170
|
+
* <br/><br/>
|
|
171
|
+
* Read more about
|
|
172
|
+
* {@link https://help.nosto.com/en/articles/664692|how to leverage the restore cart link}
|
|
173
|
+
* <br/><br/>
|
|
174
|
+
* It is not recommended to pass the restore link to an action but instead use the the
|
|
175
|
+
* session.
|
|
176
|
+
* <br/><br/>
|
|
177
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
178
|
+
* action in order for the request to be made.
|
|
179
|
+
*
|
|
180
|
+
* @see {@link Session#setRestoreLink}
|
|
181
|
+
* @public
|
|
182
|
+
* @param {String} restoreLink the secure URL to restore the user's current session
|
|
183
|
+
* @return {Action}
|
|
184
|
+
*/
|
|
185
|
+
setRestoreLink(restoreLink: string): Action;
|
|
186
|
+
/**
|
|
187
|
+
* Sets the identifier of the current page type to the current request. The different
|
|
188
|
+
* page types are product, front, search, cart, order, category, notfound and other.
|
|
189
|
+
* <br/><br/>
|
|
190
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
191
|
+
* action in order for the request to be made.
|
|
192
|
+
* <br/><br/>
|
|
193
|
+
* It is not recommended to pass the page type to an action but instead use the the
|
|
194
|
+
* session.
|
|
195
|
+
* <br/><br/>
|
|
196
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
197
|
+
* action in order for the request to be made.
|
|
198
|
+
*
|
|
199
|
+
* @see {@link Session#viewFrontPage} for when a front or home page is being viewed
|
|
200
|
+
* @see {@link Session#viewCart} for when a cart or checkout page is being viewed
|
|
201
|
+
* @see {@link Session#viewNotFound} for when a not-found or 404 page is being viewed
|
|
202
|
+
* @see {@link Session#viewProduct} for when a product page is being viewed
|
|
203
|
+
* @see {@link Session#viewCategory} for when a category, collection or brand page is being viewed
|
|
204
|
+
* @see {@link Session#viewTag} for when a tag page is being viewed
|
|
205
|
+
* @see {@link Session#viewSearch} for when a search page is being viewed
|
|
206
|
+
* @see {@link Session#viewOther} for when a miscellaneous page is being viewed
|
|
207
|
+
* @public
|
|
208
|
+
*/
|
|
209
|
+
setPageType(pageType: PageType): Action;
|
|
210
|
+
/**
|
|
211
|
+
* @public
|
|
212
|
+
* @return {Object}
|
|
213
|
+
*/
|
|
214
|
+
dumpData(): Data;
|
|
215
|
+
update(): unknown;
|
|
216
|
+
load(flags?: RecommendationRequestFlags): Promise<ActionResponse>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
declare interface ActionResponse {
|
|
220
|
+
recommendations: Record<string, unknown>;
|
|
221
|
+
campaigns?: {
|
|
222
|
+
recommendations: Record<string, unknown>;
|
|
223
|
+
content: Record<string, unknown>;
|
|
224
|
+
};
|
|
225
|
+
page_views: number;
|
|
226
|
+
geo_location: string[];
|
|
227
|
+
affinities: CustomerAffinityResponse;
|
|
228
|
+
cmpid: string;
|
|
11
229
|
}
|
|
12
230
|
|
|
13
231
|
declare type AnyFunction = (...args: unknown[]) => unknown;
|
|
@@ -15,44 +233,98 @@ declare type AnyFunction = (...args: unknown[]) => unknown;
|
|
|
15
233
|
/**
|
|
16
234
|
* @group Types
|
|
17
235
|
*/
|
|
18
|
-
export declare interface
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
email: string;
|
|
22
|
-
type: string;
|
|
23
|
-
newsletter: boolean;
|
|
236
|
+
export declare interface Cart {
|
|
237
|
+
hcid?: string;
|
|
238
|
+
items: CartItem[];
|
|
24
239
|
}
|
|
25
240
|
|
|
26
241
|
/**
|
|
27
242
|
* @group Types
|
|
28
243
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
244
|
+
declare interface CartItem {
|
|
245
|
+
name: string;
|
|
246
|
+
price_currency_code: string;
|
|
247
|
+
product_id: string;
|
|
248
|
+
quantity: number;
|
|
249
|
+
sku_id?: string;
|
|
250
|
+
unit_price: number;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @group Types
|
|
255
|
+
*/
|
|
256
|
+
declare interface ConversionItem {
|
|
257
|
+
name: string;
|
|
258
|
+
price_currency_code: string;
|
|
259
|
+
product_id: string;
|
|
260
|
+
quantity?: number;
|
|
261
|
+
sku_id?: string;
|
|
262
|
+
unit_price?: number;
|
|
31
263
|
}
|
|
32
264
|
|
|
33
265
|
/**
|
|
34
266
|
* @group Types
|
|
35
267
|
*/
|
|
36
268
|
export declare interface Customer {
|
|
37
|
-
customer_reference
|
|
269
|
+
customer_reference?: string;
|
|
38
270
|
email: string;
|
|
39
271
|
first_name: string;
|
|
272
|
+
hcid?: string;
|
|
40
273
|
last_name: string;
|
|
41
|
-
newsletter
|
|
274
|
+
newsletter?: boolean;
|
|
275
|
+
order_number?: string;
|
|
276
|
+
source?: string;
|
|
277
|
+
source_id?: string;
|
|
278
|
+
type?: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @group Types
|
|
283
|
+
*/
|
|
284
|
+
declare interface CustomerAffinityResponse {
|
|
285
|
+
discount: number;
|
|
286
|
+
top_brands: CustomerAffinityResponseItem[];
|
|
287
|
+
top_categories: CustomerAffinityResponseItem[];
|
|
288
|
+
top_product_types: CustomerAffinityResponseItem[];
|
|
289
|
+
top_skus: {
|
|
290
|
+
[index: string]: CustomerAffinityResponseItem[];
|
|
291
|
+
};
|
|
42
292
|
}
|
|
43
293
|
|
|
44
294
|
/**
|
|
45
295
|
* @group Types
|
|
46
296
|
*/
|
|
47
|
-
|
|
297
|
+
declare interface CustomerAffinityResponseItem {
|
|
48
298
|
name: string;
|
|
49
|
-
|
|
50
|
-
product_id: string;
|
|
51
|
-
quantity: number;
|
|
52
|
-
sku_id: string;
|
|
53
|
-
unit_price: number;
|
|
299
|
+
score: number;
|
|
54
300
|
}
|
|
55
301
|
|
|
302
|
+
/**
|
|
303
|
+
* @group Types
|
|
304
|
+
*/
|
|
305
|
+
declare interface Data<ProductType extends Product = Product> {
|
|
306
|
+
cart: Cart | undefined;
|
|
307
|
+
customer: Customer | undefined;
|
|
308
|
+
variation: string | undefined;
|
|
309
|
+
restoreLink: string | undefined;
|
|
310
|
+
products: ProductType[];
|
|
311
|
+
order: Order | undefined;
|
|
312
|
+
searchTerms: string[] | undefined;
|
|
313
|
+
categories: string[] | undefined;
|
|
314
|
+
categoryIds: string[] | undefined;
|
|
315
|
+
parentCategoryIds: string[] | undefined;
|
|
316
|
+
tags: string[] | undefined;
|
|
317
|
+
customFields: Record<string, string[]> | undefined;
|
|
318
|
+
elements: string[] | undefined;
|
|
319
|
+
pageType: PageType | undefined;
|
|
320
|
+
sortOrder: string | undefined;
|
|
321
|
+
pluginVersion: PluginMetadata | undefined;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
declare type EventType = typeof eventTypes[number];
|
|
325
|
+
|
|
326
|
+
declare const eventTypes: readonly ["vp", "lp", "dp", "rp", "bp", "vc", "or", "is", "cp", "ec", "es", "gc", "src", "cpr", "pl", "cc", "con"];
|
|
327
|
+
|
|
56
328
|
/**
|
|
57
329
|
* You can personalise your cart and checkout pages by using the `Nosto404` component.
|
|
58
330
|
* The component does not require any props.
|
|
@@ -75,7 +347,7 @@ export declare interface Item {
|
|
|
75
347
|
*/
|
|
76
348
|
export declare function Nosto404(props: {
|
|
77
349
|
placements?: string[];
|
|
78
|
-
}):
|
|
350
|
+
}): null;
|
|
79
351
|
|
|
80
352
|
/**
|
|
81
353
|
* You can personalise your category and collection pages by using the NostoCategory component.
|
|
@@ -102,7 +374,7 @@ export declare function Nosto404(props: {
|
|
|
102
374
|
export declare function NostoCategory(props: {
|
|
103
375
|
category: string;
|
|
104
376
|
placements?: string[];
|
|
105
|
-
}):
|
|
377
|
+
}): null;
|
|
106
378
|
|
|
107
379
|
/**
|
|
108
380
|
* You can personalise your cart and checkout pages by using the NostoCheckout component.
|
|
@@ -125,40 +397,20 @@ export declare function NostoCategory(props: {
|
|
|
125
397
|
*/
|
|
126
398
|
export declare function NostoCheckout(props: {
|
|
127
399
|
placements?: string[];
|
|
128
|
-
}):
|
|
400
|
+
}): null;
|
|
129
401
|
|
|
130
402
|
/**
|
|
131
403
|
* @group Types
|
|
132
404
|
*/
|
|
133
405
|
declare interface NostoClient {
|
|
134
|
-
setAutoLoad(autoload: boolean):
|
|
135
|
-
defaultSession():
|
|
406
|
+
setAutoLoad(autoload: boolean): void;
|
|
407
|
+
defaultSession(): Session;
|
|
136
408
|
placements: {
|
|
137
409
|
getPlacements(): string[];
|
|
138
|
-
injectCampaigns(recommendations: Record<string,
|
|
410
|
+
injectCampaigns(recommendations: Record<string, unknown>): void;
|
|
139
411
|
};
|
|
140
412
|
}
|
|
141
413
|
|
|
142
|
-
/**
|
|
143
|
-
* @group Types
|
|
144
|
-
*/
|
|
145
|
-
declare interface NostoClientSession {
|
|
146
|
-
setCart(cart?: Cart): NostoClientSession;
|
|
147
|
-
setCustomer(customer?: Customer): NostoClientSession;
|
|
148
|
-
setResponseMode(mode: string): NostoClientSession;
|
|
149
|
-
setVariation(variation?: string): NostoClientSession;
|
|
150
|
-
addOrder(order: {
|
|
151
|
-
purchase: Purchase;
|
|
152
|
-
}): SessionAction;
|
|
153
|
-
viewCategory(category: string): SessionAction;
|
|
154
|
-
viewProduct(product: string): SessionAction;
|
|
155
|
-
viewFrontPage(): SessionAction;
|
|
156
|
-
viewNotFound(): SessionAction;
|
|
157
|
-
viewOther(): SessionAction;
|
|
158
|
-
viewSearch(query: string): SessionAction;
|
|
159
|
-
viewCart(): SessionAction;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
414
|
/**
|
|
163
415
|
* @group Essential Functions
|
|
164
416
|
*/
|
|
@@ -172,7 +424,7 @@ export declare interface NostoContextType {
|
|
|
172
424
|
clientScriptLoaded: boolean;
|
|
173
425
|
currentVariation?: string;
|
|
174
426
|
renderFunction?: AnyFunction;
|
|
175
|
-
responseMode:
|
|
427
|
+
responseMode: RenderMode;
|
|
176
428
|
recommendationComponent?: React.ReactElement<{
|
|
177
429
|
nostoRecommendation: Recommendation;
|
|
178
430
|
}>;
|
|
@@ -208,7 +460,7 @@ export declare interface NostoContextType {
|
|
|
208
460
|
*/
|
|
209
461
|
export declare function NostoHome(props: {
|
|
210
462
|
placements?: string[];
|
|
211
|
-
}):
|
|
463
|
+
}): null;
|
|
212
464
|
|
|
213
465
|
/**
|
|
214
466
|
* You can personalise your order-confirmation/thank-you page by using the `NostoOrder` component.
|
|
@@ -230,11 +482,9 @@ export declare function NostoHome(props: {
|
|
|
230
482
|
* @group Components
|
|
231
483
|
*/
|
|
232
484
|
export declare function NostoOrder(props: {
|
|
233
|
-
order:
|
|
234
|
-
purchase: Purchase;
|
|
235
|
-
};
|
|
485
|
+
order: Order;
|
|
236
486
|
placements?: string[];
|
|
237
|
-
}):
|
|
487
|
+
}): null;
|
|
238
488
|
|
|
239
489
|
/**
|
|
240
490
|
* You can personalise your miscellaneous pages by using the NostoOther component.
|
|
@@ -257,7 +507,7 @@ export declare function NostoOrder(props: {
|
|
|
257
507
|
*/
|
|
258
508
|
export declare function NostoOther(props: {
|
|
259
509
|
placements?: string[];
|
|
260
|
-
}):
|
|
510
|
+
}): null;
|
|
261
511
|
|
|
262
512
|
/**
|
|
263
513
|
* Nosto React has a special component called NostoPlacement.
|
|
@@ -305,7 +555,7 @@ export declare function NostoProduct(props: {
|
|
|
305
555
|
product: string;
|
|
306
556
|
tagging?: Product;
|
|
307
557
|
placements?: string[];
|
|
308
|
-
}):
|
|
558
|
+
}): null;
|
|
309
559
|
|
|
310
560
|
/**
|
|
311
561
|
* This widget is what we call the Nosto root widget, which is responsible for adding the actual Nosto script and the JS API stub.
|
|
@@ -392,7 +642,7 @@ declare interface NostoProviderProps {
|
|
|
392
642
|
export declare function NostoSearch(props: {
|
|
393
643
|
query: string;
|
|
394
644
|
placements?: string[];
|
|
395
|
-
}):
|
|
645
|
+
}): null;
|
|
396
646
|
|
|
397
647
|
/**
|
|
398
648
|
* Nosto React requires that you pass it the details of current cart contents and the details of the currently logged-in customer, if any, on every route change.
|
|
@@ -404,55 +654,61 @@ export declare function NostoSearch(props: {
|
|
|
404
654
|
*
|
|
405
655
|
* @group Essential Functions
|
|
406
656
|
*/
|
|
407
|
-
export declare function NostoSession(props
|
|
408
|
-
cart
|
|
409
|
-
customer
|
|
657
|
+
export declare function NostoSession(props?: {
|
|
658
|
+
cart?: Cart;
|
|
659
|
+
customer?: Customer;
|
|
410
660
|
}): JSX_2.Element;
|
|
411
661
|
|
|
412
662
|
/**
|
|
413
663
|
* @group Types
|
|
414
664
|
*/
|
|
415
|
-
export declare interface
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
thumbUrl?: URL;
|
|
439
|
-
url: URL;
|
|
440
|
-
customFields?: {
|
|
441
|
-
[key: string]: string;
|
|
442
|
-
};
|
|
443
|
-
variationId?: string;
|
|
444
|
-
skus?: SKU[];
|
|
665
|
+
export declare interface Order {
|
|
666
|
+
created_at?: Date;
|
|
667
|
+
external_order_ref: string;
|
|
668
|
+
info?: OrderCustomer;
|
|
669
|
+
items: ConversionItem[];
|
|
670
|
+
order_status?: string;
|
|
671
|
+
order_status_label?: string;
|
|
672
|
+
payment_provider: string;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* @group Types
|
|
677
|
+
*/
|
|
678
|
+
declare interface OrderCustomer {
|
|
679
|
+
country: string;
|
|
680
|
+
email?: string;
|
|
681
|
+
first_name?: string;
|
|
682
|
+
last_name?: string;
|
|
683
|
+
newsletter: string;
|
|
684
|
+
order_number: string;
|
|
685
|
+
phone: string;
|
|
686
|
+
post_code: string;
|
|
687
|
+
type: string;
|
|
445
688
|
}
|
|
446
689
|
|
|
447
690
|
/**
|
|
448
691
|
* @group Types
|
|
449
692
|
*/
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
693
|
+
declare type PageType = "front" | "category" | "product" | "cart" | "search" | "notfound" | "order" | "other" | "checkout";
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* @group Types
|
|
697
|
+
*/
|
|
698
|
+
declare interface PluginMetadata {
|
|
699
|
+
mainModule?: string;
|
|
700
|
+
cmpModule?: string;
|
|
701
|
+
msiModule?: string;
|
|
454
702
|
}
|
|
455
703
|
|
|
704
|
+
/**
|
|
705
|
+
* @group Types
|
|
706
|
+
*/
|
|
707
|
+
export declare type Product = {
|
|
708
|
+
product_id: string;
|
|
709
|
+
selected_sku_id?: string;
|
|
710
|
+
};
|
|
711
|
+
|
|
456
712
|
/**
|
|
457
713
|
* @group Types
|
|
458
714
|
*/
|
|
@@ -469,31 +725,457 @@ export declare interface Recommendation {
|
|
|
469
725
|
/**
|
|
470
726
|
* @group Types
|
|
471
727
|
*/
|
|
472
|
-
declare interface
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
page_views: number;
|
|
478
|
-
recommendations: Recommendation[];
|
|
479
|
-
}>;
|
|
728
|
+
declare interface RecommendationRequestFlags {
|
|
729
|
+
skipPageViews?: boolean;
|
|
730
|
+
trackEvents?: boolean;
|
|
731
|
+
skipEvents?: boolean;
|
|
732
|
+
reloadCart?: boolean;
|
|
480
733
|
}
|
|
481
734
|
|
|
482
735
|
/**
|
|
483
736
|
* @group Types
|
|
484
737
|
*/
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
738
|
+
declare type RenderMode = "HTML" | "SIMPLE" | "JSON_170x170" | "JSON_100_X_100" | "JSON_90x70" | "JSON_50x50" | "JSON_30x30" | "JSON_100x140" | "JSON_200x200" | "JSON_400x400" | "JSON_750x750" | "JSON_10_MAX_SQUARE" | "JSON_200x200_SQUARE" | "JSON_400x400_SQUARE" | "JSON_750x750_SQUARE" | "JSON_ORIGINAL" | "VERSION_SOURCE";
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* @group Types
|
|
742
|
+
*/
|
|
743
|
+
declare interface Session {
|
|
744
|
+
/**
|
|
745
|
+
* Sets the information about the user's current shopping cart. It the user
|
|
746
|
+
* does not have any items in his shopping cart, you can pass <code>null<code>.
|
|
747
|
+
* Passing <code>null<code> will nullify the user's shopping cart on Nosto's
|
|
748
|
+
* end. You must also pass in the shopping cart content in it's entirety as
|
|
749
|
+
* partial content are not supported.
|
|
750
|
+
*
|
|
751
|
+
* @example
|
|
752
|
+
* nostojs(api => api
|
|
753
|
+
* .defaultSession()
|
|
754
|
+
* .setCart({
|
|
755
|
+
* items: [
|
|
756
|
+
* product_id: "101",
|
|
757
|
+
* sku_id: "101-S",
|
|
758
|
+
* name: "Shoe",
|
|
759
|
+
* unit_price: 34.99
|
|
760
|
+
* price_currency_code: "EUR"
|
|
761
|
+
* ]
|
|
762
|
+
* })
|
|
763
|
+
* .viewCart()
|
|
764
|
+
* .setPlacements(["free-shipper"])
|
|
765
|
+
* .update()
|
|
766
|
+
* .then(data => console.log(data)))
|
|
767
|
+
*
|
|
768
|
+
* @public
|
|
769
|
+
* @param {Cart|undefined} cart the details of the user's shopping cart contents
|
|
770
|
+
* @returns {Session} the current session
|
|
771
|
+
*/
|
|
772
|
+
setCart(cart: Cart | undefined): Session;
|
|
773
|
+
/**
|
|
774
|
+
* Sets the information about the currently logged in customer. If the current
|
|
775
|
+
* customer is not provided, you will not be able to leverage features such as
|
|
776
|
+
* triggered emails. While it is recommended to always provide the details of
|
|
777
|
+
* the currently logged in customer, it may be omitted if there are concerns
|
|
778
|
+
* about privacy or compliance.
|
|
779
|
+
*
|
|
780
|
+
* @example
|
|
781
|
+
* nostojs(api => api
|
|
782
|
+
* .defaultSession()
|
|
783
|
+
* .setCustomer({
|
|
784
|
+
* first_name: "Mridang",
|
|
785
|
+
* last_name: "Agarwalla",
|
|
786
|
+
* email: "mridang@nosto.com",
|
|
787
|
+
* newsletter: false,
|
|
788
|
+
* customer_reference: "5e3d4a9c-cf58-11ea-87d0-0242ac130003"
|
|
789
|
+
* })
|
|
790
|
+
* .viewCart()
|
|
791
|
+
* .setPlacements(["free-shipper"])
|
|
792
|
+
* .load()
|
|
793
|
+
* .then(data => console.log(data)))
|
|
794
|
+
*
|
|
795
|
+
* @public
|
|
796
|
+
* @param {Customer} customer the details of the currently logged in customer
|
|
797
|
+
* @returns {Session} the current session
|
|
798
|
+
*/
|
|
799
|
+
setCustomer(customer: Customer | undefined): Session;
|
|
800
|
+
/**
|
|
801
|
+
* Sets the current variation identifier for the session. A variation identifier
|
|
802
|
+
* identifies the current currency (or the current customer group). If your site
|
|
803
|
+
* uses multi-currency, you must provide the ISO code current currency being viewed.
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* nostojs(api => api
|
|
807
|
+
* .defaultSession()
|
|
808
|
+
* .setVariation("GBP")
|
|
809
|
+
* .viewCart()
|
|
810
|
+
* .setPlacements(["free-shipper"])
|
|
811
|
+
* .load()
|
|
812
|
+
* .then(data => console.log(data)))
|
|
813
|
+
*
|
|
814
|
+
* @public
|
|
815
|
+
* @param {String} variation the case-sensitive identifier of the current variation
|
|
816
|
+
* @returns {Session} the current session
|
|
817
|
+
*/
|
|
818
|
+
setVariation(variation: string): Session;
|
|
819
|
+
/**
|
|
820
|
+
* Sets the restore link for the current session. Restore links can be leveraged
|
|
821
|
+
* in email campaigns. Restore links allow the the user to restore the cart
|
|
822
|
+
* contents in a single click.
|
|
823
|
+
* <br/><br/>
|
|
824
|
+
* Read more about
|
|
825
|
+
* {@link https://help.nosto.com/en/articles/664692|how to leverage the restore cart link}
|
|
826
|
+
*
|
|
827
|
+
* @example
|
|
828
|
+
* nostojs(api => api
|
|
829
|
+
* .defaultSession()
|
|
830
|
+
* .setRestoreLink("https://jeans.com/session/restore?sid=6bdb69d5-ed15-4d92")
|
|
831
|
+
* .viewCart()
|
|
832
|
+
* .setPlacements(["free-shipper"])
|
|
833
|
+
* .load()
|
|
834
|
+
* .then(data => console.log(data)))
|
|
835
|
+
*
|
|
836
|
+
* @public
|
|
837
|
+
* @param {String} restoreLink the secure URL to restore the user's current session
|
|
838
|
+
* @returns {Session} the current session
|
|
839
|
+
*/
|
|
840
|
+
setRestoreLink(restoreLink: string): Session;
|
|
841
|
+
/**
|
|
842
|
+
* Sets the response type to HTML or JSON_ORIGINAL. This denotes the preferred
|
|
843
|
+
* response type of the recommendation result.
|
|
844
|
+
* If you would like to access the raw recommendation data in <code>JSON</code> form, specify
|
|
845
|
+
* <code>JSON</code>. When you specify JSON, you will need to template the result yourself.
|
|
846
|
+
* If you require a more simplified approach, specify <code>HTML</code>. When you specify
|
|
847
|
+
* <code>HTML</code>, you get back HTML blobs, that you may simply inject into
|
|
848
|
+
* you placements.
|
|
849
|
+
*
|
|
850
|
+
* @example
|
|
851
|
+
* nostojs(api => api
|
|
852
|
+
* .defaultSession()
|
|
853
|
+
* .setResponseMode("HTML")
|
|
854
|
+
* .viewCart()
|
|
855
|
+
* .setPlacements(["free-shipper"])
|
|
856
|
+
* .load()
|
|
857
|
+
* .then(data => console.log(data)))
|
|
858
|
+
*
|
|
859
|
+
* @public
|
|
860
|
+
* @param {String} mode the response mode for the recommendation data
|
|
861
|
+
* @returns {Session} the current session
|
|
862
|
+
*/
|
|
863
|
+
setResponseMode(mode: RenderMode): Session;
|
|
864
|
+
/**
|
|
865
|
+
* Create a new action for a front page. This should be used when the user
|
|
866
|
+
* visits the home page.
|
|
867
|
+
* <br/><br/>
|
|
868
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
869
|
+
* action in order for the request to be made.
|
|
870
|
+
* <br/><br/>
|
|
871
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
872
|
+
* from the action.
|
|
873
|
+
*
|
|
874
|
+
* @example
|
|
875
|
+
* nostojs(api => api
|
|
876
|
+
* .defaultSession()
|
|
877
|
+
* .viewFrontPage()
|
|
878
|
+
* .setPlacements(["best-seller"])
|
|
879
|
+
* .load()
|
|
880
|
+
* .then(data => console.log(data)))
|
|
881
|
+
*
|
|
882
|
+
*
|
|
883
|
+
* @public
|
|
884
|
+
* @returns {Action} the action instance to load content or track events.
|
|
885
|
+
*/
|
|
886
|
+
viewFrontPage(): Action;
|
|
887
|
+
/**
|
|
888
|
+
* Create a new action for a cart page. This should be used on all cart and
|
|
889
|
+
* checkout pages. If your site has a multi-step checkout, it is recommended
|
|
890
|
+
* that you send this event on each checkout page.
|
|
891
|
+
* <br/><br/>
|
|
892
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
893
|
+
* action in order for the request to be made.
|
|
894
|
+
* <br/><br/>
|
|
895
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
896
|
+
* from the action.
|
|
897
|
+
*
|
|
898
|
+
* @example
|
|
899
|
+
* nostojs(api => api
|
|
900
|
+
* .defaultSession()
|
|
901
|
+
* .viewCart()
|
|
902
|
+
* .setPlacements(["free-shipper"])
|
|
903
|
+
* .load()
|
|
904
|
+
* .then(data => console.log(data)))
|
|
905
|
+
*
|
|
906
|
+
* @public
|
|
907
|
+
* @returns {Action} the action instance to load content or track events.
|
|
908
|
+
*/
|
|
909
|
+
viewCart(): Action;
|
|
910
|
+
/**
|
|
911
|
+
* Create a new action for a not found page. This should be used only on 404
|
|
912
|
+
* pages.
|
|
913
|
+
* <br/><br/>
|
|
914
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
915
|
+
* action in order for the request to be made.
|
|
916
|
+
* <br/><br/>
|
|
917
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
918
|
+
* from the action.
|
|
919
|
+
*
|
|
920
|
+
* @example
|
|
921
|
+
* nostojs(api => api
|
|
922
|
+
* .defaultSession()
|
|
923
|
+
* .viewNotFound()
|
|
924
|
+
* .setPlacements(["best-seller"])
|
|
925
|
+
* .load()
|
|
926
|
+
* .then(data => console.log(data)))
|
|
927
|
+
*
|
|
928
|
+
* @public
|
|
929
|
+
* @returns {Action} the action instance to load content or track events.
|
|
930
|
+
*/
|
|
931
|
+
viewNotFound(): Action;
|
|
932
|
+
/**
|
|
933
|
+
* Create a new action for a product page. This must be used only when a
|
|
934
|
+
* product is being viewed. In case a specific SKU of the product is being viewed, use viewProductSku instead.
|
|
935
|
+
* <br/><br/>
|
|
936
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
937
|
+
* action in order for the request to be made.
|
|
938
|
+
* <br/><br/>
|
|
939
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
940
|
+
* from the action.
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* nostojs(api => api
|
|
944
|
+
* .defaultSession()
|
|
945
|
+
* .viewProduct("101")
|
|
946
|
+
* .setCategories(["/men/trousers"])
|
|
947
|
+
* .setRef("123", "example_reco_id")
|
|
948
|
+
* .setPlacements(["cross-seller"])
|
|
949
|
+
* .load()
|
|
950
|
+
* .then(data => console.log(data)))
|
|
951
|
+
*
|
|
952
|
+
* @public
|
|
953
|
+
* @param product
|
|
954
|
+
* @returns {Action} the action instance to load content or track events.
|
|
955
|
+
*/
|
|
956
|
+
viewProduct(product: string | Product): Action;
|
|
957
|
+
/**
|
|
958
|
+
* Create a new action for a product page when a specific SKU has been chosen. This must be used only when a
|
|
959
|
+
* product and specific SKU is being viewed.
|
|
960
|
+
* <br/><br/>
|
|
961
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
962
|
+
* action in order for the request to be made.
|
|
963
|
+
* <br/><br/>
|
|
964
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
965
|
+
* from the action.
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* nostojs(api => api
|
|
969
|
+
* .defaultSession()
|
|
970
|
+
* .viewProductSku("101", "101-sku-1")
|
|
971
|
+
* .setCategories(["/men/trousers"])
|
|
972
|
+
* .setRef("123", "example_reco_id")
|
|
973
|
+
* .setPlacements(["cross-seller"])
|
|
974
|
+
* .load()
|
|
975
|
+
* .then(data => console.log(data)))
|
|
976
|
+
*
|
|
977
|
+
* @public
|
|
978
|
+
* @param productId
|
|
979
|
+
* @param skuId
|
|
980
|
+
* @returns {Action} the action instance to load content or track events.
|
|
981
|
+
*/
|
|
982
|
+
viewProductSku(productId: string, skuId: string): Action;
|
|
983
|
+
/**
|
|
984
|
+
* Create a new action for a category page. This should be used on all
|
|
985
|
+
* category, collection of brand pages.
|
|
986
|
+
* <br/><br/>
|
|
987
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
988
|
+
* action in order for the request to be made.
|
|
989
|
+
* <br/><br/>
|
|
990
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
991
|
+
* from the action.
|
|
992
|
+
*
|
|
993
|
+
* @example
|
|
994
|
+
* nostojs(api => api
|
|
995
|
+
* .defaultSession()
|
|
996
|
+
* .viewCategory("/men/shoes")
|
|
997
|
+
* .setPlacements(["category123"])
|
|
998
|
+
* .load()
|
|
999
|
+
* .then(data => console.log(data)))
|
|
1000
|
+
*
|
|
1001
|
+
* @public
|
|
1002
|
+
* @param {Array<String>} categories
|
|
1003
|
+
* @returns {Action} the action instance to load content or track events.
|
|
1004
|
+
*/
|
|
1005
|
+
viewCategory(...categories: string[]): Action;
|
|
1006
|
+
/**
|
|
1007
|
+
* Create a new action for a tag page. This should be used only on tag pages.
|
|
1008
|
+
* <br/><br/>
|
|
1009
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
1010
|
+
* action in order for the request to be made.
|
|
1011
|
+
* <br/><br/>
|
|
1012
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
1013
|
+
* from the action.
|
|
1014
|
+
* Note: tags are not case-sensitive.
|
|
1015
|
+
*
|
|
1016
|
+
* @example
|
|
1017
|
+
* nostojs(api => api
|
|
1018
|
+
* .defaultSession()
|
|
1019
|
+
* .viewTag("colourful")
|
|
1020
|
+
* .load()
|
|
1021
|
+
* .then(data => console.log(data)))
|
|
1022
|
+
*
|
|
1023
|
+
* @public
|
|
1024
|
+
* @deprecated as this is an advanced action with a limited a use case
|
|
1025
|
+
* @param {Array<String>} tags the set of the tags being viewed.
|
|
1026
|
+
* @returns {Action} the action instance to load content or track events.
|
|
1027
|
+
*/
|
|
1028
|
+
viewTag(...tags: string[]): Action;
|
|
1029
|
+
/**
|
|
1030
|
+
* Create a new action with custom fields.
|
|
1031
|
+
* <br/><br/>
|
|
1032
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
1033
|
+
* action in order for the request to be made.
|
|
1034
|
+
* <br/><br/>
|
|
1035
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
1036
|
+
* from the action.
|
|
1037
|
+
* Note: tags are not case-sensitive.
|
|
1038
|
+
*
|
|
1039
|
+
* @example
|
|
1040
|
+
* nostojs(api => api
|
|
1041
|
+
* .defaultSession()
|
|
1042
|
+
* .viewCustomField({material: "cotton"})
|
|
1043
|
+
* .load()
|
|
1044
|
+
* .then(data => console.log(data)))
|
|
1045
|
+
*
|
|
1046
|
+
* @public
|
|
1047
|
+
* @deprecated as this is an advanced action with a limited a use case
|
|
1048
|
+
* @param {Object} customFields custom fields being viewed.
|
|
1049
|
+
* @returns {Action} the action instance to load content or track events.
|
|
1050
|
+
*/
|
|
1051
|
+
viewCustomField(customFields: Record<string, string[]>): Action;
|
|
1052
|
+
/**
|
|
1053
|
+
* Create a new action for a search page. This should be used only
|
|
1054
|
+
* on search pages. A search page action requires you to pass the search
|
|
1055
|
+
* term. For example, if the user search for "black shoes", you must pass
|
|
1056
|
+
* in "black shoes" and not an encoded version such as "black+shoes".
|
|
1057
|
+
* <br/><br/>
|
|
1058
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
1059
|
+
* action in order for the request to be made.
|
|
1060
|
+
* <br/><br/>
|
|
1061
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
1062
|
+
* from the action.
|
|
1063
|
+
* Search terms are not case-sensitive.
|
|
1064
|
+
*
|
|
1065
|
+
* @example
|
|
1066
|
+
* nostojs(api => api
|
|
1067
|
+
* .defaultSession()
|
|
1068
|
+
* .viewSearch("black shoes")
|
|
1069
|
+
* .load()
|
|
1070
|
+
* .then(data => console.log(data)))
|
|
1071
|
+
*
|
|
1072
|
+
* @public
|
|
1073
|
+
* @param {Array.<String>} searchTerms the non-encoded search terms
|
|
1074
|
+
* @returns {Action} the action instance to load content or track events.
|
|
1075
|
+
*/
|
|
1076
|
+
viewSearch(...searchTerms: string[]): Action;
|
|
1077
|
+
/**
|
|
1078
|
+
* Create a new action for a general page. This should be used only on
|
|
1079
|
+
* pages that don't have a corresponding action. For example, if the user
|
|
1080
|
+
* is viewing a page such as a "Contact Us" page, you should use the viewOther
|
|
1081
|
+
* action.
|
|
1082
|
+
* <br/><br/>
|
|
1083
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
1084
|
+
* action in order for the request to be made.
|
|
1085
|
+
* <br/><br/>
|
|
1086
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
1087
|
+
* from the action.
|
|
1088
|
+
*
|
|
1089
|
+
* @example
|
|
1090
|
+
* nostojs(api => api
|
|
1091
|
+
* .defaultSession()
|
|
1092
|
+
* .viewOther()
|
|
1093
|
+
* .load()
|
|
1094
|
+
* .then(data => console.log(data)))
|
|
1095
|
+
*
|
|
1096
|
+
* @public
|
|
1097
|
+
* @returns {Action} the action instance to load content or track events.
|
|
1098
|
+
*/
|
|
1099
|
+
viewOther(): Action;
|
|
1100
|
+
/**
|
|
1101
|
+
* Create a new action for an order page. This should only be used on order
|
|
1102
|
+
* confirmation / thank you pages.
|
|
1103
|
+
* <br/><br/>
|
|
1104
|
+
* You do not need to specify the page-type explicitly as it is inferred
|
|
1105
|
+
* from the action.
|
|
1106
|
+
* <br/><br/>
|
|
1107
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
1108
|
+
* action in order for the request to be made.
|
|
1109
|
+
*
|
|
1110
|
+
* @example
|
|
1111
|
+
* nostojs(api => {
|
|
1112
|
+
* api.defaultSession()
|
|
1113
|
+
* .addOrder({
|
|
1114
|
+
* external_order_ref: "145000006",
|
|
1115
|
+
* info: {
|
|
1116
|
+
* order_number: "195",
|
|
1117
|
+
* email: "mridang@nosto.com",
|
|
1118
|
+
* first_name: "Mridang",
|
|
1119
|
+
* last_name: "Agarwalla",
|
|
1120
|
+
* type: "order",
|
|
1121
|
+
* newsletter: true
|
|
1122
|
+
* },
|
|
1123
|
+
* items: [{
|
|
1124
|
+
* product_id: "406",
|
|
1125
|
+
* sku_id: "243",
|
|
1126
|
+
* name: "Linen Blazer (White, S)",
|
|
1127
|
+
* quantity: 1,
|
|
1128
|
+
* unit_price: 455,
|
|
1129
|
+
* price_currency_code: "EUR"
|
|
1130
|
+
* }]
|
|
1131
|
+
* })
|
|
1132
|
+
* .setPlacements(["order-related"])
|
|
1133
|
+
* .load()
|
|
1134
|
+
* .then(data => {
|
|
1135
|
+
* console.log(data.recommendations)
|
|
1136
|
+
* })
|
|
1137
|
+
* })
|
|
1138
|
+
* @public
|
|
1139
|
+
* @param {Order} order the information about the order that was placed
|
|
1140
|
+
* @returns {Action} the action instance to load content or track events.
|
|
1141
|
+
*/
|
|
1142
|
+
addOrder(order: Order): Action;
|
|
1143
|
+
/**
|
|
1144
|
+
* Creates an action to report that product was added to the shopping cart,
|
|
1145
|
+
* e.g. from the recommendation slot with "Add to cart" button.
|
|
1146
|
+
* <p>
|
|
1147
|
+
* You must invoke [the load method]{@link Action#load} on the resultant
|
|
1148
|
+
* action in order for the request to be made.
|
|
1149
|
+
*
|
|
1150
|
+
*
|
|
1151
|
+
* @example
|
|
1152
|
+
* nostojs(api => api
|
|
1153
|
+
* .defaultSession()
|
|
1154
|
+
* .reportAddToCart("123", "reco-slot-1")
|
|
1155
|
+
* .load()
|
|
1156
|
+
* .then(data => console.log(data)))
|
|
1157
|
+
*
|
|
1158
|
+
* @public
|
|
1159
|
+
* @param product
|
|
1160
|
+
* @param element
|
|
1161
|
+
* @returns {Action} the action instance to load content or track events.
|
|
1162
|
+
*/
|
|
1163
|
+
reportAddToCart(product: string, element: string): Action;
|
|
1164
|
+
/**
|
|
1165
|
+
* @example
|
|
1166
|
+
* nostojs(api => api
|
|
1167
|
+
* .defaultSession()
|
|
1168
|
+
* .recordAttribution("vp", "12345678", "123456")
|
|
1169
|
+
* .done()
|
|
1170
|
+
* .then(data => console.log(data))
|
|
1171
|
+
* @param { EventType } type
|
|
1172
|
+
* @param { String } target
|
|
1173
|
+
* @param { String | undefined } [ref]
|
|
1174
|
+
* @param { String | undefined } [refSrc]
|
|
1175
|
+
* @return { Object }
|
|
1176
|
+
*
|
|
1177
|
+
*/
|
|
1178
|
+
recordAttribution(type: EventType, target: string, ref: string, refSrc: string): object;
|
|
497
1179
|
}
|
|
498
1180
|
|
|
499
1181
|
/**
|