@salla.sa/twilight-components 2.14.342 → 2.14.343

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.
@@ -8809,6 +8809,19 @@ const SallaProductsList = class {
8809
8809
  //as a request they don't want to let the user to open the product details
8810
8810
  //todo:: find a better way to handle this request
8811
8811
  this.getSource() === 'landing-page' && (product.url = '');
8812
+ try {
8813
+ // Add source query param to product URL for tracking in Product Viewed event
8814
+ if (this.source && product.url && !product.url.includes('s-product-source=')) {
8815
+ const [urlWithoutFragment, fragment] = product.url.split('#');
8816
+ const separator = urlWithoutFragment.includes('?') ? '&' : '?';
8817
+ const pageSlug = salla.config?.get('page.slug') || 'unknown';
8818
+ const sourceValue = `${pageSlug}.${this.source}`;
8819
+ product.url = `${urlWithoutFragment}${separator}s-product-source=${sourceValue}${fragment ? '#' + fragment : ''}`;
8820
+ }
8821
+ }
8822
+ catch (error) {
8823
+ Salla.log('Error with source');
8824
+ }
8812
8825
  const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';
8813
8826
  const productCard = document.createElement(customComponentTag);
8814
8827
  productCard.product = product;
@@ -197,6 +197,19 @@ export class SallaProductsList {
197
197
  //as a request they don't want to let the user to open the product details
198
198
  //todo:: find a better way to handle this request
199
199
  this.getSource() === 'landing-page' && (product.url = '');
200
+ try {
201
+ // Add source query param to product URL for tracking in Product Viewed event
202
+ if (this.source && product.url && !product.url.includes('s-product-source=')) {
203
+ const [urlWithoutFragment, fragment] = product.url.split('#');
204
+ const separator = urlWithoutFragment.includes('?') ? '&' : '?';
205
+ const pageSlug = salla.config?.get('page.slug') || 'unknown';
206
+ const sourceValue = `${pageSlug}.${this.source}`;
207
+ product.url = `${urlWithoutFragment}${separator}s-product-source=${sourceValue}${fragment ? '#' + fragment : ''}`;
208
+ }
209
+ }
210
+ catch (error) {
211
+ Salla.log('Error with source');
212
+ }
200
213
  const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';
201
214
  const productCard = document.createElement(customComponentTag);
202
215
  productCard.product = product;
@@ -203,6 +203,19 @@ const SallaProductsList = /*@__PURE__*/ proxyCustomElement(class SallaProductsLi
203
203
  //as a request they don't want to let the user to open the product details
204
204
  //todo:: find a better way to handle this request
205
205
  this.getSource() === 'landing-page' && (product.url = '');
206
+ try {
207
+ // Add source query param to product URL for tracking in Product Viewed event
208
+ if (this.source && product.url && !product.url.includes('s-product-source=')) {
209
+ const [urlWithoutFragment, fragment] = product.url.split('#');
210
+ const separator = urlWithoutFragment.includes('?') ? '&' : '?';
211
+ const pageSlug = salla.config?.get('page.slug') || 'unknown';
212
+ const sourceValue = `${pageSlug}.${this.source}`;
213
+ product.url = `${urlWithoutFragment}${separator}s-product-source=${sourceValue}${fragment ? '#' + fragment : ''}`;
214
+ }
215
+ }
216
+ catch (error) {
217
+ Salla.log('Error with source');
218
+ }
206
219
  const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';
207
220
  const productCard = document.createElement(customComponentTag);
208
221
  productCard.product = product;
@@ -8789,6 +8789,19 @@ const SallaProductsList = class {
8789
8789
  //as a request they don't want to let the user to open the product details
8790
8790
  //todo:: find a better way to handle this request
8791
8791
  this.getSource() === 'landing-page' && (product.url = '');
8792
+ try {
8793
+ // Add source query param to product URL for tracking in Product Viewed event
8794
+ if (this.source && product.url && !product.url.includes('s-product-source=')) {
8795
+ const [urlWithoutFragment, fragment] = product.url.split('#');
8796
+ const separator = urlWithoutFragment.includes('?') ? '&' : '?';
8797
+ const pageSlug = salla.config?.get('page.slug') || 'unknown';
8798
+ const sourceValue = `${pageSlug}.${this.source}`;
8799
+ product.url = `${urlWithoutFragment}${separator}s-product-source=${sourceValue}${fragment ? '#' + fragment : ''}`;
8800
+ }
8801
+ }
8802
+ catch (error) {
8803
+ Salla.log('Error with source');
8804
+ }
8792
8805
  const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';
8793
8806
  const productCard = document.createElement(customComponentTag);
8794
8807
  productCard.product = product;