Skip to content

Commit

Permalink
feat: SSAI tracking (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
karpov-kir authored Jul 8, 2024
1 parent e607cc8 commit 202fdfd
Show file tree
Hide file tree
Showing 19 changed files with 1,936 additions and 1,250 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added
- Server side ad tracking
- It is exposed via `ConvivaAnalytics.ssai`
- An example can be found in `examples/index.html`

## 5.1.0 - 2024-06-13
### Added
- Basic client ad tracking using `Conviva.AdAnalytics`
Expand Down
35 changes: 34 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,43 @@

convivaAnalytics = new bitmovin.player.analytics.ConvivaAnalytics(player, '<CONVIVA_CUSTOMER_KEY>', {
debugLoggingEnabled: true,
gatewayUrl: 'https://youraccount-test.testonly.conviva.com', // TOUCHSTONE_SERVICE_URL for testing
// TOUCHSTONE_SERVICE_URL for testing (DO NOT USE IN PRODUCTION)
gatewayUrl: 'https://youraccount-test.testonly.conviva.com',
// This is inferred automatically, but can be overridden.
// deviceMetadata: { ... }
});

const simulateSsaiAd = () => {
// To avoid cyclic calls.
player.off(bitmovin.player.PlayerEvent.AdBreakFinished, simulateSsaiAd);

const playSsaiAd = () => {
convivaAnalytics.ssai.reportAdBreakStarted();
convivaAnalytics.ssai.reportAdStarted({
id: 'dummy-web-server-side-ad',
title: 'Dummy web server side AD',
duration: 20,
adSystem: 'dummy-server-side-ad-system',
position: Conviva.Constants.AdPosition.PREROLL,
isSlate: false,
adStitcher: 'Dummy AD stitcher',
additionalMetadata: {
dummyKey: 'dummy-value'
}
});

// "Play" the server side ad for 20 seconds.
setTimeout(() => {
convivaAnalytics.ssai.reportAdFinished();
convivaAnalytics.ssai.reportAdBreakFinished();
}, 20_000);
}

// Simulate server-side ad break with a little delay after the previous client side ad.
setTimeout(playSsaiAd, 2_000);
}

player.on(bitmovin.player.PlayerEvent.AdBreakFinished, simulateSsaiAd)
}

function loadPlayer() {
Expand Down
Loading

0 comments on commit 202fdfd

Please sign in to comment.