@depict-ai/dpc 1.0.35 → 1.0.37

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/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.35";
6
+ const $3b068891cefe570d$export$83d89fbfd8236492 = "1.0.37";
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
- (0, $lbGMC$dlog)("DPC already initialized. Returning existing instance.");
120
+ $lbGMC$dlog("DPC already initialized. Returning existing instance.");
121
121
  return window.depict.dpc;
122
122
  }
123
- (0, $b1ff6e3aa9b3b030$export$7a1bb429756ced60)(this);
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((0, $lbGMC$catchify)(() => {
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
- ...(0, $lbGMC$get_tracking_event_context_data)(),
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
- (0, $lbGMC$dlog)("Already tracked", element);
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
- (0, $lbGMC$impression_track_element)({
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
- (0, $lbGMC$impression_track_element)({
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
- (0, $lbGMC$impression_track_element)({
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
- (0, $lbGMC$derror)("No product ID set for add-to-cart click outside of product card", button);
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
- (0, $lbGMC$derror)("Could not find tracking data for add-to-cart click on button", button);
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
- (0, $lbGMC$send_depict_unfiltered)([{
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
- (0, $lbGMC$depict_click)({
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
- (0, $lbGMC$depict_click)({
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
- (0, $lbGMC$depict_click)({
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
- (0, $lbGMC$foolproof_send_beacon)((0, $lbGMC$base_url) + "/v2/create-events", request);
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
- (0, $lbGMC$dlog)("Setting product id", product_id);
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
- (0, $lbGMC$dlog)("Setting user id", user_id);
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
- (0, $lbGMC$dlog)("Setting session id", session_id);
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
- (0, $lbGMC$dlog)("Starting to observe product cards with selector", selector);
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
- (0, $lbGMC$derror)(`No tracking id found on element with attribute ${selector}`, element);
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
- (0, $lbGMC$dlog)(`Found ${parent_depict_card ? "product card" : "pdp"} add-to-cart button`, element);
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
- (0, $lbGMC$add_to_version_info)("dpc", (0, $3b068891cefe570d$export$83d89fbfd8236492));
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.35",
3
+ "version": "1.0.37",
4
4
  "packageManager": "yarn@3.2.2",
5
5
  "source": "./src/index.ts",
6
6
  "types": "ES10/index.d.ts",
@@ -71,7 +71,7 @@
71
71
  "import": "./ES10/index.js",
72
72
  "require": "./ES10/index.cjs"
73
73
  },
74
- "./dist/index.js": {
74
+ "./dist/*": {
75
75
  "import": "./dist/index.js"
76
76
  }
77
77
  },
@@ -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.35",
96
- "@depict-ai/utilishared": "^1.0.33"
95
+ "@depict-ai/types": "^1.0.36",
96
+ "@depict-ai/utilishared": "^1.0.36"
97
97
  },
98
98
  "main": "ES10/index.cjs",
99
99
  "module": "ES10/index.js"