@gumlet/insights-js-core 1.1.4 → 1.1.6

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 (53) hide show
  1. package/build/release/gumlet-insights.min.js +2 -0
  2. package/build/release/gumlet-insights.min.js.LICENSE.txt +10 -0
  3. package/build/release/package.json +1 -0
  4. package/package.json +3 -2
  5. package/.github/workflows/main.yml +0 -87
  6. package/.gitlab-ci.yml +0 -54
  7. package/bitbucket-pipelines.yml +0 -35
  8. package/docs/payload-documentation.md +0 -72
  9. package/html/bitmovin.html +0 -82
  10. package/html/dashjs.html +0 -55
  11. package/html/hlsjs.html +0 -72
  12. package/html/html5.html +0 -59
  13. package/html/shaka.html +0 -102
  14. package/html/videojs.html +0 -67
  15. package/index.html +0 -73
  16. package/jest.config.js +0 -187
  17. package/js/adapters/Bitmovin7Adapter.js +0 -352
  18. package/js/adapters/BitmovinAdapter.js +0 -198
  19. package/js/adapters/DashjsAdapter.js +0 -140
  20. package/js/adapters/HTML5Adapter.js +0 -774
  21. package/js/adapters/HlsjsAdapter.js +0 -152
  22. package/js/adapters/ShakaAdapter.js +0 -81
  23. package/js/adapters/VideoJsAdapter.js +0 -455
  24. package/js/analyticsStateMachines/Bitmovin7AnalyticsStateMachine.js +0 -471
  25. package/js/analyticsStateMachines/BitmovinAnalyticsStateMachine.js +0 -299
  26. package/js/analyticsStateMachines/HTML5AnalyticsStateMachine.js +0 -443
  27. package/js/analyticsStateMachines/VideoJsAnalyticsStateMachine.js +0 -503
  28. package/js/cast/CastClient.js +0 -50
  29. package/js/cast/CastReceiver.js +0 -37
  30. package/js/core/AdapterFactory.js +0 -41
  31. package/js/core/Analytics.js +0 -1367
  32. package/js/core/AnalyticsStateMachineFactory.js +0 -36
  33. package/js/core/GumletInsightsExport.js +0 -81
  34. package/js/enums/CDNProviders.js +0 -11
  35. package/js/enums/Events.js +0 -32
  36. package/js/enums/GumletEnum.js +0 -19
  37. package/js/enums/MIMETypes.js +0 -30
  38. package/js/enums/Players.js +0 -11
  39. package/js/enums/StreamTypes.js +0 -15
  40. package/js/utils/EventsCall.js +0 -22
  41. package/js/utils/HttpCall.js +0 -57
  42. package/js/utils/LicenseCall.js +0 -18
  43. package/js/utils/Logger.js +0 -40
  44. package/js/utils/PlayerDetector.js +0 -75
  45. package/js/utils/PlayerInitCall.js +0 -22
  46. package/js/utils/SessionCreationCall.js +0 -22
  47. package/js/utils/Settings.js +0 -3
  48. package/js/utils/Utils.js +0 -195
  49. package/precommit.bash +0 -8
  50. package/tests/stage1.test.js +0 -50
  51. package/webpack.config.debug.js +0 -34
  52. package/webpack.config.js +0 -40
  53. package/webpack.config.release.js +0 -62
