@liquidcommercedev/rmn-sdk 1.5.0-beta.3 → 1.5.0-beta.31
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 +4068 -1297
- package/dist/index.esm.js +4069 -1298
- package/dist/types/common/helpers/event-type.helper.d.ts +8 -0
- package/dist/types/common/helpers/extract-deep.helper.d.ts +28 -0
- package/dist/types/common/helpers/index.d.ts +5 -0
- package/dist/types/common/helpers/utils.helper.d.ts +35 -0
- package/dist/types/common/http/api.constant.d.ts +1 -1
- package/dist/types/common/http/api.interface.d.ts +1 -1
- package/dist/types/common/http/base.api.d.ts +1 -1
- package/dist/types/constants/index.d.ts +2 -0
- package/dist/types/constants/special-char.constant.d.ts +1 -0
- package/dist/types/enums.d.ts +9 -1
- package/dist/types/modules/element/component/skeleton/index.d.ts +2 -0
- package/dist/types/modules/element/component/skeleton/skeleton.component.d.ts +3 -0
- package/dist/types/modules/element/component/skeleton/skeleton.interface.d.ts +14 -0
- package/dist/types/modules/element/component/skeleton/skeleton.template.d.ts +2 -0
- package/dist/types/modules/element/element.constant.d.ts +3 -0
- package/dist/types/modules/element/element.service.d.ts +11 -0
- package/dist/types/modules/element/template/helper.d.ts +2 -1
- package/dist/types/modules/element/template/reservebar/in-text.template.d.ts +3 -0
- package/dist/types/modules/element/template/reservebar/index.d.ts +2 -0
- package/dist/types/modules/element/template/reservebar/video-player.template.d.ts +3 -0
- package/dist/types/modules/event/event.interface.d.ts +11 -32
- package/dist/types/modules/event/event.service.d.ts +13 -27
- package/dist/types/modules/event/index.d.ts +0 -1
- package/dist/types/modules/{event/helpers → helper-service}/index.d.ts +1 -0
- package/dist/types/modules/{event/helpers → helper-service}/intersection.service.d.ts +1 -1
- package/dist/types/modules/helper-service/localstorage.service.d.ts +85 -0
- package/dist/types/modules/{event/pubsub.d.ts → helper-service/pubsub.service.d.ts} +8 -8
- package/dist/types/modules/{event/helpers → helper-service}/resize.service.d.ts +1 -1
- package/dist/types/modules/monitor/index.d.ts +2 -0
- package/dist/types/modules/monitor/monitor.enums.d.ts +5 -0
- package/dist/types/modules/monitor/monitor.interface.d.ts +26 -0
- package/dist/types/modules/monitor/monitor.service.d.ts +12 -0
- package/dist/types/modules/monitor/monitors/datalayer.monitor.d.ts +12 -0
- package/dist/types/modules/selection/selection.interface.d.ts +18 -2
- package/dist/types/modules/selection/selection.service.d.ts +1 -0
- package/dist/types/modules/selection/selection.type.d.ts +5 -9
- package/dist/types/rmn-client.d.ts +26 -25
- package/dist/types/rmn-client.helper.d.ts +36 -0
- package/dist/types/types.d.ts +7 -5
- package/package.json +30 -30
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
- package/dist/types/modules/element/component/utils.d.ts +0 -1
- package/dist/types/modules/event/helpers/localstorage.service.d.ts +0 -26
- /package/dist/types/{static.constant.d.ts → constants/example.constant.d.ts} +0 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
import { RMN_SPOT_EVENT } from 'enums';
|
2
|
+
/**
|
3
|
+
* Determines the event type from a raw event string by checking for keyword patterns.
|
4
|
+
*
|
5
|
+
* @param {string} [event] - The raw event string to evaluate
|
6
|
+
* @returns {RMN_SPOT_EVENT | null} - The corresponding RMN_SPOT_EVENT or null if no match
|
7
|
+
*/
|
8
|
+
export declare function getEventTypeFromRawEvent(event?: string): RMN_SPOT_EVENT | null;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
type ExtractorTarget = 'ids' | 'price' | 'quantity';
|
2
|
+
type ExtractedValue = string | number;
|
3
|
+
/**
|
4
|
+
* Extracts deep values from an object based on specified target type
|
5
|
+
* @param data - The source data object to extract values from
|
6
|
+
* @param target - The type of values to extract ('ids' or 'price')
|
7
|
+
* @param options - Optional configuration for the extraction process
|
8
|
+
* @returns Array of extracted values or a single value if onlyFirst is true
|
9
|
+
*/
|
10
|
+
export declare function extractDeepValues(data: unknown, target: ExtractorTarget, options?: {
|
11
|
+
onlyFirst?: boolean;
|
12
|
+
shouldIncludeZero?: boolean;
|
13
|
+
}): ExtractedValue[] | ExtractedValue | undefined;
|
14
|
+
/**
|
15
|
+
* Cleans and normalizes an array of product IDs by:
|
16
|
+
* 1. Converting all IDs to strings
|
17
|
+
* 2. Trimming whitespace
|
18
|
+
* 3. Removing leading zeros while preserving single "0"
|
19
|
+
* 4. Filtering out empty/invalid values
|
20
|
+
*
|
21
|
+
* @param ids - Array of product IDs that can be either strings or numbers
|
22
|
+
* @returns Array of cleaned string IDs
|
23
|
+
*
|
24
|
+
* @example
|
25
|
+
* cleanProductIds(["001", " 123 ", 456, "0"]) // ["1", "123", "456", "0"]
|
26
|
+
*/
|
27
|
+
export declare function cleanProductIds(ids: Array<string | number>): string[];
|
28
|
+
export {};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import type { IFireEventParams } from 'modules/event';
|
2
|
+
export declare function fallbackEventFire(url: string): Promise<boolean>;
|
3
|
+
/**
|
4
|
+
* Helper function to decode base64 string and parse JSON
|
5
|
+
*
|
6
|
+
* @param {string} base64String - The base64 encoded JSON string
|
7
|
+
* @returns {T | null} - Decoded and parsed object or null if invalid
|
8
|
+
*/
|
9
|
+
export declare function decodeBase64Json<T>(base64String: string): T | null;
|
10
|
+
/**
|
11
|
+
* Extracts and decodes a URL from a base64-encoded query parameter.
|
12
|
+
*
|
13
|
+
* @param {string} url - The URL containing the base64-encoded query parameter.
|
14
|
+
* @returns {string | null} - The decoded URL or null if not found or invalid.
|
15
|
+
* @throws {Error} - If URL is malformed or payload is invalid.
|
16
|
+
*/
|
17
|
+
export declare function getRedirectUrlFromPayload(url: string): string | null;
|
18
|
+
/**
|
19
|
+
* Fires an event using the navigator.sendBeacon method or a fallback method if sendBeacon is not available.
|
20
|
+
* If the event is a click event and a redirect URL is found, it redirects the user to that URL.
|
21
|
+
*
|
22
|
+
* @param {IFireEventParams} params - The parameters for firing the event.
|
23
|
+
* @param {RMN_SPOT_EVENT} params.event - The event type.
|
24
|
+
* @param {string} params.eventUrl - The URL to which the event is sent.
|
25
|
+
* @returns {Promise<void>} - A promise that resolves when the event is fired.
|
26
|
+
*/
|
27
|
+
export declare function fireEvent({ event, eventUrl }: IFireEventParams): Promise<void>;
|
28
|
+
export declare function calculateScaleFactor(elementScale: number): number;
|
29
|
+
/**
|
30
|
+
* Converts an object to a query string.
|
31
|
+
*
|
32
|
+
* @param {Record<string, string|number|undefined|null>} obj - The object to be converted to a query string.
|
33
|
+
* @returns {string} - The query string.
|
34
|
+
*/
|
35
|
+
export declare function objectToQueryParams(obj?: Record<string, string | number | undefined | null>): string;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { IAuthConfigs } from '
|
1
|
+
import type { IAuthConfigs } from 'modules/auth';
|
2
2
|
export declare const REQUEST_CLOUD_PARTNER_SITE = "X-Liquid-Partner-Site";
|
3
3
|
export declare const REQUEST_CLOUD_PROTECTED_KEY = "X-Liquid-Protected";
|
4
4
|
export declare const REQUEST_CLOUD_PROTECTED_TIMESTAMP = "X-Liquid-Timestamp";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { AxiosRequestConfig, AxiosResponse } from 'axios';
|
2
2
|
import type { JWTVerifyResult } from 'jose';
|
3
|
-
import type { IAuthCredentials } from '
|
3
|
+
import type { IAuthCredentials } from 'modules/auth';
|
4
4
|
import type { ApiError } from './error.api';
|
5
5
|
export type Result<T, E = Error> = {
|
6
6
|
isOk: true;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios';
|
2
|
-
import type { IAuthCredentials } from '
|
2
|
+
import type { IAuthCredentials } from 'modules/auth';
|
3
3
|
import type { Result } from './api.interface';
|
4
4
|
import { BaseApiAbstract } from './api.interface';
|
5
5
|
import { ApiError } from './error.api';
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const SPECIAL_CHARACTER_MAPPING: Record<string, string>;
|
package/dist/types/enums.d.ts
CHANGED
@@ -9,6 +9,8 @@ export declare enum RMN_SPOT_TYPE {
|
|
9
9
|
RB_COLLECTION_BANNER_WITHOUT_TEXT_BLOCK = "rbCollectionBannerWithoutTextBlock",
|
10
10
|
RB_PRODUCT_UPCS = "rbProductUpcs",
|
11
11
|
RB_NAVIGATION_BANNER = "rbNavigationBanner",
|
12
|
+
RB_VIDEO_PLAYER = "rbVideoPlayer",
|
13
|
+
RB_IN_TEXT = "rbInText",
|
12
14
|
BILLBOARD = "billboard",
|
13
15
|
LARGE_RECTANGLE = "largeRectangle",
|
14
16
|
VERTICAL_RECTANGLE = "verticalRectangle",
|
@@ -49,13 +51,19 @@ export declare enum RMN_FILTER_PROPERTIES {
|
|
49
51
|
PUBLISHERS = "publishers",
|
50
52
|
SECTION = "section"
|
51
53
|
}
|
52
|
-
export declare enum
|
54
|
+
export declare enum RMN_EVENT {
|
53
55
|
LIFECYCLE_STATE = "LIFECYCLE_STATE",
|
56
|
+
SPOT_EVENT = "SPOT_EVENT"
|
57
|
+
}
|
58
|
+
export declare enum RMN_SPOT_EVENT {
|
54
59
|
IMPRESSION = "IMPRESSION",
|
55
60
|
CLICK = "CLICK",
|
56
61
|
PURCHASE = "PURCHASE",
|
57
62
|
ADD_TO_CART = "ADD_TO_CART",
|
63
|
+
REMOVE_FROM_CART = "REMOVE_FROM_CART",
|
64
|
+
ADD_TO_CART_FROM_DETAILS = "ADD_TO_CART_FROM_DETAILS",
|
58
65
|
ADD_TO_WISHLIST = "ADD_TO_WISHLIST",
|
66
|
+
EXPAND_PRODUCT = "EXPAND_PRODUCT",
|
59
67
|
BUY_NOW = "BUY_NOW"
|
60
68
|
}
|
61
69
|
export declare enum RMN_ENV {
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { RMN_SPOT_TYPE } from 'enums';
|
2
|
+
export interface ICustomSkeletonElementData {
|
3
|
+
spotType: RMN_SPOT_TYPE;
|
4
|
+
fluid: boolean;
|
5
|
+
width: number;
|
6
|
+
height: number;
|
7
|
+
}
|
8
|
+
export interface ICustomSkeletonElement extends HTMLElement {
|
9
|
+
data: ICustomSkeletonElementData;
|
10
|
+
}
|
11
|
+
export interface ICreateSkeletonElementParams {
|
12
|
+
fluid?: boolean;
|
13
|
+
spotType: RMN_SPOT_TYPE;
|
14
|
+
}
|
@@ -1,5 +1,8 @@
|
|
1
|
+
import type { SpotDimensionsType } from 'modules/selection';
|
1
2
|
export declare const SPOT_ELEMENT_TAG = "spot-element";
|
2
3
|
export declare const CAROUSEL_ELEMENT_TAG = "spot-carousel-element";
|
4
|
+
export declare const SKELETON_ELEMENT_TAG = "spot-skeleton-element";
|
3
5
|
export declare const GFONT_PRECONNECT = "\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n";
|
4
6
|
export declare const GFONT_SOURCE_SANS_3 = "\n <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap\">\n";
|
5
7
|
export declare const GFONT_CORMORANT = "\n <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\">\n";
|
8
|
+
export declare const SPOT_DIMENSIONS: SpotDimensionsType;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { ISpot } from 'modules/selection';
|
2
2
|
import type { ICreateCarouselElementParams } from './component/carousel';
|
3
|
+
import type { ICreateSkeletonElementParams } from './component/skeleton';
|
3
4
|
import type { ICreateSpotElementParams } from './component/spot';
|
4
5
|
import type { IElementService, ISpotColors } from './element.interface';
|
5
6
|
export declare class ElementService implements IElementService {
|
@@ -24,6 +25,16 @@ export declare class ElementService implements IElementService {
|
|
24
25
|
* @return {HTMLElement | null} - The html element or null if the browser environment is not available.
|
25
26
|
*/
|
26
27
|
createCarouselElement({ slides, config, }: ICreateCarouselElementParams): HTMLElement | null;
|
28
|
+
/**
|
29
|
+
* Creates the skeleton html element based on the provided data using shadow dom.
|
30
|
+
*
|
31
|
+
* This method is only available in browser environments.
|
32
|
+
*
|
33
|
+
* @param {ICreateSkeletonElementParams} params - The parameters to create the final element.
|
34
|
+
*
|
35
|
+
* @return {HTMLElement | null} - The html element or null if the browser environment is not available.
|
36
|
+
*/
|
37
|
+
createSkeletonElement(params: ICreateSkeletonElementParams): HTMLElement | null;
|
27
38
|
/**
|
28
39
|
* Overrides the spot colors with the provided colors.
|
29
40
|
*
|
@@ -1,4 +1,5 @@
|
|
1
|
+
import type { RMN_SPOT_TYPE } from 'enums';
|
1
2
|
import type { ISpotOverlay } from '../element.interface';
|
2
3
|
export declare function convertHexToRgba(hex: string, opacity?: number): string;
|
3
4
|
export declare function generateGradientColor(overlay?: ISpotOverlay, fallback?: string): string;
|
4
|
-
export declare function spotHtmlStringToElement(htmlString: string): HTMLElement;
|
5
|
+
export declare function spotHtmlStringToElement(htmlString: string, spotType: RMN_SPOT_TYPE): HTMLElement;
|
@@ -2,7 +2,9 @@ export * from './collection-banner-without-text-block.template';
|
|
2
2
|
export * from './homepage-hero-full-image.template';
|
3
3
|
export * from './homepage-hero-three-tile.template';
|
4
4
|
export * from './homepage-hero-two-tile.template';
|
5
|
+
export * from './in-text.template';
|
5
6
|
export * from './large-category-image-tout.template';
|
6
7
|
export * from './navigation-banner.template';
|
7
8
|
export * from './small-category-image-tout.template';
|
8
9
|
export * from './small-discover-tout.template';
|
10
|
+
export * from './video-player.template';
|
@@ -1,5 +1,10 @@
|
|
1
|
-
import type { RMN_SPOT_EVENT } from 'enums';
|
1
|
+
import type { RMN_EVENT, RMN_SPOT_EVENT } from 'enums';
|
2
2
|
import type { ISpot } from '../selection';
|
3
|
+
export type ActiveSpotsType = Map<string, // spotId
|
4
|
+
{
|
5
|
+
placementId: string;
|
6
|
+
spotElement: HTMLElement;
|
7
|
+
}>;
|
3
8
|
export interface IFireEventParams {
|
4
9
|
event: RMN_SPOT_EVENT;
|
5
10
|
eventUrl: string;
|
@@ -30,40 +35,14 @@ export interface ILifecycleState {
|
|
30
35
|
state?: Partial<ILSState>;
|
31
36
|
displayConfig?: Partial<ILSDisplayConfig>;
|
32
37
|
}
|
33
|
-
export interface
|
34
|
-
|
35
|
-
spotId: string;
|
36
|
-
spotElement: HTMLElement;
|
37
|
-
}
|
38
|
-
export interface IImpressionEvent {
|
39
|
-
placementId: string;
|
40
|
-
spotId: string;
|
41
|
-
spotElement: HTMLElement;
|
42
|
-
}
|
43
|
-
export interface IAddToCartEvent {
|
44
|
-
placementId: string;
|
45
|
-
spotId: string;
|
46
|
-
}
|
47
|
-
export interface IAddToWishlistEvent {
|
48
|
-
placementId: string;
|
49
|
-
spotId: string;
|
50
|
-
}
|
51
|
-
export interface IPurchaseEvent {
|
52
|
-
placementId: string;
|
53
|
-
spotId: string;
|
54
|
-
}
|
55
|
-
export interface IBuyNowEvent {
|
38
|
+
export interface IRmnSpotEvent {
|
39
|
+
eventType: RMN_SPOT_EVENT;
|
56
40
|
placementId: string;
|
57
41
|
spotId: string;
|
58
42
|
}
|
59
|
-
export interface
|
60
|
-
[
|
61
|
-
[
|
62
|
-
[RMN_SPOT_EVENT.IMPRESSION]: IImpressionEvent;
|
63
|
-
[RMN_SPOT_EVENT.ADD_TO_CART]: IAddToCartEvent;
|
64
|
-
[RMN_SPOT_EVENT.ADD_TO_WISHLIST]: IAddToWishlistEvent;
|
65
|
-
[RMN_SPOT_EVENT.PURCHASE]: IPurchaseEvent;
|
66
|
-
[RMN_SPOT_EVENT.BUY_NOW]: IBuyNowEvent;
|
43
|
+
export interface IRmnEventMap {
|
44
|
+
[RMN_EVENT.LIFECYCLE_STATE]: ILifecycleState;
|
45
|
+
[RMN_EVENT.SPOT_EVENT]: IRmnSpotEvent;
|
67
46
|
}
|
68
47
|
export interface IRegisterSpotParams {
|
69
48
|
placementId: string;
|
@@ -1,16 +1,17 @@
|
|
1
|
-
import {
|
2
|
-
import type {
|
1
|
+
import { RMN_EVENT } from 'enums';
|
2
|
+
import type { ISpot } from 'modules/selection';
|
3
|
+
import type { ILifecycleState, IRegisterSpotParams, IRmnEventMap } from './event.interface';
|
3
4
|
export declare class EventService {
|
4
5
|
private static instance;
|
5
|
-
private
|
6
|
-
private
|
6
|
+
private pubSubService;
|
7
|
+
private localStorageService;
|
7
8
|
private intersectionObserver;
|
8
9
|
private spotStates;
|
9
|
-
private activeSpots;
|
10
|
+
private readonly activeSpots;
|
10
11
|
private constructor();
|
11
12
|
static getInstance(): EventService;
|
12
|
-
subscribe(eventType:
|
13
|
-
publish(eventType:
|
13
|
+
subscribe(eventType: RMN_EVENT, callback: (data: IRmnEventMap[RMN_EVENT]) => void): () => void;
|
14
|
+
publish(eventType: RMN_EVENT, data: IRmnEventMap[RMN_EVENT]): void;
|
14
15
|
registerSpot(params: IRegisterSpotParams): void;
|
15
16
|
unregisterSpot(placementId: string): void;
|
16
17
|
/**
|
@@ -23,25 +24,10 @@ export declare class EventService {
|
|
23
24
|
* @returns {void}
|
24
25
|
*/
|
25
26
|
handleSpotState(placementId: string, updates: Partial<ILifecycleState>, publish?: boolean): void;
|
26
|
-
|
27
|
+
saveSpotDataToLocalStorage(placementId: string, spot: ISpot): void;
|
28
|
+
private handleClickEvent;
|
29
|
+
private handleImpressionEvent;
|
30
|
+
private getSpotIdByPlacementId;
|
31
|
+
private deepMerge;
|
27
32
|
private handleIntersectionObserver;
|
28
|
-
private fireImpressionEvent;
|
29
|
-
/**
|
30
|
-
* Fires an event using the navigator.sendBeacon method or a fallback method if sendBeacon is not available.
|
31
|
-
* If the event is a click event and a redirect URL is found, it redirects the user to that URL.
|
32
|
-
*
|
33
|
-
* @param {IFireEventParams} params - The parameters for firing the event.
|
34
|
-
* @param {RMN_SPOT_EVENT} params.event - The event type.
|
35
|
-
* @param {string} params.eventUrl - The URL to which the event is sent.
|
36
|
-
* @returns {Promise<void>} - A promise that resolves when the event is fired.
|
37
|
-
*/
|
38
|
-
private fireEvent;
|
39
|
-
private fallbackEventFire;
|
40
|
-
/**
|
41
|
-
* Extracts and decodes a URL from a base64-encoded query parameter.
|
42
|
-
*
|
43
|
-
* @param {string} url - The URL containing the base64-encoded query parameter.
|
44
|
-
* @returns {string | null} - The decoded URL or null if not found or invalid.
|
45
|
-
*/
|
46
|
-
private getRedirectUrlFromPayload;
|
47
33
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
export declare class IntersectionObserverService {
|
2
2
|
private observers;
|
3
|
-
private defaultOptions;
|
3
|
+
private readonly defaultOptions;
|
4
4
|
constructor(defaultOptions?: IntersectionObserverInit);
|
5
5
|
observe(element: HTMLElement, callback: (entry: IntersectionObserverEntry) => void, options?: IntersectionObserverInit): void;
|
6
6
|
unobserve(element: HTMLElement): void;
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import type { RMN_SPOT_TYPE } from 'enums';
|
2
|
+
import { RMN_SPOT_EVENT } from 'enums';
|
3
|
+
import type { ISpotEvent } from 'modules/selection';
|
4
|
+
export interface IFiredSpotEvent {
|
5
|
+
productId: string;
|
6
|
+
event: RMN_SPOT_EVENT;
|
7
|
+
}
|
8
|
+
export interface ILocalStorageSpot {
|
9
|
+
placementId: string;
|
10
|
+
spotId: string;
|
11
|
+
spotType: RMN_SPOT_TYPE;
|
12
|
+
events: ISpotEvent[];
|
13
|
+
firedEvents?: IFiredSpotEvent[];
|
14
|
+
productIds: Array<string | number>;
|
15
|
+
createdAt?: number;
|
16
|
+
}
|
17
|
+
export type LocalStorageSpots = Record<string, // spotId
|
18
|
+
ILocalStorageSpot>;
|
19
|
+
export declare class LocalStorageService {
|
20
|
+
private spots?;
|
21
|
+
private static instance;
|
22
|
+
private static readonly localStorageKeyPrefix;
|
23
|
+
private static localStorageKey;
|
24
|
+
private static readonly spotExpirationTime;
|
25
|
+
private static readonly encryptData;
|
26
|
+
private constructor();
|
27
|
+
static getInstance(): LocalStorageService;
|
28
|
+
setSpot(spotId: string, data: ILocalStorageSpot): void;
|
29
|
+
removeSpot(spotId: string): void;
|
30
|
+
getSpot(spotId: string): ILocalStorageSpot | undefined;
|
31
|
+
getSpots(): LocalStorageSpots | undefined;
|
32
|
+
/**
|
33
|
+
* Retrieves the user ID from the local storage key.
|
34
|
+
* If the key is not found, a new user ID is generated and set.
|
35
|
+
*
|
36
|
+
* @return the user ID extracted from the local storage key
|
37
|
+
*/
|
38
|
+
getUserId(): string;
|
39
|
+
/**
|
40
|
+
* Sets the user ID in local storage with a unique key if not already present.
|
41
|
+
* If there are existing keys, it ensures only one valid key remains,
|
42
|
+
* removing all other keys.
|
43
|
+
*
|
44
|
+
* @return {void} This method does not return a value.
|
45
|
+
*/
|
46
|
+
setUserId(): void;
|
47
|
+
private syncLocalStorage;
|
48
|
+
private updateLocalStorage;
|
49
|
+
private clearLocalStorage;
|
50
|
+
private removeExpiredSpots;
|
51
|
+
private mapToObject;
|
52
|
+
private objectToMap;
|
53
|
+
private spotEventObjectToArray;
|
54
|
+
private spotEventArrayToObject;
|
55
|
+
/**
|
56
|
+
* Converts a spot object to an array.
|
57
|
+
*
|
58
|
+
* @param {ILocalStorageSpot} obj - The spot object to convert.
|
59
|
+
* @return {SpotArrayType} An array representation of the spot object.
|
60
|
+
*/
|
61
|
+
private spotObjectToArray;
|
62
|
+
/**
|
63
|
+
* Converts an array representation of spot data into an object representation.
|
64
|
+
*
|
65
|
+
* @param {SpotArrayType} arr - The array containing spot data.
|
66
|
+
* @return {ILocalStorageSpot} An object representation of the spot data.
|
67
|
+
*/
|
68
|
+
private spotArrayToObject;
|
69
|
+
/**
|
70
|
+
* Encodes a given string into a Unicode-encoded base64 format.
|
71
|
+
*
|
72
|
+
* @param {string} str - The string to be encoded.
|
73
|
+
* @return {string} The Unicode-encoded base64 representation of the input string.
|
74
|
+
*/
|
75
|
+
private unicodeEncode;
|
76
|
+
/**
|
77
|
+
* Decodes a Base64 encoded Unicode string.
|
78
|
+
*
|
79
|
+
* @param {string} str - The Base64 encoded string to decode.
|
80
|
+
* @return {string} The decoded Unicode string.
|
81
|
+
*/
|
82
|
+
private unicodeDecode;
|
83
|
+
private encryptData;
|
84
|
+
private decryptData;
|
85
|
+
}
|
@@ -8,13 +8,13 @@ export type PubSubCallback<T> = (data: T) => void;
|
|
8
8
|
*/
|
9
9
|
export type PubSubUnsubscribe = () => void;
|
10
10
|
/**
|
11
|
-
*
|
11
|
+
* PubsubService class
|
12
12
|
* Manages event subscriptions and publications
|
13
|
-
* @template
|
13
|
+
* @template IRmnEventMap A record type defining the structure of events and their data
|
14
14
|
*/
|
15
|
-
export declare class
|
15
|
+
export declare class PubsubService<IRmnEventMap> {
|
16
16
|
private static instance;
|
17
|
-
static getInstance<
|
17
|
+
static getInstance<IRmnEventMap>(): PubsubService<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
|
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
|
42
|
+
publish<K extends keyof IRmnEventMap>(eventType: K, data: IRmnEventMap[K]): void;
|
43
43
|
}
|
44
44
|
/**
|
45
45
|
* Usage Example:
|
46
46
|
*
|
47
|
-
* interface
|
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
|
52
|
+
* const pubSub = new PubsubService<IRmnEventMap>();
|
53
53
|
*
|
54
54
|
* // Subscribe to events
|
55
55
|
* const unsubscribeLogin = pubSub.subscribe('userLogin', (data) => {
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import type { RMN_SPOT_EVENT } from 'enums';
|
2
|
+
export interface IDataLayerEvent {
|
3
|
+
event: RMN_SPOT_EVENT;
|
4
|
+
products: IProductData[];
|
5
|
+
}
|
6
|
+
export interface INormalizedEventData {
|
7
|
+
event: RMN_SPOT_EVENT;
|
8
|
+
productIds: Array<string | number>;
|
9
|
+
productPrice?: number;
|
10
|
+
productQuantity?: number;
|
11
|
+
}
|
12
|
+
export interface IFireAndPublishSpotEventParams {
|
13
|
+
spotEvent: RMN_SPOT_EVENT;
|
14
|
+
eventUrl: string;
|
15
|
+
placementId: string;
|
16
|
+
spotId: string;
|
17
|
+
}
|
18
|
+
export interface IProductData {
|
19
|
+
id: string | number;
|
20
|
+
name: string;
|
21
|
+
brand: string;
|
22
|
+
variant: string;
|
23
|
+
price: number;
|
24
|
+
quantity: number;
|
25
|
+
discount?: number;
|
26
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export declare class MonitorService {
|
2
|
+
private static instance;
|
3
|
+
private readonly implementedMonitor?;
|
4
|
+
private readonly pubSubService?;
|
5
|
+
private readonly localStorageService?;
|
6
|
+
private constructor();
|
7
|
+
static getInstance(): MonitorService;
|
8
|
+
start(): void;
|
9
|
+
private matchAndFireEvent;
|
10
|
+
private fireAndPublishSpotEvent;
|
11
|
+
private detectAnalyticsTool;
|
12
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { IDataLayerEvent } from '../monitor.interface';
|
2
|
+
export declare class DataLayerMonitor {
|
3
|
+
private static instance;
|
4
|
+
private readonly originalPush;
|
5
|
+
private listener?;
|
6
|
+
private constructor();
|
7
|
+
static getInstance(): DataLayerMonitor;
|
8
|
+
setListener(listener: (data: IDataLayerEvent) => void): void;
|
9
|
+
start(): void;
|
10
|
+
private extractProductData;
|
11
|
+
stop(): void;
|
12
|
+
}
|
@@ -2,14 +2,20 @@ import type { RMN_SPOT_EVENT, RMN_SPOT_TYPE } from 'enums';
|
|
2
2
|
import type { PlacementIdType, SpotVariantType } from 'modules/selection';
|
3
3
|
import type { RmnFilterType, RmnSpotType } from 'types';
|
4
4
|
export interface ISpotSelectionParams {
|
5
|
-
url?: string;
|
6
5
|
spots: RmnSpotType[];
|
7
6
|
filter?: Partial<RmnFilterType>;
|
7
|
+
userId?: string;
|
8
|
+
url?: string;
|
8
9
|
}
|
9
10
|
export interface ISpotEvent {
|
10
11
|
event: RMN_SPOT_EVENT;
|
11
12
|
url: string;
|
12
13
|
}
|
14
|
+
export interface ISpotEventPayload {
|
15
|
+
e: number;
|
16
|
+
u: string;
|
17
|
+
ss: string;
|
18
|
+
}
|
13
19
|
export interface ISpot {
|
14
20
|
id: string;
|
15
21
|
events: ISpotEvent[];
|
@@ -30,7 +36,17 @@ export interface ISpot {
|
|
30
36
|
mobilePrimaryImage?: string;
|
31
37
|
mobileSecondaryImage?: string;
|
32
38
|
productIds?: Array<string | number>;
|
33
|
-
|
39
|
+
videoUrl?: string;
|
40
|
+
videoOverlayImage?: string;
|
41
|
+
videoOverlayHeader?: string;
|
42
|
+
videoOverlayDescription?: string;
|
43
|
+
videoControls?: boolean;
|
44
|
+
videoAutoPlay?: boolean;
|
45
|
+
videoMute?: boolean;
|
46
|
+
videoLoop?: boolean;
|
47
|
+
rbProductUpcs?: Array<string | number>;
|
48
|
+
rbProductSalsifyGroupings?: Array<string | number>;
|
49
|
+
rbProductSalsifyPids?: Array<string | number>;
|
34
50
|
}
|
35
51
|
export type ISpots = Record<PlacementIdType, ISpot[]>;
|
36
52
|
export interface ISelectionService {
|