@eyevinn/player-analytics-client-sdk-web 0.0.8

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.
package/.eslintrc.yml ADDED
@@ -0,0 +1,31 @@
1
+ env:
2
+ browser: true
3
+ es6: true
4
+ jest/globals: true
5
+
6
+ extends:
7
+ - eslint-config-prettier
8
+ - eslint:recommended
9
+ - plugin:@typescript-eslint/recommended
10
+ - prettier
11
+
12
+ plugins:
13
+ - prettier
14
+ - jest
15
+ - "@typescript-eslint"
16
+
17
+ globals:
18
+ Promise: true
19
+
20
+ rules:
21
+ prettier/prettier:
22
+ - error
23
+ arrow-body-style: off
24
+ no-console: off
25
+ "@typescript-eslint/no-unused-vars": "error"
26
+ "@typescript-eslint/explicit-module-boundary-types": off
27
+
28
+ parser: "@typescript-eslint/parser"
29
+
30
+ parserOptions:
31
+ sourceType: module
@@ -0,0 +1,21 @@
1
+ name: Publish Github Package
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+ - uses: actions/setup-node@v1
14
+ with:
15
+ node-version: 16
16
+ registry-url: https://npm.pkg.github.com
17
+ - run: npm install
18
+ - run: npm run build
19
+ - run: npm publish
20
+ env:
21
+ NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -0,0 +1,21 @@
1
+ name: Publish npmjs
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+ - uses: actions/setup-node@v1
14
+ with:
15
+ node-version: 16
16
+ registry-url: https://registry.npmjs.org/
17
+ - run: npm install
18
+ - run: npm run build
19
+ - run: npm publish --access public
20
+ env:
21
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
package/.parcelrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "@parcel/config-default",
3
+ "transformers": {
4
+ "*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"]
5
+ }
6
+ }
package/.prettierrc ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": false,
4
+ "printWidth": 80
5
+ }
package/Readme.md ADDED
@@ -0,0 +1,111 @@
1
+ # Player Analytics Client SDK Web
2
+
3
+ Part of [Eyevinn Player Analytics Specification](https://github.com/Eyevinn/player-analytics-specification). To be used together with [Eyevinn Player Analytics Eventsink](https://github.com/Eyevinn/player-analytics-eventsink)
4
+
5
+ ```
6
+ npm install @eyevinn/player-analytics-client-sdk-web
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ ### Automatic Event Listening
12
+
13
+ ```js
14
+ import { PlayerAnalyticsConnector } from "@eyevinn/player-analytics-client-sdk-web";
15
+
16
+ // Create your instance and set the analytics eventsink endpoint
17
+ const playerAnalytics = new PlayerAnalyticsConnector("https://eventsink-url.io");
18
+
19
+ // Initiate the analytics with the base data needed
20
+ // This will create you session in the backend
21
+ playerAnalytics.init({
22
+ sessionId: "generated-unique-uuid-session-id",
23
+ live: false,
24
+ contentId: "big-buck-bunny-720",
25
+ contentUrl:
26
+ "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/720/Big_Buck_Bunny_720_10s_1MB.mp4",
27
+ });
28
+
29
+ // Get you video element from the site, or your video player of choice
30
+ const videoElement = document.querySelector("video");
31
+ // Load the analytics library with the video element to fetch the events
32
+ playerAnalytics.load(videoElement);
33
+ ```
34
+
35
+ Due to bitrate changes not being reported, and errors not being reported in any descriptive way, there is a possibility to do separate calls for these events - which you may trigger based on you video player of choice following these examples.
36
+
37
+ ```js
38
+ playerAnalytics.reportBitrateChange({
39
+ bitrate: "", // bitrate in Kbps
40
+ width: "", // optional, video width in pixels
41
+ height: "", // optional, video height in pixels
42
+ videoBitrate: "", // optional, if available provide the bitrate for the video track
43
+ audioBitrate: "", // optional, if available provide the bitrate for the audio track
44
+ });
45
+ ```
46
+
47
+ ```js
48
+ // error is fatal, i.e. sends an end event as well
49
+ playerAnalytics.reportError({
50
+ category: "", // optional, eg. NETWORK, DECODER, etc.
51
+ code: "",
52
+ message: "", // optional
53
+ data: {}, // optional
54
+ });
55
+
56
+ // warning is not fatal
57
+ playerAnalytics.reportWarning({
58
+ category: "", // optional, eg. NETWORK, DECODER, etc.
59
+ code: "",
60
+ message: "", // optional
61
+ data: {}, // optional
62
+ });
63
+ ```
64
+
65
+ ### Manual Event Triggering
66
+
67
+ ```js
68
+ import { PlayerAnalytics } from "@eyevinn/player-analytics-client-sdk-web";
69
+
70
+ // Create your instance and set the analytics eventsink endpoint
71
+ const playerAnalytics = new PlayerAnalytics("https://eventsink-url.io");
72
+ playerAnalytics.init({
73
+ sessionId: "generated-unique-uuid-session-id",
74
+ live: false,
75
+ contentId: "big-buck-bunny-720",
76
+ contentUrl:
77
+ "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/720/Big_Buck_Bunny_720_10s_1MB.mp4",
78
+ });
79
+
80
+ // then trigger the method calls accordingly, e.g.
81
+ const videoElement = document.querySelector("video");
82
+ videoElement.addEventListener("play", () => {
83
+ playerAnalytics.playing({
84
+ event: "playing",
85
+ timestamp: Date.now(),
86
+ playhead: 0,
87
+ duration: 3600,
88
+ sessionId: "generated-unique-uuid-session-id"
89
+ });
90
+ });
91
+ ```
92
+
93
+ ### Init parameters
94
+
95
+ ```ts
96
+ export interface IPlayerAnalyticsInitOptions {
97
+ sessionId?: string; // should be generated by the backend if not sent in
98
+ live: boolean;
99
+ contentId: string;
100
+ contentUrl: string;
101
+ drmType?: string;
102
+ userId?: string;
103
+ deviceId?: string;
104
+ deviceModel?: string;
105
+ deviceType?: string;
106
+ }
107
+ ```
108
+
109
+ ## Development
110
+
111
+ Run the demo page by `npm start`
@@ -0,0 +1,2 @@
1
+ export { PlayerAnalytics, IPlayerAnalyticsInitOptions, } from "./src/PlayerAnalytics";
2
+ export { PlayerAnalyticsConnector, IPlayerAnalyticsConnectorInitOptions } from "./src/PlayerAnalyticsConnector";