From c60eab6a35fb6d224a4ec99d274ff100afeb411e Mon Sep 17 00:00:00 2001 From: mlychndnnr Date: Wed, 19 Feb 2025 17:33:03 +0530 Subject: [PATCH 1/2] Tresser plugin added --- package-lock.json | 10 +++++----- package.json | 4 ++-- src/tracker.js | 2 -- webpack.config.js | 45 ++++++++++++++++++++++++++++----------------- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e0da7c..12d2f06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "newrelic-video-shaka", - "version": "0.3.0", + "version": "3.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "newrelic-video-shaka", - "version": "0.3.0", + "version": "3.0.0", "license": "MIT", "dependencies": { "codem-isoboxer": "^0.3.10", - "newrelic-video-core": "github:newrelic/video-core-js#develop" + "newrelic-video-core": "github:newrelic/video-core-js#stable" }, "devDependencies": { "@babel/core": "^7.0.0", @@ -7100,8 +7100,8 @@ "license": "MIT" }, "node_modules/newrelic-video-core": { - "version": "0.33.0", - "resolved": "git+ssh://git@github.com/newrelic/video-core-js.git#6df65c29a2a9ef61245d17b98a7b834949904aa3", + "version": "3.0.0", + "resolved": "git+ssh://git@github.com/newrelic/video-core-js.git#60d235a402fd3d29a55cd34a01ee51e3014470d3", "license": "MIT" }, "node_modules/node-int64": { diff --git a/package.json b/package.json index 9918591..2dd18b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "newrelic-video-shaka", - "version": "0.3.0", + "version": "3.0.0", "description": "New relic tracker for shaka player", "main": "src/index.js", "scripts": { @@ -22,7 +22,7 @@ "license": "MIT", "dependencies": { "codem-isoboxer": "^0.3.10", - "newrelic-video-core": "github:newrelic/video-core-js#develop" + "newrelic-video-core": "github:newrelic/video-core-js#stable" }, "devDependencies": { "@babel/core": "^7.0.0", diff --git a/src/tracker.js b/src/tracker.js index 44707eb..0ad6ace 100644 --- a/src/tracker.js +++ b/src/tracker.js @@ -39,8 +39,6 @@ export default class ShakaTracker extends nrvideo.VideoTracker { return this.player.getPlaybackRate(); } - getContentPlayhead() {} - getTrack() { var tracks = this.player.getVariantTracks(); for (var i in tracks) { diff --git a/webpack.config.js b/webpack.config.js index e8d41ca..b9b52ab 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,11 +1,18 @@ -var path = require('path') -var webpack = require('webpack') +var path = require('path'); +var webpack = require('webpack'); +var TerserPlugin = require('terser-webpack-plugin'); -var pkg = require('./package.json') -var license = '@license ' + pkg.license + - '\n' + pkg.name + ' ' + pkg.version + - '\nCopyright New Relic ' + - '\n@author ' + pkg.author +var pkg = require('./package.json'); +var license = + '@license ' + + pkg.license + + '\n' + + pkg.name + + ' ' + + pkg.version + + '\nCopyright New Relic ' + + '\n@author ' + + pkg.author; module.exports = { entry: './src/index.js', @@ -13,7 +20,7 @@ module.exports = { path: path.resolve(__dirname, './dist'), filename: pkg.name + '.min.js', library: 'nrvideo', - libraryTarget: 'umd' + libraryTarget: 'umd', }, devtool: 'source-map', module: { @@ -23,16 +30,20 @@ module.exports = { use: { loader: 'babel-loader', options: { - presets: [['@babel/preset-env', { targets: "defaults" }]] - } - } - } - ] + presets: [['@babel/preset-env', { targets: 'defaults' }]], + }, + }, + }, + ], + }, + optimization: { + minimize: true, + minimizer: [new TerserPlugin()], }, plugins: [ new webpack.BannerPlugin({ banner: license, - entryOnly: true - }) - ] -} + entryOnly: true, + }), + ], +}; From 02760a45376ca6b2aea02556a318c29c26eb8178 Mon Sep 17 00:00:00 2001 From: mlychndnnr Date: Fri, 21 Feb 2025 11:27:07 +0530 Subject: [PATCH 2/2] update: readme.md updated --- CHANGELOG.md | 7 ++ DATAMODEL.md | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++ DEVELOPING.md | 48 +++++++++++ README.md | 82 +++++++++++------- 4 files changed, 333 insertions(+), 29 deletions(-) create mode 100644 DATAMODEL.md create mode 100644 DEVELOPING.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 0816d08..22b80a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +## [3.0.0] - 2025/02/21 + +### New Event Type Introduced [VideoAction, VideoErrorAction, VideoAdAction, VideoCustomAction] + +- PageAction Deprecated. +- Some New Attributes Introduced. + ## [0.4.0] - 2024/10/07 ### Update diff --git a/DATAMODEL.md b/DATAMODEL.md new file mode 100644 index 0000000..e2d0549 --- /dev/null +++ b/DATAMODEL.md @@ -0,0 +1,225 @@ +# Introduction + +This document provides an overview of the Events and Attributes used for media monitoring in New Relic. + +# Glossary + +This section defines the key terms used in the context of New Relic Media monitoring: + +## Event Types + +- **videoAction**: Events triggered by general video interactions, such as starting, pausing, or seeking. +- **videoAdAction**: Events related to ad playback, such as starting, completing, or skipping an ad. +- **videoErrorAction**: Events triggered by errors encountered during video or ad playback. +- **videoCustomAction**: Custom events defined to capture specific actions or interactions beyond default event types. + +## Attribute + +An Attribute is a piece of data associated with an event. Attributes provide additional context or details about the event, such as the video’s title, duration, or playback position. + +- Most attributes are included with every event. +- Some attributes are specific to certain event types, such as ad-related data sent with ad events. + +## Event Type Reference + +### VideoAction + +| Attribute Name | Definition | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| actionName | The specific action being performed in the video player, such as play, pause, resume, content buffering, etc. | +| appId | The ID of your application, as recorded by New Relic. | +| appName | The name of the application. | +| playerName | The name of the video player. | +| playerVersion | The version of the video player. | +| deviceType | The specific type of the device: iPhone 8, iPad Pro, etc. | +| deviceGroup | The category of the device, such as iPhone or Tablet. | +| deviceManufacturer | The manufacturer of the device, such as Motorola or HTC. | +| deviceModel | The model number of the device. | +| deviceName | The device's name. | +| deviceSize | The display size of the device: Small, normal, large, xlarge. | +| deviceUuid | A unique identifier assigned at the time of app installation by New Relic. | +| viewSession | Trackers will generate unique IDs for every new video session. This could be the session ID from the client. | +| viewId | Trackers will generate unique IDs for every new video iteration. | +| contentId | The ID of the video. | +| contentTitle | The title of the video. | +| contentIsLive | True if the video is live. | +| contentBitrate | Bitrate (in bits) of the video. | +| contentRenditionName | Name of the rendition (e.g., 1080p). | +| contentRenditionBitrate | Target Bitrate of the rendition. | +| contentRenditionHeight | Rendition actual Height (before re-scaling). | +| contentRenditionWidth | Rendition actual Width (before re-scaling). | +| contentDuration | Duration of the video, in ms. | +| contentPlayhead | Playhead (currentTime) of the video, in ms. | +| contentLanguage | Language of the video. We recommend using locale notation, e.g., en_US. | +| contentSrc | URL of the resource being played. | +| contentPlayrate | Playrate (speed) of the video, e.g., 1.0, 0.5, 1.25. | +| contentIsFullscreen | True if the video is currently fullscreen. | +| contentIsMuted | True if the video is currently muted. | +| contentCdn | The CDN serving the content. | +| contentIsAutoplayed | If the player was auto-played. | +| contentPreload | The player preload attribute. | +| contentFps | Current FPS (Frames per second). | +| isBackgroundEvent | If the player is hidden by another window. | +| totalAdPlaytime | Total time ad is played for this video session. | +| elapsedTime | Time that has passed since the last event. | +| bufferType | When buffer starts, i.e., initial, seek, pause & connection. | +| asn | Autonomous System Number: a unique number identifying a group of IP networks that serves the content to the end user. | +| asnLatitude | The latitude of the geographic center of the postal code where the Autonomous System Network is registered. This is not the end user's latitude. | +| asnLongitude | The longitude of the geographic center of the postal code where the Autonomous System Network is registered. This is not the end user's longitude. | +| asnOrganization | The organization that owns the Autonomous System Number. Often an ISP, sometimes a private company or institution. | +| timestamp | The time (date, hour, minute, second) at which the interaction occurred. | +| instrumentation.provider | Player/agent name. | +| instrumentation.name | Name of the instrumentation collecting the data. | +| instrumentation.version | Agent’s version. | + +#### List of possible Video Actions + +| Action Name | Definition | +| ------------------------ | ------------------------------------------------------------------------------------------------ | +| PLAYER_READY | The player is ready to start sending events. | +| DOWNLOAD | Downloading data. | +| CONTENT_REQUEST | Content video has been requested. | +| CONTENT_START | Content video started (first frame shown). | +| CONTENT_END | Content video ended. | +| CONTENT_PAUSE | Content video paused. | +| CONTENT_RESUME | Content video resumed. | +| CONTENT_SEEK_START | Content video seek started. | +| CONTENT_SEEK_END | Content video seek ended. | +| CONTENT_BUFFER_START | Content video buffering started. | +| CONTENT_BUFFER_END | Content video buffering ended. | +| CONTENT_HEARTBEAT | Content video heartbeat, an event that happens once every 30 seconds while the video is playing. | +| CONTENT_RENDITION_CHANGE | Content video stream quality changed. | + +### VideoAdAction + +| Attribute Name | Definition | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| actionName | The specific action being performed in the video player, such as play, pause, resume, content buffering, etc. | +| appId | The ID of your application, as recorded by New Relic. | +| appName | The name of the application. | +| playerName | The name of the video player. | +| playerVersion | The version of the video player. | +| deviceType | The specific type of the device: iPhone 8, iPad Pro, etc. | +| deviceGroup | The category of the device, such as iPhone or Tablet. | +| deviceManufacturer | The manufacturer of the device, such as Motorola or HTC. | +| deviceModel | The model number of the device. | +| viewSession | Trackers will generate unique IDs for every new video session. This could be the session ID from the client. | +| viewId | Trackers will generate unique IDs for every new video iteration. | +| adId | The ID of the video. | +| adTitle | The title of the video. | +| adBitrate | Bitrate (in bits) of the video. | +| adRenditionName | Name of the rendition (e.g., 1080p). | +| adRenditionBitrate | Target Bitrate of the rendition. | +| adRenditionHeight | Rendition actual Height (before re-scaling). | +| adRenditionWidth | Rendition actual Width (before re-scaling). | +| adDuration | Duration of the video, in ms. | +| adPlayhead | Playhead (currentTime) of the video, in ms. | +| adLanguage | Language of the ad video. We recommend using locale notation, e.g., en_US. | +| adSrc | URL of the resource being played. | +| adCdn | The CDN serving the content. | +| adIsMuted | True if the video is currently muted. | +| adFps | Current FPS (Frames per second). | +| adQuartile | Quartile of the ad. 0 before first, 1 after first quartile, 2 after midpoint, 3 after third quartile, 4 when completed. | +| adPosition | The position of the ad. | +| adCreativeId | The creative ID of the ad. | +| adPartner | The ad partner, e.g., ima, freewheel. | +| isBackgroundEvent | If the player is hidden by another window. | +| bufferType | When buffer starts, i.e., initial, seek, pause & connection. | +| asn | Autonomous System Number: a unique number identifying a group of IP networks that serves the content to the end user. | +| asnLatitude | The latitude of the geographic center of the postal code where the Autonomous System Network is registered. This is not the end user's latitude. | +| asnLongitude | The longitude of the geographic center of the postal code where the Autonomous System Network is registered. This is not the end user's longitude. | +| asnOrganization | The organization that owns the Autonomous System Number. Often an ISP, sometimes a private company or institution. | +| timestamp | The time (date, hour, minute, second) at which the interaction occurred. | +| elapsedTime | Time that has passed since the last event. | +| instrumentation.provider | Player/agent name. | +| instrumentation.name | Name of the instrumentation collecting the data. | +| instrumentation.version | Agent’s version. | + +#### List of possible Video Ad Actions + +| Action Name | Definition | +| ------------------- | ------------------------------------------------------------------------------------------- | +| AD_REQUEST | Ad video has been requested. | +| AD_START | Ad video started (first frame shown). | +| AD_END | Ad video ended. | +| AD_PAUSE | Ad video paused. | +| AD_RESUME | Ad video resumed. | +| AD_SEEK_START | Ad video seek started. | +| AD_SEEK_END | Ad video seek ended. | +| AD_BUFFER_START | Ad video buffering started. | +| AD_BUFFER_END | Ad video buffering ended. | +| AD_HEARTBEAT | Ad video heartbeat, an event that happens once every 30 seconds while the video is playing. | +| AD_RENDITION_CHANGE | Ad video stream quality changed. | +| AD_BREAK_START | Ad break (a block of ads) started. | +| AD_BREAK_END | Ad break ended. | +| AD_QUARTILE | Ad quartile happened. | +| AD_CLICK | Ad has been clicked. | + +### VideoErrorAction + +| Attribute Name | Definition | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| actionName | The specific action being performed in the video player, such as play, pause, resume, content buffering, etc. | +| appId | The ID of your application, as recorded by New Relic. | +| appName | The name of the application. | +| playerName | The name of the video player. | +| playerVersion | The version of the video player. | +| deviceType | The specific type of the device: iPhone 8, iPad Pro, etc. | +| deviceGroup | The category of the device, such as iPhone or Tablet. | +| deviceManufacturer | The manufacturer of the device, such as Motorola or HTC. | +| deviceModel | The model number of the device. | +| viewSession | Trackers will generate unique IDs for every new video session. This could be the session ID from the client. | +| viewId | Trackers will generate unique IDs for every new video iteration. | +| contentId | The ID of the video. | +| contentTitle | The title of the video. | +| errorName | Name of the error. | +| errorCode | Error code if it's known. | +| backTrace | Stack trace of the error. | +| isBackgroundEvent | If the player is hidden by another window. | +| contentSrc | Content source URL. | +| contentCdn | Content CDN URL. | +| asn | Autonomous System Number: a unique number identifying a group of IP networks that serves the content to the end user. | +| asnLatitude | The latitude of the geographic center of the postal code where the Autonomous System Network is registered. This is not the end user's latitude. | +| asnLongitude | The longitude of the geographic center of the postal code where the Autonomous System Network is registered. This is not the end user's longitude. | +| asnOrganization | The organization that owns the Autonomous System Number. Often an ISP, sometimes a private company or institution. | +| elapsedTime | Time that has passed since the last event. | +| timestamp | The time (date, hour, minute, second) at which the interaction occurred. | +| instrumentation.provider | Player/agent name. | +| instrumentation.name | Name of the instrumentation collecting the data. | +| instrumentation.version | Agent’s version. | + +#### List of possible Video Error Actions + +| Action Name | Definition | +| ------------- | -------------------- | +| AD_ERROR | Ad video error. | +| ERROR | An error happened. | +| CRASH | App crash happened. | +| CONTENT_ERROR | Content video error. | + +### VideoCustomAction + +| Attribute Name | Definition | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| actionName | The name of the PageAction, as defined by client in their code. | +| appId | The ID of your application, as recorded by New Relic. | +| appName | The name of the application. | +| playerName | The name of the video player. | +| playerVersion | The version of the video player. | +| deviceType | The specific type of the device: iPhone 8, iPad Pro, etc. | +| deviceGroup | The category of the device, such as iPhone or Tablet. | +| deviceManufacturer | The manufacturer of the device, such as Motorola or HTC. | +| deviceModel | The model number of the device. | +| viewSession | Trackers will generate unique IDs for every new video session. This could be the session ID from the client. | +| viewId | Trackers will generate unique IDs for every new video iteration. | +| contentId | The ID of the video. | +| contentTitle | The title of the video. | +| isBackgroundEvent | If the player is hidden by another window. | +| asn | Autonomous System Number: a unique number identifying a group of IP networks that serves the content to the end user. | +| asnLatitude | The latitude of the geographic center of the postal code where the Autonomous System Network is registered. This is not the end user's latitude. | +| asnLongitude | The longitude of the geographic center of the postal code where the Autonomous System Network is registered. This is not the end user's longitude. | +| asnOrganization | The organization that owns the Autonomous System Number. Often an ISP, sometimes a private company or institution. | +| timestamp | The time (date, hour, minute, second) at which the interaction occurred. | +| instrumentation.provider | Player/agent name. | +| instrumentation.name | Name of the instrumentation collecting the data. | +| instrumentation.version | Agent’s version. | diff --git a/DEVELOPING.md b/DEVELOPING.md new file mode 100644 index 0000000..9202927 --- /dev/null +++ b/DEVELOPING.md @@ -0,0 +1,48 @@ +[![Community Project header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Project.png)](https://opensource.newrelic.com/oss-category/#community-project) + +# New Relic Shaka Tracker + +New Relic video tracking for Shaka Player. + +## Requirements + +This video monitor solutions works on top of New Relic's **Browser Agent**. + +## Build + +Install dependencies: + +``` +$ npm install +``` + +And build: + +``` +$ npm run build:dev +``` + +Or if you need a production build: + +``` +$ npm run build +``` + +## Usage + +Load **scripts** inside `dist` folder into your page. + +```html + +``` + +```javascript +nrvideo.Core.addTracker(new nrvideo.ShakaTracker(player)); +``` + +## Release + +- Create a PR. +- Once approved, Update the package version according to the semver rules. +- Update the CHANGELOG in the repo (all web repos have a changelog file). +- Create a github tag with the version. diff --git a/README.md b/README.md index dfee432..ad1a2c4 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,75 @@ -[![New Relic Experimental header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Experimental.png)](https://opensource.newrelic.com/oss-category/#new-relic-experimental) +[![Community Project header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Project.png)](https://opensource.newrelic.com/oss-category/#community-project) -# New Relic Shaka Tracker +# New Relic Shaka Tracker Agent -New Relic video tracking for Shaka Player. +The New Relic Shaka Tracker enhances your media applications by tracking video events, playback errors, and other activities, providing comprehensive insights into performance and user interactions. -## Requirements +- The Shaka tracker is available as a ready-to-use JavaScript snippet for easy copy-paste integration. +- New Relic Shaka tracker auto-detects events emitted by Shaka Player. +- Ensure that the **Browser agent** is successfully instrumented before deploying the media tracker. +- For questions and feedback on this package, please visit the [Explorer's Hub](https://discuss.newrelic.com), New Relic's community support forum. +- 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. -This video monitor solutions works on top of New Relic's **Browser Agent**. +## Adding The Shaka Tracker To Your Project -## Build +To integrate New Relic Tracker Agent into your web application effectively, you'll need to instrument the Browser Agent code first and then add the player script. Below is a guide on how to do this within your HTML file: -Install dependencies: - -``` -$ npm install +```html + + + + + + New Relic Tracker Integration + + + + + + + + ``` -And build: +## Instantiating the Shaka Tracker -``` -$ npm run build:dev -``` +```javascript +// Add a ShakaTracker +nrvideo.Core.addTracker(new nrvideo.ShakaTracker(player)); -Or if you need a production build: +// For setting userId +nrvideo.Core.addTracker(new nrvideo.ShakaTracker(player)).setUserId('userId'); -``` -$ npm run build -``` +//For setting custom attributes const tracker +const tracker = new nrvideo.ShakajsTracker(player, { + customData: { + contentTitle: 'Override Existing Title', + customPlayerName: 'myGreatPlayer', + customPlayerVersion: '9.4.2', + }, +}); -## Usage +// For Sending custom Action with Attributes -Load **scripts** inside `dist` folder into your page. +const tracker = new nrvideo.ShakaTracker(player); -```html - -``` +nrvideo.Core.addTracker(tracker); -```javascript -// var player = new shaka.Player(...) -nrvideo.Core.addTracker(new nrvideo.ShakaTracker(player)) +tracker.sendCustom('CUSTOM_ACTION', 'state time', { + test1: 'value1', + test2: 'value2', +}); ``` +## Data Model + +To understand which actions and attributes are captured and emitted by the Shaka Player under different event types, see [DataModel.md](./DATAMODEL.md). + ## Support -New Relic has open-sourced this project. This project is provided AS-IS WITHOUT WARRANTY OR DEDICATED SUPPORT. Issues and contributions should be reported to the project here on GitHub. +New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic [Explorer's Hub](https://discuss.newrelic.com). -We encourage you to bring your experiences and questions to the [Explorers Hub](https://discuss.newrelic.com) where our community members collaborate on solutions and new ideas. +We encourage you to bring your experiences and questions to the [Explorer's Hub](https://discuss.newrelic.com) where our community members collaborate on solutions and new ideas. ## Contributing @@ -59,4 +83,4 @@ If you believe you have found a security vulnerability in this project or any of ## License -New Relic Shaka Tracker is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License. \ No newline at end of file +New Relic Shaka Tracker is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.