package/js/utils/Utils.js DELETED
@@ -1,195 +0,0 @@
1
- const validString = function(string) {
2
- return (string != undefined && typeof string == 'string');
3
- };
4
-
5
- const validBoolean = function(boolean) {
6
- return (boolean != undefined && typeof boolean == 'boolean');
7
- };
8
-
9
- const validNumber = function(number) {
10
- return (number != undefined && typeof number == 'number');
11
- };
12
-
13
- const sanitizePath = function(path) {
14
- return path.replace(/\/$/g, '');
15
- };
16
-
17
- const calculateTime = function(time) {
18
- time = time * 1000;
19
- return Math.round(time);
20
- };
21
-
22
- const getCurrentTimestamp = function() {
23
- return new Date().getTime();
24
- };
25
-
26
- const getDurationFromTimestampToNow = function(timestamp) {
27
- return getCurrentTimestamp() - timestamp;
28
- };
29
-
30
- const uuidv4 = function() {
31
- return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
32
- (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16).toUpperCase()
33
- );
34
- }
35
-
36
- const getCookie = function(cname) {
37
- const name = cname + '=';
38
- const ca = document.cookie.split(';');
39
- let item = "";
40
- for (let i = 0; i < ca.length; i++) {
41
- let c = ca[i];
42
- while (c.charAt(0) == ' ') {
43
- c = c.substring(1);
44
- }
45
- if (c.indexOf(name) == 0) {
46
- item = c.substring(name.length, c.length);
47
- }
48
- }
49
-
50
- if (!item) {
51
- try {
52
- item = localStorage.getItem(cname);
53
- } catch (error) {
54
- return "";
55
- }
56
- // check if localstorage has the item
57
- let data = null;
58
- if (item){
59
- // try parsing the values as a JSON
60
- try{
61
- data = JSON.parse(item);
62
- } catch (e) {
63
- return "";
64
- }
65
- }else{
66
- return "";
67
- }
68
-
69
- // check if loaded data has expires if not return none
70
- let expiresAt = null;
71
- if (data.expires) {
72
- expiresAt = new Date(data.expires);
73
- }else{
74
- return "";
75
- }
76
-
77
- // Check if expiresAt is a valid dateTime object
78
- if (Object.prototype.toString.call(expiresAt) === "[object Date]") {
79
- // it is a date
80
- if (isNaN(expiresAt)) {
81
- // date object is not valid
82
- return "";
83
- } else {
84
- // date object is valid
85
- }
86
- } else {
87
- return "";
88
- }
89
-
90
- // Check if expires at is greater than the current time
91
- if (expiresAt.getTime() > (new Date()).getTime()) {
92
- // if data has value then return it else return ""
93
- item = data.value ? data.value : "";
94
- }else{
95
- return "";
96
- }
97
- }
98
-
99
- // return read data
100
- return item;
101
- };
102
-
103
- const setCookie = function(cname, expiry_mins=30, value=null) {
104
- let date = new Date();
105
- date.setTime(date.getTime() + (expiry_mins*60*1000));
106
- let id = !value ? uuidv4() : value;
107
- try {
108
- document.cookie = cname+'=' + id +'; expires='+date.toUTCString()+'; path=/';
109
- localStorage.setItem(cname, JSON.stringify({
110
- expires: date.getTime(),
111
- value: id
112
- }));
113
- } catch (error) {
114
- }
115
- return id;
116
- };
117
-
118
- const noOp = function() {
119
-
120
- };
121
-
122
- const times = function (fn, times) {
123
- let count = 0;
124
- let retVal;
125
- return function () {
126
- if (count >= times) {
127
- return retVal;
128
- }
129
- retVal = fn.apply(null, arguments);
130
- count++;
131
- return retVal;
132
- };
133
- };
134
-
135
- const once = function (fn) {
136
- return times(fn, 1);
137
- };
138
-
139
- const getHiddenProp = function() {
140
- const prefixes = ['webkit','moz','ms','o'];
141
- if ('hidden' in document) { return 'hidden'; }
142
- for (let i = 0; i < prefixes.length; i++){
143
- if ((prefixes[i] + 'Hidden') in document) {
144
- return prefixes[i] + 'Hidden';
145
- }
146
- }
147
- return null;
148
- };
149
-
150
- const getCustomDataString = function(customData) {
151
- if (typeof customData === 'object') {
152
- return JSON.stringify(customData);
153
- } else if (typeof customData === 'function') {
154
- return getCustomDataString(customData());
155
- } else if (typeof customData === 'undefined') {
156
- return customData;
157
- } else if (typeof customData !== 'string') {
158
- return String(customData);
159
- }
160
-
161
- return customData;
162
- };
163
-
164
- const jsonToQueryString = function(json) {
165
- return '?' +
166
- Object.keys(json).map(function(key) {
167
- return encodeURIComponent(key) + '=' +
168
- encodeURIComponent(json[key]);
169
- }).join('&');
170
- }
171
-
172
- const currentDateTimeFormatString = function() {
173
- const currentDateTime = new Date();
174
- return currentDateTime.toISOString();
175
- }
176
-
177
- export default {
178
- validString,
179
- validBoolean,
180
- validNumber,
181
- sanitizePath,
182
- calculateTime,
183
- getCurrentTimestamp,
184
- getDurationFromTimestampToNow,
185
- uuidv4,
186
- getCookie,
187
- setCookie,
188
- noOp,
189
- times,
190
- once,
191
- getHiddenProp,
192
- getCustomDataString,
193
- jsonToQueryString,
194
- currentDateTimeFormatString
195
- };
package/precommit.bash DELETED
@@ -1,8 +0,0 @@
1
- #!/bin/bash
2
-
3
- # (git status --porcelain | grep .js$ | awk 'match($0, "M"){print $2}' | xargs ./node_modules/.bin/eslint) && npm run lint:html
4
-
5
- # above command isnt't working in all cases it seems, and doesn't really have any gain (except sometimes run git commit "faster"),
6
- # we will just run lint on all for every commit as that is more reliable
7
-
8
- # npm run pretest
@@ -1,50 +0,0 @@
1
- import Analytics from '../js/core/Analytics';
2
- import {HlsjsAdapter} from '../js/adapters/HlsjsAdapter';
3
- import {HTML5AnalyticsStateMachine} from '../js/analyticsStateMachines/HTML5AnalyticsStateMachine';
4
- import Events from '../js/enums/Events';
5
- import GumletEventEnum from '../js/enums/GumletEnum';
6
- // used for async on test else returns an error regenerator-runtime is not defined
7
- import 'regenerator-runtime/runtime';
8
-
9
-
10
- jest.setTimeout(30000);
11
-
12
- function randomIntFromInterval(min, max) { // min and max included
13
- return Math.floor(Math.random() * (max - min + 1) + min)
14
- }
15
-
16
- describe('stage 1 unit tests', () => {
17
- let propertyID = "JEST_TEST_WEB_";
18
- var config = {
19
- property_id: propertyID,
20
- page_url: "Testing",
21
- test: true
22
- };
23
-
24
- test('should check if property id being passed is set in the core object', () => {
25
- let analytics = new Analytics(config);
26
- expect( analytics.propertyId ).toBe(propertyID)
27
- })
28
-
29
- test('should check if end rebuffer event have correct data and timings', async () => {
30
- // hook onto state machine callbacks to verify correct time is being sent or not
31
- let analytics = new Analytics(config);
32
- let html5AnalyticstateMacine = new HTML5AnalyticsStateMachine();
33
-
34
- // Call rebuffer start event
35
- analytics.stateMachineCallbacks.start_rebuffer(1000, html5AnalyticstateMacine.States.REBUFFERING, {}, true);
36
- // to simulate rebubffer call the rebuffer end function after a random time
37
- const randomInt = randomIntFromInterval(100, 3000)
38
- await new Promise((r) => setTimeout(r, randomInt));
39
-
40
- // call end rebuffer, data recieved is the same data that is being sent to BQ via injestion API.
41
- let data = analytics.stateMachineCallbacks.end_rebuffer(1000, html5AnalyticstateMacine.States.REBUFFERING, {}, true);
42
-
43
- // +-10 ms due to code latency, exact match is not available
44
- expect(data.millis_from_previous_event).toBeGreaterThanOrEqual(randomInt-10);
45
- expect(data.millis_from_previous_event).toBeLessThanOrEqual(randomInt+10);
46
-
47
- // previous event should be tart rebuffer
48
- expect( data.previous_event ).toBe(GumletEventEnum.START_REBUFFER);
49
- })
50
- })
@@ -1,34 +0,0 @@
1
- const path = require('path');
2
- const webpack = require('webpack');
3
- const packageProperties = require('./package.json');
4
-
5
- const {banner, entry, externals, rules, getGitVersion} = require('./webpack.config.js');
6
-
7
- module.exports = {
8
- mode: 'development',
9
- devServer: {
10
- static: {
11
- directory: path.join(__dirname),
12
- },
13
- port:8080,
14
- },
15
- entry,
16
- externals,
17
- output: {
18
- path: path.resolve('./build/debug'),
19
- // for dev-server
20
- publicPath: '/build/debug',
21
- filename: 'gumlet-insights.min.js',
22
- libraryTarget: 'umd',
23
- },
24
- module: {
25
- rules
26
- },
27
- plugins: [
28
- new webpack.BannerPlugin(banner),
29
- new webpack.DefinePlugin({
30
- __VERSION__: JSON.stringify(getGitVersion())
31
- })
32
- ],
33
- devtool: 'inline-source-map'
34
- };
package/webpack.config.js DELETED
@@ -1,40 +0,0 @@
1
- const webpack = require('webpack');
2
- const execSync = require('child_process').execSync;
3
- const packageProperties = require('./package.json');
4
-
5
- const getGitVersion = () => {
6
- return execSync('git describe --abbrev=0').toString().trim();
7
- };
8
-
9
- const getFullGitVersion = () => {
10
- return execSync('git describe').toString().trim();
11
- };
12
-
13
- const banner =
14
- '\n' +
15
- 'Copyright (C) ' + new Date().getFullYear() + ', Gumlet Pte Ltd., All Rights Reserved\n' +
16
- '\n' +
17
- 'This source code and its use and distribution, is subject to the terms\n' +
18
- 'and conditions of the applicable license agreement.\n' +
19
- '\n' +
20
- packageProperties.name + ' version ' + getFullGitVersion() + '\n';
21
-
22
- const entry = './js/core/GumletInsightsExport.js';
23
-
24
- let rules = [{
25
- test : /\.js$/,
26
- exclude: /node_modules/,
27
- loader : 'babel-loader'
28
- }];
29
-
30
- const externals = {
31
- 'hls.js': 'Hls'
32
- };
33
-
34
- module.exports = {
35
- banner,
36
- entry,
37
- externals,
38
- rules,
39
- getGitVersion
40
- };
@@ -1,62 +0,0 @@
1
- const WriteJsonPlugin = require('generate-json-webpack-plugin');
2
- const TerserPlugin = require("terser-webpack-plugin");
3
- const webpack = require('webpack');
4
- const path = require('path');
5
- const packageProperties = require('./package.json');
6
-
7
- const {getGitVersion, banner, entry, externals, rules} = require('./webpack.config.js');
8
-
9
- const releasePackageJson = {
10
- name: packageProperties.name,
11
- version: getGitVersion(),
12
- description: 'Gumlet Insights allows you to collect data from Video playback.',
13
- license: 'MIT',
14
- repository: {
15
- type: 'git',
16
- url: 'https://gitlab.com/gumlet/insights-js-core.git'
17
- },
18
- main: 'gumlet-insights.min.js',
19
- readme: 'Please visit: https://docs.gumlet.com/docs/insights-getting-started',
20
- author: 'Gumlet Pte. Ltd.',
21
- homepage: 'https://docs.gumlet.com/docs/insights-getting-started',
22
- bugs: {
23
- url: "https://www.gumlet.com/contact/"
24
- },
25
- maintainers: [{
26
- name: 'Gumlet Team',
27
- email: 'support@gumlet.com'
28
- }]
29
- };
30
-
31
- module.exports = {
32
- mode: 'production',
33
- entry,
34
- externals,
35
- output: {
36
- path: path.resolve('./build/release'),
37
- filename: 'gumlet-insights.min.js',
38
- libraryTarget: 'umd'
39
- },
40
- module: {
41
- rules
42
- },
43
- optimization: {
44
- minimize: true,
45
- minimizer: [new TerserPlugin()],
46
- },
47
- plugins: [
48
- // new webpack.optimize.UglifyJsPlugin({
49
- // compress: {
50
- // warnings: false
51
- // },
52
- // output: {
53
- // comments: false
54
- // }
55
- // }),
56
- new webpack.BannerPlugin(banner),
57
- new WriteJsonPlugin("package.json",releasePackageJson),
58
- new webpack.DefinePlugin({
59
- __VERSION__: JSON.stringify(getGitVersion())
60
- })
61
- ]
62
- };