@depict-ai/dpc 1.0.36 → 1.0.38
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/ES10/index.cjs +28 -28
- package/ES10/index.d.ts +1 -1
- package/ES10/index.js +28 -28
- package/dist/index.cjs +28 -28
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -28
- package/latest/index.cjs +23 -23
- package/latest/index.d.ts +1 -1
- package/latest/index.js +23 -23
- package/package.json +3 -3
package/ES10/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ function $parcel$interopDefault(a) {
|
|
|
17
17
|
$parcel$export(module.exports, "DPC", () => $89ae37e3a26189b4$export$820526014323765f);
|
|
18
18
|
$parcel$export(module.exports, "version", () => $fcc8287091fb489d$export$83d89fbfd8236492);
|
|
19
19
|
/*! Depict PerformanceClient */
|
|
20
|
-
const $fcc8287091fb489d$export$83d89fbfd8236492 = "1.0.
|
|
20
|
+
const $fcc8287091fb489d$export$83d89fbfd8236492 = "1.0.38";
|
|
21
21
|
let $405164bc961cc106$export$8ae64f3d447c14f7;
|
|
22
22
|
(function (ProductCardType) {
|
|
23
23
|
ProductCardType[ProductCardType["Recommendation"] = 0] = "Recommendation";
|
|
@@ -155,18 +155,18 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
155
155
|
$89ae37e3a26189b4$var$_classPrivateMethodInitSpec(this, $89ae37e3a26189b4$var$_getContextData);
|
|
156
156
|
$89ae37e3a26189b4$var$_classPrivateMethodInitSpec(this, $89ae37e3a26189b4$var$_parseOptions);
|
|
157
157
|
$89ae37e3a26189b4$var$_classPrivateMethodInitSpec(this, $89ae37e3a26189b4$var$_resetSentPageViewForCurrentHref);
|
|
158
|
-
|
|
158
|
+
$parcel$interopDefault($9AWcE$babelruntimehelpersdefineProperty)(this, "auto_observe", true);
|
|
159
159
|
$89ae37e3a26189b4$var$_classPrivateFieldInitSpec(this, $89ae37e3a26189b4$var$_has_sent_pageview_for_current_href, {
|
|
160
160
|
writable: true,
|
|
161
161
|
value: false
|
|
162
162
|
});
|
|
163
|
-
|
|
163
|
+
$parcel$interopDefault($9AWcE$babelruntimehelpersdefineProperty)(this, "tracked_elements", new WeakSet());
|
|
164
164
|
// Make sure we do not construct dpc more than once.
|
|
165
165
|
if (((_window$depict = window.depict) === null || _window$depict === void 0 ? void 0 : _window$depict.dpc) instanceof $89ae37e3a26189b4$export$820526014323765f) {
|
|
166
|
-
|
|
166
|
+
$9AWcE$depictaiutilishared.dlog("DPC already initialized. Returning existing instance.");
|
|
167
167
|
return window.depict.dpc;
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
$5323e9ffea4e414a$export$7a1bb429756ced60(this);
|
|
170
170
|
this.merchant = merchant;
|
|
171
171
|
$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_parseOptions, $89ae37e3a26189b4$var$_parseOptions2).call(this, _options);
|
|
172
172
|
$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_resetSentPageViewForCurrentHref, $89ae37e3a26189b4$var$_resetSentPageViewForCurrentHref2).call(this);
|
|
@@ -180,7 +180,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
180
180
|
*/
|
|
181
181
|
checkIfTracked(element) {
|
|
182
182
|
if (this.tracked_elements.has(element)) {
|
|
183
|
-
|
|
183
|
+
$9AWcE$depictaiutilishared.dlog("Already tracked", element);
|
|
184
184
|
return true;
|
|
185
185
|
}
|
|
186
186
|
this.tracked_elements.add(element);
|
|
@@ -195,7 +195,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
195
195
|
case (0, $405164bc961cc106$export$8ae64f3d447c14f7).Recommendation:
|
|
196
196
|
case (0, $405164bc961cc106$export$8ae64f3d447c14f7).SnakeRecommendation:
|
|
197
197
|
card.addEventListener("click", () => this.sendRecommendationClickEvent(tracking_id));
|
|
198
|
-
|
|
198
|
+
$9AWcE$depictaiutilishared.impression_track_element({
|
|
199
199
|
element: card,
|
|
200
200
|
data: {
|
|
201
201
|
recommendation_id: tracking_id,
|
|
@@ -205,7 +205,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
205
205
|
break;
|
|
206
206
|
case (0, $405164bc961cc106$export$8ae64f3d447c14f7).SearchResult:
|
|
207
207
|
card.addEventListener("click", () => this.sendSearchResultClickEvent(tracking_id));
|
|
208
|
-
|
|
208
|
+
$9AWcE$depictaiutilishared.impression_track_element({
|
|
209
209
|
element: card,
|
|
210
210
|
data: {
|
|
211
211
|
search_result_id: tracking_id,
|
|
@@ -215,7 +215,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
215
215
|
break;
|
|
216
216
|
case (0, $405164bc961cc106$export$8ae64f3d447c14f7).ProductListingResult:
|
|
217
217
|
card.addEventListener("click", () => this.sendProductListingResultClickEvent(tracking_id));
|
|
218
|
-
|
|
218
|
+
$9AWcE$depictaiutilishared.impression_track_element({
|
|
219
219
|
element: card,
|
|
220
220
|
data: {
|
|
221
221
|
product_listing_result_id: tracking_id,
|
|
@@ -238,7 +238,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
238
238
|
// If the button is not nested in a product card, it's a PDP button. Product ID set on the page is required.
|
|
239
239
|
const product_id = $89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getProductId, $89ae37e3a26189b4$var$_getProductId2).call(this);
|
|
240
240
|
if (!product_id) {
|
|
241
|
-
|
|
241
|
+
$9AWcE$depictaiutilishared.derror("No product ID set for add-to-cart click outside of product card", button);
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
this.sendAddToCartEvent({
|
|
@@ -256,7 +256,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
256
256
|
this.sendAddToCartEvent(tracking_data);
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
|
-
|
|
259
|
+
$9AWcE$depictaiutilishared.derror("Could not find tracking data for add-to-cart click on button", button);
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
@@ -302,7 +302,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
302
302
|
* Sends a recommendation click event to Depict
|
|
303
303
|
*/
|
|
304
304
|
sendRecommendationClickEvent(recommendation_id) {
|
|
305
|
-
|
|
305
|
+
$9AWcE$depictaiutilishared.depict_click({
|
|
306
306
|
recommendation_id: recommendation_id,
|
|
307
307
|
...$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getContextData, $89ae37e3a26189b4$var$_getContextData2).call(this)
|
|
308
308
|
});
|
|
@@ -311,7 +311,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
311
311
|
* Sends a search result click event to Depict
|
|
312
312
|
*/
|
|
313
313
|
sendSearchResultClickEvent(search_result_id) {
|
|
314
|
-
|
|
314
|
+
$9AWcE$depictaiutilishared.depict_click({
|
|
315
315
|
search_result_id: search_result_id,
|
|
316
316
|
...$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getContextData, $89ae37e3a26189b4$var$_getContextData2).call(this)
|
|
317
317
|
});
|
|
@@ -320,7 +320,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
320
320
|
* Sends a product listing result click event to Depict
|
|
321
321
|
*/
|
|
322
322
|
sendProductListingResultClickEvent(product_listing_result_id) {
|
|
323
|
-
|
|
323
|
+
$9AWcE$depictaiutilishared.depict_click({
|
|
324
324
|
product_listing_result_id: product_listing_result_id,
|
|
325
325
|
...$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getContextData, $89ae37e3a26189b4$var$_getContextData2).call(this)
|
|
326
326
|
});
|
|
@@ -354,7 +354,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
354
354
|
tenant: this.merchant,
|
|
355
355
|
market: this.market
|
|
356
356
|
};
|
|
357
|
-
|
|
357
|
+
$9AWcE$depictaiutilishared.foolproof_send_beacon((0, $9AWcE$depictaiutilishared.base_url) + "/v2/create-events", request);
|
|
358
358
|
}
|
|
359
359
|
/**
|
|
360
360
|
* Update the market used for tracking events
|
|
@@ -366,15 +366,15 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
366
366
|
* Update the product_id used for add-to-cart and pageview events on PDPs.
|
|
367
367
|
*/
|
|
368
368
|
setProductId(product_id) {
|
|
369
|
-
|
|
369
|
+
$9AWcE$depictaiutilishared.dlog("Setting product id", product_id);
|
|
370
370
|
this.latest_product_id = product_id;
|
|
371
371
|
this.latest_product_id_path = location.pathname;
|
|
372
|
-
if (
|
|
372
|
+
if (!$parcel$interopDefault($9AWcE$babelruntimehelpersclassPrivateFieldGet)(this, $89ae37e3a26189b4$var$_has_sent_pageview_for_current_href)) {
|
|
373
373
|
$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_sendTrackingEvent, $89ae37e3a26189b4$var$_sendTrackingEvent2).call(this, {
|
|
374
374
|
type: "page_view",
|
|
375
375
|
product_id: product_id
|
|
376
376
|
});
|
|
377
|
-
|
|
377
|
+
$parcel$interopDefault($9AWcE$babelruntimehelpersclassPrivateFieldSet)(this, $89ae37e3a26189b4$var$_has_sent_pageview_for_current_href, true);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
/**
|
|
@@ -383,7 +383,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
383
383
|
* https://docs.depict.ai/docs/performance-client#informing-depict-of-logged-in-users
|
|
384
384
|
*/
|
|
385
385
|
setUserId(user_id) {
|
|
386
|
-
|
|
386
|
+
$9AWcE$depictaiutilishared.dlog("Setting user id", user_id);
|
|
387
387
|
this.latest_user_id = user_id || undefined;
|
|
388
388
|
}
|
|
389
389
|
/**
|
|
@@ -392,7 +392,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
392
392
|
* https://docs.depict.ai/docs/performance-client#browser-sessions
|
|
393
393
|
*/
|
|
394
394
|
setSessionId(session_id) {
|
|
395
|
-
|
|
395
|
+
$9AWcE$depictaiutilishared.dlog("Setting session id", session_id);
|
|
396
396
|
this.latest_session_id = session_id || undefined;
|
|
397
397
|
}
|
|
398
398
|
/**
|
|
@@ -401,14 +401,14 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
401
401
|
observeRecommendations() {
|
|
402
402
|
for (const [attribute, type] of Object.entries((0, $e0dfb0ca4c8c037f$export$79f7900b4eea40cf))) {
|
|
403
403
|
const selector = "[".concat(attribute, "]");
|
|
404
|
-
|
|
404
|
+
$9AWcE$depictaiutilishared.dlog("Starting to observe product cards with selector", selector);
|
|
405
405
|
(0, $9AWcE$depictaiutilishared.observer).onexists(selector, _ref => {
|
|
406
406
|
let {
|
|
407
407
|
element: element
|
|
408
408
|
} = _ref;
|
|
409
409
|
const tracking_id = element.getAttribute(attribute);
|
|
410
410
|
if (!tracking_id) {
|
|
411
|
-
|
|
411
|
+
$9AWcE$depictaiutilishared.derror("No tracking id found on element with attribute ".concat(selector), element);
|
|
412
412
|
return;
|
|
413
413
|
}
|
|
414
414
|
this.trackProductCard(element, tracking_id, type);
|
|
@@ -426,7 +426,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
426
426
|
const depict_card_selector = Object.keys((0, $e0dfb0ca4c8c037f$export$79f7900b4eea40cf)).map(attribute => "[".concat(attribute, "]")).join(",");
|
|
427
427
|
// it's an add to cart button on a product card that possibly was added to the product card at a later point, if parent_depict_card is defined
|
|
428
428
|
const parent_depict_card = element.closest(depict_card_selector) || undefined;
|
|
429
|
-
|
|
429
|
+
$9AWcE$depictaiutilishared.dlog("Found ".concat(parent_depict_card ? "product card" : "pdp", " add-to-cart button"), element);
|
|
430
430
|
this.trackAddToCartButton(element, parent_depict_card);
|
|
431
431
|
};
|
|
432
432
|
(0, $9AWcE$depictaiutilishared.observer).onexists((0, $e0dfb0ca4c8c037f$export$6f11e212918dbb31), handler);
|
|
@@ -434,12 +434,12 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
434
434
|
}
|
|
435
435
|
function $89ae37e3a26189b4$var$_resetSentPageViewForCurrentHref2() {
|
|
436
436
|
let url = location.href;
|
|
437
|
-
(0, $9AWcE$depictaiutilishared.instant_exec_on_suspect_history_change).add(
|
|
437
|
+
(0, $9AWcE$depictaiutilishared.instant_exec_on_suspect_history_change).add($9AWcE$depictaiutilishared.catchify(() => {
|
|
438
438
|
const {
|
|
439
439
|
href: new_href
|
|
440
440
|
} = location;
|
|
441
441
|
if (url !== new_href) {
|
|
442
|
-
|
|
442
|
+
$parcel$interopDefault($9AWcE$babelruntimehelpersclassPrivateFieldSet)(this, $89ae37e3a26189b4$var$_has_sent_pageview_for_current_href, false);
|
|
443
443
|
url = new_href;
|
|
444
444
|
}
|
|
445
445
|
}));
|
|
@@ -458,7 +458,7 @@ function $89ae37e3a26189b4$var$_getContextData2() {
|
|
|
458
458
|
session_id: this.latest_session_id
|
|
459
459
|
};
|
|
460
460
|
return {
|
|
461
|
-
|
|
461
|
+
...$9AWcE$depictaiutilishared.get_tracking_event_context_data(),
|
|
462
462
|
...data
|
|
463
463
|
};
|
|
464
464
|
}
|
|
@@ -466,7 +466,7 @@ function $89ae37e3a26189b4$var$_sendTrackingEvent2(payload) {
|
|
|
466
466
|
// Todo. check consent. For some events, delay until consent decision, with possible timeout.
|
|
467
467
|
// For others, decide immediately based on current consent. (We shouldn't track a long history of events from before the user consented)
|
|
468
468
|
// If no consent, don't send at all, or send anonymous? I think the latter is valid, since no ID in cookie or localStorage.
|
|
469
|
-
|
|
469
|
+
$9AWcE$depictaiutilishared.send_depict_unfiltered([{
|
|
470
470
|
...payload,
|
|
471
471
|
...$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getContextData, $89ae37e3a26189b4$var$_getContextData2).call(this)
|
|
472
472
|
}], true);
|
|
@@ -475,4 +475,4 @@ function $89ae37e3a26189b4$var$_getProductId2() {
|
|
|
475
475
|
if (this.latest_product_id_path !== location.pathname) return undefined;
|
|
476
476
|
return this.latest_product_id;
|
|
477
477
|
}
|
|
478
|
-
|
|
478
|
+
$9AWcE$depictaiutilishared.add_to_version_info("dpc", (0, $fcc8287091fb489d$export$83d89fbfd8236492));
|
package/ES10/index.d.ts
CHANGED
package/ES10/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import $4uUHR$babelruntimehelpersclassPrivateFieldSet from "@babel/runtime/helpe
|
|
|
6
6
|
/*! Depict PerformanceClient */
|
|
7
7
|
import { register_es_version } from "../multi_import_deduplicator.mjs";
|
|
8
8
|
register_es_version("performance-client", "ES10");
|
|
9
|
-
const $3242b911de3d57ad$export$83d89fbfd8236492 = "1.0.
|
|
9
|
+
const $3242b911de3d57ad$export$83d89fbfd8236492 = "1.0.38";
|
|
10
10
|
let $983195e3c4979825$export$8ae64f3d447c14f7;
|
|
11
11
|
(function (ProductCardType) {
|
|
12
12
|
ProductCardType[ProductCardType["Recommendation"] = 0] = "Recommendation";
|
|
@@ -144,18 +144,18 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
144
144
|
$53af71a3700e1e90$var$_classPrivateMethodInitSpec(this, $53af71a3700e1e90$var$_getContextData);
|
|
145
145
|
$53af71a3700e1e90$var$_classPrivateMethodInitSpec(this, $53af71a3700e1e90$var$_parseOptions);
|
|
146
146
|
$53af71a3700e1e90$var$_classPrivateMethodInitSpec(this, $53af71a3700e1e90$var$_resetSentPageViewForCurrentHref);
|
|
147
|
-
|
|
147
|
+
$4uUHR$babelruntimehelpersdefineProperty(this, "auto_observe", true);
|
|
148
148
|
$53af71a3700e1e90$var$_classPrivateFieldInitSpec(this, $53af71a3700e1e90$var$_has_sent_pageview_for_current_href, {
|
|
149
149
|
writable: true,
|
|
150
150
|
value: false
|
|
151
151
|
});
|
|
152
|
-
|
|
152
|
+
$4uUHR$babelruntimehelpersdefineProperty(this, "tracked_elements", new WeakSet());
|
|
153
153
|
// Make sure we do not construct dpc more than once.
|
|
154
154
|
if (((_window$depict = window.depict) === null || _window$depict === void 0 ? void 0 : _window$depict.dpc) instanceof $53af71a3700e1e90$export$820526014323765f) {
|
|
155
|
-
|
|
155
|
+
$4uUHR$dlog("DPC already initialized. Returning existing instance.");
|
|
156
156
|
return window.depict.dpc;
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
$f06bf37f1e6136a4$export$7a1bb429756ced60(this);
|
|
159
159
|
this.merchant = merchant;
|
|
160
160
|
$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_parseOptions, $53af71a3700e1e90$var$_parseOptions2).call(this, _options);
|
|
161
161
|
$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_resetSentPageViewForCurrentHref, $53af71a3700e1e90$var$_resetSentPageViewForCurrentHref2).call(this);
|
|
@@ -169,7 +169,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
169
169
|
*/
|
|
170
170
|
checkIfTracked(element) {
|
|
171
171
|
if (this.tracked_elements.has(element)) {
|
|
172
|
-
|
|
172
|
+
$4uUHR$dlog("Already tracked", element);
|
|
173
173
|
return true;
|
|
174
174
|
}
|
|
175
175
|
this.tracked_elements.add(element);
|
|
@@ -184,7 +184,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
184
184
|
case (0, $983195e3c4979825$export$8ae64f3d447c14f7).Recommendation:
|
|
185
185
|
case (0, $983195e3c4979825$export$8ae64f3d447c14f7).SnakeRecommendation:
|
|
186
186
|
card.addEventListener("click", () => this.sendRecommendationClickEvent(tracking_id));
|
|
187
|
-
|
|
187
|
+
$4uUHR$impression_track_element({
|
|
188
188
|
element: card,
|
|
189
189
|
data: {
|
|
190
190
|
recommendation_id: tracking_id,
|
|
@@ -194,7 +194,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
194
194
|
break;
|
|
195
195
|
case (0, $983195e3c4979825$export$8ae64f3d447c14f7).SearchResult:
|
|
196
196
|
card.addEventListener("click", () => this.sendSearchResultClickEvent(tracking_id));
|
|
197
|
-
|
|
197
|
+
$4uUHR$impression_track_element({
|
|
198
198
|
element: card,
|
|
199
199
|
data: {
|
|
200
200
|
search_result_id: tracking_id,
|
|
@@ -204,7 +204,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
204
204
|
break;
|
|
205
205
|
case (0, $983195e3c4979825$export$8ae64f3d447c14f7).ProductListingResult:
|
|
206
206
|
card.addEventListener("click", () => this.sendProductListingResultClickEvent(tracking_id));
|
|
207
|
-
|
|
207
|
+
$4uUHR$impression_track_element({
|
|
208
208
|
element: card,
|
|
209
209
|
data: {
|
|
210
210
|
product_listing_result_id: tracking_id,
|
|
@@ -227,7 +227,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
227
227
|
// If the button is not nested in a product card, it's a PDP button. Product ID set on the page is required.
|
|
228
228
|
const product_id = $53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getProductId, $53af71a3700e1e90$var$_getProductId2).call(this);
|
|
229
229
|
if (!product_id) {
|
|
230
|
-
|
|
230
|
+
$4uUHR$derror("No product ID set for add-to-cart click outside of product card", button);
|
|
231
231
|
return;
|
|
232
232
|
}
|
|
233
233
|
this.sendAddToCartEvent({
|
|
@@ -245,7 +245,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
245
245
|
this.sendAddToCartEvent(tracking_data);
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
$4uUHR$derror("Could not find tracking data for add-to-cart click on button", button);
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
@@ -291,7 +291,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
291
291
|
* Sends a recommendation click event to Depict
|
|
292
292
|
*/
|
|
293
293
|
sendRecommendationClickEvent(recommendation_id) {
|
|
294
|
-
|
|
294
|
+
$4uUHR$depict_click({
|
|
295
295
|
recommendation_id: recommendation_id,
|
|
296
296
|
...$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getContextData, $53af71a3700e1e90$var$_getContextData2).call(this)
|
|
297
297
|
});
|
|
@@ -300,7 +300,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
300
300
|
* Sends a search result click event to Depict
|
|
301
301
|
*/
|
|
302
302
|
sendSearchResultClickEvent(search_result_id) {
|
|
303
|
-
|
|
303
|
+
$4uUHR$depict_click({
|
|
304
304
|
search_result_id: search_result_id,
|
|
305
305
|
...$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getContextData, $53af71a3700e1e90$var$_getContextData2).call(this)
|
|
306
306
|
});
|
|
@@ -309,7 +309,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
309
309
|
* Sends a product listing result click event to Depict
|
|
310
310
|
*/
|
|
311
311
|
sendProductListingResultClickEvent(product_listing_result_id) {
|
|
312
|
-
|
|
312
|
+
$4uUHR$depict_click({
|
|
313
313
|
product_listing_result_id: product_listing_result_id,
|
|
314
314
|
...$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getContextData, $53af71a3700e1e90$var$_getContextData2).call(this)
|
|
315
315
|
});
|
|
@@ -343,7 +343,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
343
343
|
tenant: this.merchant,
|
|
344
344
|
market: this.market
|
|
345
345
|
};
|
|
346
|
-
|
|
346
|
+
$4uUHR$foolproof_send_beacon((0, $4uUHR$base_url) + "/v2/create-events", request);
|
|
347
347
|
}
|
|
348
348
|
/**
|
|
349
349
|
* Update the market used for tracking events
|
|
@@ -355,15 +355,15 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
355
355
|
* Update the product_id used for add-to-cart and pageview events on PDPs.
|
|
356
356
|
*/
|
|
357
357
|
setProductId(product_id) {
|
|
358
|
-
|
|
358
|
+
$4uUHR$dlog("Setting product id", product_id);
|
|
359
359
|
this.latest_product_id = product_id;
|
|
360
360
|
this.latest_product_id_path = location.pathname;
|
|
361
|
-
if (
|
|
361
|
+
if (!$4uUHR$babelruntimehelpersclassPrivateFieldGet(this, $53af71a3700e1e90$var$_has_sent_pageview_for_current_href)) {
|
|
362
362
|
$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_sendTrackingEvent, $53af71a3700e1e90$var$_sendTrackingEvent2).call(this, {
|
|
363
363
|
type: "page_view",
|
|
364
364
|
product_id: product_id
|
|
365
365
|
});
|
|
366
|
-
|
|
366
|
+
$4uUHR$babelruntimehelpersclassPrivateFieldSet(this, $53af71a3700e1e90$var$_has_sent_pageview_for_current_href, true);
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
/**
|
|
@@ -372,7 +372,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
372
372
|
* https://docs.depict.ai/docs/performance-client#informing-depict-of-logged-in-users
|
|
373
373
|
*/
|
|
374
374
|
setUserId(user_id) {
|
|
375
|
-
|
|
375
|
+
$4uUHR$dlog("Setting user id", user_id);
|
|
376
376
|
this.latest_user_id = user_id || undefined;
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
@@ -381,7 +381,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
381
381
|
* https://docs.depict.ai/docs/performance-client#browser-sessions
|
|
382
382
|
*/
|
|
383
383
|
setSessionId(session_id) {
|
|
384
|
-
|
|
384
|
+
$4uUHR$dlog("Setting session id", session_id);
|
|
385
385
|
this.latest_session_id = session_id || undefined;
|
|
386
386
|
}
|
|
387
387
|
/**
|
|
@@ -390,14 +390,14 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
390
390
|
observeRecommendations() {
|
|
391
391
|
for (const [attribute, type] of Object.entries((0, $0cf01531cdd5b1ae$export$79f7900b4eea40cf))) {
|
|
392
392
|
const selector = "[".concat(attribute, "]");
|
|
393
|
-
|
|
393
|
+
$4uUHR$dlog("Starting to observe product cards with selector", selector);
|
|
394
394
|
(0, $4uUHR$observer).onexists(selector, _ref => {
|
|
395
395
|
let {
|
|
396
396
|
element: element
|
|
397
397
|
} = _ref;
|
|
398
398
|
const tracking_id = element.getAttribute(attribute);
|
|
399
399
|
if (!tracking_id) {
|
|
400
|
-
|
|
400
|
+
$4uUHR$derror("No tracking id found on element with attribute ".concat(selector), element);
|
|
401
401
|
return;
|
|
402
402
|
}
|
|
403
403
|
this.trackProductCard(element, tracking_id, type);
|
|
@@ -415,7 +415,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
415
415
|
const depict_card_selector = Object.keys((0, $0cf01531cdd5b1ae$export$79f7900b4eea40cf)).map(attribute => "[".concat(attribute, "]")).join(",");
|
|
416
416
|
// it's an add to cart button on a product card that possibly was added to the product card at a later point, if parent_depict_card is defined
|
|
417
417
|
const parent_depict_card = element.closest(depict_card_selector) || undefined;
|
|
418
|
-
|
|
418
|
+
$4uUHR$dlog("Found ".concat(parent_depict_card ? "product card" : "pdp", " add-to-cart button"), element);
|
|
419
419
|
this.trackAddToCartButton(element, parent_depict_card);
|
|
420
420
|
};
|
|
421
421
|
(0, $4uUHR$observer).onexists((0, $0cf01531cdd5b1ae$export$6f11e212918dbb31), handler);
|
|
@@ -423,12 +423,12 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
423
423
|
}
|
|
424
424
|
function $53af71a3700e1e90$var$_resetSentPageViewForCurrentHref2() {
|
|
425
425
|
let url = location.href;
|
|
426
|
-
(0, $4uUHR$instant_exec_on_suspect_history_change).add(
|
|
426
|
+
(0, $4uUHR$instant_exec_on_suspect_history_change).add($4uUHR$catchify(() => {
|
|
427
427
|
const {
|
|
428
428
|
href: new_href
|
|
429
429
|
} = location;
|
|
430
430
|
if (url !== new_href) {
|
|
431
|
-
|
|
431
|
+
$4uUHR$babelruntimehelpersclassPrivateFieldSet(this, $53af71a3700e1e90$var$_has_sent_pageview_for_current_href, false);
|
|
432
432
|
url = new_href;
|
|
433
433
|
}
|
|
434
434
|
}));
|
|
@@ -447,7 +447,7 @@ function $53af71a3700e1e90$var$_getContextData2() {
|
|
|
447
447
|
session_id: this.latest_session_id
|
|
448
448
|
};
|
|
449
449
|
return {
|
|
450
|
-
|
|
450
|
+
...$4uUHR$get_tracking_event_context_data(),
|
|
451
451
|
...data
|
|
452
452
|
};
|
|
453
453
|
}
|
|
@@ -455,7 +455,7 @@ function $53af71a3700e1e90$var$_sendTrackingEvent2(payload) {
|
|
|
455
455
|
// Todo. check consent. For some events, delay until consent decision, with possible timeout.
|
|
456
456
|
// For others, decide immediately based on current consent. (We shouldn't track a long history of events from before the user consented)
|
|
457
457
|
// If no consent, don't send at all, or send anonymous? I think the latter is valid, since no ID in cookie or localStorage.
|
|
458
|
-
|
|
458
|
+
$4uUHR$send_depict_unfiltered([{
|
|
459
459
|
...payload,
|
|
460
460
|
...$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getContextData, $53af71a3700e1e90$var$_getContextData2).call(this)
|
|
461
461
|
}], true);
|
|
@@ -464,5 +464,5 @@ function $53af71a3700e1e90$var$_getProductId2() {
|
|
|
464
464
|
if (this.latest_product_id_path !== location.pathname) return undefined;
|
|
465
465
|
return this.latest_product_id;
|
|
466
466
|
}
|
|
467
|
-
|
|
467
|
+
$4uUHR$add_to_version_info("dpc", (0, $3242b911de3d57ad$export$83d89fbfd8236492));
|
|
468
468
|
export { $53af71a3700e1e90$export$820526014323765f as DPC, $3242b911de3d57ad$export$83d89fbfd8236492 as version };
|
package/dist/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ function $parcel$interopDefault(a) {
|
|
|
17
17
|
$parcel$export(module.exports, "DPC", () => $89ae37e3a26189b4$export$820526014323765f);
|
|
18
18
|
$parcel$export(module.exports, "version", () => $fcc8287091fb489d$export$83d89fbfd8236492);
|
|
19
19
|
/*! Depict PerformanceClient */
|
|
20
|
-
const $fcc8287091fb489d$export$83d89fbfd8236492 = "1.0.
|
|
20
|
+
const $fcc8287091fb489d$export$83d89fbfd8236492 = "1.0.38";
|
|
21
21
|
let $405164bc961cc106$export$8ae64f3d447c14f7;
|
|
22
22
|
(function (ProductCardType) {
|
|
23
23
|
ProductCardType[ProductCardType["Recommendation"] = 0] = "Recommendation";
|
|
@@ -155,18 +155,18 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
155
155
|
$89ae37e3a26189b4$var$_classPrivateMethodInitSpec(this, $89ae37e3a26189b4$var$_getContextData);
|
|
156
156
|
$89ae37e3a26189b4$var$_classPrivateMethodInitSpec(this, $89ae37e3a26189b4$var$_parseOptions);
|
|
157
157
|
$89ae37e3a26189b4$var$_classPrivateMethodInitSpec(this, $89ae37e3a26189b4$var$_resetSentPageViewForCurrentHref);
|
|
158
|
-
|
|
158
|
+
$parcel$interopDefault($9AWcE$babelruntimehelpersdefineProperty)(this, "auto_observe", true);
|
|
159
159
|
$89ae37e3a26189b4$var$_classPrivateFieldInitSpec(this, $89ae37e3a26189b4$var$_has_sent_pageview_for_current_href, {
|
|
160
160
|
writable: true,
|
|
161
161
|
value: false
|
|
162
162
|
});
|
|
163
|
-
|
|
163
|
+
$parcel$interopDefault($9AWcE$babelruntimehelpersdefineProperty)(this, "tracked_elements", new WeakSet());
|
|
164
164
|
// Make sure we do not construct dpc more than once.
|
|
165
165
|
if (((_window$depict = window.depict) === null || _window$depict === void 0 ? void 0 : _window$depict.dpc) instanceof $89ae37e3a26189b4$export$820526014323765f) {
|
|
166
|
-
|
|
166
|
+
$9AWcE$depictaiutilishared.dlog("DPC already initialized. Returning existing instance.");
|
|
167
167
|
return window.depict.dpc;
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
$5323e9ffea4e414a$export$7a1bb429756ced60(this);
|
|
170
170
|
this.merchant = merchant;
|
|
171
171
|
$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_parseOptions, $89ae37e3a26189b4$var$_parseOptions2).call(this, _options);
|
|
172
172
|
$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_resetSentPageViewForCurrentHref, $89ae37e3a26189b4$var$_resetSentPageViewForCurrentHref2).call(this);
|
|
@@ -180,7 +180,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
180
180
|
*/
|
|
181
181
|
checkIfTracked(element) {
|
|
182
182
|
if (this.tracked_elements.has(element)) {
|
|
183
|
-
|
|
183
|
+
$9AWcE$depictaiutilishared.dlog("Already tracked", element);
|
|
184
184
|
return true;
|
|
185
185
|
}
|
|
186
186
|
this.tracked_elements.add(element);
|
|
@@ -195,7 +195,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
195
195
|
case (0, $405164bc961cc106$export$8ae64f3d447c14f7).Recommendation:
|
|
196
196
|
case (0, $405164bc961cc106$export$8ae64f3d447c14f7).SnakeRecommendation:
|
|
197
197
|
card.addEventListener("click", () => this.sendRecommendationClickEvent(tracking_id));
|
|
198
|
-
|
|
198
|
+
$9AWcE$depictaiutilishared.impression_track_element({
|
|
199
199
|
element: card,
|
|
200
200
|
data: {
|
|
201
201
|
recommendation_id: tracking_id,
|
|
@@ -205,7 +205,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
205
205
|
break;
|
|
206
206
|
case (0, $405164bc961cc106$export$8ae64f3d447c14f7).SearchResult:
|
|
207
207
|
card.addEventListener("click", () => this.sendSearchResultClickEvent(tracking_id));
|
|
208
|
-
|
|
208
|
+
$9AWcE$depictaiutilishared.impression_track_element({
|
|
209
209
|
element: card,
|
|
210
210
|
data: {
|
|
211
211
|
search_result_id: tracking_id,
|
|
@@ -215,7 +215,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
215
215
|
break;
|
|
216
216
|
case (0, $405164bc961cc106$export$8ae64f3d447c14f7).ProductListingResult:
|
|
217
217
|
card.addEventListener("click", () => this.sendProductListingResultClickEvent(tracking_id));
|
|
218
|
-
|
|
218
|
+
$9AWcE$depictaiutilishared.impression_track_element({
|
|
219
219
|
element: card,
|
|
220
220
|
data: {
|
|
221
221
|
product_listing_result_id: tracking_id,
|
|
@@ -238,7 +238,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
238
238
|
// If the button is not nested in a product card, it's a PDP button. Product ID set on the page is required.
|
|
239
239
|
const product_id = $89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getProductId, $89ae37e3a26189b4$var$_getProductId2).call(this);
|
|
240
240
|
if (!product_id) {
|
|
241
|
-
|
|
241
|
+
$9AWcE$depictaiutilishared.derror("No product ID set for add-to-cart click outside of product card", button);
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
this.sendAddToCartEvent({
|
|
@@ -256,7 +256,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
256
256
|
this.sendAddToCartEvent(tracking_data);
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
|
-
|
|
259
|
+
$9AWcE$depictaiutilishared.derror("Could not find tracking data for add-to-cart click on button", button);
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
@@ -302,7 +302,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
302
302
|
* Sends a recommendation click event to Depict
|
|
303
303
|
*/
|
|
304
304
|
sendRecommendationClickEvent(recommendation_id) {
|
|
305
|
-
|
|
305
|
+
$9AWcE$depictaiutilishared.depict_click({
|
|
306
306
|
recommendation_id: recommendation_id,
|
|
307
307
|
...$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getContextData, $89ae37e3a26189b4$var$_getContextData2).call(this)
|
|
308
308
|
});
|
|
@@ -311,7 +311,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
311
311
|
* Sends a search result click event to Depict
|
|
312
312
|
*/
|
|
313
313
|
sendSearchResultClickEvent(search_result_id) {
|
|
314
|
-
|
|
314
|
+
$9AWcE$depictaiutilishared.depict_click({
|
|
315
315
|
search_result_id: search_result_id,
|
|
316
316
|
...$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getContextData, $89ae37e3a26189b4$var$_getContextData2).call(this)
|
|
317
317
|
});
|
|
@@ -320,7 +320,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
320
320
|
* Sends a product listing result click event to Depict
|
|
321
321
|
*/
|
|
322
322
|
sendProductListingResultClickEvent(product_listing_result_id) {
|
|
323
|
-
|
|
323
|
+
$9AWcE$depictaiutilishared.depict_click({
|
|
324
324
|
product_listing_result_id: product_listing_result_id,
|
|
325
325
|
...$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getContextData, $89ae37e3a26189b4$var$_getContextData2).call(this)
|
|
326
326
|
});
|
|
@@ -354,7 +354,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
354
354
|
tenant: this.merchant,
|
|
355
355
|
market: this.market
|
|
356
356
|
};
|
|
357
|
-
|
|
357
|
+
$9AWcE$depictaiutilishared.foolproof_send_beacon((0, $9AWcE$depictaiutilishared.base_url) + "/v2/create-events", request);
|
|
358
358
|
}
|
|
359
359
|
/**
|
|
360
360
|
* Update the market used for tracking events
|
|
@@ -366,15 +366,15 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
366
366
|
* Update the product_id used for add-to-cart and pageview events on PDPs.
|
|
367
367
|
*/
|
|
368
368
|
setProductId(product_id) {
|
|
369
|
-
|
|
369
|
+
$9AWcE$depictaiutilishared.dlog("Setting product id", product_id);
|
|
370
370
|
this.latest_product_id = product_id;
|
|
371
371
|
this.latest_product_id_path = location.pathname;
|
|
372
|
-
if (
|
|
372
|
+
if (!$parcel$interopDefault($9AWcE$babelruntimehelpersclassPrivateFieldGet)(this, $89ae37e3a26189b4$var$_has_sent_pageview_for_current_href)) {
|
|
373
373
|
$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_sendTrackingEvent, $89ae37e3a26189b4$var$_sendTrackingEvent2).call(this, {
|
|
374
374
|
type: "page_view",
|
|
375
375
|
product_id: product_id
|
|
376
376
|
});
|
|
377
|
-
|
|
377
|
+
$parcel$interopDefault($9AWcE$babelruntimehelpersclassPrivateFieldSet)(this, $89ae37e3a26189b4$var$_has_sent_pageview_for_current_href, true);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
/**
|
|
@@ -383,7 +383,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
383
383
|
* https://docs.depict.ai/docs/performance-client#informing-depict-of-logged-in-users
|
|
384
384
|
*/
|
|
385
385
|
setUserId(user_id) {
|
|
386
|
-
|
|
386
|
+
$9AWcE$depictaiutilishared.dlog("Setting user id", user_id);
|
|
387
387
|
this.latest_user_id = user_id || undefined;
|
|
388
388
|
}
|
|
389
389
|
/**
|
|
@@ -392,7 +392,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
392
392
|
* https://docs.depict.ai/docs/performance-client#browser-sessions
|
|
393
393
|
*/
|
|
394
394
|
setSessionId(session_id) {
|
|
395
|
-
|
|
395
|
+
$9AWcE$depictaiutilishared.dlog("Setting session id", session_id);
|
|
396
396
|
this.latest_session_id = session_id || undefined;
|
|
397
397
|
}
|
|
398
398
|
/**
|
|
@@ -401,14 +401,14 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
401
401
|
observeRecommendations() {
|
|
402
402
|
for (const [attribute, type] of Object.entries((0, $e0dfb0ca4c8c037f$export$79f7900b4eea40cf))) {
|
|
403
403
|
const selector = "[".concat(attribute, "]");
|
|
404
|
-
|
|
404
|
+
$9AWcE$depictaiutilishared.dlog("Starting to observe product cards with selector", selector);
|
|
405
405
|
(0, $9AWcE$depictaiutilishared.observer).onexists(selector, _ref => {
|
|
406
406
|
let {
|
|
407
407
|
element: element
|
|
408
408
|
} = _ref;
|
|
409
409
|
const tracking_id = element.getAttribute(attribute);
|
|
410
410
|
if (!tracking_id) {
|
|
411
|
-
|
|
411
|
+
$9AWcE$depictaiutilishared.derror("No tracking id found on element with attribute ".concat(selector), element);
|
|
412
412
|
return;
|
|
413
413
|
}
|
|
414
414
|
this.trackProductCard(element, tracking_id, type);
|
|
@@ -426,7 +426,7 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
426
426
|
const depict_card_selector = Object.keys((0, $e0dfb0ca4c8c037f$export$79f7900b4eea40cf)).map(attribute => "[".concat(attribute, "]")).join(",");
|
|
427
427
|
// it's an add to cart button on a product card that possibly was added to the product card at a later point, if parent_depict_card is defined
|
|
428
428
|
const parent_depict_card = element.closest(depict_card_selector) || undefined;
|
|
429
|
-
|
|
429
|
+
$9AWcE$depictaiutilishared.dlog("Found ".concat(parent_depict_card ? "product card" : "pdp", " add-to-cart button"), element);
|
|
430
430
|
this.trackAddToCartButton(element, parent_depict_card);
|
|
431
431
|
};
|
|
432
432
|
(0, $9AWcE$depictaiutilishared.observer).onexists((0, $e0dfb0ca4c8c037f$export$6f11e212918dbb31), handler);
|
|
@@ -434,12 +434,12 @@ class $89ae37e3a26189b4$export$820526014323765f {
|
|
|
434
434
|
}
|
|
435
435
|
function $89ae37e3a26189b4$var$_resetSentPageViewForCurrentHref2() {
|
|
436
436
|
let url = location.href;
|
|
437
|
-
(0, $9AWcE$depictaiutilishared.instant_exec_on_suspect_history_change).add(
|
|
437
|
+
(0, $9AWcE$depictaiutilishared.instant_exec_on_suspect_history_change).add($9AWcE$depictaiutilishared.catchify(() => {
|
|
438
438
|
const {
|
|
439
439
|
href: new_href
|
|
440
440
|
} = location;
|
|
441
441
|
if (url !== new_href) {
|
|
442
|
-
|
|
442
|
+
$parcel$interopDefault($9AWcE$babelruntimehelpersclassPrivateFieldSet)(this, $89ae37e3a26189b4$var$_has_sent_pageview_for_current_href, false);
|
|
443
443
|
url = new_href;
|
|
444
444
|
}
|
|
445
445
|
}));
|
|
@@ -458,7 +458,7 @@ function $89ae37e3a26189b4$var$_getContextData2() {
|
|
|
458
458
|
session_id: this.latest_session_id
|
|
459
459
|
};
|
|
460
460
|
return {
|
|
461
|
-
|
|
461
|
+
...$9AWcE$depictaiutilishared.get_tracking_event_context_data(),
|
|
462
462
|
...data
|
|
463
463
|
};
|
|
464
464
|
}
|
|
@@ -466,7 +466,7 @@ function $89ae37e3a26189b4$var$_sendTrackingEvent2(payload) {
|
|
|
466
466
|
// Todo. check consent. For some events, delay until consent decision, with possible timeout.
|
|
467
467
|
// For others, decide immediately based on current consent. (We shouldn't track a long history of events from before the user consented)
|
|
468
468
|
// If no consent, don't send at all, or send anonymous? I think the latter is valid, since no ID in cookie or localStorage.
|
|
469
|
-
|
|
469
|
+
$9AWcE$depictaiutilishared.send_depict_unfiltered([{
|
|
470
470
|
...payload,
|
|
471
471
|
...$89ae37e3a26189b4$var$_classPrivateMethodGet(this, $89ae37e3a26189b4$var$_getContextData, $89ae37e3a26189b4$var$_getContextData2).call(this)
|
|
472
472
|
}], true);
|
|
@@ -475,4 +475,4 @@ function $89ae37e3a26189b4$var$_getProductId2() {
|
|
|
475
475
|
if (this.latest_product_id_path !== location.pathname) return undefined;
|
|
476
476
|
return this.latest_product_id;
|
|
477
477
|
}
|
|
478
|
-
|
|
478
|
+
$9AWcE$depictaiutilishared.add_to_version_info("dpc", (0, $fcc8287091fb489d$export$83d89fbfd8236492));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import $4uUHR$babelruntimehelpersclassPrivateFieldSet from "@babel/runtime/helpe
|
|
|
6
6
|
/*! Depict PerformanceClient */
|
|
7
7
|
import { register_es_version } from "../multi_import_deduplicator.mjs";
|
|
8
8
|
register_es_version("performance-client", "ES10");
|
|
9
|
-
const $3242b911de3d57ad$export$83d89fbfd8236492 = "1.0.
|
|
9
|
+
const $3242b911de3d57ad$export$83d89fbfd8236492 = "1.0.38";
|
|
10
10
|
let $983195e3c4979825$export$8ae64f3d447c14f7;
|
|
11
11
|
(function (ProductCardType) {
|
|
12
12
|
ProductCardType[ProductCardType["Recommendation"] = 0] = "Recommendation";
|
|
@@ -144,18 +144,18 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
144
144
|
$53af71a3700e1e90$var$_classPrivateMethodInitSpec(this, $53af71a3700e1e90$var$_getContextData);
|
|
145
145
|
$53af71a3700e1e90$var$_classPrivateMethodInitSpec(this, $53af71a3700e1e90$var$_parseOptions);
|
|
146
146
|
$53af71a3700e1e90$var$_classPrivateMethodInitSpec(this, $53af71a3700e1e90$var$_resetSentPageViewForCurrentHref);
|
|
147
|
-
|
|
147
|
+
$4uUHR$babelruntimehelpersdefineProperty(this, "auto_observe", true);
|
|
148
148
|
$53af71a3700e1e90$var$_classPrivateFieldInitSpec(this, $53af71a3700e1e90$var$_has_sent_pageview_for_current_href, {
|
|
149
149
|
writable: true,
|
|
150
150
|
value: false
|
|
151
151
|
});
|
|
152
|
-
|
|
152
|
+
$4uUHR$babelruntimehelpersdefineProperty(this, "tracked_elements", new WeakSet());
|
|
153
153
|
// Make sure we do not construct dpc more than once.
|
|
154
154
|
if (((_window$depict = window.depict) === null || _window$depict === void 0 ? void 0 : _window$depict.dpc) instanceof $53af71a3700e1e90$export$820526014323765f) {
|
|
155
|
-
|
|
155
|
+
$4uUHR$dlog("DPC already initialized. Returning existing instance.");
|
|
156
156
|
return window.depict.dpc;
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
$f06bf37f1e6136a4$export$7a1bb429756ced60(this);
|
|
159
159
|
this.merchant = merchant;
|
|
160
160
|
$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_parseOptions, $53af71a3700e1e90$var$_parseOptions2).call(this, _options);
|
|
161
161
|
$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_resetSentPageViewForCurrentHref, $53af71a3700e1e90$var$_resetSentPageViewForCurrentHref2).call(this);
|
|
@@ -169,7 +169,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
169
169
|
*/
|
|
170
170
|
checkIfTracked(element) {
|
|
171
171
|
if (this.tracked_elements.has(element)) {
|
|
172
|
-
|
|
172
|
+
$4uUHR$dlog("Already tracked", element);
|
|
173
173
|
return true;
|
|
174
174
|
}
|
|
175
175
|
this.tracked_elements.add(element);
|
|
@@ -184,7 +184,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
184
184
|
case (0, $983195e3c4979825$export$8ae64f3d447c14f7).Recommendation:
|
|
185
185
|
case (0, $983195e3c4979825$export$8ae64f3d447c14f7).SnakeRecommendation:
|
|
186
186
|
card.addEventListener("click", () => this.sendRecommendationClickEvent(tracking_id));
|
|
187
|
-
|
|
187
|
+
$4uUHR$impression_track_element({
|
|
188
188
|
element: card,
|
|
189
189
|
data: {
|
|
190
190
|
recommendation_id: tracking_id,
|
|
@@ -194,7 +194,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
194
194
|
break;
|
|
195
195
|
case (0, $983195e3c4979825$export$8ae64f3d447c14f7).SearchResult:
|
|
196
196
|
card.addEventListener("click", () => this.sendSearchResultClickEvent(tracking_id));
|
|
197
|
-
|
|
197
|
+
$4uUHR$impression_track_element({
|
|
198
198
|
element: card,
|
|
199
199
|
data: {
|
|
200
200
|
search_result_id: tracking_id,
|
|
@@ -204,7 +204,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
204
204
|
break;
|
|
205
205
|
case (0, $983195e3c4979825$export$8ae64f3d447c14f7).ProductListingResult:
|
|
206
206
|
card.addEventListener("click", () => this.sendProductListingResultClickEvent(tracking_id));
|
|
207
|
-
|
|
207
|
+
$4uUHR$impression_track_element({
|
|
208
208
|
element: card,
|
|
209
209
|
data: {
|
|
210
210
|
product_listing_result_id: tracking_id,
|
|
@@ -227,7 +227,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
227
227
|
// If the button is not nested in a product card, it's a PDP button. Product ID set on the page is required.
|
|
228
228
|
const product_id = $53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getProductId, $53af71a3700e1e90$var$_getProductId2).call(this);
|
|
229
229
|
if (!product_id) {
|
|
230
|
-
|
|
230
|
+
$4uUHR$derror("No product ID set for add-to-cart click outside of product card", button);
|
|
231
231
|
return;
|
|
232
232
|
}
|
|
233
233
|
this.sendAddToCartEvent({
|
|
@@ -245,7 +245,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
245
245
|
this.sendAddToCartEvent(tracking_data);
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
$4uUHR$derror("Could not find tracking data for add-to-cart click on button", button);
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
@@ -291,7 +291,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
291
291
|
* Sends a recommendation click event to Depict
|
|
292
292
|
*/
|
|
293
293
|
sendRecommendationClickEvent(recommendation_id) {
|
|
294
|
-
|
|
294
|
+
$4uUHR$depict_click({
|
|
295
295
|
recommendation_id: recommendation_id,
|
|
296
296
|
...$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getContextData, $53af71a3700e1e90$var$_getContextData2).call(this)
|
|
297
297
|
});
|
|
@@ -300,7 +300,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
300
300
|
* Sends a search result click event to Depict
|
|
301
301
|
*/
|
|
302
302
|
sendSearchResultClickEvent(search_result_id) {
|
|
303
|
-
|
|
303
|
+
$4uUHR$depict_click({
|
|
304
304
|
search_result_id: search_result_id,
|
|
305
305
|
...$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getContextData, $53af71a3700e1e90$var$_getContextData2).call(this)
|
|
306
306
|
});
|
|
@@ -309,7 +309,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
309
309
|
* Sends a product listing result click event to Depict
|
|
310
310
|
*/
|
|
311
311
|
sendProductListingResultClickEvent(product_listing_result_id) {
|
|
312
|
-
|
|
312
|
+
$4uUHR$depict_click({
|
|
313
313
|
product_listing_result_id: product_listing_result_id,
|
|
314
314
|
...$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getContextData, $53af71a3700e1e90$var$_getContextData2).call(this)
|
|
315
315
|
});
|
|
@@ -343,7 +343,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
343
343
|
tenant: this.merchant,
|
|
344
344
|
market: this.market
|
|
345
345
|
};
|
|
346
|
-
|
|
346
|
+
$4uUHR$foolproof_send_beacon((0, $4uUHR$base_url) + "/v2/create-events", request);
|
|
347
347
|
}
|
|
348
348
|
/**
|
|
349
349
|
* Update the market used for tracking events
|
|
@@ -355,15 +355,15 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
355
355
|
* Update the product_id used for add-to-cart and pageview events on PDPs.
|
|
356
356
|
*/
|
|
357
357
|
setProductId(product_id) {
|
|
358
|
-
|
|
358
|
+
$4uUHR$dlog("Setting product id", product_id);
|
|
359
359
|
this.latest_product_id = product_id;
|
|
360
360
|
this.latest_product_id_path = location.pathname;
|
|
361
|
-
if (
|
|
361
|
+
if (!$4uUHR$babelruntimehelpersclassPrivateFieldGet(this, $53af71a3700e1e90$var$_has_sent_pageview_for_current_href)) {
|
|
362
362
|
$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_sendTrackingEvent, $53af71a3700e1e90$var$_sendTrackingEvent2).call(this, {
|
|
363
363
|
type: "page_view",
|
|
364
364
|
product_id: product_id
|
|
365
365
|
});
|
|
366
|
-
|
|
366
|
+
$4uUHR$babelruntimehelpersclassPrivateFieldSet(this, $53af71a3700e1e90$var$_has_sent_pageview_for_current_href, true);
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
/**
|
|
@@ -372,7 +372,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
372
372
|
* https://docs.depict.ai/docs/performance-client#informing-depict-of-logged-in-users
|
|
373
373
|
*/
|
|
374
374
|
setUserId(user_id) {
|
|
375
|
-
|
|
375
|
+
$4uUHR$dlog("Setting user id", user_id);
|
|
376
376
|
this.latest_user_id = user_id || undefined;
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
@@ -381,7 +381,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
381
381
|
* https://docs.depict.ai/docs/performance-client#browser-sessions
|
|
382
382
|
*/
|
|
383
383
|
setSessionId(session_id) {
|
|
384
|
-
|
|
384
|
+
$4uUHR$dlog("Setting session id", session_id);
|
|
385
385
|
this.latest_session_id = session_id || undefined;
|
|
386
386
|
}
|
|
387
387
|
/**
|
|
@@ -390,14 +390,14 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
390
390
|
observeRecommendations() {
|
|
391
391
|
for (const [attribute, type] of Object.entries((0, $0cf01531cdd5b1ae$export$79f7900b4eea40cf))) {
|
|
392
392
|
const selector = "[".concat(attribute, "]");
|
|
393
|
-
|
|
393
|
+
$4uUHR$dlog("Starting to observe product cards with selector", selector);
|
|
394
394
|
(0, $4uUHR$observer).onexists(selector, _ref => {
|
|
395
395
|
let {
|
|
396
396
|
element: element
|
|
397
397
|
} = _ref;
|
|
398
398
|
const tracking_id = element.getAttribute(attribute);
|
|
399
399
|
if (!tracking_id) {
|
|
400
|
-
|
|
400
|
+
$4uUHR$derror("No tracking id found on element with attribute ".concat(selector), element);
|
|
401
401
|
return;
|
|
402
402
|
}
|
|
403
403
|
this.trackProductCard(element, tracking_id, type);
|
|
@@ -415,7 +415,7 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
415
415
|
const depict_card_selector = Object.keys((0, $0cf01531cdd5b1ae$export$79f7900b4eea40cf)).map(attribute => "[".concat(attribute, "]")).join(",");
|
|
416
416
|
// it's an add to cart button on a product card that possibly was added to the product card at a later point, if parent_depict_card is defined
|
|
417
417
|
const parent_depict_card = element.closest(depict_card_selector) || undefined;
|
|
418
|
-
|
|
418
|
+
$4uUHR$dlog("Found ".concat(parent_depict_card ? "product card" : "pdp", " add-to-cart button"), element);
|
|
419
419
|
this.trackAddToCartButton(element, parent_depict_card);
|
|
420
420
|
};
|
|
421
421
|
(0, $4uUHR$observer).onexists((0, $0cf01531cdd5b1ae$export$6f11e212918dbb31), handler);
|
|
@@ -423,12 +423,12 @@ class $53af71a3700e1e90$export$820526014323765f {
|
|
|
423
423
|
}
|
|
424
424
|
function $53af71a3700e1e90$var$_resetSentPageViewForCurrentHref2() {
|
|
425
425
|
let url = location.href;
|
|
426
|
-
(0, $4uUHR$instant_exec_on_suspect_history_change).add(
|
|
426
|
+
(0, $4uUHR$instant_exec_on_suspect_history_change).add($4uUHR$catchify(() => {
|
|
427
427
|
const {
|
|
428
428
|
href: new_href
|
|
429
429
|
} = location;
|
|
430
430
|
if (url !== new_href) {
|
|
431
|
-
|
|
431
|
+
$4uUHR$babelruntimehelpersclassPrivateFieldSet(this, $53af71a3700e1e90$var$_has_sent_pageview_for_current_href, false);
|
|
432
432
|
url = new_href;
|
|
433
433
|
}
|
|
434
434
|
}));
|
|
@@ -447,7 +447,7 @@ function $53af71a3700e1e90$var$_getContextData2() {
|
|
|
447
447
|
session_id: this.latest_session_id
|
|
448
448
|
};
|
|
449
449
|
return {
|
|
450
|
-
|
|
450
|
+
...$4uUHR$get_tracking_event_context_data(),
|
|
451
451
|
...data
|
|
452
452
|
};
|
|
453
453
|
}
|
|
@@ -455,7 +455,7 @@ function $53af71a3700e1e90$var$_sendTrackingEvent2(payload) {
|
|
|
455
455
|
// Todo. check consent. For some events, delay until consent decision, with possible timeout.
|
|
456
456
|
// For others, decide immediately based on current consent. (We shouldn't track a long history of events from before the user consented)
|
|
457
457
|
// If no consent, don't send at all, or send anonymous? I think the latter is valid, since no ID in cookie or localStorage.
|
|
458
|
-
|
|
458
|
+
$4uUHR$send_depict_unfiltered([{
|
|
459
459
|
...payload,
|
|
460
460
|
...$53af71a3700e1e90$var$_classPrivateMethodGet(this, $53af71a3700e1e90$var$_getContextData, $53af71a3700e1e90$var$_getContextData2).call(this)
|
|
461
461
|
}], true);
|
|
@@ -464,5 +464,5 @@ function $53af71a3700e1e90$var$_getProductId2() {
|
|
|
464
464
|
if (this.latest_product_id_path !== location.pathname) return undefined;
|
|
465
465
|
return this.latest_product_id;
|
|
466
466
|
}
|
|
467
|
-
|
|
467
|
+
$4uUHR$add_to_version_info("dpc", (0, $3242b911de3d57ad$export$83d89fbfd8236492));
|
|
468
468
|
export { $53af71a3700e1e90$export$820526014323765f as DPC, $3242b911de3d57ad$export$83d89fbfd8236492 as version };
|
package/latest/index.cjs
CHANGED
|
@@ -11,7 +11,7 @@ function $parcel$export(e, n, v, s) {
|
|
|
11
11
|
$parcel$export(module.exports, "DPC", () => $15e3eebad2263636$export$820526014323765f);
|
|
12
12
|
$parcel$export(module.exports, "version", () => $9c6b4a5c4c4f318d$export$83d89fbfd8236492);
|
|
13
13
|
/*! Depict PerformanceClient */
|
|
14
|
-
const $9c6b4a5c4c4f318d$export$83d89fbfd8236492 = "1.0.
|
|
14
|
+
const $9c6b4a5c4c4f318d$export$83d89fbfd8236492 = "1.0.38";
|
|
15
15
|
let $02e69dba644a2ef8$export$8ae64f3d447c14f7;
|
|
16
16
|
(function (ProductCardType) {
|
|
17
17
|
ProductCardType[ProductCardType["Recommendation"] = 0] = "Recommendation";
|
|
@@ -125,10 +125,10 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
125
125
|
constructor(merchant, options) {
|
|
126
126
|
// Make sure we do not construct dpc more than once.
|
|
127
127
|
if (window.depict?.dpc instanceof $15e3eebad2263636$export$820526014323765f) {
|
|
128
|
-
|
|
128
|
+
$dwOGf$depictaiutilishared.dlog("DPC already initialized. Returning existing instance.");
|
|
129
129
|
return window.depict.dpc;
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
$9ccf446d29413158$export$7a1bb429756ced60(this);
|
|
132
132
|
this.merchant = merchant;
|
|
133
133
|
this.#parseOptions(options);
|
|
134
134
|
this.#resetSentPageViewForCurrentHref();
|
|
@@ -139,7 +139,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
139
139
|
}
|
|
140
140
|
#resetSentPageViewForCurrentHref() {
|
|
141
141
|
let url = location.href;
|
|
142
|
-
(0, $dwOGf$depictaiutilishared.instant_exec_on_suspect_history_change).add(
|
|
142
|
+
(0, $dwOGf$depictaiutilishared.instant_exec_on_suspect_history_change).add($dwOGf$depictaiutilishared.catchify(() => {
|
|
143
143
|
const {
|
|
144
144
|
href: new_href
|
|
145
145
|
} = location;
|
|
@@ -163,7 +163,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
163
163
|
session_id: this.latest_session_id
|
|
164
164
|
};
|
|
165
165
|
return {
|
|
166
|
-
|
|
166
|
+
...$dwOGf$depictaiutilishared.get_tracking_event_context_data(),
|
|
167
167
|
...data
|
|
168
168
|
};
|
|
169
169
|
}
|
|
@@ -173,7 +173,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
173
173
|
*/
|
|
174
174
|
checkIfTracked(element) {
|
|
175
175
|
if (this.tracked_elements.has(element)) {
|
|
176
|
-
|
|
176
|
+
$dwOGf$depictaiutilishared.dlog("Already tracked", element);
|
|
177
177
|
return true;
|
|
178
178
|
}
|
|
179
179
|
this.tracked_elements.add(element);
|
|
@@ -188,7 +188,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
188
188
|
case (0, $02e69dba644a2ef8$export$8ae64f3d447c14f7).Recommendation:
|
|
189
189
|
case (0, $02e69dba644a2ef8$export$8ae64f3d447c14f7).SnakeRecommendation:
|
|
190
190
|
card.addEventListener("click", () => this.sendRecommendationClickEvent(tracking_id));
|
|
191
|
-
|
|
191
|
+
$dwOGf$depictaiutilishared.impression_track_element({
|
|
192
192
|
element: card,
|
|
193
193
|
data: {
|
|
194
194
|
recommendation_id: tracking_id,
|
|
@@ -198,7 +198,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
198
198
|
break;
|
|
199
199
|
case (0, $02e69dba644a2ef8$export$8ae64f3d447c14f7).SearchResult:
|
|
200
200
|
card.addEventListener("click", () => this.sendSearchResultClickEvent(tracking_id));
|
|
201
|
-
|
|
201
|
+
$dwOGf$depictaiutilishared.impression_track_element({
|
|
202
202
|
element: card,
|
|
203
203
|
data: {
|
|
204
204
|
search_result_id: tracking_id,
|
|
@@ -208,7 +208,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
208
208
|
break;
|
|
209
209
|
case (0, $02e69dba644a2ef8$export$8ae64f3d447c14f7).ProductListingResult:
|
|
210
210
|
card.addEventListener("click", () => this.sendProductListingResultClickEvent(tracking_id));
|
|
211
|
-
|
|
211
|
+
$dwOGf$depictaiutilishared.impression_track_element({
|
|
212
212
|
element: card,
|
|
213
213
|
data: {
|
|
214
214
|
product_listing_result_id: tracking_id,
|
|
@@ -231,7 +231,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
231
231
|
// If the button is not nested in a product card, it's a PDP button. Product ID set on the page is required.
|
|
232
232
|
const product_id = this.#getProductId();
|
|
233
233
|
if (!product_id) {
|
|
234
|
-
|
|
234
|
+
$dwOGf$depictaiutilishared.derror("No product ID set for add-to-cart click outside of product card", button);
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
237
|
this.sendAddToCartEvent({
|
|
@@ -249,7 +249,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
249
249
|
this.sendAddToCartEvent(tracking_data);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
$dwOGf$depictaiutilishared.derror("Could not find tracking data for add-to-cart click on button", button);
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
255
|
/**
|
|
@@ -259,7 +259,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
259
259
|
// Todo. check consent. For some events, delay until consent decision, with possible timeout.
|
|
260
260
|
// For others, decide immediately based on current consent. (We shouldn't track a long history of events from before the user consented)
|
|
261
261
|
// If no consent, don't send at all, or send anonymous? I think the latter is valid, since no ID in cookie or localStorage.
|
|
262
|
-
|
|
262
|
+
$dwOGf$depictaiutilishared.send_depict_unfiltered([{
|
|
263
263
|
...payload,
|
|
264
264
|
...this.#getContextData()
|
|
265
265
|
}], true);
|
|
@@ -305,7 +305,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
305
305
|
* Sends a recommendation click event to Depict
|
|
306
306
|
*/
|
|
307
307
|
sendRecommendationClickEvent(recommendation_id) {
|
|
308
|
-
|
|
308
|
+
$dwOGf$depictaiutilishared.depict_click({
|
|
309
309
|
recommendation_id: recommendation_id,
|
|
310
310
|
...this.#getContextData()
|
|
311
311
|
});
|
|
@@ -314,7 +314,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
314
314
|
* Sends a search result click event to Depict
|
|
315
315
|
*/
|
|
316
316
|
sendSearchResultClickEvent(search_result_id) {
|
|
317
|
-
|
|
317
|
+
$dwOGf$depictaiutilishared.depict_click({
|
|
318
318
|
search_result_id: search_result_id,
|
|
319
319
|
...this.#getContextData()
|
|
320
320
|
});
|
|
@@ -323,7 +323,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
323
323
|
* Sends a product listing result click event to Depict
|
|
324
324
|
*/
|
|
325
325
|
sendProductListingResultClickEvent(product_listing_result_id) {
|
|
326
|
-
|
|
326
|
+
$dwOGf$depictaiutilishared.depict_click({
|
|
327
327
|
product_listing_result_id: product_listing_result_id,
|
|
328
328
|
...this.#getContextData()
|
|
329
329
|
});
|
|
@@ -357,7 +357,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
357
357
|
tenant: this.merchant,
|
|
358
358
|
market: this.market
|
|
359
359
|
};
|
|
360
|
-
|
|
360
|
+
$dwOGf$depictaiutilishared.foolproof_send_beacon((0, $dwOGf$depictaiutilishared.base_url) + "/v2/create-events", request);
|
|
361
361
|
}
|
|
362
362
|
/**
|
|
363
363
|
* Update the market used for tracking events
|
|
@@ -369,7 +369,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
369
369
|
* Update the product_id used for add-to-cart and pageview events on PDPs.
|
|
370
370
|
*/
|
|
371
371
|
setProductId(product_id) {
|
|
372
|
-
|
|
372
|
+
$dwOGf$depictaiutilishared.dlog("Setting product id", product_id);
|
|
373
373
|
this.latest_product_id = product_id;
|
|
374
374
|
this.latest_product_id_path = location.pathname;
|
|
375
375
|
if (!this.#has_sent_pageview_for_current_href) {
|
|
@@ -390,7 +390,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
390
390
|
* https://docs.depict.ai/docs/performance-client#informing-depict-of-logged-in-users
|
|
391
391
|
*/
|
|
392
392
|
setUserId(user_id) {
|
|
393
|
-
|
|
393
|
+
$dwOGf$depictaiutilishared.dlog("Setting user id", user_id);
|
|
394
394
|
this.latest_user_id = user_id || undefined;
|
|
395
395
|
}
|
|
396
396
|
/**
|
|
@@ -399,7 +399,7 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
399
399
|
* https://docs.depict.ai/docs/performance-client#browser-sessions
|
|
400
400
|
*/
|
|
401
401
|
setSessionId(session_id) {
|
|
402
|
-
|
|
402
|
+
$dwOGf$depictaiutilishared.dlog("Setting session id", session_id);
|
|
403
403
|
this.latest_session_id = session_id || undefined;
|
|
404
404
|
}
|
|
405
405
|
/**
|
|
@@ -408,13 +408,13 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
408
408
|
observeRecommendations() {
|
|
409
409
|
for (const [attribute, type] of Object.entries((0, $1e7b1f32e4f0380b$export$79f7900b4eea40cf))) {
|
|
410
410
|
const selector = `[${attribute}]`;
|
|
411
|
-
|
|
411
|
+
$dwOGf$depictaiutilishared.dlog("Starting to observe product cards with selector", selector);
|
|
412
412
|
(0, $dwOGf$depictaiutilishared.observer).onexists(selector, ({
|
|
413
413
|
element: element
|
|
414
414
|
}) => {
|
|
415
415
|
const tracking_id = element.getAttribute(attribute);
|
|
416
416
|
if (!tracking_id) {
|
|
417
|
-
|
|
417
|
+
$dwOGf$depictaiutilishared.derror(`No tracking id found on element with attribute ${selector}`, element);
|
|
418
418
|
return;
|
|
419
419
|
}
|
|
420
420
|
this.trackProductCard(element, tracking_id, type);
|
|
@@ -431,10 +431,10 @@ class $15e3eebad2263636$export$820526014323765f {
|
|
|
431
431
|
const depict_card_selector = Object.keys((0, $1e7b1f32e4f0380b$export$79f7900b4eea40cf)).map(attribute => `[${attribute}]`).join(",");
|
|
432
432
|
// it's an add to cart button on a product card that possibly was added to the product card at a later point, if parent_depict_card is defined
|
|
433
433
|
const parent_depict_card = element.closest(depict_card_selector) || undefined;
|
|
434
|
-
|
|
434
|
+
$dwOGf$depictaiutilishared.dlog(`Found ${parent_depict_card ? "product card" : "pdp"} add-to-cart button`, element);
|
|
435
435
|
this.trackAddToCartButton(element, parent_depict_card);
|
|
436
436
|
};
|
|
437
437
|
(0, $dwOGf$depictaiutilishared.observer).onexists((0, $1e7b1f32e4f0380b$export$6f11e212918dbb31), handler);
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
|
-
|
|
440
|
+
$dwOGf$depictaiutilishared.add_to_version_info("dpc", (0, $9c6b4a5c4c4f318d$export$83d89fbfd8236492));
|
package/latest/index.d.ts
CHANGED
package/latest/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { add_to_version_info as $lbGMC$add_to_version_info, dlog as $lbGMC$dlog,
|
|
|
3
3
|
/*! Depict PerformanceClient */
|
|
4
4
|
import { register_es_version } from "../multi_import_deduplicator.mjs";
|
|
5
5
|
register_es_version("performance-client", "latest");
|
|
6
|
-
const $3b068891cefe570d$export$83d89fbfd8236492 = "1.0.
|
|
6
|
+
const $3b068891cefe570d$export$83d89fbfd8236492 = "1.0.38";
|
|
7
7
|
let $ba8dc1a552d27224$export$8ae64f3d447c14f7;
|
|
8
8
|
(function (ProductCardType) {
|
|
9
9
|
ProductCardType[ProductCardType["Recommendation"] = 0] = "Recommendation";
|
|
@@ -117,10 +117,10 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
117
117
|
constructor(merchant, options) {
|
|
118
118
|
// Make sure we do not construct dpc more than once.
|
|
119
119
|
if (window.depict?.dpc instanceof $fe563348936ab010$export$820526014323765f) {
|
|
120
|
-
|
|
120
|
+
$lbGMC$dlog("DPC already initialized. Returning existing instance.");
|
|
121
121
|
return window.depict.dpc;
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
$b1ff6e3aa9b3b030$export$7a1bb429756ced60(this);
|
|
124
124
|
this.merchant = merchant;
|
|
125
125
|
this.#parseOptions(options);
|
|
126
126
|
this.#resetSentPageViewForCurrentHref();
|
|
@@ -131,7 +131,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
131
131
|
}
|
|
132
132
|
#resetSentPageViewForCurrentHref() {
|
|
133
133
|
let url = location.href;
|
|
134
|
-
(0, $lbGMC$instant_exec_on_suspect_history_change).add(
|
|
134
|
+
(0, $lbGMC$instant_exec_on_suspect_history_change).add($lbGMC$catchify(() => {
|
|
135
135
|
const {
|
|
136
136
|
href: new_href
|
|
137
137
|
} = location;
|
|
@@ -155,7 +155,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
155
155
|
session_id: this.latest_session_id
|
|
156
156
|
};
|
|
157
157
|
return {
|
|
158
|
-
|
|
158
|
+
...$lbGMC$get_tracking_event_context_data(),
|
|
159
159
|
...data
|
|
160
160
|
};
|
|
161
161
|
}
|
|
@@ -165,7 +165,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
165
165
|
*/
|
|
166
166
|
checkIfTracked(element) {
|
|
167
167
|
if (this.tracked_elements.has(element)) {
|
|
168
|
-
|
|
168
|
+
$lbGMC$dlog("Already tracked", element);
|
|
169
169
|
return true;
|
|
170
170
|
}
|
|
171
171
|
this.tracked_elements.add(element);
|
|
@@ -180,7 +180,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
180
180
|
case (0, $ba8dc1a552d27224$export$8ae64f3d447c14f7).Recommendation:
|
|
181
181
|
case (0, $ba8dc1a552d27224$export$8ae64f3d447c14f7).SnakeRecommendation:
|
|
182
182
|
card.addEventListener("click", () => this.sendRecommendationClickEvent(tracking_id));
|
|
183
|
-
|
|
183
|
+
$lbGMC$impression_track_element({
|
|
184
184
|
element: card,
|
|
185
185
|
data: {
|
|
186
186
|
recommendation_id: tracking_id,
|
|
@@ -190,7 +190,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
190
190
|
break;
|
|
191
191
|
case (0, $ba8dc1a552d27224$export$8ae64f3d447c14f7).SearchResult:
|
|
192
192
|
card.addEventListener("click", () => this.sendSearchResultClickEvent(tracking_id));
|
|
193
|
-
|
|
193
|
+
$lbGMC$impression_track_element({
|
|
194
194
|
element: card,
|
|
195
195
|
data: {
|
|
196
196
|
search_result_id: tracking_id,
|
|
@@ -200,7 +200,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
200
200
|
break;
|
|
201
201
|
case (0, $ba8dc1a552d27224$export$8ae64f3d447c14f7).ProductListingResult:
|
|
202
202
|
card.addEventListener("click", () => this.sendProductListingResultClickEvent(tracking_id));
|
|
203
|
-
|
|
203
|
+
$lbGMC$impression_track_element({
|
|
204
204
|
element: card,
|
|
205
205
|
data: {
|
|
206
206
|
product_listing_result_id: tracking_id,
|
|
@@ -223,7 +223,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
223
223
|
// If the button is not nested in a product card, it's a PDP button. Product ID set on the page is required.
|
|
224
224
|
const product_id = this.#getProductId();
|
|
225
225
|
if (!product_id) {
|
|
226
|
-
|
|
226
|
+
$lbGMC$derror("No product ID set for add-to-cart click outside of product card", button);
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
229
|
this.sendAddToCartEvent({
|
|
@@ -241,7 +241,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
241
241
|
this.sendAddToCartEvent(tracking_data);
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
|
-
|
|
244
|
+
$lbGMC$derror("Could not find tracking data for add-to-cart click on button", button);
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
@@ -251,7 +251,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
251
251
|
// Todo. check consent. For some events, delay until consent decision, with possible timeout.
|
|
252
252
|
// For others, decide immediately based on current consent. (We shouldn't track a long history of events from before the user consented)
|
|
253
253
|
// If no consent, don't send at all, or send anonymous? I think the latter is valid, since no ID in cookie or localStorage.
|
|
254
|
-
|
|
254
|
+
$lbGMC$send_depict_unfiltered([{
|
|
255
255
|
...payload,
|
|
256
256
|
...this.#getContextData()
|
|
257
257
|
}], true);
|
|
@@ -297,7 +297,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
297
297
|
* Sends a recommendation click event to Depict
|
|
298
298
|
*/
|
|
299
299
|
sendRecommendationClickEvent(recommendation_id) {
|
|
300
|
-
|
|
300
|
+
$lbGMC$depict_click({
|
|
301
301
|
recommendation_id: recommendation_id,
|
|
302
302
|
...this.#getContextData()
|
|
303
303
|
});
|
|
@@ -306,7 +306,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
306
306
|
* Sends a search result click event to Depict
|
|
307
307
|
*/
|
|
308
308
|
sendSearchResultClickEvent(search_result_id) {
|
|
309
|
-
|
|
309
|
+
$lbGMC$depict_click({
|
|
310
310
|
search_result_id: search_result_id,
|
|
311
311
|
...this.#getContextData()
|
|
312
312
|
});
|
|
@@ -315,7 +315,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
315
315
|
* Sends a product listing result click event to Depict
|
|
316
316
|
*/
|
|
317
317
|
sendProductListingResultClickEvent(product_listing_result_id) {
|
|
318
|
-
|
|
318
|
+
$lbGMC$depict_click({
|
|
319
319
|
product_listing_result_id: product_listing_result_id,
|
|
320
320
|
...this.#getContextData()
|
|
321
321
|
});
|
|
@@ -349,7 +349,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
349
349
|
tenant: this.merchant,
|
|
350
350
|
market: this.market
|
|
351
351
|
};
|
|
352
|
-
|
|
352
|
+
$lbGMC$foolproof_send_beacon((0, $lbGMC$base_url) + "/v2/create-events", request);
|
|
353
353
|
}
|
|
354
354
|
/**
|
|
355
355
|
* Update the market used for tracking events
|
|
@@ -361,7 +361,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
361
361
|
* Update the product_id used for add-to-cart and pageview events on PDPs.
|
|
362
362
|
*/
|
|
363
363
|
setProductId(product_id) {
|
|
364
|
-
|
|
364
|
+
$lbGMC$dlog("Setting product id", product_id);
|
|
365
365
|
this.latest_product_id = product_id;
|
|
366
366
|
this.latest_product_id_path = location.pathname;
|
|
367
367
|
if (!this.#has_sent_pageview_for_current_href) {
|
|
@@ -382,7 +382,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
382
382
|
* https://docs.depict.ai/docs/performance-client#informing-depict-of-logged-in-users
|
|
383
383
|
*/
|
|
384
384
|
setUserId(user_id) {
|
|
385
|
-
|
|
385
|
+
$lbGMC$dlog("Setting user id", user_id);
|
|
386
386
|
this.latest_user_id = user_id || undefined;
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
@@ -391,7 +391,7 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
391
391
|
* https://docs.depict.ai/docs/performance-client#browser-sessions
|
|
392
392
|
*/
|
|
393
393
|
setSessionId(session_id) {
|
|
394
|
-
|
|
394
|
+
$lbGMC$dlog("Setting session id", session_id);
|
|
395
395
|
this.latest_session_id = session_id || undefined;
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
@@ -400,13 +400,13 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
400
400
|
observeRecommendations() {
|
|
401
401
|
for (const [attribute, type] of Object.entries((0, $f956499541bad8b0$export$79f7900b4eea40cf))) {
|
|
402
402
|
const selector = `[${attribute}]`;
|
|
403
|
-
|
|
403
|
+
$lbGMC$dlog("Starting to observe product cards with selector", selector);
|
|
404
404
|
(0, $lbGMC$observer).onexists(selector, ({
|
|
405
405
|
element: element
|
|
406
406
|
}) => {
|
|
407
407
|
const tracking_id = element.getAttribute(attribute);
|
|
408
408
|
if (!tracking_id) {
|
|
409
|
-
|
|
409
|
+
$lbGMC$derror(`No tracking id found on element with attribute ${selector}`, element);
|
|
410
410
|
return;
|
|
411
411
|
}
|
|
412
412
|
this.trackProductCard(element, tracking_id, type);
|
|
@@ -423,11 +423,11 @@ class $fe563348936ab010$export$820526014323765f {
|
|
|
423
423
|
const depict_card_selector = Object.keys((0, $f956499541bad8b0$export$79f7900b4eea40cf)).map(attribute => `[${attribute}]`).join(",");
|
|
424
424
|
// it's an add to cart button on a product card that possibly was added to the product card at a later point, if parent_depict_card is defined
|
|
425
425
|
const parent_depict_card = element.closest(depict_card_selector) || undefined;
|
|
426
|
-
|
|
426
|
+
$lbGMC$dlog(`Found ${parent_depict_card ? "product card" : "pdp"} add-to-cart button`, element);
|
|
427
427
|
this.trackAddToCartButton(element, parent_depict_card);
|
|
428
428
|
};
|
|
429
429
|
(0, $lbGMC$observer).onexists((0, $f956499541bad8b0$export$6f11e212918dbb31), handler);
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
|
|
432
|
+
$lbGMC$add_to_version_info("dpc", (0, $3b068891cefe570d$export$83d89fbfd8236492));
|
|
433
433
|
export { $fe563348936ab010$export$820526014323765f as DPC, $3b068891cefe570d$export$83d89fbfd8236492 as version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depict-ai/dpc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"packageManager": "yarn@3.2.2",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"types": "ES10/index.d.ts",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"@babel/plugin-transform-typescript": "^7.22.9",
|
|
93
93
|
"@babel/runtime": "latest",
|
|
94
94
|
"@babel/runtime-corejs3": "^7.22.6",
|
|
95
|
-
"@depict-ai/types": "^1.0.
|
|
96
|
-
"@depict-ai/utilishared": "^1.0.
|
|
95
|
+
"@depict-ai/types": "^1.0.37",
|
|
96
|
+
"@depict-ai/utilishared": "^1.0.38"
|
|
97
97
|
},
|
|
98
98
|
"main": "ES10/index.cjs",
|
|
99
99
|
"module": "ES10/index.js"
|