@liquidcommercedev/rmn-sdk 1.5.0-beta.4 → 1.5.0-beta.6

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -60,6 +60,7 @@ var RMN_SPOT_EVENT;
60
60
  RMN_SPOT_EVENT["CLICK"] = "CLICK";
61
61
  RMN_SPOT_EVENT["PURCHASE"] = "PURCHASE";
62
62
  RMN_SPOT_EVENT["ADD_TO_CART"] = "ADD_TO_CART";
63
+ RMN_SPOT_EVENT["REMOVE_FROM_CART"] = "REMOVE_FROM_CART";
63
64
  RMN_SPOT_EVENT["ADD_TO_WISHLIST"] = "ADD_TO_WISHLIST";
64
65
  RMN_SPOT_EVENT["BUY_NOW"] = "BUY_NOW";
65
66
  })(RMN_SPOT_EVENT || (RMN_SPOT_EVENT = {}));
@@ -15164,6 +15165,132 @@ const GFONT_CORMORANT = `
15164
15165
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Cormorant:ital,wght@0,300..700;1,300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap">
15165
15166
  `;
15166
15167
 
15168
+ function getEventTypeFromRawEvent(event) {
15169
+ if (!event) {
15170
+ return null;
15171
+ }
15172
+ if (event.includes('cart')) {
15173
+ if (event.includes('add')) {
15174
+ return RMN_SPOT_EVENT.ADD_TO_CART;
15175
+ }
15176
+ if (event.includes('remove')) {
15177
+ return RMN_SPOT_EVENT.REMOVE_FROM_CART;
15178
+ }
15179
+ }
15180
+ if (event.includes('purchase')) {
15181
+ return RMN_SPOT_EVENT.PURCHASE;
15182
+ }
15183
+ // if(event.includes('refund')) {
15184
+ // return RMN_SPOT_EVENT.REFUND;
15185
+ // }
15186
+ if (event.includes('wishlist') && event.includes('add')) {
15187
+ return RMN_SPOT_EVENT.ADD_TO_WISHLIST;
15188
+ }
15189
+ return null;
15190
+ }
15191
+ /**
15192
+ * Recursively extracts ID values from a nested data structure.
15193
+ * Searches for specified property names and collects their primitive values (strings/numbers).
15194
+ *
15195
+ * @param data - The data structure to search through (can be nested objects/arrays)
15196
+ * @param propertyNames - Array of property names to look for (defaults to ['id', 'upc', 'groupingId', 'sku', 'productId'])
15197
+ * @returns Array of extracted ID values (strings/numbers only)
15198
+ *
15199
+ * @example
15200
+ * const data = {
15201
+ * id: [1, 2, 3],
15202
+ * nested: { id: 'abc' },
15203
+ * items: [{ id: 456 }]
15204
+ * };
15205
+ * extractDeepIds(data); // Returns [1, 2, 3, 'abc', 456]
15206
+ */
15207
+ function extractDeepIds(data, propertyNames = ['id', 'upc', 'groupingId', 'sku', 'productId']) {
15208
+ const ids = [];
15209
+ // Set for faster property name lookups
15210
+ const propertySet = new Set(propertyNames);
15211
+ /**
15212
+ * Processes a value and extracts IDs if it matches criteria
15213
+ * @param value - The value to process
15214
+ * @param currentKey - The property name of the current value
15215
+ */
15216
+ const processValue = (value, currentKey) => {
15217
+ // Early exit for null/undefined values
15218
+ if (value == null)
15219
+ return;
15220
+ // If current key matches our target properties
15221
+ if (currentKey && propertySet.has(currentKey)) {
15222
+ if (Array.isArray(value)) {
15223
+ // Filter and push valid array values in one pass
15224
+ ids.push(...value.filter((item) => typeof item === 'string' || typeof item === 'number'));
15225
+ }
15226
+ else if (typeof value === 'string' || typeof value === 'number') {
15227
+ ids.push(value);
15228
+ }
15229
+ return; // Stop processing this branch after handling the ID
15230
+ }
15231
+ // Recursively process nested structures
15232
+ if (Array.isArray(value)) {
15233
+ value.forEach((item) => processValue(item));
15234
+ }
15235
+ else if (typeof value === 'object') {
15236
+ // Process all enumerable properties
15237
+ for (const [key, val] of Object.entries(value)) {
15238
+ processValue(val, key);
15239
+ }
15240
+ }
15241
+ };
15242
+ processValue(data);
15243
+ return ids; // No need to filter nulls as we handle that during collection
15244
+ }
15245
+
15246
+ class DataLayerMonitor {
15247
+ constructor() {
15248
+ if (!window.dataLayer) {
15249
+ return;
15250
+ }
15251
+ this.originalPush = window.dataLayer.push;
15252
+ }
15253
+ static getInstance() {
15254
+ if (!DataLayerMonitor.instance) {
15255
+ DataLayerMonitor.instance = new DataLayerMonitor();
15256
+ }
15257
+ return DataLayerMonitor.instance;
15258
+ }
15259
+ setListener(listener) {
15260
+ this.listener = listener;
15261
+ }
15262
+ start() {
15263
+ window.dataLayer.push = (...args) => {
15264
+ const result = this.originalPush.apply(window.dataLayer, args);
15265
+ const pushedEvent = args[0];
15266
+ if (this.listener) {
15267
+ const normalizedData = this.cleanEventData(pushedEvent);
15268
+ if (normalizedData) {
15269
+ this.listener(normalizedData);
15270
+ }
15271
+ }
15272
+ return result;
15273
+ };
15274
+ }
15275
+ cleanEventData(data) {
15276
+ const eventName = getEventTypeFromRawEvent(data.event);
15277
+ if (!eventName) {
15278
+ return null;
15279
+ }
15280
+ const productIds = extractDeepIds(data.value);
15281
+ return {
15282
+ event: eventName,
15283
+ productIds,
15284
+ };
15285
+ }
15286
+ stop() {
15287
+ if (this.originalPush) {
15288
+ window.dataLayer.push = this.originalPush;
15289
+ }
15290
+ this.listener = undefined;
15291
+ }
15292
+ }
15293
+
15167
15294
  class IntersectionObserverService {
15168
15295
  constructor(defaultOptions = {}) {
15169
15296
  this.observers = new Map();
@@ -15204,6 +15331,14 @@ class IntersectionObserverService {
15204
15331
  }
15205
15332
  }
15206
15333
 
15334
+ var ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX;
15335
+ (function (ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX) {
15336
+ ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["SPOT_ID"] = 0] = "SPOT_ID";
15337
+ ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["SPOT_TYPE"] = 1] = "SPOT_TYPE";
15338
+ ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["EVENTS"] = 2] = "EVENTS";
15339
+ ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["PRODUCT_IDS"] = 3] = "PRODUCT_IDS";
15340
+ ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["CREATED_AT"] = 4] = "CREATED_AT";
15341
+ })(ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX || (ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX = {}));
15207
15342
  class LocalStorage {
15208
15343
  constructor() {
15209
15344
  if (typeof window.localStorage === 'undefined') {
@@ -15229,7 +15364,11 @@ class LocalStorage {
15229
15364
  try {
15230
15365
  const parsedData = JSON.parse(localStorageData);
15231
15366
  if (parsedData && typeof parsedData === 'object') {
15232
- this.spots = this.objToMap(parsedData);
15367
+ const data = {};
15368
+ for (const [key, value] of Object.entries(parsedData)) {
15369
+ data[key] = this.arrayToObject(value);
15370
+ }
15371
+ this.spots = this.objectToMap(data);
15233
15372
  }
15234
15373
  else {
15235
15374
  this.clearLocalStorage();
@@ -15242,26 +15381,34 @@ class LocalStorage {
15242
15381
  }
15243
15382
  }
15244
15383
  setSpot(spotId, data) {
15245
- if (!this.spots)
15246
- return;
15384
+ var _a;
15247
15385
  data.createdAt = Date.now();
15248
- this.spots.set(spotId, data);
15386
+ (_a = this.spots) === null || _a === void 0 ? void 0 : _a.set(spotId, data);
15249
15387
  this.updateLocalStorage();
15250
15388
  }
15251
- getSpot(spotId) {
15252
- var _a;
15253
- return (_a = this.spots) === null || _a === void 0 ? void 0 : _a.get(spotId);
15254
- }
15255
15389
  removeSpot(spotId) {
15256
15390
  var _a;
15257
15391
  (_a = this.spots) === null || _a === void 0 ? void 0 : _a.delete(spotId);
15258
15392
  this.updateLocalStorage();
15259
15393
  }
15394
+ getSpot(spotId) {
15395
+ var _a;
15396
+ return (_a = this.spots) === null || _a === void 0 ? void 0 : _a.get(spotId);
15397
+ }
15398
+ getSpots() {
15399
+ if (!this.spots)
15400
+ return undefined;
15401
+ return this.mapToObject(this.spots);
15402
+ }
15260
15403
  updateLocalStorage() {
15261
15404
  if (!this.spots)
15262
- return;
15263
- const data = this.mapToObj(this.spots);
15264
- localStorage.setItem(LocalStorage.localStorageKey, JSON.stringify(data));
15405
+ return undefined;
15406
+ const data = this.mapToObject(this.spots);
15407
+ const dataArray = {};
15408
+ for (const [key, value] of Object.entries(data)) {
15409
+ dataArray[key] = this.objectToArray(value);
15410
+ }
15411
+ window.localStorage.setItem(LocalStorage.localStorageKey, JSON.stringify(dataArray));
15265
15412
  }
15266
15413
  clearLocalStorage() {
15267
15414
  window.localStorage.removeItem(LocalStorage.localStorageKey);
@@ -15277,12 +15424,24 @@ class LocalStorage {
15277
15424
  });
15278
15425
  this.updateLocalStorage();
15279
15426
  }
15280
- mapToObj(map) {
15427
+ mapToObject(map) {
15281
15428
  return Object.fromEntries(map);
15282
15429
  }
15283
- objToMap(obj) {
15430
+ objectToMap(obj) {
15284
15431
  return new Map(Object.entries(obj));
15285
15432
  }
15433
+ objectToArray(obj) {
15434
+ return [obj.spotId, obj.spotType, obj.events, obj.productIds, obj.createdAt];
15435
+ }
15436
+ arrayToObject(arr) {
15437
+ return {
15438
+ spotId: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_ID],
15439
+ spotType: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_TYPE],
15440
+ events: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.EVENTS],
15441
+ productIds: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.PRODUCT_IDS],
15442
+ createdAt: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.CREATED_AT],
15443
+ };
15444
+ }
15286
15445
  }
