@gofynd/fdk-client-javascript 1.4.15-beta.1 → 1.4.15-beta.11
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 +2 -2
- package/application.d.ts +1 -2
- package/application.js +2 -3
- package/index.d.ts +1 -2
- package/index.js +7 -1
- package/package.json +3 -4
- package/sdk/application/ApplicationClient.js +0 -18
- package/sdk/application/Cart/CartApplicationClient.d.ts +55 -90
- package/sdk/application/Cart/CartApplicationClient.js +60 -1185
- package/sdk/application/Catalog/CatalogApplicationClient.d.ts +90 -142
- package/sdk/application/Catalog/CatalogApplicationClient.js +187 -1293
- package/sdk/application/Common/CommonApplicationClient.d.ts +4 -8
- package/sdk/application/Common/CommonApplicationClient.js +5 -89
- package/sdk/application/Communication/CommunicationApplicationClient.d.ts +6 -19
- package/sdk/application/Communication/CommunicationApplicationClient.js +6 -145
- package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +32 -73
- package/sdk/application/Configuration/ConfigurationApplicationClient.js +31 -718
- package/sdk/application/Content/ContentApplicationClient.d.ts +46 -78
- package/sdk/application/Content/ContentApplicationClient.js +77 -914
- package/sdk/application/FileStorage/FileStorageApplicationClient.d.ts +6 -11
- package/sdk/application/FileStorage/FileStorageApplicationClient.js +19 -125
- package/sdk/application/Lead/LeadApplicationClient.d.ts +10 -18
- package/sdk/application/Lead/LeadApplicationClient.js +32 -202
- package/sdk/application/Logistic/LogisticApplicationClient.d.ts +22 -39
- package/sdk/application/Logistic/LogisticApplicationClient.js +50 -478
- package/sdk/application/Order/OrderApplicationClient.d.ts +22 -42
- package/sdk/application/Order/OrderApplicationClient.js +86 -472
- package/sdk/application/Payment/PaymentApplicationClient.d.ts +92 -212
- package/sdk/application/Payment/PaymentApplicationClient.js +57 -2102
- package/sdk/application/Rewards/RewardsApplicationClient.d.ts +14 -28
- package/sdk/application/Rewards/RewardsApplicationClient.js +16 -305
- package/sdk/application/Share/ShareApplicationClient.d.ts +14 -24
- package/sdk/application/Share/ShareApplicationClient.js +34 -294
- package/sdk/application/Theme/ThemeApplicationClient.d.ts +8 -14
- package/sdk/application/Theme/ThemeApplicationClient.js +28 -162
- package/sdk/application/User/UserApplicationClient.d.ts +85 -136
- package/sdk/application/User/UserApplicationClient.js +45 -1815
- package/sdk/application/Webhook/WebhookApplicationClient.d.ts +2 -5
- package/sdk/application/Webhook/WebhookApplicationClient.js +4 -47
- package/sdk/application/index.d.ts +0 -18
- package/sdk/application/index.js +0 -33
- package/sdk/common/Utility.d.ts +1 -1
- package/sdk/common/Utility.js +10 -7
- package/sdk/common/Validator.d.ts +1 -0
- package/sdk/common/Validator.js +20 -0
- package/sdk/common/utils.d.ts +0 -1
- package/sdk/common/utils.js +0 -14
- package/sdk/partner/OAuthClient.js +1 -0
- package/sdk/partner/Theme/ThemePartnerModel.d.ts +3 -40
- package/sdk/partner/Theme/ThemePartnerModel.js +2 -24
- package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +39 -1
- package/sdk/platform/Cart/CartPlatformApplicationClient.js +247 -1
- package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +33 -1
- package/sdk/platform/Cart/CartPlatformApplicationValidator.js +37 -0
- package/sdk/platform/Cart/CartPlatformModel.d.ts +193 -1
- package/sdk/platform/Cart/CartPlatformModel.js +132 -0
- package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +0 -7
- package/sdk/platform/Catalog/CatalogPlatformModel.js +1 -4
- package/sdk/platform/Configuration/ConfigurationPlatformModel.d.ts +14 -0
- package/sdk/platform/Configuration/ConfigurationPlatformModel.js +6 -0
- package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +0 -10
- package/sdk/platform/Order/OrderPlatformApplicationClient.js +0 -92
- package/sdk/platform/Order/OrderPlatformApplicationValidator.d.ts +1 -28
- package/sdk/platform/Order/OrderPlatformApplicationValidator.js +0 -18
- package/sdk/platform/Order/OrderPlatformClient.d.ts +10 -0
- package/sdk/platform/Order/OrderPlatformClient.js +99 -0
- package/sdk/platform/Order/OrderPlatformModel.d.ts +7 -0
- package/sdk/platform/Order/OrderPlatformModel.js +3 -0
- package/sdk/platform/Order/OrderPlatformValidator.d.ts +33 -1
- package/sdk/platform/Order/OrderPlatformValidator.js +20 -0
- package/sdk/platform/Serviceability/ServiceabilityPlatformClient.d.ts +1 -1
- package/sdk/platform/Serviceability/ServiceabilityPlatformClient.js +4 -4
- package/sdk/platform/Serviceability/ServiceabilityPlatformModel.d.ts +56 -19
- package/sdk/platform/Serviceability/ServiceabilityPlatformModel.js +42 -18
- package/sdk/platform/Serviceability/ServiceabilityPlatformValidator.d.ts +3 -3
- package/sdk/platform/Serviceability/ServiceabilityPlatformValidator.js +2 -2
- package/sdk/platform/Theme/ThemePlatformModel.d.ts +3 -40
- package/sdk/platform/Theme/ThemePlatformModel.js +2 -24
- package/sdk/public/Configuration/ConfigurationPublicClient.js +5 -2
- package/sdk/public/Content/ContentPublicClient.d.ts +1 -1
- package/sdk/public/Content/ContentPublicClient.js +14 -2
- package/sdk/public/Partner/PartnerPublicClient.d.ts +1 -1
- package/sdk/public/Partner/PartnerPublicClient.js +14 -2
- package/sdk/public/Webhook/WebhookPublicClient.js +5 -2
- package/sdk/application/Cart/CartApplicationModel.d.ts +0 -3994
- package/sdk/application/Cart/CartApplicationModel.js +0 -2497
- package/sdk/application/Cart/CartApplicationValidator.d.ts +0 -769
- package/sdk/application/Cart/CartApplicationValidator.js +0 -530
- package/sdk/application/Catalog/CatalogApplicationModel.d.ts +0 -3857
- package/sdk/application/Catalog/CatalogApplicationModel.js +0 -2629
- package/sdk/application/Catalog/CatalogApplicationValidator.d.ts +0 -791
- package/sdk/application/Catalog/CatalogApplicationValidator.js +0 -551
- package/sdk/application/Common/CommonApplicationModel.d.ts +0 -449
- package/sdk/application/Common/CommonApplicationModel.js +0 -308
- package/sdk/application/Common/CommonApplicationValidator.d.ts +0 -46
- package/sdk/application/Common/CommonApplicationValidator.js +0 -38
- package/sdk/application/Communication/CommunicationApplicationModel.d.ts +0 -293
- package/sdk/application/Communication/CommunicationApplicationModel.js +0 -201
- package/sdk/application/Communication/CommunicationApplicationValidator.d.ts +0 -29
- package/sdk/application/Communication/CommunicationApplicationValidator.js +0 -38
- package/sdk/application/Configuration/ConfigurationApplicationModel.d.ts +0 -2556
- package/sdk/application/Configuration/ConfigurationApplicationModel.js +0 -1887
- package/sdk/application/Configuration/ConfigurationApplicationValidator.d.ts +0 -179
- package/sdk/application/Configuration/ConfigurationApplicationValidator.js +0 -176
- package/sdk/application/Content/ContentApplicationModel.d.ts +0 -2133
- package/sdk/application/Content/ContentApplicationModel.js +0 -1589
- package/sdk/application/Content/ContentApplicationValidator.d.ts +0 -284
- package/sdk/application/Content/ContentApplicationValidator.js +0 -264
- package/sdk/application/FileStorage/FileStorageApplicationModel.d.ts +0 -272
- package/sdk/application/FileStorage/FileStorageApplicationModel.js +0 -190
- package/sdk/application/FileStorage/FileStorageApplicationValidator.d.ts +0 -56
- package/sdk/application/FileStorage/FileStorageApplicationValidator.js +0 -53
- package/sdk/application/Lead/LeadApplicationModel.d.ts +0 -590
- package/sdk/application/Lead/LeadApplicationModel.js +0 -480
- package/sdk/application/Lead/LeadApplicationValidator.d.ts +0 -68
- package/sdk/application/Lead/LeadApplicationValidator.js +0 -71
- package/sdk/application/Logistic/LogisticApplicationModel.d.ts +0 -1675
- package/sdk/application/Logistic/LogisticApplicationModel.js +0 -1121
- package/sdk/application/Logistic/LogisticApplicationValidator.d.ts +0 -254
- package/sdk/application/Logistic/LogisticApplicationValidator.js +0 -190
- package/sdk/application/Order/OrderApplicationModel.d.ts +0 -2296
- package/sdk/application/Order/OrderApplicationModel.js +0 -1471
- package/sdk/application/Order/OrderApplicationValidator.d.ts +0 -265
- package/sdk/application/Order/OrderApplicationValidator.js +0 -197
- package/sdk/application/Payment/PaymentApplicationModel.d.ts +0 -4058
- package/sdk/application/Payment/PaymentApplicationModel.js +0 -2630
- package/sdk/application/Payment/PaymentApplicationValidator.d.ts +0 -576
- package/sdk/application/Payment/PaymentApplicationValidator.js +0 -594
- package/sdk/application/Rewards/RewardsApplicationModel.d.ts +0 -365
- package/sdk/application/Rewards/RewardsApplicationModel.js +0 -396
- package/sdk/application/Rewards/RewardsApplicationValidator.d.ts +0 -73
- package/sdk/application/Rewards/RewardsApplicationValidator.js +0 -84
- package/sdk/application/Share/ShareApplicationModel.d.ts +0 -339
- package/sdk/application/Share/ShareApplicationModel.js +0 -234
- package/sdk/application/Share/ShareApplicationValidator.d.ts +0 -90
- package/sdk/application/Share/ShareApplicationValidator.js +0 -91
- package/sdk/application/Theme/ThemeApplicationModel.d.ts +0 -1713
- package/sdk/application/Theme/ThemeApplicationModel.js +0 -1426
- package/sdk/application/Theme/ThemeApplicationValidator.d.ts +0 -66
- package/sdk/application/Theme/ThemeApplicationValidator.js +0 -58
- package/sdk/application/User/UserApplicationModel.d.ts +0 -1943
- package/sdk/application/User/UserApplicationModel.js +0 -1382
- package/sdk/application/User/UserApplicationValidator.d.ts +0 -560
- package/sdk/application/User/UserApplicationValidator.js +0 -573
- package/sdk/application/Webhook/WebhookApplicationModel.d.ts +0 -52
- package/sdk/application/Webhook/WebhookApplicationModel.js +0 -46
- package/sdk/application/Webhook/WebhookApplicationValidator.d.ts +0 -16
- package/sdk/application/Webhook/WebhookApplicationValidator.js +0 -19
- package/sdk/common/Clickstream.d.ts +0 -1
- package/sdk/common/Clickstream.js +0 -464
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
const Clickstream = require("@gofynd/flick");
|
|
2
|
-
const { Logger } = require("../common/Logger");
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Safely extracts a value from an Object of n-depth
|
|
6
|
-
*
|
|
7
|
-
* @author Nikhil Kakade
|
|
8
|
-
* @param {function} fn
|
|
9
|
-
* @param {any} [defaultValue] - Null
|
|
10
|
-
* @returns {any}
|
|
11
|
-
*/
|
|
12
|
-
const sg = function safeGet(fn, defaultValue = null) {
|
|
13
|
-
try {
|
|
14
|
-
return fn();
|
|
15
|
-
} catch (err) {
|
|
16
|
-
return defaultValue;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Safely extracts search query and click position
|
|
21
|
-
*
|
|
22
|
-
* @author Hitendra Singh
|
|
23
|
-
* @property {string | null} query - Extracted search query if available, otherwise null
|
|
24
|
-
* @property {string | null} position - Click position from the decoded UTM
|
|
25
|
-
* content, otherwise null
|
|
26
|
-
* @property {string | null} utm_medium - The medium of the UTM (e.g.,
|
|
27
|
-
* 'product_recommendation'), otherwise null
|
|
28
|
-
* @property {string | null} utm_source - The source of the UTM (e.g.,
|
|
29
|
-
* 'product_page'), otherwise null
|
|
30
|
-
* @property {string | null} utm_campaign - The campaign of the UTM (e.g.,
|
|
31
|
-
* 'trending_products'), otherwise null
|
|
32
|
-
* @param {Object} [utm_params] - Object containing UTM parameters (utm_medium,
|
|
33
|
-
* utm_source, utm_campaign, utm_content)
|
|
34
|
-
* @returns {Object} - An object with the following properties:
|
|
35
|
-
*/
|
|
36
|
-
const fetchPositionAndQuery = function (utm_params) {
|
|
37
|
-
if (!utm_params || !Object.keys(utm_params).length) {
|
|
38
|
-
return {
|
|
39
|
-
query: null,
|
|
40
|
-
position: null,
|
|
41
|
-
utm_medium: null,
|
|
42
|
-
utm_source: null,
|
|
43
|
-
utm_campaign: null,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
utm_medium = null,
|
|
49
|
-
utm_source = null,
|
|
50
|
-
utm_campaign = null,
|
|
51
|
-
} = utm_params;
|
|
52
|
-
let query = null;
|
|
53
|
-
let position = null;
|
|
54
|
-
const queryResult = {
|
|
55
|
-
query,
|
|
56
|
-
position,
|
|
57
|
-
utm_medium,
|
|
58
|
-
utm_source,
|
|
59
|
-
utm_campaign,
|
|
60
|
-
};
|
|
61
|
-
if (utm_medium === "search") {
|
|
62
|
-
try {
|
|
63
|
-
const decodedUri = utm_params.utm_content
|
|
64
|
-
? atob(utm_params.utm_content)
|
|
65
|
-
: null;
|
|
66
|
-
if (decodedUri) {
|
|
67
|
-
const parts = decodedUri.split(":::");
|
|
68
|
-
queryResult.query = parts[0] || null;
|
|
69
|
-
queryResult.position = parts[1] || null;
|
|
70
|
-
}
|
|
71
|
-
} catch (err) {
|
|
72
|
-
return queryResult;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return queryResult;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Safely extracts company details from window object
|
|
79
|
-
*
|
|
80
|
-
* @author Hitendra Singh
|
|
81
|
-
* @returns {Object} - Company_id, company_mode and company_created_on
|
|
82
|
-
*/
|
|
83
|
-
const fetchCompanyDetails = function () {
|
|
84
|
-
//getting the current date in UTC
|
|
85
|
-
const now = new Date();
|
|
86
|
-
const formattedDate = now.toISOString();
|
|
87
|
-
const application = sg(() => window.config.application, null);
|
|
88
|
-
if (application && Object.keys(application).length) {
|
|
89
|
-
return {
|
|
90
|
-
company_id: sg(() => application.company_id, 0),
|
|
91
|
-
company_mode: sg(() => application.mode, "live"),
|
|
92
|
-
company_created_on: sg(
|
|
93
|
-
() => application.company_created_on,
|
|
94
|
-
formattedDate
|
|
95
|
-
),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
company_id: 0,
|
|
100
|
-
company_mode: "live",
|
|
101
|
-
company_created_on: formattedDate,
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
if (typeof window != "undefined") {
|
|
106
|
-
window.FPI.event.on("user.login", (eventData) => {
|
|
107
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
108
|
-
Clickstream.identify(eventData["user_id"], {
|
|
109
|
-
event_type: "identity",
|
|
110
|
-
email: sg(() => eventData["email"]),
|
|
111
|
-
phone: sg(() => eventData["phone_number"]),
|
|
112
|
-
login_value: sg(() => eventData["login_value"]),
|
|
113
|
-
method: sg(() => eventData["method"]),
|
|
114
|
-
...fetchCompanyDetails(),
|
|
115
|
-
}).catch((err) => {
|
|
116
|
-
Logger({ level: "ERROR", message: err });
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
window.FPI.event.on("user.update", (eventData) => {
|
|
121
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
122
|
-
Clickstream.identify(eventData["used_id"], {
|
|
123
|
-
event_type: "identity",
|
|
124
|
-
email: sg(() => eventData["email"]),
|
|
125
|
-
phone: sg(() => eventData["phone_number"]),
|
|
126
|
-
method: sg(() => eventData["method"]),
|
|
127
|
-
...fetchCompanyDetails(),
|
|
128
|
-
}).catch((err) => {
|
|
129
|
-
Logger({ level: "ERROR", message: err });
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
window.FPI.event.on("user.logout", (eventData) => {
|
|
134
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
135
|
-
Clickstream.sendEvent("user_logout", {
|
|
136
|
-
event_type: "identity",
|
|
137
|
-
...fetchCompanyDetails(),
|
|
138
|
-
}).catch((err) => {
|
|
139
|
-
Logger({ level: "ERROR", message: err });
|
|
140
|
-
});
|
|
141
|
-
Clickstream.reset().catch((err) => {
|
|
142
|
-
Logger({ level: "ERROR", message: err });
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
window.FPI.event.on("wishlist.add", (eventData) => {
|
|
147
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
148
|
-
const payload = {
|
|
149
|
-
wishlist_name: "TODO",
|
|
150
|
-
wishlist_id: "TODO",
|
|
151
|
-
event_type: "engagement",
|
|
152
|
-
product_id: sg(() => eventData.item["uid"]),
|
|
153
|
-
brand: sg(() => eventData.item.brand["name"]),
|
|
154
|
-
l3_category: sg(() => eventData.item.categories[0]["name"]),
|
|
155
|
-
mrp: sg(() => eventData.item.price.marked.max),
|
|
156
|
-
quantity: "TODO",
|
|
157
|
-
esp: sg(() => eventData.item.price.effective.min),
|
|
158
|
-
currency: sg(() => eventData.item.price.effective.currency_code),
|
|
159
|
-
value: "TODO",
|
|
160
|
-
source_url: "TODO",
|
|
161
|
-
...fetchCompanyDetails(),
|
|
162
|
-
};
|
|
163
|
-
const queryResult = fetchPositionAndQuery(eventData.utm_params);
|
|
164
|
-
Clickstream.sendEvent("product_wishlist_add", {
|
|
165
|
-
...payload,
|
|
166
|
-
...queryResult,
|
|
167
|
-
})
|
|
168
|
-
.then((resp) => {
|
|
169
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
170
|
-
})
|
|
171
|
-
.catch((err) => {
|
|
172
|
-
Logger({ level: "ERROR", message: err });
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
window.FPI.event.on("wishlist.remove", (eventData) => {
|
|
177
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
178
|
-
Clickstream.sendEvent("product_wishlist_remove", {
|
|
179
|
-
wishlist_name: "TODO",
|
|
180
|
-
wishlist_id: "TODO",
|
|
181
|
-
event_type: "engagement",
|
|
182
|
-
product_id: sg(() => eventData.item["uid"]),
|
|
183
|
-
brand: sg(() => eventData.item.brand["name"]),
|
|
184
|
-
l3_category: sg(() => eventData.item.categories[0]["name"]),
|
|
185
|
-
mrp: sg(() => eventData.item.price.marked.max),
|
|
186
|
-
quantity: "TODO",
|
|
187
|
-
esp: sg(() => eventData.item.price.effective.min),
|
|
188
|
-
currency: sg(() => eventData.item.price.effective.currency_code),
|
|
189
|
-
value: "TODO",
|
|
190
|
-
source_url: "TODO",
|
|
191
|
-
...fetchCompanyDetails(),
|
|
192
|
-
})
|
|
193
|
-
.then((resp) => {
|
|
194
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
195
|
-
})
|
|
196
|
-
.catch((err) => {
|
|
197
|
-
Logger({ level: "ERROR", message: err });
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
window.FPI.event.on("cart.newProduct", (eventData) => {
|
|
202
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
203
|
-
const payload = {
|
|
204
|
-
cart_id: eventData.cart_id,
|
|
205
|
-
event_type: "engagement",
|
|
206
|
-
product_id: sg(() => eventData.products[0]["uid"]),
|
|
207
|
-
article_id: sg(() => eventData.products[0]["article"]["uid"]),
|
|
208
|
-
brand: sg(() => eventData.products[0]["brand"]["name"]),
|
|
209
|
-
l3_category: sg(() => eventData.products[0]["category"]["name"]),
|
|
210
|
-
l1_category: "TODO",
|
|
211
|
-
currency: sg(() => eventData.products[0]["price"]["currency_code"]),
|
|
212
|
-
price: sg(() => eventData.products[0]["price"]["selling"]),
|
|
213
|
-
quantity: sg(() => eventData.products[0]["quantity"]["current"]),
|
|
214
|
-
source_url: "TODO",
|
|
215
|
-
position: null,
|
|
216
|
-
query: null,
|
|
217
|
-
value: "TODO",
|
|
218
|
-
...fetchCompanyDetails(),
|
|
219
|
-
};
|
|
220
|
-
const queryResult = fetchPositionAndQuery(eventData.utm_params);
|
|
221
|
-
Clickstream.sendEvent("add_to_cart", { ...payload, ...queryResult })
|
|
222
|
-
.then((resp) => {
|
|
223
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
224
|
-
})
|
|
225
|
-
.catch((err) => {
|
|
226
|
-
Logger({ level: "ERROR", message: err });
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
window.FPI.event.on("cart.remove", (eventData) => {
|
|
231
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
232
|
-
Clickstream.sendEvent("remove_from_cart", {
|
|
233
|
-
cart_id: eventData.cart_id,
|
|
234
|
-
event_type: "engagement",
|
|
235
|
-
product_id: sg(() => eventData.products[0]["uid"]),
|
|
236
|
-
brand: sg(() => eventData.products[0]["brand"]["name"]),
|
|
237
|
-
l3_category: sg(() => eventData.products[0]["category"]["name"]),
|
|
238
|
-
l1_category: "TODO",
|
|
239
|
-
currency: sg(() => eventData.products[0]["price"]["currency_code"]),
|
|
240
|
-
price: sg(() => eventData.products[0]["price"]["selling"]),
|
|
241
|
-
quantity: sg(() => eventData.products[0]["quantity"]["current"]),
|
|
242
|
-
source_url: "TODO",
|
|
243
|
-
position: null,
|
|
244
|
-
value: "TODO",
|
|
245
|
-
...fetchCompanyDetails(),
|
|
246
|
-
})
|
|
247
|
-
.then((resp) => {
|
|
248
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
249
|
-
})
|
|
250
|
-
.catch((err) => {
|
|
251
|
-
Logger({ level: "ERROR", message: err });
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
window.FPI.event.on("order.processed", (eventData) => {
|
|
256
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
257
|
-
Clickstream.sendEvent("order_complete", {
|
|
258
|
-
event_type: "conversion",
|
|
259
|
-
...eventData,
|
|
260
|
-
...fetchCompanyDetails(),
|
|
261
|
-
})
|
|
262
|
-
.then((resp) => {
|
|
263
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
264
|
-
})
|
|
265
|
-
.catch((err) => {
|
|
266
|
-
Logger({ level: "ERROR", message: err });
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
window.FPI.event.on("refund.success", (eventData) => {
|
|
271
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
272
|
-
Clickstream.sendEvent("order_refunded", {
|
|
273
|
-
event_type: "conversion",
|
|
274
|
-
...eventData,
|
|
275
|
-
...fetchCompanyDetails(),
|
|
276
|
-
})
|
|
277
|
-
.then((resp) => {
|
|
278
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
279
|
-
})
|
|
280
|
-
.catch((err) => {
|
|
281
|
-
Logger({ level: "ERROR", message: err });
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
window.FPI.event.on("order.checkout", (eventData) => {
|
|
286
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
287
|
-
Clickstream.sendEvent("order_checkout", {
|
|
288
|
-
event_type: "conversion",
|
|
289
|
-
cart_id: eventData.cart_id,
|
|
290
|
-
cart_total: sg(() => eventData.breakup_values_raw["mrp_total"]),
|
|
291
|
-
items: sg(() => eventData.products.lenght),
|
|
292
|
-
shipping: sg(() => eventData.breakup_values_raw["delivery_charge"]),
|
|
293
|
-
tax: sg(() => eventData.breakup_values_raw["gst_charges"]),
|
|
294
|
-
order_total: sg(() => eventData.breakup_values_raw["total"]),
|
|
295
|
-
currency: sg(() => eventData.products[0]["price"]["currency_code"]),
|
|
296
|
-
products: eventData.products.map((p) => {
|
|
297
|
-
return {
|
|
298
|
-
product_id: p.uid,
|
|
299
|
-
l3_category: sg(() => p.category["name"]),
|
|
300
|
-
l1_category: "TODO",
|
|
301
|
-
quantity: sg(() => p.quantity["current"]),
|
|
302
|
-
price: sg(() => p.price["marked"]),
|
|
303
|
-
value: sg(() => p.price["effective"]),
|
|
304
|
-
currency: sg(() => p.price["currency_code"]),
|
|
305
|
-
article_id: sg(() => p.article["uid"]),
|
|
306
|
-
};
|
|
307
|
-
}),
|
|
308
|
-
...fetchCompanyDetails(),
|
|
309
|
-
})
|
|
310
|
-
.then((resp) => {
|
|
311
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
312
|
-
})
|
|
313
|
-
.catch((err) => {
|
|
314
|
-
Logger({ level: "ERROR", message: err });
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
window.FPI.event.on("order.checkedout", (eventData) => {
|
|
318
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
319
|
-
Clickstream.sendEvent("order_checkedout", {
|
|
320
|
-
event_type: "conversion",
|
|
321
|
-
cart_id: eventData.cart_id,
|
|
322
|
-
cart_total: sg(() => eventData.breakup_values_raw["mrp_total"]),
|
|
323
|
-
item_total: sg(() => eventData.products.length),
|
|
324
|
-
shipping: sg(() => eventData.breakup_values_raw["delivery_charge"]),
|
|
325
|
-
tax: sg(() => eventData.breakup_values_raw["gst_charges"]),
|
|
326
|
-
order_total: sg(() => eventData.breakup_values_raw["total"]),
|
|
327
|
-
currency: sg(() => eventData.products[0]["price"]["currency_code"]),
|
|
328
|
-
order_id: sg(() => eventData.order_id),
|
|
329
|
-
products: eventData.products.map((p) => {
|
|
330
|
-
return {
|
|
331
|
-
product_id: p.uid,
|
|
332
|
-
l3_category: sg(() => p.category["name"]),
|
|
333
|
-
l1_category: "TODO",
|
|
334
|
-
quantity: sg(() => p.quantity["current"]),
|
|
335
|
-
price: sg(() => p.price["marked"]),
|
|
336
|
-
value: sg(() => p.price["effective"]),
|
|
337
|
-
currency: sg(() => p.price["currency_code"]),
|
|
338
|
-
article_id: sg(() => p.article["uid"]),
|
|
339
|
-
};
|
|
340
|
-
}),
|
|
341
|
-
...fetchCompanyDetails(),
|
|
342
|
-
})
|
|
343
|
-
.then((resp) => {
|
|
344
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
345
|
-
})
|
|
346
|
-
.catch((err) => {
|
|
347
|
-
Logger({ level: "ERROR", message: err });
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
window.FPI.event.on("product_list.view", (eventData) => {
|
|
352
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
353
|
-
if (eventData.user && eventData.user.user_id) {
|
|
354
|
-
//re identify user if the payload contains user id
|
|
355
|
-
Clickstream.identify(eventData.user.user_id, {}, false);
|
|
356
|
-
}
|
|
357
|
-
Clickstream.sendEvent("product_listing", {
|
|
358
|
-
event_type: "impression",
|
|
359
|
-
query: sg(() => eventData.slug["q"]),
|
|
360
|
-
products: eventData.items.map((p) => {
|
|
361
|
-
return {
|
|
362
|
-
product_id: p.uid,
|
|
363
|
-
name: p.name,
|
|
364
|
-
currency: sg(() => p.price["effective"]["currency_code"]),
|
|
365
|
-
mrp: sg(() => p.price["effective"]["max"]),
|
|
366
|
-
esp: sg(() => p.price["effective"]["min"]),
|
|
367
|
-
source_url: p.url,
|
|
368
|
-
brand: sg(() => p.brand["name"]),
|
|
369
|
-
};
|
|
370
|
-
}),
|
|
371
|
-
|
|
372
|
-
item_total: sg(() => eventData["page"]["item_total"]),
|
|
373
|
-
...fetchCompanyDetails(),
|
|
374
|
-
});
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
window.FPI.event.on("product.view", (eventData) => {
|
|
378
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
379
|
-
if (eventData.user && eventData.user.user_id) {
|
|
380
|
-
//re identify user if the payload contains user id
|
|
381
|
-
Clickstream.identify(eventData.user.user_id, {}, false);
|
|
382
|
-
}
|
|
383
|
-
const payload = {
|
|
384
|
-
event_type: "click",
|
|
385
|
-
product_id: sg(() => eventData.product["uid"]),
|
|
386
|
-
currency: sg(() => eventData.product.price["currency_code"]),
|
|
387
|
-
brand: sg(() => eventData.product.brand["name"]),
|
|
388
|
-
l3_category: sg(() => eventData.product.l3_category),
|
|
389
|
-
mrp: sg(() => eventData.product.price.max),
|
|
390
|
-
esp: sg(() => eventData.product.price.min),
|
|
391
|
-
l1_category: sg(() => eventData.product.l1_category),
|
|
392
|
-
source_url: sg(() => eventData.product.source_url),
|
|
393
|
-
quantity: sg(() => eventData.product.sizes[0]["quantity"]),
|
|
394
|
-
position: null,
|
|
395
|
-
query: null,
|
|
396
|
-
};
|
|
397
|
-
const queryResult = fetchPositionAndQuery(eventData.utm_params);
|
|
398
|
-
Clickstream.sendEvent("product_view", {
|
|
399
|
-
...payload,
|
|
400
|
-
...queryResult,
|
|
401
|
-
...fetchCompanyDetails(),
|
|
402
|
-
})
|
|
403
|
-
.then((resp) => {
|
|
404
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
405
|
-
})
|
|
406
|
-
.catch((err) => {
|
|
407
|
-
Logger({ level: "ERROR", message: err });
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
window.FPI.event.on("search.products", (eventData) => {
|
|
412
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
413
|
-
const payload = {
|
|
414
|
-
event_type: "search",
|
|
415
|
-
query: eventData.search_text,
|
|
416
|
-
products: [],
|
|
417
|
-
item_total: null,
|
|
418
|
-
};
|
|
419
|
-
//filter eventData.data to find the products array and item total
|
|
420
|
-
let products = [];
|
|
421
|
-
if (eventData.user && eventData.user.user_id) {
|
|
422
|
-
//re identify user if the payload contains user id
|
|
423
|
-
Clickstream.identify(eventData.user.user_id, {}, false);
|
|
424
|
-
}
|
|
425
|
-
if (eventData.data && eventData.data.length > 0) {
|
|
426
|
-
products = eventData.data
|
|
427
|
-
.filter((item) => {
|
|
428
|
-
if ((item["type"] === "product" && item.categories) || item.product)
|
|
429
|
-
return true;
|
|
430
|
-
})
|
|
431
|
-
.map((product) => {
|
|
432
|
-
return product.display || product.name;
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
const item_total = sg(() =>
|
|
437
|
-
eventData.page["item_total"] ? eventData.page["item_total"] : 0
|
|
438
|
-
);
|
|
439
|
-
if (payload.query) {
|
|
440
|
-
//only if query is present
|
|
441
|
-
Clickstream.sendEvent("product_search", {
|
|
442
|
-
...payload,
|
|
443
|
-
products,
|
|
444
|
-
item_total,
|
|
445
|
-
...fetchCompanyDetails(),
|
|
446
|
-
})
|
|
447
|
-
.then((resp) => {
|
|
448
|
-
Logger({ level: "DEBUG", message: "Click event sent" });
|
|
449
|
-
})
|
|
450
|
-
.catch((err) => {
|
|
451
|
-
Logger({ level: "ERROR", message: err });
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
window.FPI.event.on("product_list.filter", (eventData) => {
|
|
457
|
-
Logger({ level: "DEBUG", message: eventData });
|
|
458
|
-
// Clickstream.sendEvent("add_to_cart", { event_type: "conversion", product_uid: eventData.products[0]['uid'], user_id: eventData.user['user_id'], brand: eventData.products[0]['brand']['name'], category: eventData.products[0]['category']['name'], currency: eventData.products[0]['price']['currency_code'], price: eventData.products[0]['price']['selling'], quantity: eventData.products[0]['quantity']['current'], cart: [] }).then((resp) => {
|
|
459
|
-
// console.log("Event sent succesfully")
|
|
460
|
-
// }).catch(err => {
|
|
461
|
-
// console.error(err)
|
|
462
|
-
// })
|
|
463
|
-
});
|
|
464
|
-
}
|