@liquidcommercedev/rmn-sdk 1.5.0-beta.3 → 1.5.0-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +133 -11
- package/dist/index.esm.js +133 -11
- package/dist/types/modules/event/event.interface.d.ts +1 -1
- package/dist/types/modules/event/event.service.d.ts +3 -3
- package/dist/types/modules/event/helpers/datalayer.monitor.d.ts +10 -0
- package/dist/types/modules/event/helpers/index.d.ts +1 -0
- package/dist/types/modules/event/helpers/intersection.service.d.ts +1 -1
- package/dist/types/modules/event/helpers/localstorage.service.d.ts +8 -3
- package/dist/types/modules/event/helpers/resize.service.d.ts +1 -1
- package/dist/types/modules/event/index.d.ts +1 -0
- package/dist/types/modules/event/user.monitor.d.ts +13 -0
- package/dist/types/types.d.ts +4 -3
- package/package.json +1 -1
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
package/dist/index.cjs
CHANGED
@@ -15166,6 +15166,40 @@ const GFONT_CORMORANT = `
|
|
15166
15166
|
<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">
|
15167
15167
|
`;
|
15168
15168
|
|
15169
|
+
class DataLayerMonitor {
|
15170
|
+
constructor() {
|
15171
|
+
if (!window.dataLayer) {
|
15172
|
+
return;
|
15173
|
+
}
|
15174
|
+
this.originalPush = window.dataLayer.push;
|
15175
|
+
}
|
15176
|
+
static getInstance() {
|
15177
|
+
if (!DataLayerMonitor.instance) {
|
15178
|
+
DataLayerMonitor.instance = new DataLayerMonitor();
|
15179
|
+
}
|
15180
|
+
return DataLayerMonitor.instance;
|
15181
|
+
}
|
15182
|
+
setListener(listener) {
|
15183
|
+
this.listener = listener;
|
15184
|
+
}
|
15185
|
+
start() {
|
15186
|
+
window.dataLayer.push = (...args) => {
|
15187
|
+
const result = this.originalPush.apply(window.dataLayer, args);
|
15188
|
+
const pushedEvent = args[0];
|
15189
|
+
if (this.listener) {
|
15190
|
+
this.listener(pushedEvent);
|
15191
|
+
}
|
15192
|
+
return result;
|
15193
|
+
};
|
15194
|
+
}
|
15195
|
+
stop() {
|
15196
|
+
if (this.originalPush) {
|
15197
|
+
window.dataLayer.push = this.originalPush;
|
15198
|
+
}
|
15199
|
+
this.listener = undefined;
|
15200
|
+
}
|
15201
|
+
}
|
15202
|
+
|
15169
15203
|
class IntersectionObserverService {
|
15170
15204
|
constructor(defaultOptions = {}) {
|
15171
15205
|
this.observers = new Map();
|
@@ -15208,6 +15242,10 @@ class IntersectionObserverService {
|
|
15208
15242
|
|
15209
15243
|
class LocalStorage {
|
15210
15244
|
constructor() {
|
15245
|
+
if (typeof window.localStorage === 'undefined') {
|
15246
|
+
console.warn('Local storage is not supported in this environment');
|
15247
|
+
return;
|
15248
|
+
}
|
15211
15249
|
this.spots = new Map();
|
15212
15250
|
// Sync local storage with the current state
|
15213
15251
|
this.syncLocalStorage();
|
@@ -15221,7 +15259,7 @@ class LocalStorage {
|
|
15221
15259
|
return LocalStorage.instance;
|
15222
15260
|
}
|
15223
15261
|
syncLocalStorage() {
|
15224
|
-
const localStorageData = localStorage.getItem(LocalStorage.localStorageKey);
|
15262
|
+
const localStorageData = window.localStorage.getItem(LocalStorage.localStorageKey);
|
15225
15263
|
// TODO: Encrypt the data before storing it in the local storage
|
15226
15264
|
if (localStorageData) {
|
15227
15265
|
try {
|
@@ -15240,30 +15278,41 @@ class LocalStorage {
|
|
15240
15278
|
}
|
15241
15279
|
}
|
15242
15280
|
setSpot(spotId, data) {
|
15281
|
+
var _a;
|
15243
15282
|
data.createdAt = Date.now();
|
15244
|
-
this.spots.set(spotId, data);
|
15283
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.set(spotId, data);
|
15245
15284
|
this.updateLocalStorage();
|
15246
15285
|
}
|
15247
|
-
getSpot(spotId) {
|
15248
|
-
return this.spots.get(spotId);
|
15249
|
-
}
|
15250
15286
|
removeSpot(spotId) {
|
15251
|
-
|
15287
|
+
var _a;
|
15288
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.delete(spotId);
|
15252
15289
|
this.updateLocalStorage();
|
15253
15290
|
}
|
15291
|
+
getSpot(spotId) {
|
15292
|
+
var _a;
|
15293
|
+
return (_a = this.spots) === null || _a === void 0 ? void 0 : _a.get(spotId);
|
15294
|
+
}
|
15295
|
+
getSpots() {
|
15296
|
+
if (!this.spots)
|
15297
|
+
return undefined;
|
15298
|
+
return this.mapToObj(this.spots);
|
15299
|
+
}
|
15254
15300
|
updateLocalStorage() {
|
15301
|
+
if (!this.spots)
|
15302
|
+
return undefined;
|
15255
15303
|
const data = this.mapToObj(this.spots);
|
15256
15304
|
localStorage.setItem(LocalStorage.localStorageKey, JSON.stringify(data));
|
15257
15305
|
}
|
15258
15306
|
clearLocalStorage() {
|
15259
|
-
localStorage.removeItem(LocalStorage.localStorageKey);
|
15307
|
+
window.localStorage.removeItem(LocalStorage.localStorageKey);
|
15260
15308
|
}
|
15261
15309
|
removeExpiredSpots() {
|
15310
|
+
var _a;
|
15262
15311
|
const currentTime = Date.now();
|
15263
|
-
this.spots.forEach((spot, spotId) => {
|
15264
|
-
var _a;
|
15312
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.forEach((spot, spotId) => {
|
15313
|
+
var _a, _b;
|
15265
15314
|
if (currentTime - ((_a = spot.createdAt) !== null && _a !== void 0 ? _a : 0) > LocalStorage.spotExpirationTime) {
|
15266
|
-
this.spots.delete(spotId);
|
15315
|
+
(_b = this.spots) === null || _b === void 0 ? void 0 : _b.delete(spotId);
|
15267
15316
|
}
|
15268
15317
|
});
|
15269
15318
|
this.updateLocalStorage();
|
@@ -18045,6 +18094,73 @@ class PubSub {
|
|
18045
18094
|
* unsubscribeLogin();
|
18046
18095
|
*/
|
18047
18096
|
|
18097
|
+
// @TODO: Add support for user to push events to our own data layer, if they don't use any analytics tool.
|
18098
|
+
// window.rmnDataLayer = window.rmnDataLayer || [];
|
18099
|
+
// For the moment, we will only focus on sites that use Google Analytics,
|
18100
|
+
// but we will add support for other analytics tools in the future.
|
18101
|
+
var AnalyticsTool;
|
18102
|
+
(function (AnalyticsTool) {
|
18103
|
+
AnalyticsTool["GoogleAnalytics"] = "google-analytics";
|
18104
|
+
AnalyticsTool["Other"] = "Other";
|
18105
|
+
})(AnalyticsTool || (AnalyticsTool = {}));
|
18106
|
+
class UserMonitor {
|
18107
|
+
constructor() {
|
18108
|
+
const analyticsTool = this.detectAnalyticsTool();
|
18109
|
+
console.info({ analyticsTool });
|
18110
|
+
switch (analyticsTool) {
|
18111
|
+
case AnalyticsTool.GoogleAnalytics:
|
18112
|
+
this.implementedMonitor = DataLayerMonitor.getInstance();
|
18113
|
+
break;
|
18114
|
+
case AnalyticsTool.Other:
|
18115
|
+
default:
|
18116
|
+
console.warn('This site uses an unsupported analytics tool.');
|
18117
|
+
break;
|
18118
|
+
}
|
18119
|
+
if (analyticsTool === AnalyticsTool.Other) {
|
18120
|
+
return;
|
18121
|
+
}
|
18122
|
+
this.localStorage = LocalStorage.getInstance();
|
18123
|
+
}
|
18124
|
+
static getInstance() {
|
18125
|
+
if (!UserMonitor.instance) {
|
18126
|
+
UserMonitor.instance = new UserMonitor();
|
18127
|
+
}
|
18128
|
+
return UserMonitor.instance;
|
18129
|
+
}
|
18130
|
+
start() {
|
18131
|
+
if (!this.implementedMonitor)
|
18132
|
+
return;
|
18133
|
+
this.implementedMonitor.setListener((pushedEvent) => {
|
18134
|
+
var _a;
|
18135
|
+
console.info({ pushedEvent });
|
18136
|
+
console.info({ spots: (_a = this.localStorage) === null || _a === void 0 ? void 0 : _a.getSpots() });
|
18137
|
+
});
|
18138
|
+
this.implementedMonitor.start();
|
18139
|
+
}
|
18140
|
+
detectAnalyticsTool() {
|
18141
|
+
let analyticsTool = AnalyticsTool.Other;
|
18142
|
+
// Check for Google Analytics
|
18143
|
+
if (typeof window.ga !== 'undefined') {
|
18144
|
+
analyticsTool = AnalyticsTool.GoogleAnalytics;
|
18145
|
+
}
|
18146
|
+
// Check for Google Analytics 4
|
18147
|
+
if (typeof window.gtag !== 'undefined') {
|
18148
|
+
analyticsTool = AnalyticsTool.GoogleAnalytics;
|
18149
|
+
}
|
18150
|
+
// Check for Google Tag Manager
|
18151
|
+
if (typeof window.google_tag_manager !== 'undefined') {
|
18152
|
+
analyticsTool = AnalyticsTool.GoogleAnalytics;
|
18153
|
+
}
|
18154
|
+
// @TODO: Add support for other analytics tools
|
18155
|
+
// Check for Heap Analytics
|
18156
|
+
// Check for Mixpanel
|
18157
|
+
// Check for Woopra
|
18158
|
+
// Check for Segment
|
18159
|
+
// Check for Amplitude
|
18160
|
+
return analyticsTool;
|
18161
|
+
}
|
18162
|
+
}
|
18163
|
+
|
18048
18164
|
class EventService {
|
18049
18165
|
constructor() {
|
18050
18166
|
this.pubSub = PubSub.getInstance();
|
@@ -18052,6 +18168,8 @@ class EventService {
|
|
18052
18168
|
this.activeSpots = new Map();
|
18053
18169
|
this.spotStates = new Map();
|
18054
18170
|
this.intersectionObserver = new IntersectionObserverService();
|
18171
|
+
// Start the user monitor, which will track and check user interactions
|
18172
|
+
UserMonitor.getInstance().start();
|
18055
18173
|
}
|
18056
18174
|
static getInstance() {
|
18057
18175
|
if (!EventService.instance) {
|
@@ -18496,6 +18614,10 @@ class LiquidCommerceRmnClient {
|
|
18496
18614
|
*/
|
18497
18615
|
async injectSpotElement(params) {
|
18498
18616
|
var _a;
|
18617
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
18618
|
+
console.warn('LiquidCommerce Rmn Sdk: Methods which create elements are only available in browser environments.');
|
18619
|
+
return;
|
18620
|
+
}
|
18499
18621
|
const config = params.config;
|
18500
18622
|
let inject = params.inject;
|
18501
18623
|
if (!inject.length) {
|
@@ -18556,7 +18678,7 @@ class LiquidCommerceRmnClient {
|
|
18556
18678
|
placement.removeAttribute('class');
|
18557
18679
|
Object.assign(placement.style, {
|
18558
18680
|
width: '100%',
|
18559
|
-
height: '
|
18681
|
+
height: '100%',
|
18560
18682
|
display: 'flex',
|
18561
18683
|
justifyContent: 'center',
|
18562
18684
|
});
|
package/dist/index.esm.js
CHANGED
@@ -15164,6 +15164,40 @@ const GFONT_CORMORANT = `
|
|
15164
15164
|
<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
15165
|
`;
|
15166
15166
|
|
15167
|
+
class DataLayerMonitor {
|
15168
|
+
constructor() {
|
15169
|
+
if (!window.dataLayer) {
|
15170
|
+
return;
|
15171
|
+
}
|
15172
|
+
this.originalPush = window.dataLayer.push;
|
15173
|
+
}
|
15174
|
+
static getInstance() {
|
15175
|
+
if (!DataLayerMonitor.instance) {
|
15176
|
+
DataLayerMonitor.instance = new DataLayerMonitor();
|
15177
|
+
}
|
15178
|
+
return DataLayerMonitor.instance;
|
15179
|
+
}
|
15180
|
+
setListener(listener) {
|
15181
|
+
this.listener = listener;
|
15182
|
+
}
|
15183
|
+
start() {
|
15184
|
+
window.dataLayer.push = (...args) => {
|
15185
|
+
const result = this.originalPush.apply(window.dataLayer, args);
|
15186
|
+
const pushedEvent = args[0];
|
15187
|
+
if (this.listener) {
|
15188
|
+
this.listener(pushedEvent);
|
15189
|
+
}
|
15190
|
+
return result;
|
15191
|
+
};
|
15192
|
+
}
|
15193
|
+
stop() {
|
15194
|
+
if (this.originalPush) {
|
15195
|
+
window.dataLayer.push = this.originalPush;
|
15196
|
+
}
|
15197
|
+
this.listener = undefined;
|
15198
|
+
}
|
15199
|
+
}
|
15200
|
+
|
15167
15201
|
class IntersectionObserverService {
|
15168
15202
|
constructor(defaultOptions = {}) {
|
15169
15203
|
this.observers = new Map();
|
@@ -15206,6 +15240,10 @@ class IntersectionObserverService {
|
|
15206
15240
|
|
15207
15241
|
class LocalStorage {
|
15208
15242
|
constructor() {
|
15243
|
+
if (typeof window.localStorage === 'undefined') {
|
15244
|
+
console.warn('Local storage is not supported in this environment');
|
15245
|
+
return;
|
15246
|
+
}
|
15209
15247
|
this.spots = new Map();
|
15210
15248
|
// Sync local storage with the current state
|
15211
15249
|
this.syncLocalStorage();
|
@@ -15219,7 +15257,7 @@ class LocalStorage {
|
|
15219
15257
|
return LocalStorage.instance;
|
15220
15258
|
}
|
15221
15259
|
syncLocalStorage() {
|
15222
|
-
const localStorageData = localStorage.getItem(LocalStorage.localStorageKey);
|
15260
|
+
const localStorageData = window.localStorage.getItem(LocalStorage.localStorageKey);
|
15223
15261
|
// TODO: Encrypt the data before storing it in the local storage
|
15224
15262
|
if (localStorageData) {
|
15225
15263
|
try {
|
@@ -15238,30 +15276,41 @@ class LocalStorage {
|
|
15238
15276
|
}
|
15239
15277
|
}
|
15240
15278
|
setSpot(spotId, data) {
|
15279
|
+
var _a;
|
15241
15280
|
data.createdAt = Date.now();
|
15242
|
-
this.spots.set(spotId, data);
|
15281
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.set(spotId, data);
|
15243
15282
|
this.updateLocalStorage();
|
15244
15283
|
}
|
15245
|
-
getSpot(spotId) {
|
15246
|
-
return this.spots.get(spotId);
|
15247
|
-
}
|
15248
15284
|
removeSpot(spotId) {
|
15249
|
-
|
15285
|
+
var _a;
|
15286
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.delete(spotId);
|
15250
15287
|
this.updateLocalStorage();
|
15251
15288
|
}
|
15289
|
+
getSpot(spotId) {
|
15290
|
+
var _a;
|
15291
|
+
return (_a = this.spots) === null || _a === void 0 ? void 0 : _a.get(spotId);
|
15292
|
+
}
|
15293
|
+
getSpots() {
|
15294
|
+
if (!this.spots)
|
15295
|
+
return undefined;
|
15296
|
+
return this.mapToObj(this.spots);
|
15297
|
+
}
|
15252
15298
|
updateLocalStorage() {
|
15299
|
+
if (!this.spots)
|
15300
|
+
return undefined;
|
15253
15301
|
const data = this.mapToObj(this.spots);
|
15254
15302
|
localStorage.setItem(LocalStorage.localStorageKey, JSON.stringify(data));
|
15255
15303
|
}
|
15256
15304
|
clearLocalStorage() {
|
15257
|
-
localStorage.removeItem(LocalStorage.localStorageKey);
|
15305
|
+
window.localStorage.removeItem(LocalStorage.localStorageKey);
|
15258
15306
|
}
|
15259
15307
|
removeExpiredSpots() {
|
15308
|
+
var _a;
|
15260
15309
|
const currentTime = Date.now();
|
15261
|
-
this.spots.forEach((spot, spotId) => {
|
15262
|
-
var _a;
|
15310
|
+
(_a = this.spots) === null || _a === void 0 ? void 0 : _a.forEach((spot, spotId) => {
|
15311
|
+
var _a, _b;
|
15263
15312
|
if (currentTime - ((_a = spot.createdAt) !== null && _a !== void 0 ? _a : 0) > LocalStorage.spotExpirationTime) {
|
15264
|
-
this.spots.delete(spotId);
|
15313
|
+
(_b = this.spots) === null || _b === void 0 ? void 0 : _b.delete(spotId);
|
15265
15314
|
}
|
15266
15315
|
});
|
15267
15316
|
this.updateLocalStorage();
|
@@ -18043,6 +18092,73 @@ class PubSub {
|
|
18043
18092
|
* unsubscribeLogin();
|
18044
18093
|
*/
|
18045
18094
|
|
18095
|
+
// @TODO: Add support for user to push events to our own data layer, if they don't use any analytics tool.
|
18096
|
+
// window.rmnDataLayer = window.rmnDataLayer || [];
|
18097
|
+
// For the moment, we will only focus on sites that use Google Analytics,
|
18098
|
+
// but we will add support for other analytics tools in the future.
|
18099
|
+
var AnalyticsTool;
|
18100
|
+
(function (AnalyticsTool) {
|
18101
|
+
AnalyticsTool["GoogleAnalytics"] = "google-analytics";
|
18102
|
+
AnalyticsTool["Other"] = "Other";
|
18103
|
+
})(AnalyticsTool || (AnalyticsTool = {}));
|
18104
|
+
class UserMonitor {
|
18105
|
+
constructor() {
|
18106
|
+
const analyticsTool = this.detectAnalyticsTool();
|
18107
|
+
console.info({ analyticsTool });
|
18108
|
+
switch (analyticsTool) {
|
18109
|
+
case AnalyticsTool.GoogleAnalytics:
|
18110
|
+
this.implementedMonitor = DataLayerMonitor.getInstance();
|
18111
|
+
break;
|
18112
|
+
case AnalyticsTool.Other:
|
18113
|
+
default:
|
18114
|
+
console.warn('This site uses an unsupported analytics tool.');
|
18115
|
+
break;
|
18116
|
+
}
|
18117
|
+
if (analyticsTool === AnalyticsTool.Other) {
|
18118
|
+
return;
|
18119
|
+
}
|
18120
|
+
this.localStorage = LocalStorage.getInstance();
|
18121
|
+
}
|
18122
|
+
static getInstance() {
|
18123
|
+
if (!UserMonitor.instance) {
|
18124
|
+
UserMonitor.instance = new UserMonitor();
|
18125
|
+
}
|
18126
|
+
return UserMonitor.instance;
|
18127
|
+
}
|
18128
|
+
start() {
|
18129
|
+
if (!this.implementedMonitor)
|
18130
|
+
return;
|
18131
|
+
this.implementedMonitor.setListener((pushedEvent) => {
|
18132
|
+
var _a;
|
18133
|
+
console.info({ pushedEvent });
|
18134
|
+
console.info({ spots: (_a = this.localStorage) === null || _a === void 0 ? void 0 : _a.getSpots() });
|
18135
|
+
});
|
18136
|
+
this.implementedMonitor.start();
|
18137
|
+
}
|
18138
|
+
detectAnalyticsTool() {
|
18139
|
+
let analyticsTool = AnalyticsTool.Other;
|
18140
|
+
// Check for Google Analytics
|
18141
|
+
if (typeof window.ga !== 'undefined') {
|
18142
|
+
analyticsTool = AnalyticsTool.GoogleAnalytics;
|
18143
|
+
}
|
18144
|
+
// Check for Google Analytics 4
|
18145
|
+
if (typeof window.gtag !== 'undefined') {
|
18146
|
+
analyticsTool = AnalyticsTool.GoogleAnalytics;
|
18147
|
+
}
|
18148
|
+
// Check for Google Tag Manager
|
18149
|
+
if (typeof window.google_tag_manager !== 'undefined') {
|
18150
|
+
analyticsTool = AnalyticsTool.GoogleAnalytics;
|
18151
|
+
}
|
18152
|
+
// @TODO: Add support for other analytics tools
|
18153
|
+
// Check for Heap Analytics
|
18154
|
+
// Check for Mixpanel
|
18155
|
+
// Check for Woopra
|
18156
|
+
// Check for Segment
|
18157
|
+
// Check for Amplitude
|
18158
|
+
return analyticsTool;
|
18159
|
+
}
|
18160
|
+
}
|
18161
|
+
|
18046
18162
|
class EventService {
|
18047
18163
|
constructor() {
|
18048
18164
|
this.pubSub = PubSub.getInstance();
|
@@ -18050,6 +18166,8 @@ class EventService {
|
|
18050
18166
|
this.activeSpots = new Map();
|
18051
18167
|
this.spotStates = new Map();
|
18052
18168
|
this.intersectionObserver = new IntersectionObserverService();
|
18169
|
+
// Start the user monitor, which will track and check user interactions
|
18170
|
+
UserMonitor.getInstance().start();
|
18053
18171
|
}
|
18054
18172
|
static getInstance() {
|
18055
18173
|
if (!EventService.instance) {
|
@@ -18494,6 +18612,10 @@ class LiquidCommerceRmnClient {
|
|
18494
18612
|
*/
|
18495
18613
|
async injectSpotElement(params) {
|
18496
18614
|
var _a;
|
18615
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
18616
|
+
console.warn('LiquidCommerce Rmn Sdk: Methods which create elements are only available in browser environments.');
|
18617
|
+
return;
|
18618
|
+
}
|
18497
18619
|
const config = params.config;
|
18498
18620
|
let inject = params.inject;
|
18499
18621
|
if (!inject.length) {
|
@@ -18554,7 +18676,7 @@ class LiquidCommerceRmnClient {
|
|
18554
18676
|
placement.removeAttribute('class');
|
18555
18677
|
Object.assign(placement.style, {
|
18556
18678
|
width: '100%',
|
18557
|
-
height: '
|
18679
|
+
height: '100%',
|
18558
18680
|
display: 'flex',
|
18559
18681
|
justifyContent: 'center',
|
18560
18682
|
});
|
@@ -56,7 +56,7 @@ export interface IBuyNowEvent {
|
|
56
56
|
placementId: string;
|
57
57
|
spotId: string;
|
58
58
|
}
|
59
|
-
export interface
|
59
|
+
export interface IRmnEventMap {
|
60
60
|
[RMN_SPOT_EVENT.LIFECYCLE_STATE]: ILifecycleState;
|
61
61
|
[RMN_SPOT_EVENT.CLICK]: IClickEvent;
|
62
62
|
[RMN_SPOT_EVENT.IMPRESSION]: IImpressionEvent;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { RMN_SPOT_EVENT } from 'enums';
|
2
|
-
import type {
|
2
|
+
import type { ILifecycleState, IRegisterSpotParams, IRmnEventMap } from './event.interface';
|
3
3
|
export declare class EventService {
|
4
4
|
private static instance;
|
5
5
|
private pubSub;
|
@@ -9,8 +9,8 @@ export declare class EventService {
|
|
9
9
|
private activeSpots;
|
10
10
|
private constructor();
|
11
11
|
static getInstance(): EventService;
|
12
|
-
subscribe(eventType: RMN_SPOT_EVENT, callback: (data:
|
13
|
-
publish(eventType: RMN_SPOT_EVENT, data:
|
12
|
+
subscribe(eventType: RMN_SPOT_EVENT, callback: (data: IRmnEventMap[RMN_SPOT_EVENT]) => void): () => void;
|
13
|
+
publish(eventType: RMN_SPOT_EVENT, data: IRmnEventMap[RMN_SPOT_EVENT]): void;
|
14
14
|
registerSpot(params: IRegisterSpotParams): void;
|
15
15
|
unregisterSpot(placementId: string): void;
|
16
16
|
/**
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare class DataLayerMonitor {
|
2
|
+
private static instance;
|
3
|
+
private readonly originalPush;
|
4
|
+
private listener?;
|
5
|
+
private constructor();
|
6
|
+
static getInstance(): DataLayerMonitor;
|
7
|
+
setListener(listener: (data: any) => void): void;
|
8
|
+
start(): void;
|
9
|
+
stop(): void;
|
10
|
+
}
|
@@ -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;
|
@@ -1,5 +1,9 @@
|
|
1
1
|
import type { RMN_SPOT_TYPE } from 'enums';
|
2
2
|
import type { ISpotEvent } from 'modules/selection';
|
3
|
+
export type LocalStorageSpotsMapType = Map<string, // spotId
|
4
|
+
ILocalStorageSpot>;
|
5
|
+
export type LocalStorageSpotsObjType = Record<string, // spotId
|
6
|
+
ILocalStorageSpot>;
|
3
7
|
export interface ILocalStorageSpot {
|
4
8
|
spotId: string;
|
5
9
|
spotType: RMN_SPOT_TYPE;
|
@@ -8,7 +12,7 @@ export interface ILocalStorageSpot {
|
|
8
12
|
createdAt?: number;
|
9
13
|
}
|
10
14
|
export declare class LocalStorage {
|
11
|
-
private spots
|
15
|
+
private spots?;
|
12
16
|
private static instance;
|
13
17
|
private static readonly localStorageKey;
|
14
18
|
private static readonly spotExpirationTime;
|
@@ -16,10 +20,11 @@ export declare class LocalStorage {
|
|
16
20
|
static getInstance(): LocalStorage;
|
17
21
|
private syncLocalStorage;
|
18
22
|
setSpot(spotId: string, data: ILocalStorageSpot): void;
|
19
|
-
getSpot(spotId: string): ILocalStorageSpot | undefined;
|
20
23
|
removeSpot(spotId: string): void;
|
24
|
+
getSpot(spotId: string): ILocalStorageSpot | undefined;
|
25
|
+
getSpots(): LocalStorageSpotsObjType | undefined;
|
21
26
|
private updateLocalStorage;
|
22
|
-
clearLocalStorage
|
27
|
+
private clearLocalStorage;
|
23
28
|
private removeExpiredSpots;
|
24
29
|
private mapToObj;
|
25
30
|
private objToMap;
|
@@ -0,0 +1,13 @@
|
|
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 detectAnalyticsTool;
|
13
|
+
}
|
package/dist/types/types.d.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import type { IEventMap } from './modules/event';
|
2
1
|
export type { IInjectSpotElement, IInjectSpotElementConfig, IInjectSpotElementParams, IRmnCreateSpotElementConfig, ISpotColors, ISpotOverlay, } from 'modules/element';
|
3
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';
|
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';
|
7
7
|
import type { IInjectSpotElementParams } from 'modules/element';
|
8
|
+
import type { IRmnEventMap } from 'modules/event';
|
8
9
|
import type { ISpots, ISpotSelectionParams } from 'modules/selection';
|
9
10
|
export interface IRmnClient {
|
10
11
|
spotSelection(params: ISpotSelectionParams): Promise<ISpots | {
|
@@ -13,8 +14,8 @@ export interface IRmnClient {
|
|
13
14
|
injectSpotElement(params: IInjectSpotElementParams): Promise<void>;
|
14
15
|
}
|
15
16
|
export interface IRmnEventManager {
|
16
|
-
subscribe: (eventType: RMN_SPOT_EVENT, callback: (data:
|
17
|
-
publish: (eventType: RMN_SPOT_EVENT, data:
|
17
|
+
subscribe: (eventType: RMN_SPOT_EVENT, callback: (data: IRmnEventMap[RMN_SPOT_EVENT]) => void) => () => void;
|
18
|
+
publish: (eventType: RMN_SPOT_EVENT, data: IRmnEventMap[RMN_SPOT_EVENT]) => void;
|
18
19
|
destroySpot: (placementId: string) => void;
|
19
20
|
}
|
20
21
|
export interface IRmnConfig {
|
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.
|
5
|
+
"version": "1.5.0-beta.5",
|
6
6
|
"homepage": "https://docs.liquidcommerce.co/rmn-sdk",
|
7
7
|
"main": "./dist/index.cjs",
|
8
8
|
"module": "./dist/index.esm.js",
|