Skip to content

Commit

Permalink
feat(analytics): add support for tracking control
Browse files Browse the repository at this point in the history
Add support for the `trackers` property to the `player.options` in order to
store tracker instances. This makes it easier to access trackers directly from
the player. Use of this feature remains optional.

```javascript
// add custom tracker
const player = new Pillarbox('my-player', {
  trackers: {
    customTracker: new CustomTracker(player),
    anotherTracker: new AnotherTracker(player),
  }
})
```

Add the ability to disable trackers per playback session by introducing the
`disableTrackers` property provided directly to the `player.src`. As most trackers
take an instance of the player as a parameter. This will make it easier to access
the disableTrackers property to determine whether or not the tracker should be
disabled for the current playback session.

```javascript
// disable a tracker for the playback session
player.src({
  src : 'urn:xyz',
  type: 'srgssr/urn',
  disableTrackers : ['anotherTracker']
});

// disable all trackers for the playback session
player.src({
  src : 'urn:xyz',
  type: 'srgssr/urn',
  disableTrackers : true
})
```

Add support for SRG SSR-compliant media playback tracking.

- add `trackers` to Pillarbox default options
- add the `SRGAnalytics` class and unit tests
- add `PlayerEvents` that contains all `mediaElement` events
- srgssr middleware
  - add a function to handle SRG SSR analytics
  - update `composeSrcMediaData` to handle `disableTrackers`
  - move the construction of the main resources array into its own function
  - update unit tests

Refers to issue #32
  • Loading branch information
amtins committed Oct 6, 2023
1 parent bde23b0 commit 548be84
Show file tree
Hide file tree
Showing 9 changed files with 1,758 additions and 21 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@srgssr/pillarbox-web",
"description": "Pillarbox is the modern SRG SSR player",
"version": "0.0.7",
"version": "0.6.9",
"main": "dist/pillarbox.js",
"targets": {
"github-page": {
Expand Down
Loading

0 comments on commit 548be84

Please sign in to comment.