NPAW **** Code samples: * NPAW (https://raw.githubusercontent.com/castlabs/prestoplay-web-code-samples/refs/heads/main/examples/analytics/npaw_v7.js): the complete setup with the NPAW v7 SDK, a custom "errorFilter", and buttons that trigger recoverable and fatal errors. To get started with NPAW analytics, install the NPAW SDK and NPAW adapters. Note: The legacy Youbora v6 SDK integration is still available. To use it instead, configure the player with a "youbora" key instead of "npaw". It uses a separate "YouboraConfiguration" (https://players.castlabs.com/web/latest/docs/api/clpp.YouboraConfiguration.md) — its options aren't identical to "npaw"'s. npm install npaw-plugin@7.3.21 npm install npaw-plugin-adapters@7.3.21 Alternatively, to install the ES5 version of the NPAW library, run: npm install npaw-plugin-es5@7.3.21 npm install npaw-plugin-adapters-es5s@7.3.21 Import the PRESTOplay Youbora plugin and the NPAW SDK: import {clpp} from "@castlabs/prestoplay"; import "@castlabs/prestoplay/cl.mse"; import "@castlabs/prestoplay/cl.dash"; import "@castlabs/prestoplay/cl.youbora"; import * as NpawPlugin from 'npaw-plugin'; import * as NpawPluginAdapters from 'npaw-plugin-adapters'; window.NpawPlugin = NpawPlugin; window.NpawPluginAdapters = NpawPluginAdapters; For custom NPAW configuration, see the example below. For full details, see the NPAW documentation (https://documentation.npaw.com/integration-docs/docs/options-analytics-js). const playerConfig = { ... npaw: { accountCode: '', // ... other NPAW options } }; You can also pass additional NPAW options per source, in the "npaw" key of the "Player.open" (https://players.castlabs.com/web/latest/docs/api/clpp.Player.md#open) configuration. Custom error and events reporting ================================= To report custom errors or events as described in the NPAW documentation (https://documentation.npaw.com/integration-docs/docs/custom-video-events-js), access the underlying NPAW adapter: const adapter = player.getPlugin(clpp.npaw.NpawPlugin.Id) .getAdapter(); // The adapter may be null if there is no active session. if (adapter) { adapter.fireError(code, message); // Report an error and send a /stop event to stop the current session. adapter.fireFatalError(code, message); // Fire a custom event. adapter.fireEvent('eventName', dimensions, values, topLevelDimensions); } NPAW App Analytics ================== To use NPAW App Analytics with PRESTOplay for Web Apps, pass your NPAW plugin instance to the player via "setNpawPlugin". For App Analytics configuration details, see the NPAW documentation (https://documentation.npaw.com/integration-docs/docs/app-analytics-js). Import packages: import {clpp} from "@castlabs/prestoplay"; import "@castlabs/prestoplay/cl.mse"; import "@castlabs/prestoplay/cl.dash"; import "@castlabs/prestoplay/cl.youbora"; import * as NpawPlugin from 'npaw-plugin'; import * as NpawPluginAdapters from 'npaw-plugin-adapters'; window.NpawPlugin = NpawPlugin; window.NpawPluginAdapters = NpawPluginAdapters; Use the NPAW plugin: const player = new clpp.Player('video', { license: '', viewerId: '', npaw: { accountCode: '' // ... other NPAW options } }); const appAnalyticsPlugin = new NpawPlugin(''); player.getPlugin(clpp.npaw.NpawPlugin.Id) .setNpawPlugin(appAnalyticsPlugin); // Now you can start playback. player.open({ source: 'http://example.com/Manifest.mpd', }); // Start session logging. sessionsPlugin.appAnalytics.newSession(); // Fire a session custom tracking event. sessionsPlugin.appAnalytics.fireEvent( 'search', // Name of the event { // Dimensions terms: 'searchedTerms' }, { // Values foundItems: 25 }); Custom error filter =================== Use the "npaw.errorFilter" config option to prevent specific errors from being reported to the NPAW service, or to modify an error's "code", "message", "severity", or add extra "metadata". const player = new clpp.Player('video', { license: '', npaw: { accountCode: '', errorFilter: error => { // Prevent error 3003 from being reported by returning null. if (error.code === 3003) { return null; } return { code: `${error.code}`, message: error.message, severity: error.severity, // metadata: { ... }, // Must be a serializable object. }; }, // ... other NPAW options } });