@eyevinn/player-analytics-client-sdk-web 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/Readme.md +31 -33
  2. package/package.json +2 -2
package/Readme.md CHANGED
@@ -14,20 +14,18 @@ npm install @eyevinn/player-analytics-client-sdk-web
14
14
  import { PlayerAnalyticsConnector } from "@eyevinn/player-analytics-client-sdk-web";
15
15
 
16
16
  // Create your instance and set the analytics eventsink endpoint
17
- const playerAnalytics = new PlayerAnalyticsConnector("https://your-eventsink-url.io");
17
+ const playerAnalytics = new PlayerAnalyticsConnector(
18
+ "https://your-eventsink-url.io"
19
+ );
18
20
 
19
21
  // Initiate the analytics with the base data needed
20
22
  // This will create you session in the backend
21
23
  try {
22
24
  await playerAnalytics.init({
23
25
  sessionId: "generated-unique-uuid-session-id",
24
- live: false,
25
- contentId: "big-buck-bunny-720",
26
- contentUrl:
27
- "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/720/Big_Buck_Bunny_720_10s_1MB.mp4",
28
26
  });
29
27
 
30
- // Get you video element from the site, or your video player of choice
28
+ // Get your video element from the site, or your video player of choice
31
29
  const videoElement = document.querySelector("video");
32
30
  // Load the analytics library with the video element to fetch the events
33
31
  playerAnalytics.load(videoElement);
@@ -42,11 +40,11 @@ Due to bitrate changes not being reported, and errors not being reported in any
42
40
 
43
41
  ```js
44
42
  playerAnalytics.reportBitrateChange({
45
- bitrate: "", // bitrate in Kbps
46
- width: "", // optional, video width in pixels
47
- height: "", // optional, video height in pixels
48
- videoBitrate: "", // optional, if available provide the bitrate for the video track
49
- audioBitrate: "", // optional, if available provide the bitrate for the audio track
43
+ bitrate: 246.440, // bitrate in Kbps
44
+ width: 320, // optional, video width in pixels
45
+ height: 136, // optional, video height in pixels
46
+ videoBitrate: 0, // optional, if available provide the bitrate for the video track
47
+ audioBitrate: 0, // optional, if available provide the bitrate for the audio track
50
48
  });
51
49
  ```
52
50
 
@@ -96,10 +94,9 @@ videoElement.addEventListener("play", () => {
96
94
  timestamp: Date.now(),
97
95
  playhead: 0,
98
96
  duration: 3600,
99
- sessionId: "generated-unique-uuid-session-id"
97
+ sessionId: "generated-unique-uuid-session-id",
100
98
  });
101
99
  });
102
-
103
100
  ```
104
101
 
105
102
  ### Report Metadata
@@ -108,33 +105,41 @@ You can report your metadata at a later stage in your code and tailor ther callb
108
105
  In this example we're using hls.js
109
106
 
110
107
  ```js
111
- import Hls from "hls.js"
108
+ import Hls from "hls.js";
112
109
  import { PlayerAnalyticsConnector } from "@eyevinn/player-analytics-client-sdk-web";
113
110
 
114
111
  // Create your instance and set the analytics eventsink endpoint
115
112
  const playerAnalytics = new PlayerAnalytics("https://your-eventsink-url.io");
116
113
  await playerAnalytics.initiateAnalyticsReporter({
117
114
  sessionId: "generated-unique-uuid-session-id",
118
- contentId: "big-buck-bunny-720",
119
- contentUrl:
120
- "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/720/Big_Buck_Bunny_720_10s_1MB.mp4",
121
115
  });
122
116
 
123
117
  const hls = new Hls();
124
118
  const videoElement = document.querySelector("video");
125
119
 
126
- hls.attachMedia(videoElement)
127
- hls.load(src)
120
+ hls.attachMedia(videoElement);
121
+ hls.load(src);
128
122
  hls.on(Hls.Events.LEVEL_LOADED, (event, data) => {
129
123
  playerAnalytics.metadata({
130
- event: "metadata",
131
- payload: {
132
- isLive: data?.details?.level?.live
133
- }
134
- })
135
- })
124
+ live: data?.details?.level?.live,
125
+ });
126
+ });
127
+ ```
136
128
 
129
+ These are the available keys for metadata, which can be sent anytime between a `init` and a `stopped` call.
137
130
 
131
+ ```ts
132
+ export interface TMetadataEventPayload {
133
+ live?: boolean;
134
+ contentTitle?: string;
135
+ contentId?: string;
136
+ contentUrl?: string;
137
+ drmType?: string;
138
+ userId?: string;
139
+ deviceId?: string;
140
+ deviceModel?: string;
141
+ deviceType?: string;
142
+ }
138
143
  ```
139
144
 
140
145
  ### Constructor parameters
@@ -149,14 +154,7 @@ These applies to both the `PlayerAnalyticsConnector` and `PlayerAnalytics`.
149
154
  ```ts
150
155
  export interface IPlayerAnalyticsInitOptions {
151
156
  sessionId?: string; // should be generated by the backend if not sent in
152
- live?: boolean;
153
- contentId: string;
154
- contentUrl: string;
155
- drmType?: string;
156
- userId?: string;
157
- deviceId?: string;
158
- deviceModel?: string;
159
- deviceType?: string;
157
+ hearbeatInterval?: number; //Defaults to 30_000 (ms)
160
158
  }
161
159
  ```
162
160
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eyevinn/player-analytics-client-sdk-web",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "EPAS Client SDK for Web",
5
5
  "source": "index.ts",
6
6
  "main": "dist/index.js",
@@ -39,6 +39,6 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@eyevinn/player-analytics-specification": "0.3.1",
42
- "@eyevinn/video-event-filter": "^1.1.0"
42
+ "@eyevinn/video-event-filter": "^1.1.4"
43
43
  }
44
44
  }