@newrelic/video-videojs 4.0.3 → 4.1.1
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 +47 -3
- package/README.md +450 -66
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.LICENSE.txt +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.LICENSE.txt +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/umd/newrelic-video-videojs.min.js +1 -1
- package/dist/umd/newrelic-video-videojs.min.js.LICENSE.txt +1 -1
- package/dist/umd/newrelic-video-videojs.min.js.map +1 -1
- package/package.json +1 -1
- package/src/techs/contrib-hls.js +64 -52
- package/src/techs/hls-js.js +29 -12
- package/src/techs/shaka.js +37 -10
- package/src/tracker.js +77 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,57 @@
|
|
|
1
|
-
## [4.
|
|
1
|
+
## [4.1.1](https://github.com/newrelic/video-videojs-js/compare/v4.1.0...v4.1.1) (2026-04-17)
|
|
2
|
+
|
|
3
|
+
### Documentation
|
|
4
|
+
|
|
5
|
+
- **README.md:** Added Best Practices section (contentTitle, userId, custom attributes, gradual rollout with feature flags)
|
|
6
|
+
- **README.md:** Promoted Bitrate Metrics to top-level section with detailed table format and NRQL query examples
|
|
7
|
+
- **README.md:** Updated Data Model event descriptions to include heartbeats and media errors
|
|
8
|
+
- **README.md:** Fixed DATAMODEL.md link casing
|
|
9
|
+
- **README.md:** Updated Table of Contents with new sections (Prerequisites, Best Practices, Bitrate Metrics)
|
|
10
|
+
- **README.md:** Renamed Contributing to Contribute for consistency across trackers
|
|
11
|
+
|
|
12
|
+
## [4.1.0](https://github.com/newrelic/video-videojs-js/compare/v4.0.3...v4.1.0) (2026-04-08)
|
|
13
|
+
|
|
14
|
+
### Breaking Changes
|
|
15
|
+
|
|
16
|
+
- **Method Renames:** Bitrate methods renamed for clarity
|
|
17
|
+
- `getMeasuredBitrate()` → `getSegmentDownloadBitrate()` - ABR bandwidth estimate from player stats
|
|
18
|
+
- `getDownloadBitrate()` → `getNetworkDownloadBitrate()` - Instantaneous network throughput
|
|
19
|
+
- **Note:** Most users won't be affected as these methods are primarily used internally by the tracker
|
|
20
|
+
|
|
21
|
+
### Deprecated
|
|
22
|
+
|
|
23
|
+
- **Removed `getRenditionBitrate()` method** - No longer needed with improved bitrate tracking system
|
|
2
24
|
|
|
25
|
+
### Enhancements
|
|
26
|
+
|
|
27
|
+
- **Bitrate Metrics Refactoring:**
|
|
28
|
+
- Implemented consistent fallback pattern across all bitrate methods (VHS direct access → tech wrapper fallback)
|
|
29
|
+
- Simplified network download bitrate to use direct throughput access
|
|
30
|
+
- Enhanced bitrate tracking with four distinct metrics for comprehensive quality analysis
|
|
31
|
+
- Updated all tech wrappers (VHS, hls.js, Shaka) with consistent implementations
|
|
32
|
+
|
|
33
|
+
- **Comprehensive Documentation Rewrite:**
|
|
34
|
+
- **README.md:** Complete rewrite with professional structure, badges, features section, table of contents, two installation options, expanded API reference, and clear New Relic support channels
|
|
35
|
+
- **datamodel.md:** Complete rewrite with comprehensive event reference, all four bitrate metrics definitions, QoE attributes, complete attribute tables for all event types, and SSAI/DAI support documentation
|
|
36
|
+
- **DEVELOPING.md:** Complete development guide with setup, build instructions, project structure, testing guidelines, and release process
|
|
37
|
+
- **REVIEW.md:** NEW FILE - Code review guidelines and standards for contributors
|
|
38
|
+
|
|
39
|
+
### Documentation
|
|
40
|
+
|
|
41
|
+
- Added clear instructions to obtain configuration from [one.newrelic.com](https://one.newrelic.com)
|
|
42
|
+
- Updated all bitrate metric definitions with accurate sources and use cases
|
|
43
|
+
- Added comprehensive API reference with method signatures and examples
|
|
44
|
+
- Enhanced support section with multiple New Relic support channels
|
|
45
|
+
- Added third-party library license disclosure
|
|
46
|
+
|
|
47
|
+
## [4.0.3](https://github.com/newrelic/video-videojs-js/compare/v4.0.2...v4.0.3) (2025-11-21)
|
|
3
48
|
|
|
4
49
|
### Bug Fixes
|
|
5
50
|
|
|
6
|
-
|
|
51
|
+
- removed github token ([f5f9ade](https://github.com/newrelic/video-videojs-js/commit/f5f9ade01c9af411d72ec74874f8d0750c5f0f66))
|
|
7
52
|
|
|
8
53
|
# CHANGELOG
|
|
9
54
|
|
|
10
|
-
|
|
11
55
|
## [4.0.2] - 2025-10-21
|
|
12
56
|
|
|
13
57
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -1,131 +1,515 @@
|
|
|
1
1
|
[](https://opensource.newrelic.com/oss-category/#community-project)
|
|
2
2
|
|
|
3
|
-
# New Relic
|
|
3
|
+
# New Relic Video.js Tracker
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://badge.fury.io/js/%40newrelic%2Fvideo-videojs)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- New Relic Videojs tracker auto-detects events emitted by Videojs Player.
|
|
9
|
-
- Ensure that the **Browser agent** is successfully instrumented before deploying the media tracker.
|
|
10
|
-
- For questions and feedback on this package, please visit the [Explorer's Hub](https://discuss.newrelic.com), New Relic's community support forum.
|
|
11
|
-
- Looking to contribute to the Player Name agent code base? See [DEVELOPING.md](./DEVELOPING.md) for instructions on building and testing the browser agent library, and Contributors.
|
|
8
|
+
The New Relic Video.js Tracker provides comprehensive video analytics for applications using Video.js Player. Track video events, monitor playback quality, identify errors, and gain deep insights into user engagement and streaming performance.
|
|
12
9
|
|
|
13
|
-
##
|
|
10
|
+
## Features
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
- 🎯 **Automatic Event Detection** - Captures Video.js player events automatically without manual instrumentation
|
|
13
|
+
- 📊 **Comprehensive Bitrate Tracking** - Four distinct bitrate metrics for complete quality analysis
|
|
14
|
+
- 🎬 **Ad Tracking Support** - Full support for IMA, Freewheel, and SSAI (Server-Side Ad Insertion)
|
|
15
|
+
- 🔧 **Multi-Tech Support** - Works with VHS, hls.js, and Shaka Player
|
|
16
|
+
- 📈 **QoE Metrics** - Quality of Experience aggregation for startup time, buffering, and playback quality
|
|
17
|
+
- 🎨 **Event Segregation** - Organized event types: `VideoAction`, `VideoAdAction`, `VideoErrorAction`, `VideoCustomAction`
|
|
18
|
+
- 🚀 **Easy Integration** - NPM package or direct script include
|
|
19
|
+
|
|
20
|
+
## Table of Contents
|
|
21
|
+
|
|
22
|
+
- [Installation](#installation)
|
|
23
|
+
- [Option 1: NPM/Yarn](#option-1-install-via-npmyarn)
|
|
24
|
+
- [Option 2: Direct Script Include](#option-2-direct-script-include-without-npm)
|
|
25
|
+
- [Prerequisites](#prerequisites)
|
|
26
|
+
- [Usage](#usage)
|
|
27
|
+
- [Best Practices](#best-practices)
|
|
28
|
+
- [Configuration Options](#configuration-options)
|
|
29
|
+
- [API Reference](#api-reference)
|
|
30
|
+
- [Bitrate Metrics](#bitrate-metrics)
|
|
31
|
+
- [Ad Tracking Support](#ad-tracking-support)
|
|
32
|
+
- [Data Model](#data-model)
|
|
33
|
+
- [Support](#support)
|
|
34
|
+
- [Contribute](#contribute)
|
|
35
|
+
- [License](#license)
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### Option 1: Install via NPM/Yarn
|
|
40
|
+
|
|
41
|
+
Install the package using your preferred package manager:
|
|
42
|
+
|
|
43
|
+
**NPM:**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install @newrelic/video-videojs
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Yarn:**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
yarn add @newrelic/video-videojs
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Option 2: Direct Script Include (Without NPM)
|
|
56
|
+
|
|
57
|
+
For quick integration without a build system, include the tracker directly in your HTML:
|
|
16
58
|
|
|
17
59
|
```html
|
|
18
60
|
<!DOCTYPE html>
|
|
19
|
-
<html
|
|
61
|
+
<html>
|
|
20
62
|
<head>
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
<!--
|
|
26
|
-
<script src="path/to/videojs
|
|
63
|
+
<!-- Video.js Player -->
|
|
64
|
+
<link href="https://vjs.zencdn.net/7.20.3/video-js.css" rel="stylesheet" />
|
|
65
|
+
<script src="https://vjs.zencdn.net/7.20.3/video.js"></script>
|
|
66
|
+
|
|
67
|
+
<!-- New Relic Video.js Tracker -->
|
|
68
|
+
<script src="path/to/newrelic-video-videojs.min.js"></script>
|
|
27
69
|
</head>
|
|
28
70
|
<body>
|
|
29
|
-
|
|
71
|
+
<video id="myVideo" class="video-js" controls width="640" height="480">
|
|
72
|
+
<source src="https://your-video-source.mp4" type="video/mp4" />
|
|
73
|
+
</video>
|
|
74
|
+
|
|
75
|
+
<script>
|
|
76
|
+
// Initialize Video.js player
|
|
77
|
+
var player = videojs('myVideo');
|
|
78
|
+
|
|
79
|
+
// Configure New Relic tracker with info from one.newrelic.com
|
|
80
|
+
const options = {
|
|
81
|
+
info: {
|
|
82
|
+
licenseKey: 'YOUR_LICENSE_KEY',
|
|
83
|
+
beacon: 'YOUR_BEACON_URL',
|
|
84
|
+
applicationId: 'YOUR_APP_ID',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Initialize tracker
|
|
89
|
+
const tracker = new VideojsTracker(player, options);
|
|
90
|
+
</script>
|
|
30
91
|
</body>
|
|
31
92
|
</html>
|
|
32
93
|
```
|
|
33
94
|
|
|
34
|
-
|
|
95
|
+
**Setup Steps:**
|
|
96
|
+
|
|
97
|
+
1. **Get Configuration** - Visit [one.newrelic.com](https://one.newrelic.com) and follow the Streaming Video & Ads onboarding flow to get your `licenseKey`, `beacon`, `applicationID`, and integration code snippet.
|
|
98
|
+
2. **Integrate** - Include the script in your HTML and initialize with your configuration
|
|
99
|
+
|
|
100
|
+
## Prerequisites
|
|
101
|
+
|
|
102
|
+
Before using the tracker, ensure you have:
|
|
103
|
+
|
|
104
|
+
- **New Relic Account** - Active New Relic account with valid application credentials (`beacon`, `applicationId`, `licenseKey`)
|
|
105
|
+
- **Video.js Player** - Video.js player integrated in your application
|
|
106
|
+
|
|
107
|
+
## Usage
|
|
108
|
+
|
|
109
|
+
### Getting Your Configuration
|
|
35
110
|
|
|
36
|
-
|
|
111
|
+
Before initializing the tracker, obtain your New Relic configuration:
|
|
37
112
|
|
|
38
|
-
|
|
39
|
-
|
|
113
|
+
1. Log in to [one.newrelic.com](https://one.newrelic.com)
|
|
114
|
+
2. Navigate to the video agent onboarding flow
|
|
115
|
+
3. Copy your credentials: `licenseKey`, `beacon`, and `applicationId`
|
|
116
|
+
|
|
117
|
+
### Basic Setup
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
import VideojsTracker from '@newrelic/video-videojs';
|
|
121
|
+
|
|
122
|
+
// Initialize Video.js player
|
|
123
|
+
const player = videojs('myVideo');
|
|
124
|
+
|
|
125
|
+
// Set player version (required)
|
|
126
|
+
player.version = videojs.VERSION;
|
|
127
|
+
|
|
128
|
+
// Configure tracker with credentials from one.newrelic.com
|
|
129
|
+
const options = {
|
|
130
|
+
info: {
|
|
131
|
+
licenseKey: 'YOUR_LICENSE_KEY',
|
|
132
|
+
beacon: 'YOUR_BEACON_URL',
|
|
133
|
+
applicationId: 'YOUR_APP_ID',
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Initialize tracker
|
|
138
|
+
const tracker = new VideojsTracker(player, options);
|
|
40
139
|
```
|
|
41
140
|
|
|
42
|
-
|
|
43
|
-
|
|
141
|
+
### Advanced Configuration
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
const options = {
|
|
145
|
+
info: {
|
|
146
|
+
licenseKey: 'YOUR_LICENSE_KEY',
|
|
147
|
+
beacon: 'YOUR_BEACON_URL',
|
|
148
|
+
applicationId: 'YOUR_APP_ID',
|
|
149
|
+
},
|
|
150
|
+
config: {
|
|
151
|
+
qoeAggregate: true, // Enable QoE event aggregation
|
|
152
|
+
qoeIntervalFactor: 2, // Send QoE events every 2 harvest cycles
|
|
153
|
+
},
|
|
154
|
+
customData: {
|
|
155
|
+
contentTitle: 'My Video Title',
|
|
156
|
+
customPlayerName: 'MyCustomPlayer',
|
|
157
|
+
customAttribute: 'customValue',
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const tracker = new VideojsTracker(player, options);
|
|
44
162
|
```
|
|
45
163
|
|
|
46
|
-
##
|
|
164
|
+
## Best Practices
|
|
165
|
+
|
|
166
|
+
### 1. Setting `contentTitle`
|
|
167
|
+
|
|
168
|
+
The `contentTitle` attribute will display a value if your video metadata contains title information. If the metadata does not include a title, `contentTitle` will not be populated. For best results, ensure you explicitly set this attribute during initialization:
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
const tracker = new VideojsTracker(player, {
|
|
172
|
+
info: {
|
|
173
|
+
licenseKey: 'YOUR_LICENSE_KEY',
|
|
174
|
+
beacon: 'YOUR_BEACON_URL',
|
|
175
|
+
applicationId: 'YOUR_APP_ID',
|
|
176
|
+
},
|
|
177
|
+
customData: {
|
|
178
|
+
contentTitle: 'My Video Title', // Explicitly set from your metadata
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
```
|
|
47
182
|
|
|
183
|
+
If your title changes dynamically (e.g., playlist or queue):
|
|
48
184
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
185
|
+
```javascript
|
|
186
|
+
tracker.setOptions({
|
|
187
|
+
customData: {
|
|
188
|
+
contentTitle: 'New Video Title',
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
```
|
|
52
192
|
|
|
53
|
-
|
|
54
|
-
- Create a New Relic account and obtain your license key.
|
|
55
|
-
- Install the New Relic Streaming video agent in your application.
|
|
56
|
-
- Configure the video agent with your license key and application ID.
|
|
193
|
+
### 2. Setting `userId`
|
|
57
194
|
|
|
58
|
-
|
|
195
|
+
Set a user identifier to track video analytics per user:
|
|
59
196
|
|
|
60
197
|
```javascript
|
|
61
|
-
|
|
62
|
-
|
|
198
|
+
// Set userId during initialization
|
|
199
|
+
const tracker = new VideojsTracker(player, {
|
|
63
200
|
info: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
201
|
+
licenseKey: 'YOUR_LICENSE_KEY',
|
|
202
|
+
beacon: 'YOUR_BEACON_URL',
|
|
203
|
+
applicationId: 'YOUR_APP_ID',
|
|
67
204
|
},
|
|
68
|
-
|
|
205
|
+
customData: {
|
|
206
|
+
contentTitle: 'Video Title',
|
|
207
|
+
userId: 'user-12345',
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Or set userId separately using the API method
|
|
212
|
+
tracker.setUserId('user-12345');
|
|
69
213
|
```
|
|
70
214
|
|
|
215
|
+
### 3. Adding Custom Attributes for Your Deployment
|
|
216
|
+
|
|
217
|
+
Add custom attributes unique to your deployment to improve data aggregation and analysis:
|
|
218
|
+
|
|
71
219
|
```javascript
|
|
72
|
-
|
|
220
|
+
const tracker = new VideojsTracker(player, {
|
|
221
|
+
info: {
|
|
222
|
+
licenseKey: 'YOUR_LICENSE_KEY',
|
|
223
|
+
beacon: 'YOUR_BEACON_URL',
|
|
224
|
+
applicationId: 'YOUR_APP_ID',
|
|
225
|
+
},
|
|
226
|
+
customData: {
|
|
227
|
+
// Required for identification
|
|
228
|
+
contentTitle: videoMetadata.title,
|
|
229
|
+
userId: currentUser.id,
|
|
230
|
+
|
|
231
|
+
// Custom attributes for your deployment
|
|
232
|
+
subscriptionTier: 'premium', // User subscription level
|
|
233
|
+
contentProvider: 'studio-abc', // Content source
|
|
234
|
+
region: 'us-west-2', // Geographic region
|
|
235
|
+
cdnProvider: 'cloudflare', // CDN being used
|
|
236
|
+
deviceType: 'desktop', // Device category
|
|
237
|
+
appVersion: '2.1.0', // Your app version
|
|
238
|
+
campaign: 'spring-promo', // Marketing campaign
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Use these attributes in New Relic queries:**
|
|
244
|
+
|
|
245
|
+
```sql
|
|
246
|
+
-- Analyze by subscription tier
|
|
247
|
+
SELECT count(*) FROM VideoAction WHERE actionName = 'CONTENT_START'
|
|
248
|
+
FACET subscriptionTier SINCE 1 day ago
|
|
249
|
+
|
|
250
|
+
-- Monitor by region
|
|
251
|
+
SELECT average(contentNetworkDownloadBitrate) FROM VideoAction
|
|
252
|
+
FACET region SINCE 1 hour ago
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### 4. Gradual Rollout with Feature Flags
|
|
73
256
|
|
|
74
|
-
|
|
257
|
+
When deploying to production, use feature flags to enable the tracker gradually. This helps you:
|
|
258
|
+
|
|
259
|
+
- Validate data collection without impacting all users
|
|
260
|
+
- Monitor performance impact at scale
|
|
261
|
+
- Catch issues before full deployment
|
|
262
|
+
- Control monitoring costs
|
|
263
|
+
|
|
264
|
+
```javascript
|
|
265
|
+
// Example using a feature flag
|
|
266
|
+
const rolloutPercentage = 5; // Start with 5% of users
|
|
267
|
+
|
|
268
|
+
function shouldEnableTracking(userId) {
|
|
269
|
+
// Simple percentage-based rollout
|
|
270
|
+
const hash = userId
|
|
271
|
+
.split('')
|
|
272
|
+
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
|
273
|
+
return hash % 100 < rolloutPercentage;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const player = videojs('myVideo');
|
|
75
277
|
player.version = videojs.VERSION;
|
|
76
278
|
|
|
77
|
-
// initialize
|
|
78
|
-
|
|
279
|
+
// Only initialize tracker if user is in rollout
|
|
280
|
+
if (shouldEnableTracking(currentUser.id)) {
|
|
281
|
+
const tracker = new VideojsTracker(player, {
|
|
282
|
+
info: {
|
|
283
|
+
licenseKey: 'YOUR_LICENSE_KEY',
|
|
284
|
+
beacon: 'YOUR_BEACON_URL',
|
|
285
|
+
applicationId: 'YOUR_APP_ID',
|
|
286
|
+
},
|
|
287
|
+
customData: {
|
|
288
|
+
contentTitle: videoMetadata.title,
|
|
289
|
+
userId: currentUser.id,
|
|
290
|
+
rolloutGroup: `${rolloutPercentage}%`, // Track which rollout group
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
```
|
|
79
295
|
|
|
80
|
-
|
|
296
|
+
**Recommended Rollout Schedule:**
|
|
81
297
|
|
|
82
|
-
|
|
83
|
-
|
|
298
|
+
| Phase | Percentage | Duration | Validation |
|
|
299
|
+
| --------- | ---------- | --------- | ---------------------------------- |
|
|
300
|
+
| Initial | 5% | 2-3 days | Verify data flowing to New Relic |
|
|
301
|
+
| Early | 15% | 3-5 days | Check data quality and performance |
|
|
302
|
+
| Expansion | 25% | 5-7 days | Validate across device types |
|
|
303
|
+
| Majority | 50% | 1-2 weeks | Monitor at scale |
|
|
304
|
+
| Full | 100% | Ongoing | Complete deployment |
|
|
305
|
+
|
|
306
|
+
## Configuration Options
|
|
307
|
+
|
|
308
|
+
### QoE (Quality of Experience) Settings
|
|
309
|
+
|
|
310
|
+
| Option | Type | Default | Description |
|
|
311
|
+
| ------------------- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
312
|
+
| `qoeAggregate` | boolean | `false` | Enable Quality of Experience event aggregation. Set to `true` to collect QoE metrics like startup time, buffering, and average bitrate. |
|
|
313
|
+
| `qoeIntervalFactor` | number | `1` | Controls QoE event frequency. A value of `N` sends QoE events once every N harvest cycles. Must be a positive integer. QoE events are always included on first and final harvest cycles. |
|
|
314
|
+
|
|
315
|
+
### Custom Data
|
|
316
|
+
|
|
317
|
+
Add custom attributes to all events:
|
|
318
|
+
|
|
319
|
+
```javascript
|
|
320
|
+
customData: {
|
|
321
|
+
contentTitle: 'My Video Title', // Override video title
|
|
322
|
+
customPlayerName: 'MyPlayer', // Custom player identifier
|
|
323
|
+
customPlayerVersion: '1.0.0', // Custom player version
|
|
324
|
+
userId: '12345', // User identifier
|
|
325
|
+
// Add any custom attributes you need
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
> **Limit:** The maximum total number of custom attributes per event is **150**. Any attributes beyond this limit will be dropped.
|
|
330
|
+
|
|
331
|
+
> **Note:** There are special reserved keywords used for default attributes (such as `actionName`, `contentBitrate`, `playerName`, `viewSession`, etc.). Please do not use these as custom attribute names, as they will be dropped. See [DATAMODEL.md](./DATAMODEL.md) for the complete list of reserved attribute names.
|
|
332
|
+
|
|
333
|
+
## API Reference
|
|
334
|
+
|
|
335
|
+
### Core Methods
|
|
336
|
+
|
|
337
|
+
#### `tracker.setUserId(userId)`
|
|
338
|
+
|
|
339
|
+
Set a unique identifier for the current user.
|
|
340
|
+
|
|
341
|
+
```javascript
|
|
342
|
+
tracker.setUserId('user-12345');
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
#### `tracker.setHarvestInterval(milliseconds)`
|
|
346
|
+
|
|
347
|
+
Configure how frequently data is sent to New Relic. Accepts values between 1000ms (1 second) and 300000ms (5 minutes).
|
|
348
|
+
|
|
349
|
+
```javascript
|
|
350
|
+
tracker.setHarvestInterval(30000); // Send data every 30 seconds
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### `tracker.sendCustom(actionName, attributes)`
|
|
354
|
+
|
|
355
|
+
Send custom events with arbitrary attributes.
|
|
356
|
+
|
|
357
|
+
```javascript
|
|
358
|
+
tracker.sendCustom('VideoBookmarked', {
|
|
359
|
+
timestamp: Date.now(),
|
|
360
|
+
position: player.currentTime(),
|
|
361
|
+
userId: 'user-12345',
|
|
362
|
+
bookmarkId: 'bookmark-789',
|
|
363
|
+
});
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
#### `tracker.setOptions(options)`
|
|
367
|
+
|
|
368
|
+
Update tracker configuration after initialization.
|
|
369
|
+
|
|
370
|
+
```javascript
|
|
371
|
+
tracker.setOptions({
|
|
84
372
|
customData: {
|
|
85
|
-
contentTitle: '
|
|
86
|
-
|
|
87
|
-
|
|
373
|
+
contentTitle: 'New Video Title',
|
|
374
|
+
season: '1',
|
|
375
|
+
episode: '3',
|
|
376
|
+
},
|
|
377
|
+
});
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Example: Complete Integration
|
|
381
|
+
|
|
382
|
+
```javascript
|
|
383
|
+
import VideojsTracker from '@newrelic/video-videojs';
|
|
384
|
+
|
|
385
|
+
// Initialize player and tracker
|
|
386
|
+
const player = videojs('myVideo');
|
|
387
|
+
player.version = videojs.VERSION;
|
|
388
|
+
|
|
389
|
+
const tracker = new VideojsTracker(player, {
|
|
390
|
+
info: {
|
|
391
|
+
licenseKey: 'YOUR_LICENSE_KEY',
|
|
392
|
+
beacon: 'YOUR_BEACON_URL',
|
|
393
|
+
applicationId: 'YOUR_APP_ID',
|
|
88
394
|
},
|
|
395
|
+
config: {
|
|
396
|
+
qoeAggregate: true,
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// Set user context
|
|
401
|
+
tracker.setUserId('user-12345');
|
|
402
|
+
|
|
403
|
+
// Configure reporting interval
|
|
404
|
+
tracker.setHarvestInterval(30000);
|
|
405
|
+
|
|
406
|
+
// Send custom events
|
|
407
|
+
player.on('userEngagement', () => {
|
|
408
|
+
tracker.sendCustom('UserEngaged', {
|
|
409
|
+
action: 'like',
|
|
410
|
+
timestamp: Date.now(),
|
|
411
|
+
});
|
|
89
412
|
});
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
## Bitrate Metrics
|
|
90
416
|
|
|
91
|
-
|
|
92
|
-
tracker.setUserId('userId');
|
|
417
|
+
The tracker captures four distinct bitrate metrics providing complete quality analysis:
|
|
93
418
|
|
|
94
|
-
|
|
95
|
-
|
|
419
|
+
| Attribute | Description | Use Case |
|
|
420
|
+
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
|
|
421
|
+
| `contentBitrate` | Encoding bitrate (in bps) of the currently playing rendition from the manifest | Monitor actual video quality being delivered |
|
|
422
|
+
| `contentManifestBitrate` | Maximum available bitrate (in bps) across all renditions in the manifest. Represents the highest quality capability of the stream | Understand maximum quality potential |
|
|
423
|
+
| `contentSegmentDownloadBitrate` | ABR estimated bandwidth (in bps) from the player's stats object, used by the ABR algorithm for quality switching decisions | Analyze ABR decision-making |
|
|
424
|
+
| `contentNetworkDownloadBitrate` | Instantaneous download throughput (in bps) from the most recent segment download. Represents raw network download speed | Monitor real-time network performance |
|
|
96
425
|
|
|
97
|
-
|
|
98
|
-
tracker.sendCustom('CustomAction', { data: "custom-test" })
|
|
426
|
+
### Bitrate Monitoring Example
|
|
99
427
|
|
|
428
|
+
```javascript
|
|
429
|
+
// All bitrate metrics are automatically captured and sent with each event
|
|
430
|
+
// Access them in New Relic Insights queries:
|
|
431
|
+
|
|
432
|
+
// NRQL Query Examples:
|
|
433
|
+
// SELECT average(contentNetworkDownloadBitrate) FROM VideoAction WHERE actionName = 'CONTENT_HEARTBEAT'
|
|
434
|
+
// SELECT contentBitrate, contentSegmentDownloadBitrate FROM VideoAction WHERE actionName = 'CONTENT_RENDITION_CHANGE'
|
|
100
435
|
```
|
|
101
436
|
|
|
102
|
-
##
|
|
437
|
+
## Ad Tracking Support
|
|
438
|
+
|
|
439
|
+
The tracker provides comprehensive ad tracking capabilities:
|
|
103
440
|
|
|
104
|
-
|
|
105
|
-
> **Attention:**
|
|
106
|
-
> This version supports tracking for SSAI (Server-Side Ad Insertion), checkout examples in [/samples/dai/index.html](./samples/dai/index.html)
|
|
441
|
+
### Supported Ad Technologies
|
|
107
442
|
|
|
443
|
+
- **IMA (Interactive Media Ads)** - Google IMA SDK integration
|
|
444
|
+
- **Freewheel** - Freewheel ad platform support
|
|
445
|
+
- **SSAI (Server-Side Ad Insertion)** - Dynamic Ad Insertion (DAI) support
|
|
446
|
+
|
|
447
|
+
### SSAI/DAI Integration
|
|
448
|
+
|
|
449
|
+
Server-Side Ad Insertion is fully supported with automatic detection and tracking:
|
|
450
|
+
|
|
451
|
+
```javascript
|
|
452
|
+
// SSAI is automatically detected - no additional configuration needed
|
|
453
|
+
const tracker = new VideojsTracker(player, options);
|
|
454
|
+
|
|
455
|
+
// The tracker will automatically capture:
|
|
456
|
+
// - Ad breaks, starts, and completions
|
|
457
|
+
// - Ad quartiles and click events
|
|
458
|
+
// - SSAI-specific metadata
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
**Example:** See [samples/dai/index.html](./samples/dai/index.html) for a complete SSAI implementation.
|
|
108
462
|
|
|
109
463
|
## Data Model
|
|
110
464
|
|
|
111
|
-
|
|
465
|
+
The tracker captures comprehensive video analytics across four event types:
|
|
466
|
+
|
|
467
|
+
- **VideoAction** - Playback events (play, pause, buffer, seek, quality changes, heartbeats)
|
|
468
|
+
- **VideoAdAction** - Ad events (ad start, quartiles, completions, clicks)
|
|
469
|
+
- **VideoErrorAction** - Error events (playback failures, network errors, media errors)
|
|
470
|
+
- **VideoCustomAction** - Custom events defined by your application
|
|
471
|
+
|
|
472
|
+
**Full Documentation:** See [DATAMODEL.md](./DATAMODEL.md) for complete event and attribute reference.
|
|
112
473
|
|
|
113
474
|
## Support
|
|
114
475
|
|
|
115
|
-
|
|
476
|
+
Should you need assistance with New Relic products, you are in good hands with several support channels.
|
|
116
477
|
|
|
117
|
-
|
|
478
|
+
If the issue has been confirmed as a bug or is a feature request, please file a [GitHub issue](../../issues).
|
|
118
479
|
|
|
119
|
-
|
|
480
|
+
### Support Channels
|
|
120
481
|
|
|
121
|
-
|
|
482
|
+
- **[New Relic Documentation](https://docs.newrelic.com)**: Comprehensive guidance for using our platform
|
|
483
|
+
- **[New Relic Community](https://discuss.newrelic.com)**: The best place to engage in troubleshooting questions
|
|
484
|
+
- **[New Relic University](https://learn.newrelic.com)**: A range of online training for New Relic users of every level
|
|
485
|
+
- **[New Relic Technical Support](https://support.newrelic.com)**: 24/7/365 ticketed support. Read more about our [Technical Support Offerings](https://docs.newrelic.com/docs/licenses/license-information/general-usage-licenses/support-plan)
|
|
122
486
|
|
|
123
|
-
|
|
487
|
+
### Additional Resources
|
|
488
|
+
|
|
489
|
+
- **[DATAMODEL.md](./DATAMODEL.md)** - Complete event and attribute reference
|
|
490
|
+
- **[DEVELOPING.md](./DEVELOPING.md)** - Building and testing instructions
|
|
491
|
+
- **[REVIEW.md](./REVIEW.md)** - Code review guidelines
|
|
492
|
+
|
|
493
|
+
## Contribute
|
|
494
|
+
|
|
495
|
+
We encourage your contributions to improve the Video.js Tracker! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
|
|
496
|
+
|
|
497
|
+
If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at opensource@newrelic.com.
|
|
498
|
+
|
|
499
|
+
For more details on how best to contribute, see [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
500
|
+
|
|
501
|
+
### A note about vulnerabilities
|
|
124
502
|
|
|
125
503
|
As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
|
|
126
504
|
|
|
127
|
-
If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through
|
|
505
|
+
If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through our [bug bounty program](https://docs.newrelic.com/docs/security/security-privacy/information-security/report-security-vulnerabilities/).
|
|
506
|
+
|
|
507
|
+
If you would like to contribute to this project, review [these guidelines](./CONTRIBUTING.md).
|
|
508
|
+
|
|
509
|
+
To all contributors, we thank you! Without your contribution, this project would not be what it is today.
|
|
128
510
|
|
|
129
511
|
## License
|
|
130
512
|
|
|
131
|
-
|
|
513
|
+
The Video.js Tracker is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
|
|
514
|
+
|
|
515
|
+
The Video.js Tracker also uses source code from third-party libraries. Full details on which libraries are used and the terms under which they are licensed can be found in the [third-party notices document](./THIRD_PARTY_NOTICES.md).
|