@liquidcommercedev/rmn-sdk 1.5.0-beta.33 → 1.5.0-beta.35

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 CHANGED
@@ -1,89 +1,233 @@
1
- ![](https://storage.googleapis.com/liquid-platform/repo_lc_dark.webp)
1
+ # Liquid Commerce Retail Media Network (RMN) SDK
2
2
 
3
- # LiquidCommerce RMN SDK
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 is bundled for use with both import/require , if you need the client side use the script below, compiled down to ES2015.
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
- >`<script src="https://js.liquidcommerce.co/sdk/v1"></script>`
16
+ ## Installation
12
17
 
13
- | Method | Description |
14
- |-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
15
- | `spotSelection({})` | A sample authenticated interaction with our Decision API that receives custom personalized ADs using machine learning and event based data. |
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
- # METHODS
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
- ## Authentication
58
+ ## Usage
21
59
 
22
- The Liquid Commerce library provides convenient, secure, and encrypted access to our Liquid Commerce methods through API Key authentication.
60
+ ### Basic Implementation
23
61
 
24
- ### Installation
62
+ ```typescript
63
+ import { RmnClient } from '@liquidcommercedev/rmn-sdk';
25
64
 
26
- Install the package with:
65
+ // Initialize the client
66
+ const client = await RmnClient('your-api-key', {
67
+ env: 'production'
68
+ });
27
69
 
28
- ```sh
29
- npm install @liquidcommercedev/rmn-sdk
30
- # or
31
- yarn add @liquidcommercedev/rmn-sdk
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
- The Liquid Commerce methods use API keys to authenticate requests. You can request your keys from your Partnerships liaison.
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
- Development mode secret keys have the prefix dev_ and Production ready secret keys have the prefix prod_.
104
+ ### Event Handling
37
105
 
38
- Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.
106
+ ```typescript
107
+ const eventManager = RmnEventManager();
39
108
 
40
- Once you create a new instance of the LiquidCommerce() library it will generate an access token that then automatically attaches to each request, the access token has a 1hour expiry that continues to refresh on each call. If an hour has passed without using the token, you must authenticate again to fetch a fresh access token.
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
- All API requests in production must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Calls made over plain HTTP will fail. API requests without authentication will also fail.
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
- > **ALL LIVE/PRODUCTION API REQUESTS AND RESPONSES ARE ENCRYPTED IN TRANSMISSION.**
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
- <!-- prettier-ignore -->
48
- ```js
49
- const RmnClient = require('@liquidcommercedev/rmn-sdk');
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
- For ES modules and async/await:
174
+ ## Best Practices
53
175
 
54
- ```js
55
- import { RmnClient } from '@liquidcommercedev/rmn-sdk';
56
- ```
176
+ ### Performance Optimization
57
177
 
58
- ### Usage
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
- ```js
61
- import { RmnClient } from '@liquidcommercedev/rmn-sdk';
62
- // Your Account token provided to you through your account representative
63
- const client = await RmnClient('YOUR_API_KEY', {
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
- ## Selection
188
+ 3. **Error Handling**
189
+ - Implement proper error boundaries
190
+ - Provide fallback content
191
+ - Monitor spot lifecycle states
69
192
 
70
- A sample authenticated interaction with our Decision API that receives custom personalized ADs using machine learning and event based data.
193
+ ### Event Tracking
71
194
 
72
- ### Sample Spot Selection
195
+ 1. **Impression Tracking**
196
+ - Ensure proper viewport tracking
197
+ - Handle carousel impressions appropriately
198
+ - Monitor viewability metrics
73
199
 
74
- An example use case for LiquidCommerce's `spotSelection({})` method.
200
+ 2. **Interaction Tracking**
201
+ - Track all user interactions
202
+ - Implement proper event debugging
203
+ - Monitor conversion events
75
204
 
76
- <!-- prettier-ignore -->
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
- const spots = await client.spotSelection({
85
- "spots": ['billboard', 'leaderboard']
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
- console.log({ spots });
89
- ```
233
+ [License information here]