Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add playback monitoring #267

Merged
merged 6 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/middleware/srgssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import Image from '../utils/Image.js';
import Drm from '../utils/Drm.js';
import AkamaiTokenService from '../utils/AkamaiTokenService.js';
import SRGAnalytics from '../analytics/SRGAnalytics.js';
import SRGAnalytics from '../trackers/SRGAnalytics.js';
import PillarboxMonitoring from '../trackers/PillarboxMonitoring.js';
import MediaComposition from '../dataProvider/model/MediaComposition.js';

// Translations
Expand Down Expand Up @@ -471,6 +472,8 @@
* @returns {Promise<import('./typedef').ComposedSrcMediaData>} - The composed source media data.
*/
static async getSrcMediaObj(player, srcObj) {
player.trigger('pillarbox-monitoring/sessionstart');
amtins marked this conversation as resolved.
Show resolved Hide resolved

const { src: urn, ...srcOptions } = srcObj;
const mediaComposition = await SrgSsr.getMediaComposition(
urn,
Expand Down Expand Up @@ -597,6 +600,33 @@
}
}

/**
* SRG monitoring singleton.
*
* @param {import('video.js/dist/types/player').default} player
*
* @returns {PillarboxMonitoring} instance of PillarboxMonitoring
*/
static srgMonitoring(player) {
if (player.options().trackers.srgMonitoring === false) return;

Check warning on line 611 in src/middleware/srgssr.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 611 in src/middleware/srgssr.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

if (!player.options().trackers.srgMonitoring) {
const srgMonitoring = new PillarboxMonitoring(player, {
debug: player.debug(),
playerVersion: Pillarbox.VERSION.pillarbox,
playerName: 'Pillarbox',
});

player.options({
trackers: {
srgMonitoring,
},
});
}

return player.options().trackers.srgMonitoring;
}

/**
* Update player's poster.
*
Expand Down Expand Up @@ -635,7 +665,7 @@
* @returns {Object}
*/
static middleware(player) {

SrgSsr.srgMonitoring(player);
SrgSsr.cuechangeEventProxy(player);

return {
Expand Down
Loading
Loading