@gumlet/insights-js-core 1.0.1 → 1.1.0

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 (54) hide show
  1. package/.github/workflows/main.yml +87 -0
  2. package/.gitlab-ci.yml +54 -0
  3. package/LICENSE +21 -0
  4. package/README.md +30 -0
  5. package/bitbucket-pipelines.yml +35 -0
  6. package/docs/payload-documentation.md +72 -0
  7. package/html/bitmovin.html +82 -0
  8. package/html/dashjs.html +55 -0
  9. package/html/hlsjs.html +72 -0
  10. package/html/html5.html +59 -0
  11. package/html/shaka.html +102 -0
  12. package/html/videojs.html +67 -0
  13. package/index.html +73 -0
  14. package/jest.config.js +187 -0
  15. package/js/adapters/Bitmovin7Adapter.js +352 -0
  16. package/js/adapters/BitmovinAdapter.js +198 -0
  17. package/js/adapters/DashjsAdapter.js +140 -0
  18. package/js/adapters/HTML5Adapter.js +774 -0
  19. package/js/adapters/HlsjsAdapter.js +152 -0
  20. package/js/adapters/ShakaAdapter.js +81 -0
  21. package/js/adapters/VideoJsAdapter.js +455 -0
  22. package/js/analyticsStateMachines/Bitmovin7AnalyticsStateMachine.js +471 -0
  23. package/js/analyticsStateMachines/BitmovinAnalyticsStateMachine.js +299 -0
  24. package/js/analyticsStateMachines/HTML5AnalyticsStateMachine.js +443 -0
  25. package/js/analyticsStateMachines/VideoJsAnalyticsStateMachine.js +503 -0
  26. package/js/cast/CastClient.js +50 -0
  27. package/js/cast/CastReceiver.js +37 -0
  28. package/js/core/AdapterFactory.js +41 -0
  29. package/js/core/Analytics.js +1357 -0
  30. package/js/core/AnalyticsStateMachineFactory.js +36 -0
  31. package/js/core/GumletInsightsExport.js +75 -0
  32. package/js/enums/CDNProviders.js +11 -0
  33. package/js/enums/Events.js +32 -0
  34. package/js/enums/GumletEnum.js +19 -0
  35. package/js/enums/MIMETypes.js +30 -0
  36. package/js/enums/Players.js +11 -0
  37. package/js/enums/StreamTypes.js +15 -0
  38. package/js/utils/EventsCall.js +22 -0
  39. package/js/utils/HttpCall.js +57 -0
  40. package/js/utils/LicenseCall.js +18 -0
  41. package/js/utils/Logger.js +40 -0
  42. package/js/utils/PlayerDetector.js +75 -0
  43. package/js/utils/PlayerInitCall.js +22 -0
  44. package/js/utils/SessionCreationCall.js +22 -0
  45. package/js/utils/Settings.js +3 -0
  46. package/js/utils/Utils.js +195 -0
  47. package/package.json +62 -1
  48. package/precommit.bash +8 -0
  49. package/tests/stage1.test.js +50 -0
  50. package/webpack.config.debug.js +34 -0
  51. package/webpack.config.js +40 -0
  52. package/webpack.config.release.js +62 -0
  53. package/gumlet-insights.min.js +0 -2
  54. package/gumlet-insights.min.js.LICENSE.txt +0 -10
