@liquidcommercedev/rmn-sdk 1.5.0-beta.34 → 1.5.0-beta.36
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/README.md +201 -57
- package/dist/index.cjs +568 -984
- package/dist/index.esm.js +568 -984
- package/package.json +14 -27
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
package/README.md
CHANGED
@@ -1,89 +1,233 @@
|
|
1
|
-
|
1
|
+
# Liquid Commerce Retail Media Network (RMN) SDK
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
The Liquid Commerce RMN SDK provides an easier way to interact with our Retail Media Network APIs through a server-side SDK for Node.js and Web JS script (more libraries will soon follow).
|
3
|
+
The Liquid Commerce RMN SDK enables retailers to transform their digital properties into powerful advertising platforms. It provides a comprehensive solution for implementing retail media advertising, supporting standard IAB ad formats and custom spot types.
|
6
4
|
|
7
5
|
## Overview
|
8
6
|
|
9
|
-
The RMN SDK
|
7
|
+
The RMN SDK facilitates the integration of retail media advertising within e-commerce platforms, offering:
|
8
|
+
|
9
|
+
- Multiple spot type support including IAB Standard formats
|
10
|
+
- Dynamic spot selection and placement
|
11
|
+
- Comprehensive event tracking and analytics
|
12
|
+
- Carousel displays for multiple advertisements
|
13
|
+
- Proximity-based loading for optimal performance
|
14
|
+
- Flexible deployment across server-side and client-side environments
|
10
15
|
|
11
|
-
|
16
|
+
## Installation
|
12
17
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
| `createSpotElement({})` | A simple method that makes your life easier by creating the spot element ready for injection anywhere in your site. |
|
18
|
+
```bash
|
19
|
+
npm install @liquidcommercedev/rmn-sdk
|
20
|
+
```
|
17
21
|
|
18
|
-
|
22
|
+
## Core Concepts
|
23
|
+
|
24
|
+
### Spot Types
|
25
|
+
|
26
|
+
The SDK supports IAB Standard Formats including:
|
27
|
+
- Billboard
|
28
|
+
- Rectangle variants (Large, Medium, Small)
|
29
|
+
- Leaderboard variants
|
30
|
+
- Skyscraper formats
|
31
|
+
- Mobile-specific formats
|
32
|
+
- Interstitials
|
33
|
+
- ...and more to come
|
34
|
+
|
35
|
+
### Event System
|
36
|
+
|
37
|
+
The SDK implements a comprehensive event tracking system:
|
38
|
+
|
39
|
+
```typescript
|
40
|
+
enum RMN_EVENT {
|
41
|
+
LIFECYCLE_STATE = 'LIFECYCLE_STATE',
|
42
|
+
SPOT_EVENT = 'SPOT_EVENT'
|
43
|
+
}
|
44
|
+
|
45
|
+
enum RMN_SPOT_EVENT {
|
46
|
+
IMPRESSION = 'IMPRESSION',
|
47
|
+
CLICK = 'CLICK',
|
48
|
+
PURCHASE = 'PURCHASE',
|
49
|
+
ADD_TO_CART = 'ADD_TO_CART',
|
50
|
+
REMOVE_FROM_CART = 'REMOVE_FROM_CART',
|
51
|
+
ADD_TO_CART_FROM_DETAILS = 'ADD_TO_CART_FROM_DETAILS',
|
52
|
+
ADD_TO_WISHLIST = 'ADD_TO_WISHLIST',
|
53
|
+
EXPAND_PRODUCT = 'EXPAND_PRODUCT',
|
54
|
+
BUY_NOW = 'BUY_NOW'
|
55
|
+
}
|
56
|
+
```
|
19
57
|
|
20
|
-
##
|
58
|
+
## Usage
|
21
59
|
|
22
|
-
|
60
|
+
### Basic Implementation
|
23
61
|
|
24
|
-
|
62
|
+
```typescript
|
63
|
+
import { RmnClient } from '@liquidcommercedev/rmn-sdk';
|
25
64
|
|
26
|
-
|
65
|
+
// Initialize the client
|
66
|
+
const client = await RmnClient('your-api-key', {
|
67
|
+
env: 'production'
|
68
|
+
});
|
27
69
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
70
|
+
// Request spots
|
71
|
+
const spots = await client.spotSelection({
|
72
|
+
spots: [{
|
73
|
+
placementId: 'sidebar-ad',
|
74
|
+
spot: RMN_SPOT_TYPE.MEDIUM_RECTANGLE,
|
75
|
+
count: 1
|
76
|
+
}],
|
77
|
+
filter: {
|
78
|
+
section: 'category-page',
|
79
|
+
category: 'electronics'
|
80
|
+
}
|
81
|
+
});
|
32
82
|
```
|
33
83
|
|
34
|
-
|
84
|
+
### Spot Injection
|
85
|
+
|
86
|
+
```typescript
|
87
|
+
await client.injectSpotElement({
|
88
|
+
inject: [{
|
89
|
+
placementId: 'sidebar-ad',
|
90
|
+
spotType: RMN_SPOT_TYPE.MEDIUM_RECTANGLE,
|
91
|
+
config: {
|
92
|
+
fluid: true,
|
93
|
+
colors: {
|
94
|
+
textColor: '#333333',
|
95
|
+
backgroundColor: '#FFFFFF',
|
96
|
+
ctaTextColor: '#FFFFFF',
|
97
|
+
ctaBorderColor: '#000000'
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}]
|
101
|
+
});
|
102
|
+
```
|
35
103
|
|
36
|
-
|
104
|
+
### Event Handling
|
37
105
|
|
38
|
-
|
106
|
+
```typescript
|
107
|
+
const eventManager = RmnEventManager();
|
39
108
|
|
40
|
-
|
109
|
+
// Track spot visibility
|
110
|
+
eventManager.subscribe(RMN_EVENT.SPOT_EVENT, (data) => {
|
111
|
+
if (data.eventType === RMN_SPOT_EVENT.IMPRESSION) {
|
112
|
+
console.log('Spot impression:', data.spotId);
|
113
|
+
}
|
114
|
+
});
|
41
115
|
|
42
|
-
|
116
|
+
// Track user interactions
|
117
|
+
eventManager.subscribe(RMN_EVENT.SPOT_EVENT, (data) => {
|
118
|
+
if (data.eventType === RMN_SPOT_EVENT.CLICK) {
|
119
|
+
console.log('Spot clicked:', data.spotId);
|
120
|
+
}
|
121
|
+
});
|
122
|
+
```
|
43
123
|
|
44
|
-
|
45
|
-
|
124
|
+
## Advanced Features
|
125
|
+
|
126
|
+
### Spot Manager Service
|
127
|
+
|
128
|
+
The SpotManager handles the lifecycle and state management of spots:
|
129
|
+
|
130
|
+
```typescript
|
131
|
+
interface ILifecycleState {
|
132
|
+
identifier: {
|
133
|
+
placementId: string;
|
134
|
+
spotId: string;
|
135
|
+
spotType: string;
|
136
|
+
};
|
137
|
+
dom: {
|
138
|
+
visibleOnViewport: boolean;
|
139
|
+
spotElement?: HTMLElement;
|
140
|
+
};
|
141
|
+
state: {
|
142
|
+
mounted: boolean;
|
143
|
+
unmounted: boolean;
|
144
|
+
loading: boolean;
|
145
|
+
error?: string;
|
146
|
+
};
|
147
|
+
displayConfig: {
|
148
|
+
isCarousel: boolean;
|
149
|
+
isCarouselItem: boolean;
|
150
|
+
isSingleItem: boolean;
|
151
|
+
};
|
152
|
+
}
|
153
|
+
```
|
46
154
|
|
47
|
-
|
48
|
-
|
49
|
-
|
155
|
+
### Filtering Options
|
156
|
+
|
157
|
+
The SDK supports comprehensive filtering capabilities:
|
158
|
+
|
159
|
+
```typescript
|
160
|
+
enum RMN_FILTER_PROPERTIES {
|
161
|
+
KEYWORDS = 'keywords',
|
162
|
+
PAGE_LOCATION = 'pageLocation',
|
163
|
+
PARENTCO = 'parentCo',
|
164
|
+
BRAND = 'brand',
|
165
|
+
CATEGORY = 'category',
|
166
|
+
TYPE = 'type',
|
167
|
+
CLASSIFICATION = 'classification',
|
168
|
+
HOLIDAY = 'holiday',
|
169
|
+
PUBLISHERS = 'publishers',
|
170
|
+
SECTION = 'section'
|
171
|
+
}
|
50
172
|
```
|
51
173
|
|
52
|
-
|
174
|
+
## Best Practices
|
53
175
|
|
54
|
-
|
55
|
-
import { RmnClient } from '@liquidcommercedev/rmn-sdk';
|
56
|
-
```
|
176
|
+
### Performance Optimization
|
57
177
|
|
58
|
-
|
178
|
+
1. **Proximity Loading**
|
179
|
+
- Utilize the built-in proximity observer
|
180
|
+
- Configure appropriate thresholds for your use case
|
181
|
+
- Implement proper cleanup
|
59
182
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
env: 'staging'
|
65
|
-
});
|
66
|
-
```
|
183
|
+
2. **State Management**
|
184
|
+
- Track spot lifecycle states
|
185
|
+
- Handle unmounting properly
|
186
|
+
- Clear resources when spots are destroyed
|
67
187
|
|
68
|
-
|
188
|
+
3. **Error Handling**
|
189
|
+
- Implement proper error boundaries
|
190
|
+
- Provide fallback content
|
191
|
+
- Monitor spot lifecycle states
|
69
192
|
|
70
|
-
|
193
|
+
### Event Tracking
|
71
194
|
|
72
|
-
|
195
|
+
1. **Impression Tracking**
|
196
|
+
- Ensure proper viewport tracking
|
197
|
+
- Handle carousel impressions appropriately
|
198
|
+
- Monitor viewability metrics
|
73
199
|
|
74
|
-
|
200
|
+
2. **Interaction Tracking**
|
201
|
+
- Track all user interactions
|
202
|
+
- Implement proper event debugging
|
203
|
+
- Monitor conversion events
|
75
204
|
|
76
|
-
|
77
|
-
```js
|
78
|
-
import RmnClient from '@liquidcommercedev/rmn-sdk';
|
79
|
-
// Your Account token provided to you through your account representative
|
80
|
-
const client = await RmnClient('YOUR_API_KEY', {
|
81
|
-
env: 'staging'
|
82
|
-
});
|
205
|
+
## TypeScript Support
|
83
206
|
|
84
|
-
|
85
|
-
|
86
|
-
|
207
|
+
The SDK is written in TypeScript and provides comprehensive type definitions for all features:
|
208
|
+
|
209
|
+
- Spot Types and Configurations
|
210
|
+
- Event Systems and Handlers
|
211
|
+
- Service Interfaces
|
212
|
+
- State Management Types
|
213
|
+
|
214
|
+
## Environment Support
|
215
|
+
|
216
|
+
### Browser Environment
|
217
|
+
- Full DOM manipulation support
|
218
|
+
- Lifecycle management
|
219
|
+
- Event tracking
|
220
|
+
- Proximity loading
|
221
|
+
|
222
|
+
### Server Environment
|
223
|
+
- Spot selection support
|
224
|
+
- SSR compatibility
|
225
|
+
- Reduced feature set
|
226
|
+
|
227
|
+
## Contributing
|
228
|
+
|
229
|
+
Please refer to our contribution guidelines for information on how to participate in the development of this SDK.
|
230
|
+
|
231
|
+
## License
|
87
232
|
|
88
|
-
|
89
|
-
```
|
233
|
+
[License information here]
|