@weeb_services/wapi-core
Advanced tools
Comparing version 1.4.0 to 1.4.1-alpha1
@@ -5,2 +5,9 @@ const Middleware = require('./base.middleware') | ||
class Track extends Middleware { | ||
constructor (name, version, environment) { | ||
super() | ||
this.name = name | ||
this.version = version | ||
this.environment = environment | ||
} | ||
async exec (req) { | ||
@@ -20,9 +27,20 @@ let ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress | ||
} | ||
const visitor = ua(req.config.track, {https: true}) | ||
visitor.pageview({ | ||
const visitor = ua(req.config.track, uid, {https: true, strictCidFormat: false}) | ||
const trackingData = { | ||
uid, | ||
uip: ip, | ||
ua: req.headers['user-agent'], | ||
dl: fullUrl | ||
}, (err) => { | ||
dl: fullUrl, | ||
an: `${this.name}_${this.environment}`, | ||
av: this.version | ||
} | ||
if (req.account) { | ||
const extraData = { | ||
cd1: req.account.discordUserId, | ||
cd2: req.account.id, | ||
cd3: req.account.name | ||
} | ||
Object.assign(trackingData, extraData) | ||
} | ||
visitor.pageview(trackingData, (err) => { | ||
if (err) { | ||
@@ -29,0 +47,0 @@ console.log(err) |
{ | ||
"name": "@weeb_services/wapi-core", | ||
"version": "1.4.0", | ||
"version": "1.4.1-alpha1", | ||
"description": "Weeb API core", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
70631
406
2