@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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,153 @@
1
+ # Changelog
2
+
3
+ All notable changes to the Mixpeek Context Adapter for Prebid.js will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2025-10-08
9
+
10
+ ### Added
11
+
12
+ #### Core Features
13
+ - **Mixpeek Context Adapter** for Prebid.js integration
14
+ - Real-time contextual analysis using Mixpeek's multimodal AI engine
15
+ - Support for page, video, and image content extraction
16
+ - Automatic IAB taxonomy classification
17
+ - Brand safety scoring
18
+ - Keyword extraction
19
+ - Sentiment analysis
20
+
21
+ #### Content Extraction
22
+ - **Page Extractor**: Extracts text, meta tags, Open Graph data, and structured data
23
+ - **Video Extractor**: Extracts video metadata, source URLs, and frame snapshots
24
+ - **Image Extractor**: Extracts primary images with metadata and dimensions
25
+ - Auto-detection mode for optimal content type selection
26
+
27
+ #### API Integration
28
+ - Full Mixpeek API client with retry logic and timeout handling
29
+ - Support for multiple feature extractors
30
+ - Custom feature extractor configuration
31
+ - Document creation and retrieval
32
+ - Health check endpoint
33
+
34
+ #### Caching
35
+ - In-memory cache with configurable TTL
36
+ - LocalStorage persistence
37
+ - Automatic cache expiration and pruning
38
+ - Cache statistics and monitoring
39
+
40
+ #### Targeting
41
+ - Injection of contextual targeting keys into Prebid ad requests
42
+ - Support for both `ortb2Imp` and legacy bid params
43
+ - Comprehensive key-value schema (taxonomy, brand safety, keywords, etc.)
44
+
45
+ #### Events
46
+ - `mixpeekContextReady` - Context successfully loaded
47
+ - `mixpeekContextError` - Error during enrichment
48
+ - `mixpeekContextCached` - Cached context used
49
+ - `mixpeekApiRequest` - API request initiated
50
+ - `mixpeekApiResponse` - API response received
51
+
52
+ #### Testing
53
+ - Comprehensive unit test suite
54
+ - Integration tests for end-to-end workflows
55
+ - Test setup with mocked browser environment
56
+ - Coverage for all core modules
57
+
58
+ #### Documentation
59
+ - Detailed README with quickstart guide
60
+ - Integration guide with step-by-step instructions
61
+ - API reference documentation
62
+ - Example implementation with live demo
63
+ - Postman collection for API testing
64
+
65
+ #### Examples
66
+ - Publisher demo with contextual ad enrichment
67
+ - Debug panel for real-time monitoring
68
+ - Multiple ad unit configurations
69
+ - Event listener examples
70
+
71
+ #### Configuration
72
+ - Flexible configuration via `pbjs.setConfig()`
73
+ - Support for API key, collection ID, and namespace
74
+ - Configurable timeout, cache TTL, and retry attempts
75
+ - Debug mode for development
76
+ - Multiple content modes (auto, page, video, image)
77
+
78
+ ### Technical Details
79
+
80
+ - **Language**: JavaScript (ES6)
81
+ - **Module Format**: UMD (Universal Module Definition)
82
+ - **Browser Support**: Modern browsers with ES6 support
83
+ - **Dependencies**: None (standalone)
84
+ - **Build System**: Webpack
85
+ - **Testing**: Jest
86
+ - **Linting**: ESLint with Standard config
87
+
88
+ ### Performance
89
+
90
+ - API latency: <250ms (typical)
91
+ - Cache hit latency: <10ms
92
+ - No blocking of ad auction
93
+ - Graceful fallback on errors
94
+
95
+ ### Security
96
+
97
+ - HTTPS-only API communication
98
+ - Bearer token authentication
99
+ - No PII collection or transmission
100
+ - Content-only analysis
101
+ - Optional namespace isolation
102
+
103
+ ### Compliance
104
+
105
+ - GDPR compliant (no user tracking)
106
+ - CCPA compliant (contextual only)
107
+ - No cookies or user identifiers
108
+ - Privacy-first targeting
109
+
110
+ ---
111
+
112
+ ## [Unreleased]
113
+
114
+ ### Planned for v1.1.0
115
+ - Server-side adapter for Prebid Server
116
+ - WebSocket support for real-time video scene changes
117
+ - Batched API calls for multi-slot pages
118
+ - Extended video analysis with frame-by-frame processing
119
+ - Custom taxonomy support
120
+ - Analytics dashboard integration
121
+
122
+ ### Planned for v1.2.0
123
+ - Machine learning model caching
124
+ - Edge function deployment support
125
+ - Advanced clustering and similarity matching
126
+ - Multi-language support
127
+ - Enhanced brand safety categories
128
+
129
+ ---
130
+
131
+ ## Release History
132
+
133
+ - **v1.0.0** (2025-10-08) - Initial release
134
+
135
+ ---
136
+
137
+ ## Upgrade Guide
138
+
139
+ ### From Development to v1.0.0
140
+
141
+ This is the first stable release. No migration required.
142
+
143
+ ---
144
+
145
+ ## Support
146
+
147
+ For questions, issues, or feature requests:
148
+
149
+ - **Documentation**: https://docs.mixpeek.com
150
+ - **GitHub Issues**: https://github.com/mixpeek/prebid-contextual-adapter/issues
151
+ - **Email**: support@mixpeek.com
152
+ - **Slack**: https://mixpeek.com/slack
153
+
package/ENDPOINTS.md ADDED
@@ -0,0 +1,308 @@
1
+ # API Endpoint Configuration
2
+
3
+ The Mixpeek adapter can work with different API endpoints. This is useful for development, staging, and production environments.
4
+
5
+ ## Available Endpoints
6
+
7
+ | Environment | URL | Use Case |
8
+ |-------------|-----|----------|
9
+ | **Development** | `https://server-xb24.onrender.com` | Testing and development (default) |
10
+ | **Production** | `https://api.mixpeek.com` | Production deployment |
11
+ | **Local** | `http://localhost:8000` | Local development |
12
+
13
+ ## Quick Configuration
14
+
15
+ ### Method 1: Environment Variable (Recommended)
16
+
17
+ Set the endpoint before running tests or building:
18
+
19
+ ```bash
20
+ # Use development server (default)
21
+ export MIXPEEK_API_ENDPOINT=https://server-xb24.onrender.com
22
+
23
+ # Or use production
24
+ export MIXPEEK_API_ENDPOINT=https://api.mixpeek.com
25
+
26
+ # Or use local server
27
+ export MIXPEEK_API_ENDPOINT=http://localhost:8000
28
+ ```
29
+
30
+ ### Method 2: Configuration File
31
+
32
+ Edit `.mixpeek.config.js`:
33
+
34
+ ```javascript
35
+ module.exports = {
36
+ // Option 1: Direct URL
37
+ endpoint: 'https://server-xb24.onrender.com',
38
+
39
+ // Option 2: Use predefined names
40
+ endpoint: 'development', // or 'production', 'local'
41
+
42
+ // Your credentials
43
+ apiKey: process.env.MIXPEEK_API_KEY,
44
+ collectionId: process.env.MIXPEEK_COLLECTION_ID,
45
+
46
+ // Other settings...
47
+ timeout: 5000,
48
+ debug: true
49
+ }
50
+ ```
51
+
52
+ ### Method 3: Prebid Configuration
53
+
54
+ Set the endpoint directly in your Prebid setup:
55
+
56
+ ```javascript
57
+ pbjs.setConfig({
58
+ mixpeek: {
59
+ apiKey: 'YOUR_API_KEY',
60
+ collectionId: 'YOUR_COLLECTION_ID',
61
+ endpoint: 'https://server-xb24.onrender.com', // Development server
62
+ // endpoint: 'https://api.mixpeek.com', // Production server
63
+ timeout: 5000,
64
+ featureExtractors: ['taxonomy']
65
+ }
66
+ });
67
+ ```
68
+
69
+ ### Method 4: Window Global (Browser)
70
+
71
+ For browser-based configuration:
72
+
73
+ ```html
74
+ <script>
75
+ // Set before loading the adapter
76
+ window.MIXPEEK_API_ENDPOINT = 'https://server-xb24.onrender.com';
77
+ </script>
78
+ <script src="mixpeekContextAdapter.js"></script>
79
+ ```
80
+
81
+ ## Switching Between Endpoints
82
+
83
+ ### For Development & Testing
84
+
85
+ ```bash
86
+ # Set development endpoint
87
+ export MIXPEEK_API_ENDPOINT=https://server-xb24.onrender.com
88
+ export MIXPEEK_API_KEY=your_dev_key
89
+
90
+ # Validate setup
91
+ npm run validate
92
+
93
+ # Run tests
94
+ npm run test:live
95
+ ```
96
+
97
+ ### For Production Deployment
98
+
99
+ ```bash
100
+ # Set production endpoint
101
+ export MIXPEEK_API_ENDPOINT=https://api.mixpeek.com
102
+ export MIXPEEK_API_KEY=your_prod_key
103
+
104
+ # Build
105
+ npm run build
106
+
107
+ # Test
108
+ npm run test:live
109
+ ```
110
+
111
+ ### Quick Switch Script
112
+
113
+ Create a shell script for easy switching:
114
+
115
+ ```bash
116
+ #!/bin/bash
117
+ # switch-endpoint.sh
118
+
119
+ case "$1" in
120
+ dev|development)
121
+ export MIXPEEK_API_ENDPOINT=https://server-xb24.onrender.com
122
+ echo "✅ Switched to development: https://server-xb24.onrender.com"
123
+ ;;
124
+ prod|production)
125
+ export MIXPEEK_API_ENDPOINT=https://api.mixpeek.com
126
+ echo "✅ Switched to production: https://api.mixpeek.com"
127
+ ;;
128
+ local)
129
+ export MIXPEEK_API_ENDPOINT=http://localhost:8000
130
+ echo "✅ Switched to local: http://localhost:8000"
131
+ ;;
132
+ *)
133
+ echo "Usage: source switch-endpoint.sh [dev|prod|local]"
134
+ return 1
135
+ ;;
136
+ esac
137
+
138
+ # Usage:
139
+ # source switch-endpoint.sh dev
140
+ # npm run test:live
141
+ ```
142
+
143
+ ## Environment-Specific Configuration
144
+
145
+ ### Development (.env.development)
146
+
147
+ ```bash
148
+ MIXPEEK_API_ENDPOINT=https://server-xb24.onrender.com
149
+ MIXPEEK_API_KEY=sk_dev_key
150
+ MIXPEEK_COLLECTION_ID=col_dev_collection
151
+ MIXPEEK_NAMESPACE=development
152
+ ```
153
+
154
+ ### Production (.env.production)
155
+
156
+ ```bash
157
+ MIXPEEK_API_ENDPOINT=https://api.mixpeek.com
158
+ MIXPEEK_API_KEY=sk_prod_key
159
+ MIXPEEK_COLLECTION_ID=col_prod_collection
160
+ MIXPEEK_NAMESPACE=production
161
+ ```
162
+
163
+ Load with:
164
+
165
+ ```bash
166
+ # Development
167
+ export $(cat .env.development | xargs)
168
+ npm run test:live
169
+
170
+ # Production
171
+ export $(cat .env.production | xargs)
172
+ npm run build
173
+ ```
174
+
175
+ ## Verifying Current Endpoint
176
+
177
+ Check which endpoint is configured:
178
+
179
+ ```bash
180
+ # Validation script shows current endpoint
181
+ npm run validate
182
+ ```
183
+
184
+ Output will show:
185
+ ```
186
+ 📋 Configuration Check:
187
+ API Key: ✅ Set
188
+ Collection ID: ✅ Set
189
+ Namespace: ⚠️ Not set (using default)
190
+ Endpoint: https://server-xb24.onrender.com 👈 Current endpoint
191
+ ```
192
+
193
+ ## CI/CD Configuration
194
+
195
+ ### GitHub Actions
196
+
197
+ ```yaml
198
+ name: Test
199
+
200
+ on: [push, pull_request]
201
+
202
+ jobs:
203
+ test-dev:
204
+ runs-on: ubuntu-latest
205
+ steps:
206
+ - uses: actions/checkout@v3
207
+ - name: Test against dev server
208
+ env:
209
+ MIXPEEK_API_ENDPOINT: https://server-xb24.onrender.com
210
+ MIXPEEK_API_KEY: ${{ secrets.MIXPEEK_DEV_API_KEY }}
211
+ run: npm run test:live
212
+
213
+ test-prod:
214
+ runs-on: ubuntu-latest
215
+ if: github.ref == 'refs/heads/main'
216
+ steps:
217
+ - uses: actions/checkout@v3
218
+ - name: Test against production
219
+ env:
220
+ MIXPEEK_API_ENDPOINT: https://api.mixpeek.com
221
+ MIXPEEK_API_KEY: ${{ secrets.MIXPEEK_PROD_API_KEY }}
222
+ run: npm run test:live
223
+ ```
224
+
225
+ ## Performance Considerations
226
+
227
+ Different endpoints may have different performance characteristics:
228
+
229
+ | Endpoint | Typical Latency | Notes |
230
+ |----------|----------------|-------|
231
+ | Development | 500-2000ms | Slower, may cold start |
232
+ | Production | 100-500ms | Optimized, globally distributed |
233
+ | Local | 10-50ms | Fastest, no network latency |
234
+
235
+ Adjust timeout accordingly:
236
+
237
+ ```javascript
238
+ pbjs.setConfig({
239
+ mixpeek: {
240
+ endpoint: 'https://server-xb24.onrender.com',
241
+ timeout: 5000 // Higher timeout for dev server
242
+ }
243
+ });
244
+ ```
245
+
246
+ ## Troubleshooting
247
+
248
+ ### "Cannot connect to endpoint"
249
+
250
+ Check if the server is running:
251
+
252
+ ```bash
253
+ curl https://server-xb24.onrender.com/v1/health
254
+ ```
255
+
256
+ Expected response:
257
+ ```json
258
+ {
259
+ "status": "healthy",
260
+ "version": "0.1.0"
261
+ }
262
+ ```
263
+
264
+ ### "Wrong endpoint being used"
265
+
266
+ Verify environment variable is set:
267
+
268
+ ```bash
269
+ echo $MIXPEEK_API_ENDPOINT
270
+ ```
271
+
272
+ Clear and reset if needed:
273
+
274
+ ```bash
275
+ unset MIXPEEK_API_ENDPOINT
276
+ export MIXPEEK_API_ENDPOINT=https://server-xb24.onrender.com
277
+ ```
278
+
279
+ ### "Different results between endpoints"
280
+
281
+ Development and production may have:
282
+ - Different feature extractor versions
283
+ - Different taxonomy versions
284
+ - Different data/collections
285
+
286
+ Use the same collection ID across environments when possible.
287
+
288
+ ## Current Default
289
+
290
+ The adapter currently defaults to the **development server** for testing:
291
+
292
+ ```
293
+ https://server-xb24.onrender.com
294
+ ```
295
+
296
+ This can be changed in:
297
+ - `.env.example` - Default environment file
298
+ - `.mixpeek.config.js` - Configuration file
299
+ - `src/config/constants.js` - Code default
300
+ - `tests/live-api/setup.js` - Test default
301
+
302
+ ## Support
303
+
304
+ For endpoint-specific issues:
305
+ - **Development server**: Check [https://server-xb24.onrender.com/](https://server-xb24.onrender.com/) status
306
+ - **Production API**: Check [https://status.mixpeek.com](https://status.mixpeek.com)
307
+ - **General help**: support@mixpeek.com
308
+
package/LICENSE ADDED
@@ -0,0 +1,68 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner.
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+
37
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
38
+
39
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work; and
40
+
41
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file.
42
+
43
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions.
44
+
45
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work.
46
+
47
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
48
+
49
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work.
50
+
51
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License.
52
+
53
+ END OF TERMS AND CONDITIONS
54
+
55
+ Copyright 2025 Mixpeek
56
+
57
+ Licensed under the Apache License, Version 2.0 (the "License");
58
+ you may not use this file except in compliance with the License.
59
+ You may obtain a copy of the License at
60
+
61
+ http://www.apache.org/licenses/LICENSE-2.0
62
+
63
+ Unless required by applicable law or agreed to in writing, software
64
+ distributed under the License is distributed on an "AS IS" BASIS,
65
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66
+ See the License for the specific language governing permissions and
67
+ limitations under the License.
68
+