@go1/beam 1.0.6 → 1.0.10

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/index.js +25 -27
  2. package/package.json +16 -22
package/index.js CHANGED
@@ -1,14 +1,13 @@
1
- 'use strict'
1
+ "use strict";
2
2
 
3
- const axios = require('axios');
4
- const axiosRetry = require('axios-retry');
5
- const version = require('./package.json').version;
3
+ const axios = require("axios");
4
+ const axiosRetry = require("axios-retry");
5
+ const version = require("./package.json").version;
6
6
 
7
7
  const setImmediate = global.setImmediate || process.nextTick.bind(process);
8
- const noop = () => { };
8
+ const noop = () => {};
9
9
 
10
10
  /**
11
-
12
11
  Options Params: {
13
12
  flushAt?: int // How many items in queue before flush
14
13
  flushInterval?: int // Batch window in MS
@@ -25,7 +24,7 @@ const getTrackingEndpoint = (env) => {
25
24
  default:
26
25
  return "https://track.qa.go1.cloud/v1";
27
26
  }
28
- }
27
+ };
29
28
 
30
29
  class Beam {
31
30
  constructor(options = {}) {
@@ -54,11 +53,7 @@ class Beam {
54
53
  }
55
54
 
56
55
  setContext(newContext) {
57
- this.internalContext = Object.assign(
58
- {},
59
- this.context,
60
- newContext,
61
- );
56
+ this.internalContext = { ...this.internalContext, ...newContext };
62
57
  }
63
58
 
64
59
  identify(user, portal) {
@@ -75,15 +70,18 @@ class Beam {
75
70
  }
76
71
 
77
72
  this.setContext({
78
- user: user && user.id && {
79
- id: parseInt(user.id, 10) || null,
80
- },
81
- account: account && account.id && {
82
- id: parseInt(account.id, 10) || null,
83
- },
84
- portal: portal && portal.id && {
85
- id: parseInt(portal.id, 10) || null
86
- }
73
+ user: user &&
74
+ user.id && {
75
+ id: parseInt(user.id, 10) || null,
76
+ },
77
+ account: account &&
78
+ account.id && {
79
+ id: parseInt(account.id, 10) || null,
80
+ },
81
+ portal: portal &&
82
+ portal.id && {
83
+ id: parseInt(portal.id, 10) || null,
84
+ },
87
85
  });
88
86
  }
89
87
 
@@ -100,9 +98,9 @@ class Beam {
100
98
  this.internalContext,
101
99
  {
102
100
  library: {
103
- name: 'beam-node',
104
- version
105
- }
101
+ name: "beam-node",
102
+ version,
103
+ },
106
104
  },
107
105
  event.context
108
106
  );
@@ -147,16 +145,16 @@ class Beam {
147
145
  BatchData.push(eventEntry);
148
146
  }
149
147
 
150
- const done = err => {
148
+ const done = (err) => {
151
149
  callback(err, BatchData);
152
150
  };
153
151
  axios({
154
- method: 'POST',
152
+ method: "POST",
155
153
  url: this.endpoint,
156
154
  data: BatchData,
157
155
  })
158
156
  .then(() => done())
159
- .catch(err => {
157
+ .catch((err) => {
160
158
  if (err.response) {
161
159
  const error = new Error(err.response.statusText);
162
160
  return done(error);
package/package.json CHANGED
@@ -1,40 +1,34 @@
1
1
  {
2
2
  "name": "@go1/beam",
3
- "version": "1.0.6",
3
+ "version": "1.0.10",
4
4
  "description": "Tracking / Analytics Tooling",
5
5
  "main": "index.js",
6
6
  "private": false,
7
7
  "dependencies": {
8
- "axios": "^0.19.2",
9
- "axios-retry": "^3.1.8"
8
+ "axios": "^0.27.2",
9
+ "axios-retry": "^3.2.5"
10
10
  },
11
11
  "devDependencies": {
12
- "babel-eslint": "^10.0.1",
13
- "eslint": "^5.16.0",
12
+ "eslint": "^8.18.0",
14
13
  "eslint-config-airbnb-es5": "^1.2.0",
15
- "eslint-config-standard": "^12.0.0",
16
- "eslint-plugin-es5": "^1.3.1",
17
- "eslint-plugin-standard": "^4.0.0",
18
- "husky": "^2.7.0",
19
- "jest": "^26.0.0",
20
- "uglify-js": "^3.6.0"
14
+ "eslint-config-standard": "^17.0.0",
15
+ "eslint-plugin-es5": "^1.5.0",
16
+ "husky": "^8.0.1",
17
+ "jest": "^28.1.1",
18
+ "jsdom": "^20.0.2",
19
+ "uglify-js": "^3.16.1"
21
20
  },
22
21
  "scripts": {
23
22
  "build:browser": "uglifyjs --compress --mangle -o ./build/browser/analytics.js -- index.js",
24
- "build:node": "rm -r ./build/node && mkdir -p ./build/node && cp node.js ./build/node/index.js",
23
+ "build:node": "rm -rf ./build/node && mkdir -p ./build/node && cp node.js ./build/node/index.js",
25
24
  "lint:browser": "eslint index.js",
26
- "test": "jest --runInBand"
25
+ "test": "jest --runInBand --coverage",
26
+ "prepare": "husky install"
27
27
  },
28
28
  "repository": {
29
29
  "type": "git",
30
- "url": "git@code.go1.com.au:houston/tracking/beam.git"
30
+ "url": "git@code.go1.com.au:team-ai2/telemetry/beam.git"
31
31
  },
32
- "author": "",
33
- "license": "ISC",
34
- "husky": {
35
- "hooks": {
36
- "pre-commit": "npm run lint:browser",
37
- "pre-push": "npm run lint:browser"
38
- }
39
- }
32
+ "author": "Team AI2",
33
+ "license": "ISC"
40
34
  }