@reportportal/client-javascript
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -5,4 +5,4 @@ const pjson = require('./../package.json'); | ||
const PJSON_NAME = pjson.name; | ||
const GOOGLE_ANALYTICS_INSTANCE = 'UA-96321031-1'; | ||
const GOOGLE_ANALYTICS_INSTANCE = 'UA-173456809-1'; | ||
module.exports = { PJSON_VERSION, PJSON_NAME, GOOGLE_ANALYTICS_INSTANCE }; |
## [5.0.1] - 2020-08-14 | ||
### Changed | ||
- Packages publishing workflow improved | ||
### Added | ||
- The ability to disable google analytics | ||
## [5.0.0] - 2020-06-09 | ||
@@ -3,0 +9,0 @@ ### Added |
@@ -0,0 +0,0 @@ const EVENTS = { |
@@ -35,7 +35,6 @@ /* eslint-disable quotes,no-console,class-methods-use-this */ | ||
this.baseURL = [params.endpoint, params.project].join('/'); | ||
const headers = { | ||
const headers = Object.assign({ | ||
'User-Agent': 'NodeJS', | ||
Authorization: `bearer ${params.token}`, | ||
...(params.headers || {}), | ||
}; | ||
}, params.headers || {}); | ||
this.headers = headers; | ||
@@ -117,2 +116,15 @@ this.options = { | ||
triggerAnalyticsEvent() { | ||
if (this.config.disableGA) { | ||
return; | ||
} | ||
if (this.analytics.agentParams) { | ||
const label = getAgentEventLabel(this.analytics.agentParams); | ||
this.analytics.trackEvent(Object.assign(CLIENT_JAVASCRIPT_EVENTS.START_LAUNCH, { label })); | ||
} else { | ||
this.analytics.trackEvent(CLIENT_JAVASCRIPT_EVENTS.START_LAUNCH); | ||
} | ||
} | ||
/** | ||
@@ -194,8 +206,3 @@ * Start launch and report it. | ||
} | ||
if (this.analytics.agentParams) { | ||
const label = getAgentEventLabel(this.analytics.agentParams); | ||
this.analytics.trackEvent(Object.assign(CLIENT_JAVASCRIPT_EVENTS.START_LAUNCH, { label })); | ||
} else { | ||
this.analytics.trackEvent(CLIENT_JAVASCRIPT_EVENTS.START_LAUNCH); | ||
} | ||
this.triggerAnalyticsEvent(); | ||
return { | ||
@@ -645,6 +652,5 @@ tempId, | ||
{ | ||
headers: { | ||
...this.headers, | ||
headers: Object.assign(this.headers, { | ||
'Content-Type': `multipart/form-data; boundary=${MULTIPART_BOUNDARY}`, | ||
}, | ||
}), | ||
}, | ||
@@ -651,0 +657,0 @@ ) |
{ | ||
"name": "@reportportal/client-javascript", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "ReportPortal client for node.js", | ||
@@ -42,3 +42,3 @@ "author": "ReportPortal.io", | ||
"devDependencies": { | ||
"codecov": "3.6.5", | ||
"codecov": "3.7.1", | ||
"eslint": "5.16.0", | ||
@@ -45,0 +45,0 @@ "eslint-config-airbnb-base": "^13.1.0", |
@@ -132,2 +132,3 @@ # ReportPortal js client | ||
We use Google Analytics for sending anonymous usage information as library's name/version and the agent's name/version when the launchStart is called. This information might help us to improve reportportal-client. Used by the ReportPortal team only and not for sharing with 3rd parties. | ||
You can disable Google Analytics by specify the following parameter **disableGA** with the value **true**. | ||
@@ -134,0 +135,0 @@ ### finishLaunch |
@@ -91,2 +91,49 @@ const RPClient = require('../lib/report-portal-client.js'); | ||
describe('triggerAnalyticsEvent', () => { | ||
it('should not call analytics.trackEvent if disableGA is true', () => { | ||
const client = new RPClient({ | ||
token: 'startLaunchTest', | ||
endpoint: 'https://rp.us/api/v1', | ||
project: 'tst', | ||
disableGA: true, | ||
}); | ||
spyOn(events, 'getAgentEventLabel').and.returnValue('name|version'); | ||
spyOn(client.analytics, 'trackEvent'); | ||
client.triggerAnalyticsEvent(); | ||
expect(client.analytics.trackEvent).not.toHaveBeenCalled(); | ||
}); | ||
it('should call analytics.trackEvent with label if agentParams is not empty', () => { | ||
const client = new RPClient({ | ||
token: 'startLaunchTest', | ||
endpoint: 'https://rp.us/api/v1', | ||
project: 'tst', | ||
}); | ||
client.analytics.agentParams = { name: 'name', version: 'version' }; | ||
spyOn(events, 'getAgentEventLabel').and.returnValue('name|version'); | ||
spyOn(client.analytics, 'trackEvent'); | ||
client.triggerAnalyticsEvent(); | ||
expect(client.analytics.trackEvent).toHaveBeenCalledWith( | ||
Object.assign(events.CLIENT_JAVASCRIPT_EVENTS.START_LAUNCH, { label: 'name|version' }), | ||
); | ||
}); | ||
it('should call analytics.trackEvent without label if agentParams is empty', () => { | ||
const client = new RPClient({ | ||
token: 'startLaunchTest', | ||
endpoint: 'https://rp.us/api/v1', | ||
project: 'tst', | ||
}); | ||
spyOn(client.analytics, 'trackEvent'); | ||
client.triggerAnalyticsEvent(); | ||
expect(client.analytics.trackEvent).toHaveBeenCalledWith(events.CLIENT_JAVASCRIPT_EVENTS.START_LAUNCH); | ||
}); | ||
}); | ||
describe('startLaunch', () => { | ||
@@ -156,38 +203,2 @@ it('should call restClient with suitable parameters', () => { | ||
it('should call analytics.trackEvent with label if agentParams is not empty', () => { | ||
const client = new RPClient({ | ||
token: 'startLaunchTest', | ||
endpoint: 'https://rp.us/api/v1', | ||
project: 'tst', | ||
}); | ||
const time = 12345734; | ||
client.analytics.agentParams = { name: 'name', version: 'version' }; | ||
spyOn(events, 'getAgentEventLabel').and.returnValue('name|version'); | ||
spyOn(client.analytics, 'trackEvent'); | ||
client.startLaunch({ | ||
startTime: time, | ||
}); | ||
expect(client.analytics.trackEvent).toHaveBeenCalledWith( | ||
Object.assign(events.CLIENT_JAVASCRIPT_EVENTS.START_LAUNCH, { label: 'name|version' }), | ||
); | ||
}); | ||
it('should call analytics.trackEvent without label if agentParams is empty', () => { | ||
const client = new RPClient({ | ||
token: 'startLaunchTest', | ||
endpoint: 'https://rp.us/api/v1', | ||
project: 'tst', | ||
}); | ||
const time = 12345734; | ||
spyOn(client.analytics, 'trackEvent'); | ||
client.startLaunch({ | ||
startTime: time, | ||
}); | ||
expect(client.analytics.trackEvent).toHaveBeenCalledWith(events.CLIENT_JAVASCRIPT_EVENTS.START_LAUNCH); | ||
}); | ||
it('dont start new launch if launchDataRQ.id is not empty', () => { | ||
@@ -194,0 +205,0 @@ const client = new RPClient({ token: 'startLaunchTest', endpoint: 'https://rp.us/api/v1', project: 'tst' }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1962
298
135828
33