@liquidcommercedev/rmn-sdk 1.5.0-beta.11 → 1.5.0-beta.13

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
@@ -584,6 +584,69 @@ const RB_SPOTS_SELECTION_EXAMPLE = {
584
584
  },
585
585
  ],
586
586
  };
587
+ const IAB_SPOTS_SELECTION_EXAMPLE = {
588
+ banner: [],
589
+ billboard: [
590
+ {
591
+ id: 'kol567',
592
+ spot: exports.RMN_SPOT_TYPE.BILLBOARD,
593
+ variant: `${exports.RMN_SPOT_TYPE.BILLBOARD}V2`,
594
+ width: 1140,
595
+ height: 640,
596
+ header: 'Holiday Gift Guide',
597
+ description: 'Perfect spirits for every occasion',
598
+ ctaText: 'Shop Gifts',
599
+ textColor: '#ffffff',
600
+ ctaTextColor: '#ffffff',
601
+ primaryImage: 'https://placehold.co/1140x640/png?text=Gift+Guide',
602
+ mobilePrimaryImage: 'https://placehold.co/640x640/png?text=Mobile+Gifts',
603
+ events: SPOT_EVENTS_EXAMPLE,
604
+ productIds: [25, 26],
605
+ },
606
+ {
607
+ id: 'hpm390',
608
+ spot: exports.RMN_SPOT_TYPE.BILLBOARD,
609
+ variant: `${exports.RMN_SPOT_TYPE.BILLBOARD}V2`,
610
+ width: 1140,
611
+ height: 640,
612
+ header: 'Summer Wine Festival',
613
+ description: 'Refreshing wines for summer',
614
+ ctaText: 'Shop Festival',
615
+ textColor: '#ffffff',
616
+ ctaTextColor: '#ffffff',
617
+ primaryImage: 'https://placehold.co/1140x640/png?text=Wine+Festival',
618
+ mobilePrimaryImage: 'https://placehold.co/640x640/png?text=Mobile+Festival',
619
+ events: SPOT_EVENTS_EXAMPLE,
620
+ productIds: [27, 28],
621
+ },
622
+ ],
623
+ button2: [],
624
+ featurePhoneLargeBanner: [],
625
+ featurePhoneMediumBanner: [],
626
+ featurePhoneSmallBanner: [],
627
+ halfPage: [],
628
+ inText: [],
629
+ largeLeaderboard: [],
630
+ largeRectangle: [],
631
+ leaderboard: [],
632
+ mediumRectangle: [],
633
+ microBar: [],
634
+ mobilePhoneInterstitial1: [],
635
+ mobilePhoneInterstitial2: [],
636
+ mobilePhoneInterstitial3: [],
637
+ popUp: [],
638
+ portrait: [],
639
+ rbProductUpcs: [],
640
+ skyscraper: [],
641
+ smallRectangle: [],
642
+ smallSquare: [],
643
+ smartphoneBanner1: [],
644
+ smartphoneBanner2: [],
645
+ square: [],
646
+ verticalBanner: [],
647
+ verticalRectangle: [],
648
+ wideSkyscraper: [],
649
+ };
587
650
 
588
651
  const REQUEST_CLOUD_PARTNER_SITE = 'X-Liquid-Partner-Site';
589
652
  const REQUEST_CLOUD_PROTECTED_KEY = 'X-Liquid-Protected';
