Skip to content

Commit

Permalink
Some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Jul 17, 2023
1 parent 07f9b08 commit 5cf1c62
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions statistics/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const axios = require('axios');
const { MEASUREMENT_ID, API_KEY, PJSON_NAME, PJSON_VERSION, INTERPRETER } = require('./constants');
const { getClientId } = require('./client-id');

const hasOption = (options, optionName) => {
return Object.prototype.hasOwnProperty.call(options, optionName);
};

class Statistics {
constructor(eventName, agentParams) {
this.eventName = eventName;
Expand All @@ -14,18 +18,10 @@ class Statistics {
client_name: PJSON_NAME,
client_version: PJSON_VERSION,
};
if (
agentParams &&
Object.prototype.hasOwnProperty.call(agentParams, 'name') &&
agentParams.name
) {
if (agentParams && hasOption(agentParams, 'name') && agentParams.name) {
params.agent_name = agentParams.name;
}
if (
agentParams &&
Object.prototype.hasOwnProperty.call(agentParams, 'version') &&
agentParams.version
) {
if (agentParams && hasOption(agentParams, 'version') && agentParams.version) {
params.agent_version = agentParams.version;
}
return params;
Expand Down

0 comments on commit 5cf1c62

Please sign in to comment.