@inappstory/slide-api 0.1.50 → 0.1.51

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/dist/index.cjs CHANGED
@@ -5896,7 +5896,7 @@ let SlideApi$1 = class SlideApi {
5896
5896
  handled = true;
5897
5897
  }
5898
5898
  }
5899
- if (handled) {
5899
+ if (handled && linkType !== "products") {
5900
5900
  try {
5901
5901
  const cardId = this.slide.cardId;
5902
5902
  const cardType = this.slide.cardType;
@@ -20941,11 +20941,12 @@ class ProductComponentsFactory {
20941
20941
  },
20942
20942
  });
20943
20943
  }
20944
- createProductCheckout(bottomSheet) {
20944
+ createProductCheckout(bottomSheet, params) {
20945
20945
  return new ProductCheckout({
20946
20946
  onClose: () => bottomSheet.close(),
20947
20947
  onCheckout: () => {
20948
20948
  this.widgetDeps.slideApiDeps.productCartClicked();
20949
+ params.onCheckout();
20949
20950
  },
20950
20951
  translations: this.props.translations,
20951
20952
  });
@@ -20988,9 +20989,9 @@ class ProductOfferMapper {
20988
20989
  oldPrice: offerDto.oldPrice,
20989
20990
  currency: offerDto.currency,
20990
20991
  description: offerDto.description,
20991
- imageUrls: offerDto.images?.map(image => image.url) ?? [],
20992
+ imageUrls: offerDto.blobImages?.map(image => image.url) ?? [],
20992
20993
  adult: offerDto.adult,
20993
- coverUrl: offerDto.coverUrl,
20994
+ coverUrl: offerDto.blobCoverUrl,
20994
20995
  groupId: offerDto.groupId,
20995
20996
  url: offerDto.url,
20996
20997
  };
@@ -21056,6 +21057,7 @@ class ProductDetailsBottomSheet extends RenderableComponent {
21056
21057
  quantity: payload.quantity,
21057
21058
  });
21058
21059
  this.showProductCheckout();
21060
+ this.props.onAddToCart({ offer, quantity: payload.quantity });
21059
21061
  },
21060
21062
  isCartSupported,
21061
21063
  isCartQuantityEnabled,
@@ -21063,7 +21065,9 @@ class ProductDetailsBottomSheet extends RenderableComponent {
21063
21065
  this.updateBottomSheetContent(productDetails);
21064
21066
  }
21065
21067
  showProductCheckout() {
21066
- const productCheckout = this.factory.createProductCheckout(this.bottomSheet);
21068
+ const productCheckout = this.factory.createProductCheckout(this.bottomSheet, {
21069
+ onCheckout: this.props.onCheckout,
21070
+ });
21067
21071
  this.updateBottomSheetContent(productCheckout);
21068
21072
  }
21069
21073
  updateBottomSheetContent(content) {
@@ -21115,7 +21119,9 @@ class ProductCheckoutBottomSheet extends RenderableComponent {
21115
21119
  return this.bottomSheet.render();
21116
21120
  }
21117
21121
  open() {
21118
- const productCheckout = this.factory.createProductCheckout(this.bottomSheet);
21122
+ const productCheckout = this.factory.createProductCheckout(this.bottomSheet, {
21123
+ onCheckout: this.props.onCheckout,
21124
+ });
21119
21125
  this.updateBottomSheetContent(productCheckout);
21120
21126
  this.bottomSheet.open();
21121
21127
  }
@@ -21286,33 +21292,34 @@ class ProductOfferRepository {
21286
21292
  }
21287
21293
  }