@@ -6803,40 +6866,60 @@ class ObjectHelper {
6803
6866
  /**
6804
6867
  * Recursively extracts ID values from a nested data structure.
6805
6868
  * Searches for specified property names and collects their primitive values (strings/numbers).
6869
+ * Captures properties ending with 'id' and any additional specified property names.
6806
6870
  *
6807
6871
  * @param data - The data structure to search through (can be nested objects/arrays)
6808
- * @param propertyNames - Array of property names to look for
6872
+ * @param propertyNames - Array of additional property names to look for (optional)
6809
6873
  * @returns Array of extracted ID values (strings/numbers only)
6810
6874
  *
6811
6875
  * @example
6812
6876
  * const data = {
6813
6877
  * id: [1, 2, 3],
6814
- * nested: { id: 'abc' },
6815
- * items: [{ id: 456 }]
6878
+ * nested: { id: 'abc', userId: 123 },
6879
+ * items: [{ id: 456, productId: '789', sku: 'ABC123' }]
6816
6880
  * };
6817
- * extractDeepIds(data); // Returns [1, 2, 3, 'abc', 456]
6881
+ * extractDeepIds(data); // Returns [1, 2, 3, 'abc', 123, 456, '789', 'ABC123']
6818
6882
  */
6819
6883
  function extractDeepIds(data, propertyNames) {
6820
6884
  const ids = [];
6821
- const defaulPropertyNames = [
6822
- 'id',
6823
- 'upc',
6824
- 'groupingId',
6825
- 'sku',
6826
- 'productId',
6827
- 'item_id',
6828
- 'isbn',
6829
- 'asin',
6830
- 'mpn',
6885
+ const defaultPropertyNames = [
6886
+ // Universal product identifiers
6887
+ 'gtin', // Global Trade Item Number
6888
+ 'gtin8', // 8-digit GTIN
6889
+ 'gtin12', // 12-digit GTIN (UPC)
6890
+ 'gtin13', // 13-digit GTIN (EAN)
6891
+ 'gtin14', // 14-digit GTIN
6892
+ 'mpn', // Manufacturer Part Number
6893
+ 'sku', // Stock Keeping Unit
6894
+ 'upc', // Universal Product Code
6895
+ 'ean', // European Article Number
6896
+ 'isbn', // International Standard Book Number
6897
+ 'isbn10', // 10-digit ISBN
6898
+ 'isbn13', // 13-digit ISBN
6899
+ 'asin', // Amazon Standard Identification Number
6900
+ // Product codes and references
6901
+ 'coupon',
6902
+ 'barcode',
6903
+ 'product_code',
6904
+ 'part_number',
6831
6905
  'model_number',
6832
- 'article_number',
6833
- 'variant_id',
6906
+ 'item_variant',
6834
6907
  'item_number',
6835
- 'catalog_id',
6836
- 'reference_id',
6908
+ 'article_number',
6909
+ 'reference',
6910
+ 'groupingId',
6837
6911
  ];
6838
- // Set for faster property name lookups
6839
- const propertySet = new Set(defaulPropertyNames);
6912
+ // Convert property names to lowercase for consistent comparison
6913
+ const additionalProperties = new Set((defaultPropertyNames).map((name) => name.toLowerCase()));
6914
+ /**
6915
+ * Checks if a property name is an ID field
6916
+ * @param key - The property name to check
6917
+ * @returns boolean indicating if the key is an ID field
6918
+ */
6919
+ const isIdField = (key) => {
6920
+ const lowercaseKey = key.toLowerCase();
6921
+ return lowercaseKey.endsWith('id') || additionalProperties.has(lowercaseKey);
6922
+ };
6840
6923
  /**
6841
6924
  * Processes a value and extracts IDs if it matches criteria
6842
6925
  * @param value - The value to process
@@ -6847,7 +6930,7 @@ function extractDeepIds(data, propertyNames) {
6847
6930
  if (value == null)
6848
6931
  return;
6849
6932
  // If current key matches our target properties
6850
- if (currentKey && propertySet.has(currentKey)) {
6933
+ if (currentKey && isIdField(currentKey)) {
6851
6934
  if (Array.isArray(value)) {
6852
6935
  // Filter and push valid array values in one pass
6853
6936
  ids.push(...value.filter((item) => typeof item === 'string' || typeof item === 'number'));
@@ -6869,7 +6952,7 @@ function extractDeepIds(data, propertyNames) {
6869
6952
  }
6870
6953
  };
6871
6954
  processValue(data);
6872
- return ids; // No need to filter nulls as we handle that during collection
6955
+ return ids;
6873
6956
  }
6874
6957
  // Fallback method using fetch if sendBeacon isn't available
6875
6958
  async function fallbackEventFire(url) {
@@ -16122,6 +16205,17 @@ var ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX;
16122
16205
  ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["PRODUCT_IDS"] = 4] = "PRODUCT_IDS";
16123
16206
  ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["CREATED_AT"] = 5] = "CREATED_AT";
16124
16207
  })(ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX || (ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX = {}));
16208
+ const LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX = {
16209
+ [exports.RMN_SPOT_EVENT.IMPRESSION]: 0,
16210
+ [exports.RMN_SPOT_EVENT.CLICK]: 1,
16211
+ [exports.RMN_SPOT_EVENT.PURCHASE]: 2,
16212
+ [exports.RMN_SPOT_EVENT.ADD_TO_CART]: 3,
16213
+ [exports.RMN_SPOT_EVENT.REMOVE_FROM_CART]: 4,
16214
+ [exports.RMN_SPOT_EVENT.ADD_TO_CART_FROM_DETAILS]: 5,
16215
+ [exports.RMN_SPOT_EVENT.ADD_TO_WISHLIST]: 6,
16216
+ [exports.RMN_SPOT_EVENT.EXPAND_PRODUCT]: 7,
16217
+ [exports.RMN_SPOT_EVENT.BUY_NOW]: 8,
16218
+ };
16125
16219
  class LocalStorageService {
16126
16220
  constructor() {
16127
16221
  if (typeof window.localStorage === 'undefined') {
@@ -16149,7 +16243,7 @@ class LocalStorageService {
16149
16243
  if (parsedData && typeof parsedData === 'object') {
16150
16244
  const data = {};
16151
16245
  for (const [key, value] of Object.entries(parsedData)) {
16152
- data[key] = this.arrayToObject(value);
16246
+ data[key] = this.spotArrayToObject(value);
16153
16247
  }
16154
16248
  this.spots = this.objectToMap(data);
16155
16249
  }
@@ -16189,7 +16283,7 @@ class LocalStorageService {
16189
16283
  const data = this.mapToObject(this.spots);
16190
16284
  const dataArray = {};
16191
16285
  for (const [key, value] of Object.entries(data)) {
16192
- dataArray[key] = this.objectToArray(value);
16286
+ dataArray[key] = this.spotObjectToArray(value);
16193
16287
  }
16194
16288
  try {
16195
16289
  const encryptedData = this.encryptData(JSON.stringify(dataArray));
@@ -16220,15 +16314,34 @@ class LocalStorageService {
16220
16314
  objectToMap(obj) {
16221
16315
  return new Map(Object.entries(obj));
16222
16316
  }
16223
- objectToArray(obj) {
16224
- return [obj.placementId, obj.spotId, obj.spotType, obj.events, obj.productIds, obj.createdAt];
16317
+ spotEventObjectToArray(events) {
16318
+ return Object.keys(LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX).map((type) => {
16319
+ const result = events.find((item) => item.event === type);
16320
+ return result && result.event === type ? result.url : '';
16321
+ });
16322
+ }
16323
+ spotEventArrayToObject(arr) {
16324
+ return Object.keys(LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX).map((type) => ({
16325
+ event: type,
16326
+ url: arr[LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX[type]],
16327
+ }));
16225
16328
  }
16226
- arrayToObject(arr) {
16329
+ spotObjectToArray(obj) {
16330
+ return [
16331
+ obj.placementId,
16332
+ obj.spotId,
16333
+ obj.spotType,
16334
+ this.spotEventObjectToArray(obj.events),
16335
+ obj.productIds,
16336
+ obj.createdAt,
16337
+ ];
16338
+ }
16339
+ spotArrayToObject(arr) {
16227
16340
  return {
16228
16341
  placementId: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.PLACEMENT_ID],
16229
16342
  spotId: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_ID],
16230
16343
  spotType: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_TYPE],
16231
- events: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.EVENTS],
16344
+ events: this.spotEventArrayToObject(arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.EVENTS]),
16232
16345
  productIds: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.PRODUCT_IDS],
16233
16346
  createdAt: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.CREATED_AT],
16234
16347
  };
@@ -16238,16 +16351,14 @@ class LocalStorageService {
16238
16351
  return data;
16239
16352
  // For now, we are using base64 encoding to encrypt the data
16240
16353
  // Later we will use Jose encryption
16241
- const encryptedData = btoa(data);
16242
- return encryptedData;
16354
+ return btoa(data);
16243
16355
  }
16244
16356
  decryptData(data) {
16245
16357
  if (!LocalStorageService.encryptData)
16246
16358
  return data;
16247
16359
  // For now, we are using base64 encoding to encrypt
16248
16360
  // Later we will use Jose encryption
16249
- const decryptedData = atob(data);
16250
- return decryptedData;
16361
+ return atob(data);
16251
16362
  }
16252
16363
  }
16253
16364
  LocalStorageService.localStorageKey = 'lc_rmn';
@@ -18895,7 +19006,7 @@ class DataLayerMonitor {
18895
19006
  if (!eventName) {
18896
19007
  return null;
18897
19008
  }
18898
- const productIds = extractDeepIds(data.value);
19009
+ const productIds = extractDeepIds(data);
18899
19010
  return {
18900
19011
  event: eventName,
18901
19012
  productIds,
@@ -19560,7 +19671,7 @@ class LiquidCommerceRmnClient {
19560
19671
  }
19561
19672
  }
19562
19673
  useSpotSelectionExample(inject) {
19563
- const examples = RB_SPOTS_SELECTION_EXAMPLE;
19674
+ const examples = { ...RB_SPOTS_SELECTION_EXAMPLE, ...IAB_SPOTS_SELECTION_EXAMPLE };
19564
19675
  const data = {};
19565
19676
  inject.map((item) => {
19566
19677
  var _a, _b, _c;
package/dist/index.esm.js CHANGED
@@ -582,6 +582,69 @@ const RB_SPOTS_SELECTION_EXAMPLE = {
582
582
  },
583
583
  ],
584
584
  };
585
+ const IAB_SPOTS_SELECTION_EXAMPLE = {
586
+ banner: [],
587
+ billboard: [
588
+ {
589
+ id: 'kol567',
590
+ spot: RMN_SPOT_TYPE.BILLBOARD,
591
+ variant: `${RMN_SPOT_TYPE.BILLBOARD}V2`,
592
+ width: 1140,
593
+ height: 640,
594
+ header: 'Holiday Gift Guide',
595
+ description: 'Perfect spirits for every occasion',
596
+ ctaText: 'Shop Gifts',
597
+ textColor: '#ffffff',
598
+ ctaTextColor: '#ffffff',
599
+ primaryImage: 'https://placehold.co/1140x640/png?text=Gift+Guide',
600
+ mobilePrimaryImage: 'https://placehold.co/640x640/png?text=Mobile+Gifts',
601
+ events: SPOT_EVENTS_EXAMPLE,
602
+ productIds: [25, 26],
603
+ },
604
+ {
605
+ id: 'hpm390',
606
+ spot: RMN_SPOT_TYPE.BILLBOARD,
607
+ variant: `${RMN_SPOT_TYPE.BILLBOARD}V2`,
608
+ width: 1140,
609
+ height: 640,
610
+ header: 'Summer Wine Festival',
611
+ description: 'Refreshing wines for summer',
612
+ ctaText: 'Shop Festival',
613
+ textColor: '#ffffff',
614
+ ctaTextColor: '#ffffff',
615
+ primaryImage: 'https://placehold.co/1140x640/png?text=Wine+Festival',
616
+ mobilePrimaryImage: 'https://placehold.co/640x640/png?text=Mobile+Festival',
617
+ events: SPOT_EVENTS_EXAMPLE,
618
+ productIds: [27, 28],
619
+ },
620
+ ],
621
+ button2: [],
622
+ featurePhoneLargeBanner: [],
623
+ featurePhoneMediumBanner: [],
624
+ featurePhoneSmallBanner: [],
625
+ halfPage: [],
626
+ inText: [],
627
+ largeLeaderboard: [],
628
+ largeRectangle: [],
629
+ leaderboard: [],
630
+ mediumRectangle: [],
631
+ microBar: [],
632
+ mobilePhoneInterstitial1: [],
633
+ mobilePhoneInterstitial2: [],
634
+ mobilePhoneInterstitial3: [],
635
+ popUp: [],
636
+ portrait: [],
637
+ rbProductUpcs: [],
638
+ skyscraper: [],
639
+ smallRectangle: [],
640
+ smallSquare: [],
641
+ smartphoneBanner1: [],
642
+ smartphoneBanner2: [],
643
+ square: [],
644
+ verticalBanner: [],
645
+ verticalRectangle: [],
646
+ wideSkyscraper: [],
647
+ };
585
648
 
586
649
  const REQUEST_CLOUD_PARTNER_SITE = 'X-Liquid-Partner-Site';
587
650
  const REQUEST_CLOUD_PROTECTED_KEY = 'X-Liquid-Protected';
@@ -6801,40 +6864,60 @@ class ObjectHelper {
6801
6864
  /**
6802
6865
  * Recursively extracts ID values from a nested data structure.
6803
6866
  * Searches for specified property names and collects their primitive values (strings/numbers).
6867
+ * Captures properties ending with 'id' and any additional specified property names.
6804
6868
  *
6805
6869
  * @param data - The data structure to search through (can be nested objects/arrays)
6806
- * @param propertyNames - Array of property names to look for
6870
+ * @param propertyNames - Array of additional property names to look for (optional)
6807
6871
  * @returns Array of extracted ID values (strings/numbers only)
6808
6872
  *
6809
6873
  * @example
6810
6874
  * const data = {
6811
6875
  * id: [1, 2, 3],
6812
- * nested: { id: 'abc' },
6813
- * items: [{ id: 456 }]
6876
+ * nested: { id: 'abc', userId: 123 },
6877
+ * items: [{ id: 456, productId: '789', sku: 'ABC123' }]
6814
6878
  * };
6815
- * extractDeepIds(data); // Returns [1, 2, 3, 'abc', 456]
6879
+ * extractDeepIds(data); // Returns [1, 2, 3, 'abc', 123, 456, '789', 'ABC123']
6816
6880
  */
6817
6881
  function extractDeepIds(data, propertyNames) {
6818
6882
  const ids = [];
6819
- const defaulPropertyNames = [
6820
- 'id',
6821
- 'upc',
6822
- 'groupingId',
6823
- 'sku',
6824
- 'productId',
6825
- 'item_id',
6826
- 'isbn',
6827
- 'asin',
6828
- 'mpn',
6883
+ const defaultPropertyNames = [
6884
+ // Universal product identifiers
6885
+ 'gtin', // Global Trade Item Number
6886
+ 'gtin8', // 8-digit GTIN
6887
+ 'gtin12', // 12-digit GTIN (UPC)
6888
+ 'gtin13', // 13-digit GTIN (EAN)
6889
+ 'gtin14', // 14-digit GTIN
6890
+ 'mpn', // Manufacturer Part Number
6891
+ 'sku', // Stock Keeping Unit
6892
+ 'upc', // Universal Product Code
6893
+ 'ean', // European Article Number
6894
+ 'isbn', // International Standard Book Number
6895
+ 'isbn10', // 10-digit ISBN
6896
+ 'isbn13', // 13-digit ISBN
6897
+ 'asin', // Amazon Standard Identification Number
6898
+ // Product codes and references
6899
+ 'coupon',
6900
+ 'barcode',
6901
+ 'product_code',
6902
+ 'part_number',
6829
6903
  'model_number',
6830
- 'article_number',
6831
- 'variant_id',
6904
+ 'item_variant',
6832
6905
  'item_number',
6833
- 'catalog_id',
6834
- 'reference_id',
6906
+ 'article_number',
6907
+ 'reference',
6908
+ 'groupingId',
6835
6909
  ];
6836
- // Set for faster property name lookups
6837
- const propertySet = new Set(defaulPropertyNames);
6910
+ // Convert property names to lowercase for consistent comparison
6911
+ const additionalProperties = new Set((defaultPropertyNames).map((name) => name.toLowerCase()));
6912
+ /**
6913
+ * Checks if a property name is an ID field
6914
+ * @param key - The property name to check
6915
+ * @returns boolean indicating if the key is an ID field
6916
+ */
6917
+ const isIdField = (key) => {
6918
+ const lowercaseKey = key.toLowerCase();
6919
+ return lowercaseKey.endsWith('id') || additionalProperties.has(lowercaseKey);
6920
+ };
6838
6921
  /**
6839
6922
  * Processes a value and extracts IDs if it matches criteria
6840
6923
  * @param value - The value to process
@@ -6845,7 +6928,7 @@ function extractDeepIds(data, propertyNames) {
6845
6928
  if (value == null)
6846
6929
  return;
6847
6930
  // If current key matches our target properties
6848
- if (currentKey && propertySet.has(currentKey)) {
6931
+ if (currentKey && isIdField(currentKey)) {
6849
6932
  if (Array.isArray(value)) {
6850
6933
  // Filter and push valid array values in one pass
6851
6934
  ids.push(...value.filter((item) => typeof item === 'string' || typeof item === 'number'));
@@ -6867,7 +6950,7 @@ function extractDeepIds(data, propertyNames) {
6867
6950
  }
6868
6951
  };
6869
6952
  processValue(data);
6870
- return ids; // No need to filter nulls as we handle that during collection
6953
+ return ids;
6871
6954
  }
6872
6955
  // Fallback method using fetch if sendBeacon isn't available
6873
6956
  async function fallbackEventFire(url) {
@@ -16120,6 +16203,17 @@ var ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX;
16120
16203
  ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["PRODUCT_IDS"] = 4] = "PRODUCT_IDS";
16121
16204
  ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["CREATED_AT"] = 5] = "CREATED_AT";
16122
16205
  })(ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX || (ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX = {}));
16206
+ const LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX = {
16207
+ [RMN_SPOT_EVENT.IMPRESSION]: 0,
16208
+ [RMN_SPOT_EVENT.CLICK]: 1,
16209
+ [RMN_SPOT_EVENT.PURCHASE]: 2,
16210
+ [RMN_SPOT_EVENT.ADD_TO_CART]: 3,
16211
+ [RMN_SPOT_EVENT.REMOVE_FROM_CART]: 4,
16212
+ [RMN_SPOT_EVENT.ADD_TO_CART_FROM_DETAILS]: 5,
16213
+ [RMN_SPOT_EVENT.ADD_TO_WISHLIST]: 6,
16214
+ [RMN_SPOT_EVENT.EXPAND_PRODUCT]: 7,
16215
+ [RMN_SPOT_EVENT.BUY_NOW]: 8,
16216
+ };
16123
16217
  class LocalStorageService {
16124
16218
  constructor() {
16125
16219
  if (typeof window.localStorage === 'undefined') {
@@ -16147,7 +16241,7 @@ class LocalStorageService {
16147
16241
  if (parsedData && typeof parsedData === 'object') {
16148
16242
  const data = {};
16149
16243
  for (const [key, value] of Object.entries(parsedData)) {
16150
- data[key] = this.arrayToObject(value);
16244
+ data[key] = this.spotArrayToObject(value);
16151
16245
  }
16152
16246
  this.spots = this.objectToMap(data);
16153
16247
  }
@@ -16187,7 +16281,7 @@ class LocalStorageService {
16187
16281
  const data = this.mapToObject(this.spots);
16188
16282
  const dataArray = {};
16189
16283
  for (const [key, value] of Object.entries(data)) {
16190
- dataArray[key] = this.objectToArray(value);
16284
+ dataArray[key] = this.spotObjectToArray(value);
16191
16285
  }
16192
16286
  try {
16193
16287
  const encryptedData = this.encryptData(JSON.stringify(dataArray));
@@ -16218,15 +16312,34 @@ class LocalStorageService {
16218
16312
  objectToMap(obj) {
16219
16313
  return new Map(Object.entries(obj));
16220
16314
  }
16221
- objectToArray(obj) {
16222
- return [obj.placementId, obj.spotId, obj.spotType, obj.events, obj.productIds, obj.createdAt];
16315
+ spotEventObjectToArray(events) {
16316
+ return Object.keys(LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX).map((type) => {
16317
+ const result = events.find((item) => item.event === type);
16318
+ return result && result.event === type ? result.url : '';
16319
+ });
16320
+ }
16321
+ spotEventArrayToObject(arr) {
16322
+ return Object.keys(LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX).map((type) => ({
16323
+ event: type,
16324
+ url: arr[LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX[type]],
16325
+ }));
16223
16326
  }
16224
- arrayToObject(arr) {
16327
+ spotObjectToArray(obj) {
16328
+ return [
16329
+ obj.placementId,
16330
+ obj.spotId,
16331
+ obj.spotType,
16332
+ this.spotEventObjectToArray(obj.events),
16333
+ obj.productIds,
16334
+ obj.createdAt,
16335
+ ];
16336
+ }
16337
+ spotArrayToObject(arr) {
16225
16338
  return {
16226
16339
  placementId: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.PLACEMENT_ID],
16227
16340
  spotId: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_ID],
16228
16341
  spotType: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_TYPE],
16229
- events: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.EVENTS],
16342
+ events: this.spotEventArrayToObject(arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.EVENTS]),
16230
16343
  productIds: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.PRODUCT_IDS],
16231
16344
  createdAt: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.CREATED_AT],
16232
16345
  };
@@ -16236,16 +16349,14 @@ class LocalStorageService {
16236
16349
  return data;
16237
16350
  // For now, we are using base64 encoding to encrypt the data
16238
16351
  // Later we will use Jose encryption
16239
- const encryptedData = btoa(data);
16240
- return encryptedData;
16352
+ return btoa(data);
16241
16353
  }
16242
16354
  decryptData(data) {
16243
16355
  if (!LocalStorageService.encryptData)
16244
16356
  return data;
16245
16357
  // For now, we are using base64 encoding to encrypt
16246
16358
  // Later we will use Jose encryption
16247
- const decryptedData = atob(data);
16248
- return decryptedData;
16359
+ return atob(data);
16249
16360
  }
16250
16361
  }
16251
16362
  LocalStorageService.localStorageKey = 'lc_rmn';
@@ -18893,7 +19004,7 @@ class DataLayerMonitor {
18893
19004
  if (!eventName) {
18894
19005
  return null;
18895
19006
  }
18896
- const productIds = extractDeepIds(data.value);
19007
+ const productIds = extractDeepIds(data);
18897
19008
  return {
18898
19009
  event: eventName,
18899
19010
  productIds,
@@ -19558,7 +19669,7 @@ class LiquidCommerceRmnClient {
19558
19669
  }
19559
19670
  }
19560
19671
  useSpotSelectionExample(inject) {
19561
- const examples = RB_SPOTS_SELECTION_EXAMPLE;
19672
+ const examples = { ...RB_SPOTS_SELECTION_EXAMPLE, ...IAB_SPOTS_SELECTION_EXAMPLE };
19562
19673
  const data = {};
19563
19674
  inject.map((item) => {
19564
19675
  var _a, _b, _c;
@@ -2,18 +2,19 @@ import type { IFireEventParams } from 'modules/event';
2
2
  /**
3
3
  * Recursively extracts ID values from a nested data structure.
4
4
  * Searches for specified property names and collects their primitive values (strings/numbers).
5
+ * Captures properties ending with 'id' and any additional specified property names.
5
6
  *
6
7
  * @param data - The data structure to search through (can be nested objects/arrays)
7
- * @param propertyNames - Array of property names to look for
8
+ * @param propertyNames - Array of additional property names to look for (optional)
8
9
  * @returns Array of extracted ID values (strings/numbers only)
9
10
  *
10
11
  * @example
11
12
  * const data = {
12
13
  * id: [1, 2, 3],
13
- * nested: { id: 'abc' },
14
- * items: [{ id: 456 }]
14
+ * nested: { id: 'abc', userId: 123 },
15
+ * items: [{ id: 456, productId: '789', sku: 'ABC123' }]
15
16
  * };
16
- * extractDeepIds(data); // Returns [1, 2, 3, 'abc', 456]
17
+ * extractDeepIds(data); // Returns [1, 2, 3, 'abc', 123, 456, '789', 'ABC123']
17
18
  */
18
19
  export declare function extractDeepIds(data: any, propertyNames?: string[]): Array<string | number>;
19
20
  export declare function fallbackEventFire(url: string): Promise<boolean>;
@@ -16,7 +16,7 @@ export type LocalStorageSpotArray = [
16
16
  string,
17
17
  string,
18
18
  RMN_SPOT_TYPE,
19
- ISpotEvent[],
19
+ string[],
20
20
  Array<string | number>,
21
21
  // PRODUCT_IDS = 4
22
22
  number | undefined
@@ -29,6 +29,17 @@ export declare enum ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX {
29
29
  PRODUCT_IDS = 4,
30
30
  CREATED_AT = 5
31
31
  }
32
+ export declare const LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX: {
33
+ readonly IMPRESSION: 0;
34
+ readonly CLICK: 1;
35
+ readonly PURCHASE: 2;
36
+ readonly ADD_TO_CART: 3;
37
+ readonly REMOVE_FROM_CART: 4;
38
+ readonly ADD_TO_CART_FROM_DETAILS: 5;
39
+ readonly ADD_TO_WISHLIST: 6;
40
+ readonly EXPAND_PRODUCT: 7;
41
+ readonly BUY_NOW: 8;
42
+ };
32
43
  export type LocalStorageSpotsArrayType = Record<string, // spotId
33
44
  LocalStorageSpotArray>;
34
45
  export declare class LocalStorageService {
@@ -49,8 +60,10 @@ export declare class LocalStorageService {
49
60
  private removeExpiredSpots;
50
61
  private mapToObject;
51
62
  private objectToMap;
52
- private objectToArray;
53
- private arrayToObject;
63
+ private spotEventObjectToArray;
64
+ private spotEventArrayToObject;
65
+ private spotObjectToArray;
66
+ private spotArrayToObject;
54
67
  private encryptData;
55
68
  private decryptData;
56
69
  }
@@ -1,4 +1,8 @@
1
1
  import type { RMN_SPOT_EVENT } from 'enums';
2
+ export interface IDataLayerEvent {
3
+ event: string;
4
+ [key: string]: any;
5
+ }
2
6
  export interface INormalizedEventData {
3
7
  event: RMN_SPOT_EVENT;
4
8
  productIds: Array<string | number>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@liquidcommercedev/rmn-sdk",
3
3
  "description": "LiquidCommerce RMN SDK",
4
4
  "author": "LiquidCommerce Tech",
5
- "version": "1.5.0-beta.11",
5
+ "version": "1.5.0-beta.13",
6
6
  "homepage": "https://docs.liquidcommerce.co/rmn-sdk",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.esm.js",