@antscorp/antsomi-ui 2.0.108 → 2.0.110
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/es/components/organism/ActivityTimeline/ActivityTimeline.js +3 -3
- package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +122 -1285
- package/es/components/organism/ActivityTimeline/components/ItemEvent/ItemEvent.js +7 -1
- package/es/components/organism/ActivityTimeline/components/ItemGroupEvent/ItemGroupEvent.js +14 -2
- package/es/components/organism/ActivityTimeline/constants.d.ts +18 -18
- package/es/components/organism/ActivityTimeline/constants.js +7 -8
- package/es/components/organism/ActivityTimeline/index.d.ts +530 -1
- package/es/components/organism/ActivityTimeline/index.js +9 -1
- package/es/components/organism/ActivityTimeline/styled.js +4 -0
- package/es/components/organism/ActivityTimeline/utils.d.ts +7 -1
- package/es/components/organism/ActivityTimeline/utils.js +224 -162
- package/es/locales/en/google-sheet.json +109 -8
- package/es/locales/i18n.d.ts +306 -3
- package/es/locales/ja/google-sheet.json +301 -200
- package/es/locales/vi/google-sheet.json +118 -17
- package/es/services/MediaTemplateDesign/UploadFile/index.js +4 -4
- package/package.json +4 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
import { DATA_EVENT, mapTranslateCode } from './constants';
|
|
3
3
|
import { get } from 'lodash';
|
|
4
|
-
import { translate, translations } from '@antscorp/antsomi-
|
|
4
|
+
import { translate, translations } from '@antscorp/antsomi-locales';
|
|
5
5
|
import { safeParse } from '@antscorp/antsomi-ui/es/utils';
|
|
6
6
|
import { formatDate, formatUTCDateTZ } from '@antscorp/antsomi-ui/es/utils/date';
|
|
7
7
|
import { getPortalFormatDateTimeLong, getPortalTimeZone, } from '@antscorp/antsomi-ui/es/utils/portal';
|
|
@@ -19,7 +19,7 @@ export const getValuesReplace = (objectReplace, data) => {
|
|
|
19
19
|
return values;
|
|
20
20
|
}
|
|
21
21
|
objectReplace.forEach((item) => {
|
|
22
|
-
if (item !== 'product_name' && item !== 'page_name') {
|
|
22
|
+
if (item !== 'product_name' && item !== 'page_name' && item !== 'page_type') {
|
|
23
23
|
if (item === 'x_point' || item === 'store_link') {
|
|
24
24
|
if (item === 'store_link') {
|
|
25
25
|
values[item] =
|
|
@@ -119,7 +119,176 @@ export const getProductName = (data) => {
|
|
|
119
119
|
productNames = arrayProductName.join(', ');
|
|
120
120
|
return productNames;
|
|
121
121
|
};
|
|
122
|
-
|
|
122
|
+
// Handler functions for each eType
|
|
123
|
+
const handleProductEvent = (itemEvent, validateExtra, data, eType) => {
|
|
124
|
+
let listProductName = 'N/A';
|
|
125
|
+
listProductName = getProductName(itemEvent.items);
|
|
126
|
+
data.product_name = listProductName;
|
|
127
|
+
if (itemEvent.pageType === 'order_completed') {
|
|
128
|
+
data.order_id = validateExtra.order_id || 'N/A';
|
|
129
|
+
}
|
|
130
|
+
else if (itemEvent.pageType === 'purchase') {
|
|
131
|
+
data.order_id = validateExtra.order_id || 'N/A';
|
|
132
|
+
data.num_of_products = itemEvent.items.length || 'N/A';
|
|
133
|
+
}
|
|
134
|
+
else if (itemEvent.pageType === 'search') {
|
|
135
|
+
data.keywords = validateExtra.src_search_term || 'N/A';
|
|
136
|
+
}
|
|
137
|
+
else if (itemEvent.pageType === 'product_list_view') {
|
|
138
|
+
data.product_list = getProductName(itemEvent.items);
|
|
139
|
+
}
|
|
140
|
+
else if (itemEvent.pageType === 'click' ||
|
|
141
|
+
itemEvent.pageType === 'view' ||
|
|
142
|
+
itemEvent.pageType === 'add_to_cart') {
|
|
143
|
+
data.product_name = getStringHtmlByType(itemEvent.items[0], eType);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const handleOrderEvent = (validateExtra, data) => {
|
|
147
|
+
data.order_id = safeParse(validateExtra.order_id, 'N/A');
|
|
148
|
+
};
|
|
149
|
+
const handleTransactionEvent = (itemEvent, validateExtra, data) => {
|
|
150
|
+
if (itemEvent.pageType === 'purchase') {
|
|
151
|
+
data.order_id = safeParse(validateExtra.order_id, 'N/A');
|
|
152
|
+
const { num_of_products } = getStoreLinkAndNumberProduct(validateExtra, itemEvent);
|
|
153
|
+
data.num_of_products = num_of_products;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
data.transaction_id = safeParse(validateExtra.transaction_id, 'N/A');
|
|
157
|
+
const { num_of_products, store_link } = getStoreLinkAndNumberProduct(validateExtra, itemEvent);
|
|
158
|
+
data.num_of_products = num_of_products;
|
|
159
|
+
data.store_link = store_link;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const handlePageEvent = (itemEvent, data) => {
|
|
163
|
+
if (itemEvent.pageType === 'view') {
|
|
164
|
+
const validateExtra = itemEvent.extra || {};
|
|
165
|
+
const locationUrl = safeParse(validateExtra.location_url, '');
|
|
166
|
+
const pageType = safeParse(validateExtra.page_type, '');
|
|
167
|
+
// Use page_title if available, otherwise fallback to location_url
|
|
168
|
+
const pageTypeText = pageType.length > 0 ? pageType : locationUrl;
|
|
169
|
+
// Build clickable link to location_url
|
|
170
|
+
if (locationUrl.length > 0 && pageTypeText.length > 0) {
|
|
171
|
+
data.page_type = `<a class="title-have-url" href="${encodeURI(locationUrl)}" target="_blank">${pageTypeText}</a>`;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
data.page_type = `<span class="title-no-url">${pageTypeText || 'N/A'}</span>`;
|
|
175
|
+
}
|
|
176
|
+
// Add event_source_name from insightPropertyName
|
|
177
|
+
data.event_source_name = safeParse(itemEvent.insightPropertyName, 'N/A');
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const handleTicketEvent = (itemEvent, data) => {
|
|
181
|
+
if (itemEvent.pageType === 'send') {
|
|
182
|
+
data.array_ticket_names = getProductName(itemEvent.items);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const handleConversationEvent = (itemEvent, data) => {
|
|
186
|
+
if (itemEvent.pageType === 'chat') {
|
|
187
|
+
data.channel_name = itemEvent.items[0].category || 'N/A';
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const handleUserEvent = (itemEvent, validateExtra, data) => {
|
|
191
|
+
if (itemEvent.pageType === 'identify' || itemEvent.pageType === 'reset_anonymous_id') {
|
|
192
|
+
data.user_id = itemEvent.userId;
|
|
193
|
+
}
|
|
194
|
+
else if (itemEvent.pageType === 'redeem_point' || itemEvent.pageType === 'earn_point') {
|
|
195
|
+
data.x_point = validateExtra.point || 'N/A';
|
|
196
|
+
data.transaction_id = validateExtra.transaction_id || 'N/A';
|
|
197
|
+
const { store_link } = getStoreLinkAndNumberProduct(validateExtra, itemEvent);
|
|
198
|
+
data.store_link = store_link;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
const handleAdvertisingEvent = (itemEvent, validateExtra, data) => {
|
|
202
|
+
if (itemEvent.pageType === 'impression' ||
|
|
203
|
+
itemEvent.pageType === 'viewable' ||
|
|
204
|
+
itemEvent.pageType === 'click') {
|
|
205
|
+
data.campaign_name = safeParse(validateExtra.utm_campaign, 'N/A');
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const handleBrowsingEvent = (itemEvent, validateExtra, data) => {
|
|
209
|
+
if (itemEvent.pageType === 'product_search') {
|
|
210
|
+
data.keyword = safeParse(validateExtra.src_search_term, '');
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const handleEvoucherEvent = (itemEvent, validateExtra, data) => {
|
|
214
|
+
if (itemEvent.pageType === 'received') {
|
|
215
|
+
data.x_code = safeParse(validateExtra.coupon_code, 'N/A');
|
|
216
|
+
data.campaign_name = safeParse((validateExtra.campaign || {}).name, 'N/A');
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const handleStoreEvent = (itemEvent, data) => {
|
|
220
|
+
if (itemEvent.pageType === 'visit') {
|
|
221
|
+
data.step_section = itemEvent.extra.step_section;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const handleScreenviewEvent = (itemEvent, validateExtra, data) => {
|
|
225
|
+
if (itemEvent.pageType === 'view') {
|
|
226
|
+
data.event_source_name = safeParse(itemEvent.insightPropertyName, 'N/A');
|
|
227
|
+
if (validateExtra.screen_type) {
|
|
228
|
+
data.screen_type = validateExtra.screen_type;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const handleEventTrackingCode = (eventTracking, keyTitleEvent, validateExtra, valuesReplace, infoEvent, config) => {
|
|
233
|
+
const { story = {} } = validateExtra;
|
|
234
|
+
if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'promotion_code_sent_tracking') {
|
|
235
|
+
valuesReplace.promotion_code = valuesReplace.event_name;
|
|
236
|
+
delete valuesReplace.event_name;
|
|
237
|
+
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
238
|
+
if (validateExtra.channel &&
|
|
239
|
+
mapTranslateCode.promotion_code_sent_tracking[parseInt(validateExtra.channel.id)]) {
|
|
240
|
+
infoEvent.translateCode =
|
|
241
|
+
mapTranslateCode.promotion_code_sent_tracking[parseInt(validateExtra.channel.id)].translateLabel;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'promotion_code_used_tracking') {
|
|
245
|
+
valuesReplace.promotion_code = valuesReplace.event_name;
|
|
246
|
+
delete valuesReplace.event_name;
|
|
247
|
+
infoEvent.translateCode = translations._EVENT_CODE_USED_SMS;
|
|
248
|
+
}
|
|
249
|
+
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'viewable_advertising') {
|
|
250
|
+
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
251
|
+
delete valuesReplace.campaign_name;
|
|
252
|
+
if (validateExtra.channel &&
|
|
253
|
+
mapTranslateCode.viewable_advertising[parseInt(validateExtra.channel.id)]) {
|
|
254
|
+
infoEvent.translateCode =
|
|
255
|
+
mapTranslateCode.viewable_advertising[parseInt(validateExtra.channel.id)].translateLabel;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'impression_advertising') {
|
|
259
|
+
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
260
|
+
delete valuesReplace.campaign_name;
|
|
261
|
+
if (validateExtra.channel &&
|
|
262
|
+
mapTranslateCode.impression_advertising[parseInt(validateExtra.channel.id)]) {
|
|
263
|
+
infoEvent.translateCode =
|
|
264
|
+
mapTranslateCode.impression_advertising[parseInt(validateExtra.channel.id)].translateLabel;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'click_advertising') {
|
|
268
|
+
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
269
|
+
delete valuesReplace.campaign_name;
|
|
270
|
+
if (validateExtra.channel &&
|
|
271
|
+
mapTranslateCode.click_advertising[parseInt(validateExtra.channel.id)]) {
|
|
272
|
+
infoEvent.translateCode =
|
|
273
|
+
mapTranslateCode.click_advertising[parseInt(validateExtra.channel.id)].translateLabel;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'sent_tracking') {
|
|
277
|
+
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
278
|
+
delete valuesReplace.campaign_name;
|
|
279
|
+
if (validateExtra.channel &&
|
|
280
|
+
mapTranslateCode.sent_tracking[parseInt(validateExtra.channel.id)]) {
|
|
281
|
+
infoEvent.translateCode =
|
|
282
|
+
mapTranslateCode.sent_tracking[parseInt(validateExtra.channel.id)].translateLabel;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'journey_bo_update_info') {
|
|
286
|
+
valuesReplace.journey_name = `<strong>${story.storyName}</strong>`;
|
|
287
|
+
delete valuesReplace.campaign_name;
|
|
288
|
+
infoEvent.translateCode = translations._EVENT_BO_UPDATE;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const prepareInitialData = (itemEvent, eType, eventTracking, customerName) => {
|
|
123
292
|
const keyTitleEvent = `${itemEvent.eventCategoryId}@@${itemEvent.eventActionId}`;
|
|
124
293
|
const validateExtra = itemEvent.extra || {};
|
|
125
294
|
const promotionCodes = itemEvent.items
|
|
@@ -127,142 +296,64 @@ export const getInfoEvent = (eType, itemEvent, eventTracking, customerName, conf
|
|
|
127
296
|
.map((item) => item.name || item.id)
|
|
128
297
|
.join(', ');
|
|
129
298
|
let titleEvent = `${itemEvent.pageType} ${eType}`;
|
|
130
|
-
let infoEvent = DATA_EVENT.map[titleEvent];
|
|
131
299
|
titleEvent = `${titleEvent}${promotionCodes.length > 0
|
|
132
300
|
? `: <strong style="color: rgb(239, 51, 63);">${promotionCodes}</strong>`
|
|
133
301
|
: ''}`;
|
|
134
|
-
const data = {
|
|
135
|
-
|
|
302
|
+
const data = {
|
|
303
|
+
event_name: titleEvent,
|
|
304
|
+
customer_name: customerName === '_THIS_PERSON_UPPERCASE'
|
|
305
|
+
? translate(translations._THIS_PERSON_UPPERCASE, 'This user')
|
|
306
|
+
: customerName,
|
|
307
|
+
};
|
|
136
308
|
if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'promotion_code_sent_tracking' ||
|
|
137
309
|
eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'promotion_code_used_tracking') {
|
|
138
310
|
data.event_name = `<strong style="color: rgb(239, 51, 63);">${promotionCodes}</strong>`;
|
|
139
311
|
}
|
|
140
|
-
data.customer_name =
|
|
141
|
-
customerName === '_THIS_PERSON_UPPERCASE'
|
|
142
|
-
? translate(translations._THIS_PERSON_UPPERCASE, 'This user')
|
|
143
|
-
: customerName;
|
|
144
|
-
if (eventTracking.map[keyTitleEvent]) {
|
|
145
|
-
titleEvent = eventTracking.map[keyTitleEvent].translateLabel;
|
|
146
|
-
}
|
|
147
312
|
if (validateExtra.store !== undefined) {
|
|
148
313
|
const { store_link } = getStoreLinkAndNumberProduct(validateExtra, itemEvent);
|
|
149
314
|
data.store_link = store_link;
|
|
150
315
|
}
|
|
151
|
-
|
|
316
|
+
return { keyTitleEvent, validateExtra, titleEvent, data, promotionCodes };
|
|
317
|
+
};
|
|
318
|
+
const processEventByType = (eType, itemEvent, validateExtra, data) => {
|
|
152
319
|
if (eType === 'product') {
|
|
153
|
-
|
|
154
|
-
listProductName = getProductName(itemEvent.items);
|
|
155
|
-
data.product_name = listProductName;
|
|
156
|
-
if (itemEvent.pageType === 'order_completed') {
|
|
157
|
-
// PAGETYPE ORDER_COMPLETE
|
|
158
|
-
data.order_id = validateExtra.order_id || 'N/A';
|
|
159
|
-
}
|
|
160
|
-
else if (itemEvent.pageType === 'purchase') {
|
|
161
|
-
// PAGETYPE PURCHASE
|
|
162
|
-
data.order_id = validateExtra.order_id || 'N/A';
|
|
163
|
-
data.num_of_products = itemEvent.items.length || 'N/A';
|
|
164
|
-
}
|
|
165
|
-
else if (itemEvent.pageType === 'search') {
|
|
166
|
-
// PAGETYPE SEARCH
|
|
167
|
-
data.keywords = validateExtra.src_search_term || 'N/A';
|
|
168
|
-
}
|
|
169
|
-
else if (itemEvent.pageType === 'product_list_view') {
|
|
170
|
-
// PAGETYPE PRODUCT_LIST_VIEW
|
|
171
|
-
data.product_list = getProductName(itemEvent.items);
|
|
172
|
-
}
|
|
173
|
-
else if (itemEvent.pageType === 'click' ||
|
|
174
|
-
itemEvent.pageType === 'view' ||
|
|
175
|
-
itemEvent.pageType === 'add_to_cart') {
|
|
176
|
-
// PAGETYPE CLICK OR VIEW
|
|
177
|
-
// eslint-disable-next-line no-console
|
|
178
|
-
console.log('itemEvent.items[0]', itemEvent);
|
|
179
|
-
data.product_name = getStringHtmlByType(itemEvent.items[0], eType);
|
|
180
|
-
}
|
|
320
|
+
handleProductEvent(itemEvent, validateExtra, data, eType);
|
|
181
321
|
}
|
|
182
322
|
else if (eType === 'order') {
|
|
183
|
-
|
|
184
|
-
data.order_id = safeParse(validateExtra.order_id, 'N/A');
|
|
323
|
+
handleOrderEvent(validateExtra, data);
|
|
185
324
|
}
|
|
186
325
|
else if (eType === 'transaction') {
|
|
187
|
-
|
|
188
|
-
if (itemEvent.pageType === 'purchase') {
|
|
189
|
-
data.order_id = safeParse(validateExtra.order_id, 'N/A');
|
|
190
|
-
const { num_of_products } = getStoreLinkAndNumberProduct(validateExtra, itemEvent);
|
|
191
|
-
data.num_of_products = num_of_products;
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
// PAGETYPE PURCHASE_OFFLINE
|
|
195
|
-
data.transaction_id = safeParse(validateExtra.transaction_id, 'N/A');
|
|
196
|
-
const { num_of_products, store_link } = getStoreLinkAndNumberProduct(validateExtra, itemEvent);
|
|
197
|
-
data.num_of_products = num_of_products;
|
|
198
|
-
data.store_link = store_link;
|
|
199
|
-
}
|
|
326
|
+
handleTransactionEvent(itemEvent, validateExtra, data);
|
|
200
327
|
}
|
|
201
328
|
else if (eType === 'page' || eType === 'pageview') {
|
|
202
|
-
|
|
203
|
-
if (itemEvent.pageType === 'view') {
|
|
204
|
-
// PAGETYPE VIEW
|
|
205
|
-
data.page_name = getStringHtmlByType(itemEvent.items[0], eType);
|
|
206
|
-
}
|
|
329
|
+
handlePageEvent(itemEvent, data);
|
|
207
330
|
}
|
|
208
331
|
else if (eType === 'ticket') {
|
|
209
|
-
|
|
210
|
-
if (itemEvent.pageType === 'send') {
|
|
211
|
-
// PAGETYPE SEND
|
|
212
|
-
data.array_ticket_names = getProductName(itemEvent.items);
|
|
213
|
-
}
|
|
332
|
+
handleTicketEvent(itemEvent, data);
|
|
214
333
|
}
|
|
215
334
|
else if (eType === 'conversation') {
|
|
216
|
-
|
|
217
|
-
if (itemEvent.pageType === 'chat') {
|
|
218
|
-
// PAGETYPE CHAT
|
|
219
|
-
data.channel_name = itemEvent.items[0].category || 'N/A';
|
|
220
|
-
}
|
|
335
|
+
handleConversationEvent(itemEvent, data);
|
|
221
336
|
}
|
|
222
337
|
else if (eType === 'user') {
|
|
223
|
-
|
|
224
|
-
if (itemEvent.pageType === 'identify' || itemEvent.pageType === 'reset_anonymous_id') {
|
|
225
|
-
// PAGETYPE IDENTIFY OR RESET_ANONYMUS_ID
|
|
226
|
-
data.user_id = itemEvent.userId;
|
|
227
|
-
}
|
|
228
|
-
else if (itemEvent.pageType === 'redeem_point' || itemEvent.pageType === 'earn_point') {
|
|
229
|
-
// PAGETYPE REDEEM_POINT OR EARN_POINT
|
|
230
|
-
data.x_point = validateExtra.point || 'N/A';
|
|
231
|
-
data.transaction_id = validateExtra.transaction_id || 'N/A';
|
|
232
|
-
const { store_link } = getStoreLinkAndNumberProduct(validateExtra, itemEvent);
|
|
233
|
-
data.store_link = store_link;
|
|
234
|
-
}
|
|
338
|
+
handleUserEvent(itemEvent, validateExtra, data);
|
|
235
339
|
}
|
|
236
340
|
else if (eType === 'advertising') {
|
|
237
|
-
|
|
238
|
-
if (itemEvent.pageType === 'impression' ||
|
|
239
|
-
itemEvent.pageType === 'viewable' ||
|
|
240
|
-
itemEvent.pageType === 'click') {
|
|
241
|
-
// PAGETYPE IMPRESSION , VIEWABLE, CLICK
|
|
242
|
-
data.campaign_name = safeParse(validateExtra.utm_campaign, 'N/A');
|
|
243
|
-
}
|
|
341
|
+
handleAdvertisingEvent(itemEvent, validateExtra, data);
|
|
244
342
|
}
|
|
245
343
|
else if (eType === 'browsing') {
|
|
246
|
-
|
|
247
|
-
data.keyword = safeParse(validateExtra.src_search_term, '');
|
|
248
|
-
}
|
|
344
|
+
handleBrowsingEvent(itemEvent, validateExtra, data);
|
|
249
345
|
}
|
|
250
346
|
else if (eType === 'evoucher') {
|
|
251
|
-
|
|
252
|
-
data.x_code = safeParse(validateExtra.coupon_code, 'N/A');
|
|
253
|
-
data.campaign_name = safeParse((validateExtra.campaign || {}).name, 'N/A');
|
|
254
|
-
}
|
|
347
|
+
handleEvoucherEvent(itemEvent, validateExtra, data);
|
|
255
348
|
}
|
|
256
349
|
else if (eType === 'store') {
|
|
257
|
-
|
|
258
|
-
data.step_section = itemEvent.extra.step_section;
|
|
259
|
-
}
|
|
350
|
+
handleStoreEvent(itemEvent, data);
|
|
260
351
|
}
|
|
261
352
|
else if (eType === 'screenview') {
|
|
262
|
-
|
|
263
|
-
data.screen_type = validateExtra.screen_type;
|
|
264
|
-
}
|
|
353
|
+
handleScreenviewEvent(itemEvent, validateExtra, data);
|
|
265
354
|
}
|
|
355
|
+
};
|
|
356
|
+
const buildInfoEvent = (infoEvent, eventTracking, keyTitleEvent, validateExtra, data, config) => {
|
|
266
357
|
let valuesReplace = {};
|
|
267
358
|
if (infoEvent) {
|
|
268
359
|
infoEvent.iconName = get(eventTracking, `map.${keyTitleEvent}.iconUrl`);
|
|
@@ -281,66 +372,12 @@ export const getInfoEvent = (eType, itemEvent, eventTracking, customerName, conf
|
|
|
281
372
|
iconName: eventTracking.map[keyTitleEvent]?.iconUrl,
|
|
282
373
|
showRedeem: false,
|
|
283
374
|
};
|
|
284
|
-
const { story = {} } = validateExtra;
|
|
285
|
-
// data.event_name = titleEvent;
|
|
286
375
|
valuesReplace = getValuesReplace(infoEvent.objectReplace, data);
|
|
287
|
-
|
|
288
|
-
valuesReplace.promotion_code = valuesReplace.event_name;
|
|
289
|
-
delete valuesReplace.event_name;
|
|
290
|
-
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
291
|
-
if (validateExtra.channel &&
|
|
292
|
-
mapTranslateCode.promotion_code_sent_tracking[parseInt(validateExtra.channel.id)]) {
|
|
293
|
-
infoEvent.translateCode =
|
|
294
|
-
mapTranslateCode.promotion_code_sent_tracking[parseInt(validateExtra.channel.id)].translateLabel;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'promotion_code_used_tracking') {
|
|
298
|
-
valuesReplace.promotion_code = valuesReplace.event_name;
|
|
299
|
-
delete valuesReplace.event_name;
|
|
300
|
-
infoEvent.translateCode = translations._EVENT_CODE_USED_SMS;
|
|
301
|
-
}
|
|
302
|
-
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'viewable_advertising') {
|
|
303
|
-
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
304
|
-
delete valuesReplace.campaign_name;
|
|
305
|
-
if (validateExtra.channel &&
|
|
306
|
-
mapTranslateCode.viewable_advertising[parseInt(validateExtra.channel.id)]) {
|
|
307
|
-
infoEvent.translateCode =
|
|
308
|
-
mapTranslateCode.viewable_advertising[parseInt(validateExtra.channel.id)].translateLabel;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'impression_advertising') {
|
|
312
|
-
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
313
|
-
delete valuesReplace.campaign_name;
|
|
314
|
-
if (validateExtra.channel &&
|
|
315
|
-
mapTranslateCode.impression_advertising[parseInt(validateExtra.channel.id)]) {
|
|
316
|
-
infoEvent.translateCode =
|
|
317
|
-
mapTranslateCode.impression_advertising[parseInt(validateExtra.channel.id)].translateLabel;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'click_advertising') {
|
|
321
|
-
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
322
|
-
delete valuesReplace.campaign_name;
|
|
323
|
-
if (validateExtra.channel &&
|
|
324
|
-
mapTranslateCode.click_advertising[parseInt(validateExtra.channel.id)]) {
|
|
325
|
-
infoEvent.translateCode =
|
|
326
|
-
mapTranslateCode.click_advertising[parseInt(validateExtra.channel.id)].translateLabel;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'sent_tracking') {
|
|
330
|
-
valuesReplace.journey_name = `<a class="title-have-url" href=${urlJourney(validateExtra, config)} target="_blank">${story.storyName}</a>`;
|
|
331
|
-
delete valuesReplace.campaign_name;
|
|
332
|
-
if (validateExtra.channel &&
|
|
333
|
-
mapTranslateCode.sent_tracking[parseInt(validateExtra.channel.id)]) {
|
|
334
|
-
infoEvent.translateCode =
|
|
335
|
-
mapTranslateCode.sent_tracking[parseInt(validateExtra.channel.id)].translateLabel;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
else if (eventTracking.map[keyTitleEvent]?.eventTrackingCode === 'journey_bo_update_info') {
|
|
339
|
-
valuesReplace.journey_name = `<strong>${story.storyName}</strong>`;
|
|
340
|
-
delete valuesReplace.campaign_name;
|
|
341
|
-
infoEvent.translateCode = translations._EVENT_BO_UPDATE;
|
|
342
|
-
}
|
|
376
|
+
handleEventTrackingCode(eventTracking, keyTitleEvent, validateExtra, valuesReplace, infoEvent, config);
|
|
343
377
|
}
|
|
378
|
+
return { infoEvent, valuesReplace };
|
|
379
|
+
};
|
|
380
|
+
const buildFullContentEvent = (infoEvent, titleEvent, valuesReplace, data) => {
|
|
344
381
|
let fullContentEvent = translate(infoEvent.translateCode, titleEvent, valuesReplace);
|
|
345
382
|
if (infoEvent.objectReplace.includes('store_link') === false && data.store_link !== undefined) {
|
|
346
383
|
fullContentEvent += ` ${translateAt} <strong style="color: rgb(239, 51, 63);">${data.store_link}</strong>`;
|
|
@@ -348,6 +385,9 @@ export const getInfoEvent = (eType, itemEvent, eventTracking, customerName, conf
|
|
|
348
385
|
else if (data.step_section) {
|
|
349
386
|
fullContentEvent += ` ${translateAt} <strong style="color: rgb(239, 51, 63);">${data.step_section}</strong>`;
|
|
350
387
|
}
|
|
388
|
+
return fullContentEvent;
|
|
389
|
+
};
|
|
390
|
+
const calculateSlideSettings = (itemEvent, infoEvent) => {
|
|
351
391
|
let perShow = 2;
|
|
352
392
|
if (itemEvent.items.length > 0 && itemEvent.items[0].item_type === 'product') {
|
|
353
393
|
perShow = itemEvent.items.length < 2 ? itemEvent.items.length : 2;
|
|
@@ -358,6 +398,28 @@ export const getInfoEvent = (eType, itemEvent, eventTracking, customerName, conf
|
|
|
358
398
|
limitShowSlide = infoEvent.limitShowSlide;
|
|
359
399
|
}
|
|
360
400
|
}
|
|
401
|
+
return { perShow, limitShowSlide };
|
|
402
|
+
};
|
|
403
|
+
export const getInfoEvent = (params) => {
|
|
404
|
+
const { eType, itemEvent, eventTracking, config, customerName: customerNameParam } = params;
|
|
405
|
+
const customerName = customerNameParam || '_THIS_PERSON_UPPERCASE';
|
|
406
|
+
// Step 1: Prepare initial data and extract common fields
|
|
407
|
+
const { keyTitleEvent, validateExtra, titleEvent: initialTitleEvent, data, } = prepareInitialData(itemEvent, eType, eventTracking, customerName);
|
|
408
|
+
// Step 2: Update titleEvent if eventTracking has a mapping
|
|
409
|
+
let titleEvent = initialTitleEvent;
|
|
410
|
+
if (eventTracking.map[keyTitleEvent]) {
|
|
411
|
+
titleEvent = eventTracking.map[keyTitleEvent].translateLabel;
|
|
412
|
+
}
|
|
413
|
+
// Step 3: Process event based on eType
|
|
414
|
+
processEventByType(eType, itemEvent, validateExtra, data);
|
|
415
|
+
// Step 4: Build infoEvent and valuesReplace
|
|
416
|
+
let infoEvent = DATA_EVENT.map[`${itemEvent.pageType} ${eType}`];
|
|
417
|
+
const { infoEvent: processedInfoEvent, valuesReplace } = buildInfoEvent(infoEvent, eventTracking, keyTitleEvent, validateExtra, data, config);
|
|
418
|
+
infoEvent = processedInfoEvent;
|
|
419
|
+
// Step 5: Build full content event text
|
|
420
|
+
const fullContentEvent = buildFullContentEvent(infoEvent, titleEvent, valuesReplace, data);
|
|
421
|
+
// Step 6: Calculate slide settings
|
|
422
|
+
const { perShow, limitShowSlide } = calculateSlideSettings(itemEvent, infoEvent);
|
|
361
423
|
return {
|
|
362
424
|
titleEvent,
|
|
363
425
|
fullContentEvent,
|