15287
15446
  LocalStorage.localStorageKey = 'lc_rmn';
15288
15447
  LocalStorage.spotExpirationTime = 1000 * 60 * 60 * 24 * 7; // 7 days
@@ -17976,7 +18135,7 @@ const SPOT_TEMPLATE_HTML_ELEMENT = (spot, config) => {
17976
18135
  /**
17977
18136
  * PubSub class
17978
18137
  * Manages event subscriptions and publications
17979
- * @template IEventMap A record type defining the structure of events and their data
18138
+ * @template IRmnEventMap A record type defining the structure of events and their data
17980
18139
  */
17981
18140
  class PubSub {
17982
18141
  constructor() {
@@ -18030,12 +18189,12 @@ class PubSub {
18030
18189
  /**
18031
18190
  * Usage Example:
18032
18191
  *
18033
- * interface IEventMap {
18192
+ * interface IRmnEventMap {
18034
18193
  * userLogin: { username: string; timestamp: number };
18035
18194
  * pageView: { url: string; timestamp: number };
18036
18195
  * }
18037
18196
  *
18038
- * const pubSub = new PubSub<IEventMap>();
18197
+ * const pubSub = new PubSub<IRmnEventMap>();
18039
18198
  *
18040
18199
  * // Subscribe to events
18041
18200
  * const unsubscribeLogin = pubSub.subscribe('userLogin', (data) => {
@@ -18054,6 +18213,78 @@ class PubSub {
18054
18213
  * unsubscribeLogin();
18055
18214
  */
18056
18215
 
18216
+ // @TODO: Add support for user to push events to our own data layer, if they don't use any analytics tool.
18217
+ // window.rmnDataLayer = window.rmnDataLayer || [];
18218
+ // For the moment, we will only focus on sites that use Google Analytics,
18219
+ // but we will add support for other analytics tools in the future.
18220
+ var AnalyticsTool;
18221
+ (function (AnalyticsTool) {
18222
+ AnalyticsTool["GoogleAnalytics"] = "google-analytics";
18223
+ AnalyticsTool["Other"] = "Other";
18224
+ })(AnalyticsTool || (AnalyticsTool = {}));
18225
+ class UserMonitor {
18226
+ constructor() {
18227
+ const analyticsTool = this.detectAnalyticsTool();
18228
+ switch (analyticsTool) {
18229
+ case AnalyticsTool.GoogleAnalytics:
18230
+ this.implementedMonitor = DataLayerMonitor.getInstance();
18231
+ break;
18232
+ case AnalyticsTool.Other:
18233
+ default:
18234
+ console.warn('This site uses an unsupported analytics tool.');
18235
+ break;
18236
+ }
18237
+ if (analyticsTool === AnalyticsTool.Other) {
18238
+ return;
18239
+ }
18240
+ this.localStorage = LocalStorage.getInstance();
18241
+ }
18242
+ static getInstance() {
18243
+ if (!UserMonitor.instance) {
18244
+ UserMonitor.instance = new UserMonitor();
18245
+ }
18246
+ return UserMonitor.instance;
18247
+ }
18248
+ start() {
18249
+ if (!this.implementedMonitor)
18250
+ return;
18251
+ this.implementedMonitor.setListener((eventData) => {
18252
+ var _a;
18253
+ this.matchAndFireEvent(eventData, (_a = this.localStorage) === null || _a === void 0 ? void 0 : _a.getSpots());
18254
+ });
18255
+ this.implementedMonitor.start();
18256
+ }
18257
+ matchAndFireEvent(
18258
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
18259
+ _eventData,
18260
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
18261
+ _spots) {
18262
+ // console.info({ eventData, spots });
18263
+ }
18264
+ detectAnalyticsTool() {
18265
+ let analyticsTool = AnalyticsTool.Other;
18266
+ // Check for Google Analytics
18267
+ if (typeof window.ga !== 'undefined') {
18268
+ analyticsTool = AnalyticsTool.GoogleAnalytics;
18269
+ }
18270
+ // Check for Google Analytics 4
18271
+ if (typeof window.gtag !== 'undefined') {
18272
+ analyticsTool = AnalyticsTool.GoogleAnalytics;
18273
+ }
18274
+ // Check for Google Tag Manager
18275
+ if (typeof window.google_tag_manager !== 'undefined') {
18276
+ analyticsTool = AnalyticsTool.GoogleAnalytics;
18277
+ }
18278
+ // @TODO: Add support for other analytics tools
18279
+ // Check for Heap Analytics
18280
+ // Check for Mixpanel
18281
+ // Check for Woopra
18282
+ // Check for Segment
18283
+ // Check for Amplitude
18284
+ return analyticsTool;
18285
+ }
18286
+ }
18287
+
18057
18288
  class EventService {
18058
18289
  constructor() {
18059
18290
  this.pubSub = PubSub.getInstance();
@@ -18061,6 +18292,8 @@ class EventService {
18061
18292
  this.activeSpots = new Map();
18062
18293
  this.spotStates = new Map();
18063
18294
  this.intersectionObserver = new IntersectionObserverService();
18295
+ // Start the user monitor, which will track and check user interactions
18296
+ UserMonitor.getInstance().start();
18064
18297
  }
18065
18298
  static getInstance() {
18066
18299
  if (!EventService.instance) {
@@ -18505,6 +18738,10 @@ class LiquidCommerceRmnClient {
18505
18738
  */
18506
18739
  async injectSpotElement(params) {
18507
18740
  var _a;
18741
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
18742
+ console.warn('LiquidCommerce Rmn Sdk: Methods which create elements are only available in browser environments.');
18743
+ return;
18744
+ }
18508
18745
  const config = params.config;
18509
18746
  let inject = params.inject;
18510
18747
  if (!inject.length) {
@@ -55,6 +55,7 @@ export declare enum RMN_SPOT_EVENT {
55
55
  CLICK = "CLICK",
56
56
  PURCHASE = "PURCHASE",
57
57
  ADD_TO_CART = "ADD_TO_CART",
58
+ REMOVE_FROM_CART = "REMOVE_FROM_CART",
58
59
  ADD_TO_WISHLIST = "ADD_TO_WISHLIST",
59
60
  BUY_NOW = "BUY_NOW"
60
61
  }
@@ -44,6 +44,10 @@ export interface IAddToCartEvent {
44
44
  placementId: string;
45
45
  spotId: string;
46
46
  }
47
+ export interface IRemoveFromCartEvent {
48
+ placementId: string;
49
+ spotId: string;
50
+ }
47
51
  export interface IAddToWishlistEvent {
48
52
  placementId: string;
49
53
  spotId: string;
@@ -61,6 +65,7 @@ export interface IRmnEventMap {
61
65
  [RMN_SPOT_EVENT.CLICK]: IClickEvent;
62
66
  [RMN_SPOT_EVENT.IMPRESSION]: IImpressionEvent;
63
67
  [RMN_SPOT_EVENT.ADD_TO_CART]: IAddToCartEvent;
68
+ [RMN_SPOT_EVENT.REMOVE_FROM_CART]: IRemoveFromCartEvent;
64
69
  [RMN_SPOT_EVENT.ADD_TO_WISHLIST]: IAddToWishlistEvent;
65
70
  [RMN_SPOT_EVENT.PURCHASE]: IPurchaseEvent;
66
71
  [RMN_SPOT_EVENT.BUY_NOW]: IBuyNowEvent;
@@ -0,0 +1,21 @@
1
+ import type { RMN_SPOT_EVENT } from 'enums';
2
+ export interface IDataLayerEvent {
3
+ event?: string;
4
+ value?: any[];
5
+ [key: string]: any;
6
+ }
7
+ export interface INormalizedEventData {
8
+ event: RMN_SPOT_EVENT;
9
+ productIds: Array<string | number>;
10
+ }
11
+ export declare class DataLayerMonitor {
12
+ private static instance;
13
+ private readonly originalPush;
14
+ private listener?;
15
+ private constructor();
16
+ static getInstance(): DataLayerMonitor;
17
+ setListener(listener: (data: INormalizedEventData) => void): void;
18
+ start(): void;
19
+ private cleanEventData;
20
+ stop(): void;
21
+ }
@@ -1,3 +1,4 @@
1
+ export * from './datalayer.monitor';
1
2
  export * from './intersection.service';
2
3
  export * from './localstorage.service';
3
4
  export * from './resize.service';
@@ -7,6 +7,27 @@ export interface ILocalStorageSpot {
7
7
  productIds: Array<string | number>;
8
8
  createdAt?: number;
9
9
  }
10
+ export type LocalStorageSpotsMapType = Map<string, // spotId
11
+ ILocalStorageSpot>;
12
+ export type LocalStorageSpotsObjectType = Record<string, // spotId
13
+ ILocalStorageSpot>;
14
+ export type LocalStorageSpotArray = [
15
+ string,
16
+ RMN_SPOT_TYPE,
17
+ ISpotEvent[],
18
+ Array<string | number>,
19
+ // PRODUCT_IDS = 3
20
+ number | undefined
21
+ ];
22
+ export declare enum ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX {
23
+ SPOT_ID = 0,
24
+ SPOT_TYPE = 1,
25
+ EVENTS = 2,
26
+ PRODUCT_IDS = 3,
27
+ CREATED_AT = 4
28
+ }
29
+ export type LocalStorageSpotsArrayType = Record<string, // spotId
30
+ LocalStorageSpotArray>;
10
31
  export declare class LocalStorage {
11
32
  private spots?;
12
33
  private static instance;
@@ -16,11 +37,14 @@ export declare class LocalStorage {
16
37
  static getInstance(): LocalStorage;
17
38
  private syncLocalStorage;
18
39
  setSpot(spotId: string, data: ILocalStorageSpot): void;
19
- getSpot(spotId: string): ILocalStorageSpot | undefined;
20
40
  removeSpot(spotId: string): void;
41
+ getSpot(spotId: string): ILocalStorageSpot | undefined;
42
+ getSpots(): LocalStorageSpotsObjectType | undefined;
21
43
  private updateLocalStorage;
22
- clearLocalStorage(): void;
44
+ private clearLocalStorage;
23
45
  private removeExpiredSpots;
24
- private mapToObj;
25
- private objToMap;
46
+ private mapToObject;
47
+ private objectToMap;
48
+ private objectToArray;
49
+ private arrayToObject;
26
50
  }
@@ -0,0 +1,24 @@
1
+ import { RMN_SPOT_EVENT } from 'enums';
2
+ export interface IExtractIdsProps {
3
+ id?: string | number;
4
+ upc?: string | number;
5
+ [key: string]: string | number | undefined;
6
+ }
7
+ export declare function getEventTypeFromRawEvent(event?: string): RMN_SPOT_EVENT | null;
8
+ /**
9
+ * Recursively extracts ID values from a nested data structure.
10
+ * Searches for specified property names and collects their primitive values (strings/numbers).
11
+ *
12
+ * @param data - The data structure to search through (can be nested objects/arrays)
13
+ * @param propertyNames - Array of property names to look for (defaults to ['id', 'upc', 'groupingId', 'sku', 'productId'])
14
+ * @returns Array of extracted ID values (strings/numbers only)
15
+ *
16
+ * @example
17
+ * const data = {
18
+ * id: [1, 2, 3],
19
+ * nested: { id: 'abc' },
20
+ * items: [{ id: 456 }]
21
+ * };
22
+ * extractDeepIds(data); // Returns [1, 2, 3, 'abc', 456]
23
+ */
24
+ export declare function extractDeepIds(data: any, propertyNames?: readonly string[]): Array<string | number>;
@@ -2,3 +2,4 @@ export * from './event.constant';
2
2
  export * from './event.interface';
3
3
  export * from './event.service';
4
4
  export * from './helpers';
5
+ export * from './user.monitor';
@@ -10,11 +10,11 @@ export type PubSubUnsubscribe = () => void;
10
10
  /**
11
11
  * PubSub class
12
12
  * Manages event subscriptions and publications
13
- * @template IEventMap A record type defining the structure of events and their data
13
+ * @template IRmnEventMap A record type defining the structure of events and their data
14
14
  */
15
- export declare class PubSub<IEventMap> {
15
+ export declare class PubSub<IRmnEventMap> {
16
16
  private static instance;
17
- static getInstance<IEventMap>(): PubSub<IEventMap>;
17
+ static getInstance<IRmnEventMap>(): PubSub<IRmnEventMap>;
18
18
  /**
19
19
  * Object to store subscribers for each event type
20
20
  */
@@ -30,7 +30,7 @@ export declare class PubSub<IEventMap> {
30
30
  * console.log(`User ${data.username} logged in`);
31
31
  * });
32
32
  */
33
- subscribe<K extends keyof IEventMap>(eventType: K, callback: PubSubCallback<IEventMap[K]>): PubSubUnsubscribe;
33
+ subscribe<K extends keyof IRmnEventMap>(eventType: K, callback: PubSubCallback<IRmnEventMap[K]>): PubSubUnsubscribe;
34
34
  /**
35
35
  * Publish an event
36
36
  * @param eventType - The type of event to publish
@@ -39,17 +39,17 @@ export declare class PubSub<IEventMap> {
39
39
  * @Example:
40
40
  * pubSub.publish('userLogin', { username: 'john_doe', timestamp: Date.now() });
41
41
  */
42
- publish<K extends keyof IEventMap>(eventType: K, data: IEventMap[K]): void;
42
+ publish<K extends keyof IRmnEventMap>(eventType: K, data: IRmnEventMap[K]): void;
43
43
  }
44
44
  /**
45
45
  * Usage Example:
46
46
  *
47
- * interface IEventMap {
47
+ * interface IRmnEventMap {
48
48
  * userLogin: { username: string; timestamp: number };
49
49
  * pageView: { url: string; timestamp: number };
50
50
  * }
51
51
  *
52
- * const pubSub = new PubSub<IEventMap>();
52
+ * const pubSub = new PubSub<IRmnEventMap>();
53
53
  *
54
54
  * // Subscribe to events
55
55
  * const unsubscribeLogin = pubSub.subscribe('userLogin', (data) => {
@@ -0,0 +1,14 @@
1
+ export declare enum AnalyticsTool {
2
+ GoogleAnalytics = "google-analytics",
3
+ Other = "Other"
4
+ }
5
+ export declare class UserMonitor {
6
+ private static instance;
7
+ private readonly implementedMonitor?;
8
+ private readonly localStorage?;
9
+ private constructor();
10
+ static getInstance(): UserMonitor;
11
+ start(): void;
12
+ private matchAndFireEvent;
13
+ private detectAnalyticsTool;
14
+ }
@@ -1,6 +1,6 @@
1
1
  export type { IInjectSpotElement, IInjectSpotElementConfig, IInjectSpotElementParams, IRmnCreateSpotElementConfig, ISpotColors, ISpotOverlay, } from 'modules/element';
2
2
  export type { CarouselNavPositionType, ICarouselButtonOptions, ICarouselDotOptions, ICarouselOptions, } from 'modules/element/component/carousel';
3
- export type { IAddToCartEvent, IAddToWishlistEvent, IBuyNowEvent, IClickEvent, IImpressionEvent, ILifecycleState, ILSDisplayConfig, ILSDom, ILSIdentifier, ILSState, IPurchaseEvent, IRmnEventMap, } from 'modules/event';
3
+ export type { IAddToCartEvent, IAddToWishlistEvent, IBuyNowEvent, IClickEvent, IImpressionEvent, ILifecycleState, ILSDisplayConfig, ILSDom, ILSIdentifier, ILSState, IPurchaseEvent, IRemoveFromCartEvent, IRmnEventMap, } from 'modules/event';
4
4
  export type { ISpots, RmnFilterType, RmnSpotType } from 'modules/selection';
5
5
  export { ISpot, ISpotEvent, ISpotSelectionParams } from 'modules/selection';
6
6
  import type { RMN_ENV, RMN_SPOT_EVENT } from 'enums';
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.4",
5
+ "version": "1.5.0-beta.6",
6
6
  "homepage": "https://docs.liquidcommerce.co/rmn-sdk",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.esm.js",