@mixpeek/prebid 1.0.0

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.
@@ -0,0 +1,519 @@
1
+ # Migration Guide: v1 → v2 (RTD Module)
2
+
3
+ > 🔄 **Breaking Changes:** Version 2.0 introduces a proper Prebid RTD submodule structure
4
+ > 📅 **Release Date:** TBD
5
+ > ⏱️ **Migration Time:** ~15-30 minutes
6
+
7
+ ---
8
+
9
+ ## What's Changing?
10
+
11
+ Version 2.0 restructures the Mixpeek adapter to follow Prebid's official Real-Time Data (RTD) module pattern, matching how modules like **Qortex** and **Rayn** work.
12
+
13
+ ### Key Changes
14
+
15
+ 1. **Configuration Structure** - New `realTimeData.dataProviders[]` pattern
16
+ 2. **Module Registration** - Now a proper RTD submodule
17
+ 3. **Data Format** - Enhanced `ortb2.site.content` injection
18
+ 4. **IAB Mapping** - Built-in IAB Content Taxonomy v3.0 support
19
+
20
+ ---
21
+
22
+ ## Quick Migration Checklist
23
+
24
+ - [ ] Update configuration from `mixpeek: {}` to `realTimeData.dataProviders[]`
25
+ - [ ] Add `auctionDelay` parameter
26
+ - [ ] Add `waitForIt` flag
27
+ - [ ] Move all params inside `params:` object
28
+ - [ ] Test with debug mode enabled
29
+ - [ ] Verify `ortb2.site.content` is populated
30
+ - [ ] Update IAB mapping with your taxonomy's node_ids (optional)
31
+ - [ ] Update tests if using the adapter
32
+
33
+ ---
34
+
35
+ ## Configuration Migration
36
+
37
+ ### v1 (Old) ❌
38
+ ```javascript
39
+ pbjs.setConfig({
40
+ mixpeek: {
41
+ apiKey: 'sk_your_api_key',
42
+ collectionId: 'col_your_collection',
43
+ endpoint: 'https://server-xb24.onrender.com',
44
+ namespace: 'production',
45
+ featureExtractors: ['taxonomy', 'brand-safety'],
46
+ mode: 'auto',
47
+ timeout: 250,
48
+ cacheTTL: 300,
49
+ enableCache: true,
50
+ debug: false
51
+ }
52
+ })
53
+ ```
54
+
55
+ ### v2 (New) ✅
56
+ ```javascript
57
+ pbjs.setConfig({
58
+ realTimeData: {
59
+ auctionDelay: 250, // NEW: Max time to wait for RTD providers
60
+ dataProviders: [{ // NEW: Array of RTD providers
61
+ name: 'mixpeek', // NEW: Provider name
62
+ waitForIt: true, // NEW: Wait for this provider
63
+ params: { // NEW: Wrap all config in params
64
+ apiKey: 'sk_your_api_key',
65
+ collectionId: 'col_your_collection',
66
+ endpoint: 'https://server-xb24.onrender.com',
67
+ namespace: 'production',
68
+ featureExtractors: ['taxonomy', 'brand-safety'],
69
+ mode: 'auto',
70
+ timeout: 250,
71
+ cacheTTL: 300,
72
+ enableCache: true,
73
+ debug: false
74
+ }
75
+ }]
76
+ }
77
+ })
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Detailed Migration Steps
83
+
84
+ ### Step 1: Update Configuration Structure
85
+
86
+ **Before (v1):**
87
+ ```javascript
88
+ pbjs.setConfig({
89
+ mixpeek: { /* config */ }
90
+ })
91
+ ```
92
+
93
+ **After (v2):**
94
+ ```javascript
95
+ pbjs.setConfig({
96
+ realTimeData: {
97
+ auctionDelay: 250,
98
+ dataProviders: [{
99
+ name: 'mixpeek',
100
+ waitForIt: true,
101
+ params: { /* config */ }
102
+ }]
103
+ }
104
+ })
105
+ ```
106
+
107
+ **Changes:**
108
+ 1. Replace `mixpeek: {}` with `realTimeData: {}`
109
+ 2. Add `auctionDelay` at top level
110
+ 3. Add `dataProviders` array
111
+ 4. Wrap config in `params: {}`
112
+
113
+ ### Step 2: Add New RTD Parameters
114
+
115
+ Add these new parameters to control RTD behavior:
116
+
117
+ | Parameter | Type | Required | Default | Description |
118
+ |-----------|------|----------|---------|-------------|
119
+ | `auctionDelay` | number | ❌ | 250 | Max time (ms) to wait for all RTD providers |
120
+ | `name` | string | ✅ | - | Must be `'mixpeek'` |
121
+ | `waitForIt` | boolean | ❌ | false | Whether to wait for this provider |
122
+
123
+ **Example:**
124
+ ```javascript
125
+ realTimeData: {
126
+ auctionDelay: 300, // Wait up to 300ms for RTD data
127
+ dataProviders: [{
128
+ name: 'mixpeek', // Required
129
+ waitForIt: true, // Wait for Mixpeek
130
+ params: { /* ... */ }
131
+ }]
132
+ }
133
+ ```
134
+
135
+ ### Step 3: Move All Config to `params`
136
+
137
+ All your existing Mixpeek configuration goes inside the `params` object:
138
+
139
+ ```javascript
140
+ params: {
141
+ // All your existing config
142
+ apiKey: 'sk_...',
143
+ collectionId: 'col_...',
144
+ endpoint: '...',
145
+ // etc.
146
+ }
147
+ ```
148
+
149
+ ### Step 4: Update Multiple RTD Providers (if applicable)
150
+
151
+ If you're using multiple RTD providers (e.g., with ID5 or RampID):
152
+
153
+ **Before (v1):**
154
+ ```javascript
155
+ pbjs.setConfig({
156
+ mixpeek: { /* ... */ }
157
+ })
158
+
159
+ // Separate config for ID5
160
+ pbjs.setConfig({
161
+ userId: {
162
+ auctionDelay: 50,
163
+ userIds: [{
164
+ name: 'id5Id',
165
+ params: { /* ... */ }
166
+ }]
167
+ }
168
+ })
169
+ ```
170
+
171
+ **After (v2):**
172
+ ```javascript
173
+ pbjs.setConfig({
174
+ realTimeData: {
175
+ auctionDelay: 300, // Combined delay for all RTD providers
176
+ dataProviders: [
177
+ {
178
+ name: 'mixpeek',
179
+ waitForIt: true,
180
+ params: { /* Mixpeek config */ }
181
+ },
182
+ {
183
+ name: 'id5',
184
+ waitForIt: true,
185
+ params: { /* ID5 config */ }
186
+ }
187
+ ]
188
+ }
189
+ })
190
+ ```
191
+
192
+ ---
193
+
194
+ ## What's New in v2
195
+
196
+ ### 1. Enhanced ortb2 Data Structure ✨
197
+
198
+ v2 now injects data into **both** site-level and impression-level locations:
199
+
200
+ **Site-Level (`ortb2.site.content`):**
201
+ ```javascript
202
+ {
203
+ "ortb2": {
204
+ "site": {
205
+ "content": {
206
+ "cat": ["IAB19-11"], // NEW: IAB categories
207
+ "cattax": 6, // NEW: Taxonomy version
208
+ "genre": "Technology - AI", // NEW: Genre
209
+ "keywords": "ai,tech", // NEW: Keywords
210
+ "language": "en", // NEW: Language
211
+ "title": "Page Title", // NEW: Title
212
+ "url": "https://...", // NEW: URL
213
+ "ext": { // NEW: Extension data
214
+ "data": {
215
+ "mixpeek": {
216
+ "score": 0.94,
217
+ "brandSafety": 0.98,
218
+ "sentiment": "positive"
219
+ }
220
+ }
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
226
+ ```
227
+
228
+ **Impression-Level (`ortb2Imp.ext.data`):**
229
+ ```javascript
230
+ {
231
+ "hb_mixpeek_taxonomy": "IAB19-11",
232
+ "hb_mixpeek_category": "Technology > AI",
233
+ // ... same as v1
234
+ }
235
+ ```
236
+
237
+ ### 2. Built-in IAB Mapping 🗺️
238
+
239
+ v2 includes IAB Content Taxonomy v3.0 mapping:
240
+
241
+ - Maps Mixpeek's `node_id` to IAB codes
242
+ - Multiple fallback strategies
243
+ - Configurable mappings
244
+
245
+ See `src/utils/iabMapping.js` for details.
246
+
247
+ ### 3. Consent Management Integration 🔒
248
+
249
+ v2 properly integrates with Prebid's consent framework:
250
+
251
+ ```javascript
252
+ // Automatically receives and logs consent
253
+ init: function(config, userConsent) {
254
+ // userConsent includes GDPR and USP data
255
+ }
256
+ ```
257
+
258
+ ### 4. Standard RTD Interface 🔌
259
+
260
+ v2 implements Prebid's official RTD submodule interface:
261
+
262
+ - `init()` - Initialize with consent
263
+ - `getBidRequestData()` - Enrich bid requests
264
+ - `getTargetingData()` - Provide targeting keys
265
+
266
+ ---
267
+
268
+ ## Testing Your Migration
269
+
270
+ ### 1. Enable Debug Mode
271
+
272
+ ```javascript
273
+ realTimeData: {
274
+ auctionDelay: 250,
275
+ dataProviders: [{
276
+ name: 'mixpeek',
277
+ waitForIt: true,
278
+ params: {
279
+ apiKey: 'sk_...',
280
+ collectionId: 'col_...',
281
+ debug: true // Enable debug logging
282
+ }
283
+ }]
284
+ }
285
+ ```
286
+
287
+ ### 2. Check Console Logs
288
+
289
+ Look for these messages:
290
+
291
+ ```
292
+ [mixpeek] Initializing Mixpeek RTD module
293
+ [mixpeek] getBidRequestData called
294
+ [mixpeek] Context retrieved successfully
295
+ [mixpeek] Injected site.content data
296
+ [mixpeek] Enriched 3 ad units
297
+ ```
298
+
299
+ ### 3. Verify ortb2 Data
300
+
301
+ Inspect the bid request:
302
+
303
+ ```javascript
304
+ pbjs.onEvent('beforeRequestBids', function(bidRequest) {
305
+ console.log('ortb2 site.content:',
306
+ bidRequest.ortb2Fragments?.global?.site?.content)
307
+
308
+ console.log('Ad unit enrichment:',
309
+ bidRequest.adUnits[0]?.ortb2Imp?.ext?.data)
310
+ })
311
+ ```
312
+
313
+ ### 4. Verify Auction Not Blocked
314
+
315
+ Check that auctions aren't delayed unnecessarily:
316
+
317
+ ```javascript
318
+ const startTime = Date.now()
319
+
320
+ pbjs.requestBids({
321
+ bidsBackHandler: function() {
322
+ const duration = Date.now() - startTime
323
+ console.log(`Auction completed in ${duration}ms`)
324
+ // Should be ~250-500ms depending on API latency
325
+ }
326
+ })
327
+ ```
328
+
329
+ ---
330
+
331
+ ## Common Migration Issues
332
+
333
+ ### Issue 1: "Module not found" or Silent Failure
334
+
335
+ **Symptoms:**
336
+ - No logs in console
337
+ - No context enrichment
338
+ - No errors
339
+
340
+ **Cause:** Configuration not properly structured
341
+
342
+ **Solution:**
343
+ ```javascript
344
+ // Make sure you have this exact structure
345
+ pbjs.setConfig({
346
+ realTimeData: { // Must be "realTimeData"
347
+ dataProviders: [{ // Must be array
348
+ name: 'mixpeek', // Must be exactly 'mixpeek'
349
+ params: { /* ... */ } // Must have params object
350
+ }]
351
+ }
352
+ })
353
+ ```
354
+
355
+ ### Issue 2: Auction Blocked Too Long
356
+
357
+ **Symptoms:**
358
+ - Auctions taking > 500ms
359
+ - Timeout errors
360
+
361
+ **Cause:** `auctionDelay` too high or API too slow
362
+
363
+ **Solution:**
364
+ ```javascript
365
+ realTimeData: {
366
+ auctionDelay: 200, // Reduce delay
367
+ dataProviders: [{
368
+ name: 'mixpeek',
369
+ waitForIt: false, // Don't wait if API is slow
370
+ params: {
371
+ timeout: 150 // Reduce API timeout
372
+ }
373
+ }]
374
+ }
375
+ ```
376
+
377
+ ### Issue 3: No ortb2.site.content Data
378
+
379
+ **Symptoms:**
380
+ - `ortb2Imp.ext.data` populated
381
+ - `ortb2.site.content` missing
382
+
383
+ **Cause:** Using v1 module
384
+
385
+ **Solution:** Ensure you're loading the v2 RTD provider module, not the v1 adapter.
386
+
387
+ ### Issue 4: IAB Codes Not Showing
388
+
389
+ **Symptoms:**
390
+ - Context data present
391
+ - No IAB codes in `ortb2.site.content.cat`
392
+
393
+ **Cause:** Mixpeek taxonomy not mapped
394
+
395
+ **Solution:**
396
+ 1. Run E2E tests to discover your node_ids:
397
+ ```bash
398
+ npm run test:e2e
399
+ ```
400
+ 2. Update `src/utils/iabMapping.js` with your mappings:
401
+ ```javascript
402
+ export const MIXPEEK_NODE_TO_IAB = {
403
+ 'your_node_id': 'IAB19-11',
404
+ // ... add your mappings
405
+ }
406
+ ```
407
+
408
+ ---
409
+
410
+ ## Rollback Plan
411
+
412
+ If you need to rollback to v1:
413
+
414
+ ### 1. Revert Configuration
415
+
416
+ ```javascript
417
+ // Back to v1 format
418
+ pbjs.setConfig({
419
+ mixpeek: {
420
+ apiKey: 'sk_...',
421
+ collectionId: 'col_...',
422
+ // ... v1 config
423
+ }
424
+ })
425
+ ```
426
+
427
+ ### 2. Revert Package
428
+
429
+ ```bash
430
+ npm install @mixpeek/prebid-contextual-adapter@1.x
431
+ ```
432
+
433
+ ### 3. Clear Cache
434
+
435
+ ```bash
436
+ # Clear browser cache
437
+ # Or programmatically:
438
+ window.MixpeekContextAdapter.clearCache()
439
+ ```
440
+
441
+ ---
442
+
443
+ ## Breaking Changes Summary
444
+
445
+ | Change | v1 | v2 | Required Action |
446
+ |--------|----|----|----------------|
447
+ | **Config structure** | `mixpeek: {}` | `realTimeData.dataProviders[]` | Update config |
448
+ | **Module type** | Custom hooks | RTD submodule | No code change |
449
+ | **ortb2 location** | Imp-level only | Site + Imp level | Verify bidders receive data |
450
+ | **Consent** | Not handled | Integrated | Test with GDPR/USP |
451
+ | **IAB mapping** | Manual | Built-in | Optional: configure mappings |
452
+
453
+ ---
454
+
455
+ ## Benefits of Migrating
456
+
457
+ ✅ **Standard Pattern** - Follows official Prebid RTD structure
458
+ ✅ **Better Integration** - Works with other RTD modules
459
+ ✅ **Enhanced Data** - ortb2.site.content for DSPs
460
+ ✅ **IAB Compliant** - Built-in taxonomy mapping
461
+ ✅ **Consent Aware** - Respects GDPR/USP
462
+ ✅ **Future Proof** - Ready for Prebid repository submission
463
+
464
+ ---
465
+
466
+ ## Timeline
467
+
468
+ ### Deprecation Schedule
469
+
470
+ - **v2.0 Release:** TBD
471
+ - **v1 Support:** 6 months after v2 release
472
+ - **v1 End of Life:** 12 months after v2 release
473
+
474
+ ### Recommended Migration Timeline
475
+
476
+ - **Weeks 1-2:** Test v2 in staging environment
477
+ - **Week 3:** Gradual rollout to 10% of traffic
478
+ - **Week 4:** Rollout to 50% of traffic
479
+ - **Week 5:** Full production rollout
480
+ - **Week 6+:** Monitor and optimize
481
+
482
+ ---
483
+
484
+ ## Support
485
+
486
+ Need help with migration?
487
+
488
+ - **Documentation:** [Full Integration Guide](integration-guide.md)
489
+ - **Examples:** See `examples/` directory
490
+ - **Issues:** [GitHub Issues](https://github.com/mixpeek/prebid-contextual-adapter/issues)
491
+ - **Email:** support@mixpeek.com
492
+ - **Slack:** [Join our Slack](https://mixpeek.com/slack)
493
+
494
+ ---
495
+
496
+ ## FAQ
497
+
498
+ ### Do I need to update my API key?
499
+ No, existing API keys work with v2.
500
+
501
+ ### Will my existing collection work?
502
+ Yes, collections are fully compatible.
503
+
504
+ ### Do I need to change my ad units?
505
+ No, ad unit configuration remains the same.
506
+
507
+ ### What about caching?
508
+ Caching works the same way in v2.
509
+
510
+ ### Can I run v1 and v2 simultaneously?
511
+ No, only one version should be active at a time.
512
+
513
+ ### Do I need to update my tests?
514
+ Yes, if your tests reference the old configuration format.
515
+
516
+ ---
517
+
518
+ **Ready to migrate?** Follow the steps above and you'll be running v2 in no time! 🚀
519
+