@gofynd/fdk-client-javascript 1.4.8 → 1.4.10-beta.1
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 -1
- package/package.json +1 -1
- package/sdk/application/Configuration/ConfigurationApplicationModel.d.ts +5 -0
- package/sdk/application/Configuration/ConfigurationApplicationModel.js +2 -0
- package/sdk/common/Clickstream.js +117 -24
- package/sdk/platform/Billing/BillingPlatformClient.d.ts +0 -402
- package/sdk/platform/Billing/BillingPlatformClient.js +79 -3301
- package/sdk/platform/Billing/BillingPlatformModel.d.ts +396 -4080
- package/sdk/platform/Billing/BillingPlatformModel.js +253 -2684
- package/sdk/platform/Billing/BillingPlatformValidator.d.ts +1 -456
- package/sdk/platform/Billing/BillingPlatformValidator.js +0 -490
- package/sdk/platform/Configuration/ConfigurationPlatformModel.d.ts +5 -0
- package/sdk/platform/Configuration/ConfigurationPlatformModel.js +2 -0
- package/sdk/public/PublicClient.d.ts +0 -2
- package/sdk/public/PublicClient.js +0 -4
- package/sdk/public/index.d.ts +0 -1
- package/sdk/public/index.js +0 -2
- package/sdk/public/Billing/BillingPublicClient.d.ts +0 -56
- package/sdk/public/Billing/BillingPublicClient.js +0 -349
- package/sdk/public/Billing/BillingPublicModel.d.ts +0 -919
- package/sdk/public/Billing/BillingPublicModel.js +0 -560
- package/sdk/public/Billing/BillingPublicValidator.d.ts +0 -43
- package/sdk/public/Billing/BillingPublicValidator.js +0 -50
package/README.md
CHANGED
|
@@ -237,7 +237,7 @@ console.log("Active Theme: ", response.information.name);
|
|
|
237
237
|
The above code will log the curl command in the console
|
|
238
238
|
|
|
239
239
|
```bash
|
|
240
|
-
curl --request GET "https://api.fynd.com/service/application/theme/v1.0/applied-theme" --header 'authorization: Bearer <authorization-token>' --header 'x-fp-sdk-version: 1.4.
|
|
240
|
+
curl --request GET "https://api.fynd.com/service/application/theme/v1.0/applied-theme" --header 'authorization: Bearer <authorization-token>' --header 'x-fp-sdk-version: 1.4.10-beta.1' --header 'x-fp-date: 20230222T115108Z' --header 'x-fp-signature: v1.1:1e3ab3b02b5bc626e3c32a37ee844266ade02bbcbaafc28fc7a0e46a76a7a1a8'
|
|
241
241
|
Active Theme: Emerge
|
|
242
242
|
```
|
|
243
243
|
|
package/package.json
CHANGED
|
@@ -222,6 +222,7 @@ export = ConfigurationApplicationModel;
|
|
|
222
222
|
*/
|
|
223
223
|
/**
|
|
224
224
|
* @typedef GoogleMap
|
|
225
|
+
* @property {boolean} [enabled] - Shows whether Google map integration is enabled or not.
|
|
225
226
|
* @property {GoogleMapCredentials} [credentials]
|
|
226
227
|
*/
|
|
227
228
|
/**
|
|
@@ -1253,6 +1254,10 @@ type FyndRewardsCredentials = {
|
|
|
1253
1254
|
/** @returns {GoogleMap} */
|
|
1254
1255
|
declare function GoogleMap(): GoogleMap;
|
|
1255
1256
|
type GoogleMap = {
|
|
1257
|
+
/**
|
|
1258
|
+
* - Shows whether Google map integration is enabled or not.
|
|
1259
|
+
*/
|
|
1260
|
+
enabled?: boolean;
|
|
1256
1261
|
credentials?: GoogleMapCredentials;
|
|
1257
1262
|
};
|
|
1258
1263
|
/** @returns {GoogleMapCredentials} */
|
|
@@ -252,6 +252,7 @@ const Joi = require("joi");
|
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
254
|
* @typedef GoogleMap
|
|
255
|
+
* @property {boolean} [enabled] - Shows whether Google map integration is enabled or not.
|
|
255
256
|
* @property {GoogleMapCredentials} [credentials]
|
|
256
257
|
*/
|
|
257
258
|
|
|
@@ -1174,6 +1175,7 @@ class ConfigurationApplicationModel {
|
|
|
1174
1175
|
/** @returns {GoogleMap} */
|
|
1175
1176
|
static GoogleMap() {
|
|
1176
1177
|
return Joi.object({
|
|
1178
|
+
enabled: Joi.boolean(),
|
|
1177
1179
|
credentials: ConfigurationApplicationModel.GoogleMapCredentials(),
|
|
1178
1180
|
});
|
|
1179
1181
|
}
|
|
@@ -30,21 +30,59 @@ const fetchPositionAndQuery = function (utm_params) {
|
|
|
30
30
|
position: null,
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
|
|
34
|
+
if (utm_params.utm_medium === "search") {
|
|
35
|
+
try {
|
|
36
|
+
const decodedUri = utm_params.utm_content
|
|
37
|
+
? atob(utm_params.utm_content)
|
|
38
|
+
: null;
|
|
39
|
+
if (decodedUri) {
|
|
40
|
+
const parts = decodedUri.split(":::");
|
|
41
|
+
return {
|
|
42
|
+
query: parts[0] || null,
|
|
43
|
+
position: parts[1] || null,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
} catch (err) {
|
|
47
|
+
return {
|
|
48
|
+
query: null,
|
|
49
|
+
position: null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
42
52
|
}
|
|
43
53
|
return {
|
|
44
54
|
query: null,
|
|
45
55
|
position: null,
|
|
46
56
|
};
|
|
47
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Safely extracts company details from window object
|
|
60
|
+
*
|
|
61
|
+
* @author Hitendra Singh
|
|
62
|
+
* @returns {Object} - Company_id, company_mode and company_created_on
|
|
63
|
+
*/
|
|
64
|
+
const fetchCompanyDetails = function () {
|
|
65
|
+
//getting the current date in UTC
|
|
66
|
+
const now = new Date();
|
|
67
|
+
const formattedDate = now.toISOString();
|
|
68
|
+
const application = sg(() => window.config.application, null);
|
|
69
|
+
if (application && Object.keys(application).length) {
|
|
70
|
+
return {
|
|
71
|
+
company_id: sg(() => application.company_id, 0),
|
|
72
|
+
company_mode: sg(() => application.mode, "live"),
|
|
73
|
+
company_created_on: sg(
|
|
74
|
+
() => application.company_created_on,
|
|
75
|
+
formattedDate
|
|
76
|
+
),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
company_id: 0,
|
|
81
|
+
company_mode: "live",
|
|
82
|
+
company_created_on: formattedDate,
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
48
86
|
if (typeof window != "undefined") {
|
|
49
87
|
window.FPI.event.on("user.login", (eventData) => {
|
|
50
88
|
Logger({ level: "DEBUG", message: eventData });
|
|
@@ -54,6 +92,7 @@ if (typeof window != "undefined") {
|
|
|
54
92
|
phone: sg(() => eventData["phone_number"]),
|
|
55
93
|
login_value: sg(() => eventData["login_value"]),
|
|
56
94
|
method: sg(() => eventData["method"]),
|
|
95
|
+
...fetchCompanyDetails(),
|
|
57
96
|
}).catch((err) => {
|
|
58
97
|
Logger({ level: "ERROR", message: err });
|
|
59
98
|
});
|
|
@@ -66,6 +105,7 @@ if (typeof window != "undefined") {
|
|
|
66
105
|
email: sg(() => eventData["email"]),
|
|
67
106
|
phone: sg(() => eventData["phone_number"]),
|
|
68
107
|
method: sg(() => eventData["method"]),
|
|
108
|
+
...fetchCompanyDetails(),
|
|
69
109
|
}).catch((err) => {
|
|
70
110
|
Logger({ level: "ERROR", message: err });
|
|
71
111
|
});
|
|
@@ -73,11 +113,12 @@ if (typeof window != "undefined") {
|
|
|
73
113
|
|
|
74
114
|
window.FPI.event.on("user.logout", (eventData) => {
|
|
75
115
|
Logger({ level: "DEBUG", message: eventData });
|
|
76
|
-
Clickstream.sendEvent("user_logout", {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
116
|
+
Clickstream.sendEvent("user_logout", {
|
|
117
|
+
event_type: "identity",
|
|
118
|
+
...fetchCompanyDetails(),
|
|
119
|
+
}).catch((err) => {
|
|
120
|
+
Logger({ level: "ERROR", message: err });
|
|
121
|
+
});
|
|
81
122
|
Clickstream.reset().catch((err) => {
|
|
82
123
|
Logger({ level: "ERROR", message: err });
|
|
83
124
|
});
|
|
@@ -98,6 +139,7 @@ if (typeof window != "undefined") {
|
|
|
98
139
|
currency: sg(() => eventData.item.price.effective.currency_code),
|
|
99
140
|
value: "TODO",
|
|
100
141
|
source_url: "TODO",
|
|
142
|
+
...fetchCompanyDetails(),
|
|
101
143
|
};
|
|
102
144
|
const queryResult = fetchPositionAndQuery(eventData.utm_params);
|
|
103
145
|
Clickstream.sendEvent("product_wishlist_add", {
|
|
@@ -127,6 +169,7 @@ if (typeof window != "undefined") {
|
|
|
127
169
|
currency: sg(() => eventData.item.price.effective.currency_code),
|
|
128
170
|
value: "TODO",
|
|
129
171
|
source_url: "TODO",
|
|
172
|
+
...fetchCompanyDetails(),
|
|
130
173
|
})
|
|
131
174
|
.then((resp) => {
|
|
132
175
|
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
@@ -153,6 +196,7 @@ if (typeof window != "undefined") {
|
|
|
153
196
|
position: null,
|
|
154
197
|
query: null,
|
|
155
198
|
value: "TODO",
|
|
199
|
+
...fetchCompanyDetails(),
|
|
156
200
|
};
|
|
157
201
|
const queryResult = fetchPositionAndQuery(eventData.utm_params);
|
|
158
202
|
Clickstream.sendEvent("add_to_cart", { ...payload, ...queryResult })
|
|
@@ -179,6 +223,7 @@ if (typeof window != "undefined") {
|
|
|
179
223
|
source_url: "TODO",
|
|
180
224
|
position: null,
|
|
181
225
|
value: "TODO",
|
|
226
|
+
...fetchCompanyDetails(),
|
|
182
227
|
})
|
|
183
228
|
.then((resp) => {
|
|
184
229
|
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
@@ -193,6 +238,7 @@ if (typeof window != "undefined") {
|
|
|
193
238
|
Clickstream.sendEvent("order_complete", {
|
|
194
239
|
event_type: "conversion",
|
|
195
240
|
...eventData,
|
|
241
|
+
...fetchCompanyDetails(),
|
|
196
242
|
})
|
|
197
243
|
.then((resp) => {
|
|
198
244
|
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
@@ -207,6 +253,7 @@ if (typeof window != "undefined") {
|
|
|
207
253
|
Clickstream.sendEvent("order_refunded", {
|
|
208
254
|
event_type: "conversion",
|
|
209
255
|
...eventData,
|
|
256
|
+
...fetchCompanyDetails(),
|
|
210
257
|
})
|
|
211
258
|
.then((resp) => {
|
|
212
259
|
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
@@ -239,6 +286,40 @@ if (typeof window != "undefined") {
|
|
|
239
286
|
article_id: sg(() => p.article["uid"]),
|
|
240
287
|
};
|
|
241
288
|
}),
|
|
289
|
+
...fetchCompanyDetails(),
|
|
290
|
+
})
|
|
291
|
+
.then((resp) => {
|
|
292
|
+
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
293
|
+
})
|
|
294
|
+
.catch((err) => {
|
|
295
|
+
Logger({ level: "ERROR", message: err });
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
window.FPI.event.on("order.checkedout", (eventData) => {
|
|
299
|
+
Logger({ level: "DEBUG", message: eventData });
|
|
300
|
+
Clickstream.sendEvent("order_checkedout", {
|
|
301
|
+
event_type: "conversion",
|
|
302
|
+
cart_id: eventData.cart_id,
|
|
303
|
+
cart_total: sg(() => eventData.breakup_values_raw["mrp_total"]),
|
|
304
|
+
item_total: sg(() => eventData.products.length),
|
|
305
|
+
shipping: sg(() => eventData.breakup_values_raw["delivery_charge"]),
|
|
306
|
+
tax: sg(() => eventData.breakup_values_raw["gst_charges"]),
|
|
307
|
+
order_total: sg(() => eventData.breakup_values_raw["total"]),
|
|
308
|
+
currency: sg(() => eventData.products[0]["price"]["currency_code"]),
|
|
309
|
+
order_id: sg(() => eventData.order_id),
|
|
310
|
+
products: eventData.products.map((p) => {
|
|
311
|
+
return {
|
|
312
|
+
product_id: p.uid,
|
|
313
|
+
l3_category: sg(() => p.category["name"]),
|
|
314
|
+
l1_category: "TODO",
|
|
315
|
+
quantity: sg(() => p.quantity["current"]),
|
|
316
|
+
price: sg(() => p.price["marked"]),
|
|
317
|
+
value: sg(() => p.price["effective"]),
|
|
318
|
+
currency: sg(() => p.price["currency_code"]),
|
|
319
|
+
article_id: sg(() => p.article["uid"]),
|
|
320
|
+
};
|
|
321
|
+
}),
|
|
322
|
+
...fetchCompanyDetails(),
|
|
242
323
|
})
|
|
243
324
|
.then((resp) => {
|
|
244
325
|
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
@@ -266,6 +347,7 @@ if (typeof window != "undefined") {
|
|
|
266
347
|
}),
|
|
267
348
|
|
|
268
349
|
item_total: sg(() => eventData["page"]["item_total"]),
|
|
350
|
+
...fetchCompanyDetails(),
|
|
269
351
|
});
|
|
270
352
|
});
|
|
271
353
|
|
|
@@ -286,7 +368,11 @@ if (typeof window != "undefined") {
|
|
|
286
368
|
query: null,
|
|
287
369
|
};
|
|
288
370
|
const queryResult = fetchPositionAndQuery(eventData.utm_params);
|
|
289
|
-
Clickstream.sendEvent("product_view", {
|
|
371
|
+
Clickstream.sendEvent("product_view", {
|
|
372
|
+
...payload,
|
|
373
|
+
...queryResult,
|
|
374
|
+
...fetchCompanyDetails(),
|
|
375
|
+
})
|
|
290
376
|
.then((resp) => {
|
|
291
377
|
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
292
378
|
})
|
|
@@ -304,21 +390,28 @@ if (typeof window != "undefined") {
|
|
|
304
390
|
item_total: null,
|
|
305
391
|
};
|
|
306
392
|
//filter eventData.data to find the products array and item total
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
393
|
+
let products = [];
|
|
394
|
+
if (eventData.data && eventData.data.length > 0) {
|
|
395
|
+
products = eventData.data
|
|
396
|
+
.filter((item) => {
|
|
397
|
+
if ((item["type"] === "product" && item.categories) || item.product)
|
|
398
|
+
return true;
|
|
399
|
+
})
|
|
400
|
+
.map((product) => {
|
|
401
|
+
return product.display || product.name;
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const item_total = sg(() =>
|
|
406
|
+
eventData.page["item_total"] ? eventData.page["item_total"] : 0
|
|
407
|
+
);
|
|
316
408
|
if (payload.query) {
|
|
317
409
|
//only if query is present
|
|
318
410
|
Clickstream.sendEvent("product_search", {
|
|
319
411
|
...payload,
|
|
320
412
|
products,
|
|
321
413
|
item_total,
|
|
414
|
+
...fetchCompanyDetails(),
|
|
322
415
|
})
|
|
323
416
|
.then((resp) => {
|
|
324
417
|
Logger({ level: "DEBUG", message: "Click event sent" });
|