@forge/util
Advanced tools
Comparing version 0.3.2 to 0.3.3
{ | ||
"name": "@forge/util", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "module": "./packages", |
{ | ||
"name": "analytics-node-client", | ||
"version": "1.0.108", | ||
"version": "1.0.110", | ||
"description": "Analytics Serverside client for Node JS", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -20,2 +20,3 @@ # Analytics Node Client | ||
subproduct: 'software' // Optional | ||
sendEventHook: (event) => {} // Optional callback | ||
}); | ||
@@ -69,3 +70,3 @@ ``` | ||
#### Reporing OS info/version | ||
#### Reporting OS info/version | ||
OS version can be optionally reported with `os` attribute of an event: | ||
@@ -76,3 +77,3 @@ ```javascript | ||
os: { | ||
name: os.platformt(), | ||
name: os.platform(), | ||
version: os.version() | ||
@@ -83,2 +84,12 @@ } | ||
#### Reporting event creation time | ||
Creation time of the analytics event can be optionally reported with the `timestamp` attribute of an event: | ||
```javascript | ||
this.analyticsClient.track({ | ||
... | ||
timestamp: new Date() | ||
}) | ||
``` | ||
For compatibility with the underlying `node-analytics` library the timestamp must be supplied as a Date object. | ||
This creation timestamp will be reflected as `originalTimestamp` after processing. | ||
@@ -85,0 +96,0 @@ |
@@ -104,3 +104,4 @@ 'use strict'; | ||
constructor({env, product, subproduct, datacenter, version, origin, flushAt, flushInterval, baseUrl}) { | ||
constructor( | ||
{env, product, subproduct, sendEventHook, datacenter, version, origin, flushAt, flushInterval, baseUrl}) { | ||
requireValue(env, 'env'); | ||
@@ -113,2 +114,3 @@ requireValue(product, 'product'); | ||
subproduct, | ||
sendEventHook, | ||
datacenter, | ||
@@ -126,30 +128,129 @@ origin: useDefault(origin, EVENT_ORIGIN), | ||
sendOperationalEvent( | ||
{userIdType, userId, anonymousId, tenantIdType, tenantId, operationalEvent, subproduct, product, os}) { | ||
return validateOperationalEvent({userIdType, userId, anonymousId, tenantIdType, tenantId, operationalEvent}) | ||
_eventCallback(event) { | ||
if (this.config.sendEventHook) { | ||
this.config.sendEventHook(event); | ||
} | ||
} | ||
_buildCompleteTrackEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, trackEvent, subproduct, product, os, timestamp | ||
}) { | ||
return { | ||
userId, | ||
anonymousId, | ||
event: trackEvent.actionSubject + ' ' + trackEvent.action, | ||
properties: AnalyticsClient._buildProperties({ | ||
userIdType, | ||
tenantIdType, | ||
tenantId, | ||
trackEvent, | ||
subproduct: useDefault(subproduct, this.config.subproduct), | ||
product: useDefault(product, this.config.product), | ||
env: this.config.env, | ||
datacenter: this.config.datacenter, | ||
version: this.config.version, | ||
origin: useDefault(trackEvent.origin, this.config.origin) | ||
}), | ||
timestamp, | ||
context: { | ||
os | ||
} | ||
}; | ||
} | ||
_buildCompleteOperationalEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, operationalEvent, subproduct, product, os, timestamp | ||
}) { | ||
return { | ||
userId, | ||
anonymousId, | ||
event: operationalEvent.actionSubject + ' ' + operationalEvent.action, | ||
properties: AnalyticsClient._buildOperationalProperties({ | ||
userIdType, | ||
tenantIdType, | ||
tenantId, | ||
operationalEvent, | ||
subproduct: useDefault(subproduct, this.config.subproduct), | ||
product: useDefault(product, this.config.product), | ||
env: this.config.env, | ||
datacenter: this.config.datacenter, | ||
version: this.config.version, | ||
origin: useDefault(operationalEvent.origin, this.config.origin) | ||
}), | ||
timestamp, | ||
context: { | ||
os | ||
} | ||
}; | ||
} | ||
_buildCompleteUIEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, uiEvent, subproduct, product, os, timestamp | ||
}) { | ||
return { | ||
userId, | ||
anonymousId, | ||
event: uiEvent.actionSubject + ' ' + uiEvent.action, | ||
properties: AnalyticsClient._buildUIProperties({ | ||
userIdType, | ||
tenantIdType, | ||
tenantId, | ||
uiEvent, | ||
subproduct: useDefault(subproduct, this.config.subproduct), | ||
product: useDefault(product, this.config.product), | ||
env: this.config.env, | ||
datacenter: this.config.datacenter, | ||
version: this.config.version, | ||
origin: useDefault(uiEvent.origin, this.config.origin) | ||
}), | ||
timestamp, | ||
context: { | ||
os | ||
} | ||
}; | ||
} | ||
_buildScreenEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, name, screenEvent, subproduct, product, os, timestamp | ||
}) { | ||
return { | ||
userId, | ||
anonymousId, | ||
name, | ||
properties: AnalyticsClient._buildScreenProperties({ | ||
userIdType, | ||
tenantIdType, | ||
tenantId, | ||
screenEvent, | ||
subproduct: useDefault(subproduct, this.config.subproduct), | ||
product: useDefault(product, this.config.product), | ||
env: this.config.env, | ||
datacenter: this.config.datacenter, | ||
version: this.config.version, | ||
origin: useDefault(screenEvent.origin, this.config.origin) | ||
}), | ||
timestamp, | ||
context: { | ||
os | ||
} | ||
}; | ||
} | ||
sendOperationalEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, operationalEvent, subproduct, product, os, timestamp | ||
}) { | ||
return validateOperationalEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, timestamp, operationalEvent | ||
}) | ||
.then(() => | ||
new Promise((resolve, reject) => { | ||
this.analyticsClient.track({ | ||
userId, | ||
anonymousId, | ||
event: operationalEvent.actionSubject + ' ' + operationalEvent.action, | ||
properties: AnalyticsClient._buildOperationalProperties({ | ||
userIdType, | ||
tenantIdType, | ||
tenantId, | ||
operationalEvent, | ||
subproduct: useDefault(subproduct, this.config.subproduct), | ||
product: useDefault(product, this.config.product), | ||
env: this.config.env, | ||
datacenter: this.config.datacenter, | ||
version: this.config.version, | ||
origin: useDefault(operationalEvent.origin, this.config.origin) | ||
}), | ||
context: { | ||
os | ||
} | ||
}, (error, data) => { | ||
const completeEvent = this._buildCompleteOperationalEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, | ||
operationalEvent, subproduct, product, os, timestamp | ||
}); | ||
this.analyticsClient.track(completeEvent, (error, data) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
this._eventCallback(completeEvent); | ||
resolve(data); | ||
@@ -162,29 +263,17 @@ } | ||
sendTrackEvent({userIdType, userId, anonymousId, tenantIdType, tenantId, trackEvent, subproduct, product, os}) { | ||
return validateTrackEvent({userIdType, userId, anonymousId, tenantIdType, tenantId, trackEvent}) | ||
sendTrackEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, trackEvent, subproduct, product, os, timestamp | ||
}) { | ||
return validateTrackEvent({userIdType, userId, anonymousId, tenantIdType, tenantId, timestamp, trackEvent}) | ||
.then(() => | ||
new Promise((resolve, reject) => { | ||
this.analyticsClient.track({ | ||
userId, | ||
anonymousId, | ||
event: trackEvent.actionSubject + ' ' + trackEvent.action, | ||
properties: AnalyticsClient._buildProperties({ | ||
userIdType, | ||
tenantIdType, | ||
tenantId, | ||
trackEvent, | ||
subproduct: useDefault(subproduct, this.config.subproduct), | ||
product: useDefault(product, this.config.product), | ||
env: this.config.env, | ||
datacenter: this.config.datacenter, | ||
version: this.config.version, | ||
origin: useDefault(trackEvent.origin, this.config.origin) | ||
}), | ||
context: { | ||
os | ||
} | ||
}, (error, data) => { | ||
const completeEvent = this._buildCompleteTrackEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, | ||
trackEvent, subproduct, product, os, timestamp | ||
}); | ||
this.analyticsClient.track(completeEvent, (error, data) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
this._eventCallback(completeEvent); | ||
resolve(data); | ||
@@ -197,29 +286,17 @@ } | ||
sendUIEvent({userIdType, userId, anonymousId, tenantIdType, tenantId, uiEvent, subproduct, product, os}) { | ||
return validateUIEvent({userIdType, userId, anonymousId, tenantIdType, tenantId, uiEvent}) | ||
sendUIEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, uiEvent, subproduct, product, os, timestamp | ||
}) { | ||
return validateUIEvent({userIdType, userId, anonymousId, tenantIdType, tenantId, timestamp, uiEvent}) | ||
.then(() => | ||
new Promise((resolve, reject) => { | ||
this.analyticsClient.track({ | ||
userId, | ||
anonymousId, | ||
event: uiEvent.actionSubject + ' ' + uiEvent.action, | ||
properties: AnalyticsClient._buildUIProperties({ | ||
userIdType, | ||
tenantIdType, | ||
tenantId, | ||
uiEvent, | ||
subproduct: useDefault(subproduct, this.config.subproduct), | ||
product: useDefault(product, this.config.product), | ||
env: this.config.env, | ||
datacenter: this.config.datacenter, | ||
version: this.config.version, | ||
origin: useDefault(uiEvent.origin, this.config.origin) | ||
}), | ||
context: { | ||
os | ||
} | ||
}, (error, data) => { | ||
const completeEvent = this._buildCompleteUIEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, | ||
tenantId, uiEvent, subproduct, product, os, timestamp | ||
}); | ||
this.analyticsClient.track(completeEvent, (error, data) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
this._eventCallback(completeEvent); | ||
resolve(data); | ||
@@ -232,30 +309,19 @@ } | ||
sendScreenEvent({userIdType, userId, anonymousId, tenantIdType, tenantId, name, screenEvent, subproduct, product, | ||
os}) { | ||
return validateScreenEvent({userIdType, userId, anonymousId, tenantIdType, tenantId, name, screenEvent}) | ||
sendScreenEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, name, screenEvent, subproduct, product, os, timestamp | ||
}) { | ||
return validateScreenEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, name, timestamp, screenEvent | ||
}) | ||
.then(() => | ||
new Promise((resolve, reject) => { | ||
this.analyticsClient.page({ | ||
userId, | ||
anonymousId, | ||
name, | ||
properties: AnalyticsClient._buildScreenProperties({ | ||
userIdType, | ||
tenantIdType, | ||
tenantId, | ||
screenEvent, | ||
subproduct: useDefault(subproduct, this.config.subproduct), | ||
product: useDefault(product, this.config.product), | ||
env: this.config.env, | ||
datacenter: this.config.datacenter, | ||
version: this.config.version, | ||
origin: useDefault(screenEvent.origin, this.config.origin) | ||
}), | ||
context: { | ||
os | ||
} | ||
}, (error, data) => { | ||
const completeEvent = this._buildScreenEvent({ | ||
userIdType, userId, anonymousId, tenantIdType, tenantId, | ||
name, screenEvent, subproduct, product, os, timestamp | ||
}); | ||
this.analyticsClient.page(completeEvent, (error, data) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
this._eventCallback(completeEvent); | ||
resolve(data); | ||
@@ -262,0 +328,0 @@ } |
@@ -9,8 +9,3 @@ const { lstatSync, readdirSync } = require('fs'); | ||
packages.forEach(path => { | ||
exec(`cd ${path} && npm install --production`, (err) => { | ||
if (err) { | ||
console.error(err); | ||
process.exit(err.code); | ||
} | ||
}); | ||
exec(`cd ${path} && npm install --production`); | ||
}); |
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
175383
1665