@@ -0,0 +1,102 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+
6
+ <link rel="icon" href="https://assets.gumlet.io/assets/round-logo.png?w=32" sizes="32x32" />
7
+ <link rel="icon" href="https://assets.gumlet.io/assets/round-logo.png?w=192" sizes="192x192" />
8
+ <link rel="apple-touch-icon-precomposed" href="https://assets.gumlet.io/assets/round-logo.png?w=180" />
9
+ <meta name="msapplication-TileImage" content="https://assets.gumlet.io/assets/round-logo.png?w=270" />
10
+
11
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous" />
12
+ <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous">
13
+ </script>
14
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous">
15
+ </script>
16
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous">
17
+ </script>
18
+
19
+ <title>Shaka Player Insights</title>
20
+
21
+ <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/2.3.0/shaka-player.compiled.js"></script> -->
22
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/3.3.1/shaka-player.compiled.js"></script>
23
+ <script type="text/javascript" src="/build/debug/gumlet-insights.min.js"></script>
24
+
25
+ </head>
26
+ <body>
27
+ <div id="player" style="width: 400px">
28
+
29
+ <video id="my-video" preload="none" width="640" height="264" controls muted></video>
30
+
31
+ <p><a href="shaka.html">Click</a></p>
32
+ </div>
33
+
34
+ <script type="text/javascript">
35
+
36
+ var config = {
37
+ property_id: 'BNVzRZKD',
38
+ customData1: "",
39
+ customData2: 'customData2',
40
+ videoId: 'ShakaTestAngelOne',
41
+ userId: 'customer#1'
42
+ };
43
+
44
+ var analytics = gumlet.insights(config);
45
+
46
+ let manifestUri = 'https://video.gumlet.io/5f462c1561cf8a766464ffc4/61dd877c6ec832ab2aaa1837/7.mpd'
47
+
48
+ function initApp() {
49
+ // Install built-in polyfills to patch browser incompatibilities.
50
+ shaka.polyfill.installAll();
51
+
52
+ // Check to see if the browser supports the basic APIs Shaka needs.
53
+ if (shaka.Player.isBrowserSupported()) {
54
+ // Everything looks good!
55
+ initPlayer();
56
+ } else {
57
+ // This browser does not have the minimum set of APIs we need.
58
+ console.error('Browser not supported!');
59
+ }
60
+ }
61
+
62
+ function initPlayer() {
63
+
64
+ var startTime = new Date().getTime();
65
+
66
+ // Create a Player instance.
67
+ var video = document.getElementById('my-video');
68
+ var player = new shaka.Player(video);
69
+
70
+ analytics.registerShakaPlayer(player, {starttime: startTime, mediaElement: video});
71
+
72
+ // Attach player to the window to make it easy to access in the JS console.
73
+ window.player = player;
74
+
75
+ // Listen for error events.
76
+ player.addEventListener('error', onErrorEvent);
77
+
78
+ // Try to load a manifest.
79
+ // This is an asynchronous process.
80
+ player.load(manifestUri).then(function() {
81
+ // This runs if the asynchronous load is successful.
82
+ console.log('The video has now been loaded!');
83
+ // onError is executed if the asynchronous load fails.
84
+ }).catch(onError);
85
+ }
86
+
87
+ function onErrorEvent(event) {
88
+ // Extract the shaka.util.Error object from the event.
89
+ onError(event.detail);
90
+ }
91
+
92
+ function onError(error) {
93
+ // Log the error.
94
+ console.error('Error code', error.code, 'object', error);
95
+ }
96
+
97
+ document.addEventListener('DOMContentLoaded', initApp);
98
+
99
+ </script>
100
+
101
+ </body>
102
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+
6
+ <link rel="icon" href="https://assets.gumlet.io/assets/round-logo.png?w=32" sizes="32x32" />
7
+ <link rel="icon" href="https://assets.gumlet.io/assets/round-logo.png?w=192" sizes="192x192" />
8
+ <link rel="apple-touch-icon-precomposed" href="https://assets.gumlet.io/assets/round-logo.png?w=180" />
9
+ <meta name="msapplication-TileImage" content="https://assets.gumlet.io/assets/round-logo.png?w=270" />
10
+
11
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous" />
12
+ <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous">
13
+ </script>
14
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous">
15
+ </script>
16
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous">
17
+ </script>
18
+
19
+ <title>VideoJS Player Insights</title>
20
+
21
+ <link href="http://vjs.zencdn.net/5.15.1/video-js.css" rel="stylesheet" />
22
+
23
+ <script type="text/javascript" src="/build/debug/gumlet-insights.min.js"></script>
24
+ </head>
25
+ <body>
26
+ <div id="player" style="width: 400px"></div>
27
+ <script src="http://vjs.zencdn.net/5.15.1/video.js"></script>
28
+ <!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.7.0/videojs-contrib-hls.min.js"></script> -->
29
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.15.0/videojs-contrib-hls.min.js"></script>
30
+
31
+ <video id="my-video" class="video-js" controls preload="false" autoplay width="640" height="264">
32
+ <source src="https://video.gumlet.io/5f462c1561cf8a766464ffc4/61b8ac77b7e0439691e7c2af/1.m3u8" type="application/x-mpegURL" />
33
+ <p class="vjs-no-js">
34
+ To view this video please enable JavaScript, and consider upgrading to a web browser that
35
+ <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
36
+ </p>
37
+ </video>
38
+ <script type="text/javascript">
39
+
40
+ /* global bitmovin videojs */
41
+
42
+ var config = {
43
+ // Your bitmovin analytics key
44
+ // TODO: remove the key after testing
45
+ key: 'e73a3577-d91c-4214-9e6d-938fb936818a',
46
+ property_id: 'BNVzRZKD',
47
+ player: gumlet.insights.Players.VIDEOJS,
48
+ cdnProvider: gumlet.insights.CdnProviders.AKAMAI,
49
+ experimentName: 'bitmovinanalytics-local',
50
+ videoId: 'Sintel',
51
+ userId: 'customer#1',
52
+ debug: true
53
+ };
54
+ var analytics = gumlet.insights(config);
55
+
56
+ var options = {
57
+ preload: false
58
+ };
59
+
60
+ var player = videojs('my-video', options);
61
+ analytics.registerVideoJSPlayer(player);
62
+
63
+
64
+ </script>
65
+ <a href="videojs.html">Click</a>
66
+ </body>
67
+ </html>
package/index.html ADDED
@@ -0,0 +1,73 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" href="https://assets.gumlet.io/assets/round-logo.png?w=32" sizes="32x32" />
6
+ <link rel="icon" href="https://assets.gumlet.io/assets/round-logo.png?w=192" sizes="192x192" />
7
+ <link rel="apple-touch-icon-precomposed" href="https://assets.gumlet.io/assets/round-logo.png?w=180" />
8
+ <meta name="msapplication-TileImage" content="https://assets.gumlet.io/assets/round-logo.png?w=270" />
9
+
10
+ <title>
11
+ Gumlet Insights SDK
12
+ </title>
13
+
14
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous" />
15
+ <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous">
16
+ </script>
17
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous">
18
+ </script>
19
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous">
20
+ </script>
21
+ </head>
22
+ <body>
23
+ <div style="width: 600px; margin: 0 auto;">
24
+ <p></p>
25
+ <h1>
26
+ <a href="https://gumlet.com/">
27
+ <img src="https://assets.gumlet.io/assets/logo.svg?w=200&dpr=2.0" style="width:200px;">
28
+ </a>
29
+ Insights SDK
30
+ </h1>
31
+ <p>
32
+
33
+ <a href="https://github.com/gumlet/insights-js-core">
34
+ https://github.com/gumlet/insights-js-core
35
+ </a>
36
+ </p>
37
+ <p>
38
+ <h2>
39
+ Integration demos:
40
+ </h2>
41
+ </p>
42
+ <p>
43
+ <ul>
44
+ <li>
45
+ <a href="html/hlsjs.html">
46
+ Hls.js
47
+ </a>
48
+ </li>
49
+ <li>
50
+ <a href="html/videojs.html">
51
+ Videojs
52
+ </a>
53
+ </li>
54
+ <li>
55
+ <a href="html/shaka.html">
56
+ Shaka
57
+ </a>
58
+ </li>
59
+ <li>
60
+ <a href="html/dashjs.html">
61
+ Dash.js
62
+ </a>
63
+ </li>
64
+ <li>
65
+ <a href="html/html5.html">
66
+ HLML5
67
+ </a>
68
+ </li>
69
+ </ul>
70
+ </p>
71
+ </div>
72
+ </body>
73
+ </html>
package/jest.config.js ADDED
@@ -0,0 +1,187 @@
1
+ // For a detailed explanation regarding each configuration property, visit:
2
+ // https://jestjs.io/docs/en/configuration.html
3
+
4
+ module.exports = {
5
+ // All imported modules in your tests should be mocked automatically
6
+ // automock: false,
7
+
8
+ // Stop running tests after the first failure
9
+ // bail: false,
10
+
11
+ // Respect "browser" field in package.json when resolving modules
12
+ // browser: false,
13
+
14
+ // The directory where Jest should store its cached dependency information
15
+ // cacheDirectory: "/var/folders/7r/6cspl23s31d_bs2h0mllmvq00000gn/T/jest_dx",
16
+
17
+ // Automatically clear mock calls and instances between every test
18
+ clearMocks: true,
19
+ // globalSetup: './tests/setup/global-setup.js',
20
+ // globalTeardown: './tests/setup/global-teardown.js',
21
+ testEnvironment: 'node',
22
+ // testEnvironment: './tests/setup/mongo-environment.js'
23
+
24
+ // Indicates whether the coverage information should be collected while executing the test
25
+ // collectCoverage: true,
26
+
27
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
28
+ // collectCoverageFrom: null,
29
+
30
+ // The directory where Jest should output its coverage files
31
+ // coverageDirectory: "coverage",
32
+
33
+ // An array of regexp pattern strings used to skip coverage collection
34
+ // coveragePathIgnorePatterns: [
35
+ // "/node_modules/"
36
+ // ],
37
+
38
+ // A list of reporter names that Jest uses when writing coverage reports
39
+ coverageReporters: [
40
+ "json",
41
+ "text",
42
+ "cobertura"
43
+ ],
44
+
45
+ // An object that configures minimum threshold enforcement for coverage results
46
+ // coverageThreshold: null,
47
+
48
+ // Make calling deprecated APIs throw helpful error messages
49
+ // errorOnDeprecated: false,
50
+
51
+ // Force coverage collection from ignored files usin a array of glob patterns
52
+ // forceCoverageMatch: [],
53
+
54
+ // A path to a module which exports an async function that is triggered once before all test suites
55
+ // globalSetup: null,
56
+
57
+ // A path to a module which exports an async function that is triggered once after all test suites
58
+ // globalTeardown: null,
59
+
60
+ // A set of global variables that need to be available in all test environments
61
+ globals: {
62
+ crypto: {
63
+ getRandomValues: (arr) => require("crypto").randomBytes(arr.length),
64
+ },
65
+ },
66
+
67
+ // An array of directory names to be searched recursively up from the requiring module's location
68
+ // moduleDirectories: [
69
+ // "node_modules"
70
+ // ],
71
+
72
+ // An array of file extensions your modules use
73
+ // moduleFileExtensions: [
74
+ // "js",
75
+ // "json",
76
+ // "jsx",
77
+ // "node"
78
+ // ],
79
+
80
+ // A map from regular expressions to module names that allow to stub out resources with a single module
81
+ // moduleNameMapper: {},
82
+
83
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
84
+ // modulePathIgnorePatterns: [],
85
+
86
+ // Activates notifications for test results
87
+ // notify: false,
88
+
89
+ // An enum that specifies notification mode. Requires { notify: true }
90
+ // notifyMode: "always",
91
+
92
+ // A preset that is used as a base for Jest's configuration
93
+ // preset: null,
94
+
95
+ // Run tests from one or more projects
96
+ // projects: null,
97
+
98
+ // Use this configuration option to add custom reporters to Jest
99
+ // reporters: undefined,
100
+
101
+ // Automatically reset mock state between every test
102
+ // resetMocks: false,
103
+
104
+ // Reset the module registry before running each individual test
105
+ // resetModules: false,
106
+
107
+ // A path to a custom resolver
108
+ // resolver: null,
109
+
110
+ // Automatically restore mock state between every test
111
+ // restoreMocks: false,
112
+
113
+ // The root directory that Jest should scan for tests and modules within
114
+ // rootDir: null,
115
+
116
+ // A list of paths to directories that Jest should use to search for files in
117
+ // roots: [
118
+ // "<rootDir>"
119
+ // ],
120
+
121
+ // Allows you to use a custom runner instead of Jest's default test runner
122
+ // runner: "jest-runner",
123
+
124
+ // The paths to modules that run some code to configure or set up the testing environment before each test
125
+ // setupFiles: [],
126
+
127
+ // The path to a module that runs some code to configure or set up the testing framework before each test
128
+ // setupTestFrameworkScriptFile: './config/jest.setup.js',
129
+
130
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
131
+ // snapshotSerializers: [],
132
+
133
+ // The test environment that will be used for testing
134
+ // testEnvironment: "node",
135
+
136
+ // Options that will be passed to the testEnvironment
137
+ // testEnvironmentOptions: {},
138
+
139
+ // Adds a location field to test results
140
+ // testLocationInResults: false,
141
+
142
+ // The glob patterns Jest uses to detect test files
143
+ // testMatch: [
144
+ // "**/__tests__/**/*.js?(x)",
145
+ // "**/?(*.)+(spec|test).js?(x)"
146
+ // ],
147
+
148
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
149
+ // testPathIgnorePatterns: [
150
+ // "/node_modules/"
151
+ // ],
152
+
153
+ // The regexp pattern Jest uses to detect test files
154
+ // testRegex: "",
155
+
156
+ // This option allows the use of a custom results processor
157
+ // testResultsProcessor: null,
158
+
159
+ // This option allows use of a custom test runner
160
+ // testRunner: "jasmine2",
161
+
162
+ // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
163
+ // testURL: "about:blank",
164
+
165
+ // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
166
+ // timers: "real",
167
+
168
+ // A map from regular expressions to paths to transformers
169
+ // transform: null,
170
+
171
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
172
+ // transformIgnorePatterns: [
173
+ // "/node_modules/"
174
+ // ],
175
+
176
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
177
+ // unmockedModulePathPatterns: undefined,
178
+
179
+ // Indicates whether each individual test should be reported during the run
180
+ verbose: false,
181
+
182
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
183
+ // watchPathIgnorePatterns: [],
184
+
185
+ // Whether to use watchman for file crawling
186
+ // watchman: true,
187
+ };