21288
21294
  static collectDistinctImageUrls(offers, into) {
21289
- for (const o of offers) {
21290
- if (o.coverUrl) {
21291
- into.add(o.coverUrl);
21295
+ for (const offer of offers) {
21296
+ if (offer.coverUrl) {
21297
+ into.add(offer.coverUrl);
21292
21298
  }
21293
- if (o.images?.length) {
21294
- for (const img of o.images) {
21299
+ if (offer.images?.length) {
21300
+ for (const img of offer.images) {
21295
21301
  if (img.url) {
21296
21302
  into.add(img.url);
21297
21303
  }
21298
21304
  }
21299
21305
  }
21300
- if (o.subOffersApi?.length) {
21301
- this.collectDistinctImageUrls(o.subOffersApi, into);
21306
+ if (offer.subOffersApi?.length) {
21307
+ this.collectDistinctImageUrls(offer.subOffersApi, into);
21302
21308
  }
21303
21309
  }
21304
21310
  }
21305
21311
  static applyImageBlobMap(offers, originalToBlob) {
21306
- for (const o of offers) {
21307
- const coverOrig = o.coverUrl;
21312
+ for (const offer of offers) {
21313
+ const coverOrig = offer.coverUrl;
21308
21314
  if (coverOrig) {
21309
21315
  const blobUrl = originalToBlob.get(coverOrig);
21310
21316
  if (blobUrl) {
21311
- o.coverUrl = blobUrl;
21317
+ offer.blobCoverUrl = blobUrl;
21312
21318
  }
21313
21319
  }
21314
- if (o.images?.length) {
21315
- for (const img of o.images) {
21320
+ if (offer.images?.length) {
21321
+ offer.blobImages = offer.images.map(image => ({ ...image }));
21322
+ for (const img of offer.blobImages) {
21316
21323
  const urlOrig = img.url;
21317
21324
  const blobUrl = originalToBlob.get(urlOrig);
21318
21325
  if (blobUrl) {
@@ -21320,8 +21327,8 @@ class ProductOfferRepository {
21320
21327
  }
21321
21328
  }
21322
21329
  }
21323
- if (o.subOffersApi?.length) {
21324
- this.applyImageBlobMap(o.subOffersApi, originalToBlob);
21330
+ if (offer.subOffersApi?.length) {
21331
+ this.applyImageBlobMap(offer.subOffersApi, originalToBlob);
21325
21332
  }
21326
21333
  }
21327
21334
  }
@@ -21675,6 +21682,12 @@ class WidgetProducts extends WidgetBase {
21675
21682
  openUrl: getTagData(this.element, "msgOpenUrl") ?? "",
21676
21683
  },
21677
21684
  height: backgroundViewHeight + scrollViewGroupHeight,
21685
+ onCheckout: () => {
21686
+ this.statEventGoToCart();
21687
+ },
21688
+ onAddToCart: (event) => {
21689
+ this.statEventAddToCart(event);
21690
+ },
21678
21691
  });
21679
21692
  const isCartEnabled = getTagData(this.element, "isCartEnabled") === "true";
21680
21693
  const isCartQuantityEnabled = !getTagData(this.element, "isCartQuantityEnabled") || getTagData(this.element, "isCartQuantityEnabled") === "true";
@@ -21682,6 +21695,49 @@ class WidgetProducts extends WidgetBase {
21682
21695
  this.productsView.appendChild(bs.render());
21683
21696
  bs.open({ offer, isCartSupported, isCartQuantityEnabled });
21684
21697
  };
21698
+ statEventGoToCart() {
21699
+ try {
21700
+ const captionViewText = this.captionView?.textContent ?? "";
21701
+ this.sendStatisticEventToApp("w-products-go-to-cart", {
21702
+ ...this.statisticEventBaseFieldsShortForm,
21703
+ wi: this.elementId,
21704
+ wl: captionViewText,
21705
+ }, {
21706
+ ...this.statisticEventBaseFieldsFullForm,
21707
+ widget_id: this.elementId,
21708
+ widget_label: captionViewText,
21709
+ }, {
21710
+ forceEnableStatisticV2: false,
21711
+ });
21712
+ }
21713
+ catch (error) {
21714
+ console.error(error);
21715
+ }
21716
+ }
21717
+ statEventAddToCart({ offer, quantity }) {
21718
+ try {
21719
+ const captionViewText = this.captionView?.textContent ?? "";
21720
+ this.sendStatisticEventToApp("w-products-add-to-cart", {
21721
+ ...this.statisticEventBaseFieldsShortForm,
21722
+ wi: this.elementId,
21723
+ wl: captionViewText,
21724
+ wv: offer.offerId,
21725
+ wvi: offer.id,
21726
+ }, {
21727
+ ...this.statisticEventBaseFieldsFullForm,
21728
+ widget_id: this.elementId,
21729
+ widget_label: captionViewText,
21730
+ widget_value: offer.offerId,
21731
+ quantity,
21732
+ widget_value_id: offer.id,
21733
+ }, {
21734
+ forceEnableStatisticV2: false,
21735
+ });
21736
+ }
21737
+ catch (error) {
21738
+ console.error(error);
21739
+ }
21740
+ }
21685
21741
  createScrollView(offers) {
21686
21742
  const scrollViewGroup = document.createElement("div");
21687
21743
  scrollViewGroup.classList.add("ias-products-scroll-view-group");
@@ -22169,7 +22225,7 @@ class WidgetProductCarousel extends WidgetBase {
22169
22225
  this.onWidgetRequirePauseUI();
22170
22226
  }
22171
22227
  e.stopPropagation();
22172
- this.statEventWidgetCardClick(offer);
22228
+ this.statEventClickPurchaseButton(offer);
22173
22229
  if (isCartSupported) {
22174
22230
  this.addToCart(offer, button);
22175
22231
  }
@@ -22215,6 +22271,7 @@ class WidgetProductCarousel extends WidgetBase {
22215
22271
  bs.open();
22216
22272
  this.isBottomSheetOpened = true;
22217
22273
  this.disableHostUIInteraction();
22274
+ this.statEventAddToCart({ offer: offerDto, quantity: 1 });
22218
22275
  }
22219
22276
  catch (error) {
22220
22277
  if (error instanceof Error) {
@@ -22254,6 +22311,12 @@ class WidgetProductCarousel extends WidgetBase {
22254
22311
  this.productsView = null;
22255
22312
  }
22256
22313
  },
22314
+ onCheckout: () => {
22315
+ this.statEventGoToCart();
22316
+ },
22317
+ onAddToCart: (event) => {
22318
+ this.statEventAddToCart(event);
22319
+ },
22257
22320
  };
22258
22321
  }
22259
22322
  statEventWidgetCardClick(offer) {
@@ -22262,8 +22325,8 @@ class WidgetProductCarousel extends WidgetBase {
22262
22325
  this.sendStatisticEventToApp("w-product-carousel-card-click", {
22263
22326
  ...this.statisticEventBaseFieldsShortForm,
22264
22327
  wi: this.elementId,
22265
- wl: captionViewText,
22266
22328
  wv: offer.offerId,
22329
+ wl: captionViewText,
22267
22330
  wvi: offer.id,
22268
22331
  }, {
22269
22332
  ...this.statisticEventBaseFieldsFullForm,
@@ -22279,6 +22342,63 @@ class WidgetProductCarousel extends WidgetBase {
22279
22342
  console.error(error);
22280
22343
  }
22281
22344
  }
22345
+ statEventClickPurchaseButton(offer) {
22346
+ try {
22347
+ this.sendStatisticEventToApp("w-product-carousel-buy-click", {
22348
+ ...this.statisticEventBaseFieldsShortForm,
22349
+ wi: this.elementId,
22350
+ wv: offer.offerId,
22351
+ wvi: offer.id,
22352
+ }, {
22353
+ ...this.statisticEventBaseFieldsFullForm,
22354
+ widget_id: this.elementId,
22355
+ widget_value: offer.offerId,
22356
+ widget_value_id: offer.id,
22357
+ }, {
22358
+ forceEnableStatisticV2: false,
22359
+ });
22360
+ }
22361
+ catch (error) {
22362
+ console.error(error);
22363
+ }
22364
+ }
22365
+ statEventAddToCart({ offer, quantity }) {
22366
+ try {
22367
+ this.sendStatisticEventToApp("w-product-carousel-add-to-cart", {
22368
+ ...this.statisticEventBaseFieldsShortForm,
22369
+ wi: this.elementId,
22370
+ wv: offer.offerId,
22371
+ wvi: offer.id,
22372
+ }, {
22373
+ ...this.statisticEventBaseFieldsFullForm,
22374
+ widget_id: this.elementId,
22375
+ widget_value: offer.offerId,
22376
+ quantity,
22377
+ widget_value_id: offer.id,
22378
+ }, {
22379
+ forceEnableStatisticV2: false,
22380
+ });
22381
+ }
22382
+ catch (error) {
22383
+ console.error(error);
22384
+ }
22385
+ }
22386
+ statEventGoToCart() {
22387
+ try {
22388
+ this.sendStatisticEventToApp("w-product-carousel-go-to-cart", {
22389
+ ...this.statisticEventBaseFieldsShortForm,
22390
+ wi: this.elementId,
22391
+ }, {
22392
+ ...this.statisticEventBaseFieldsFullForm,
22393
+ widget_id: this.elementId,
22394
+ }, {
22395
+ forceEnableStatisticV2: false,
22396
+ });
22397
+ }
22398
+ catch (error) {
22399
+ console.error(error);
22400
+ }
22401
+ }
22282
22402
  isCartSupported() {
22283
22403
  const isCartEnabled = getTagData(this.element, "isCartEnabled") === "true";
22284
22404
  return this.widgetDeps.slideApiDeps.isSdkSupportProductCart && isCartEnabled;
@@ -26898,6 +27018,10 @@ class WidgetScratchCard extends WidgetBase {
26898
27018
  ...this.statisticEventBaseFieldsShortForm,
26899
27019
  wi: this.elementId,
26900
27020
  d: duration,
27021
+ }, {
27022
+ ...this.statisticEventBaseFieldsFullForm,
27023
+ widget_id: this.elementId,
27024
+ duration_ms: duration,
26901
27025
  });
26902
27026
  }
26903
27027
  saveToLocalData() {