@balena/event-log
Advanced tools
Comparing version 4.1.0 to 4.1.1-fix-for-latest-vendor-ga-version-9d59332777aab6005fe5ee75ce4c7562c2e38da0
@@ -7,2 +7,6 @@ # Change Log | ||
## 4.1.1 - 2020-12-04 | ||
* test: Update GA mock checks for the latest client behavior [Thodoris Greasidis] | ||
## 4.1.0 - 2020-07-15 | ||
@@ -9,0 +13,0 @@ |
{ | ||
"name": "@balena/event-log", | ||
"version": "4.1.0", | ||
"version": "4.1.1-fix-for-latest-vendor-ga-version-9d59332777aab6005fe5ee75ce4c7562c2e38da0", | ||
"description": "Balena events logging util", | ||
@@ -5,0 +5,0 @@ "main": "build/balena-event-log.js", |
@@ -192,5 +192,5 @@ var pick = require('lodash/pick'); | ||
if (err) { | ||
return reject(err) | ||
return reject(err); | ||
} | ||
resolve(result) | ||
resolve(result); | ||
}, | ||
@@ -208,10 +208,12 @@ ); | ||
return new Promise(function (resolve) { | ||
resolve(hooks.afterCreate.call( | ||
_this, | ||
err, | ||
type, | ||
jsonData, | ||
applicationId, | ||
deviceId, | ||
)); | ||
resolve( | ||
hooks.afterCreate.call( | ||
_this, | ||
err, | ||
type, | ||
jsonData, | ||
applicationId, | ||
deviceId, | ||
), | ||
); | ||
}).catch(function (err2) { | ||
@@ -245,9 +247,9 @@ // discard the hook error | ||
return runAfterHook(); | ||
}) | ||
if (callback) { | ||
p.then((result) => { | ||
callback(null, result); | ||
}, callback); | ||
} | ||
return p; | ||
}); | ||
if (callback) { | ||
p.then((result) => { | ||
callback(null, result); | ||
}, callback); | ||
} | ||
return p; | ||
}, | ||
@@ -254,0 +256,0 @@ // These functions are only available for use in the browser |
@@ -61,2 +61,26 @@ var Analytics = require('analytics-client') | ||
function validateGaData (data, event, user) { | ||
try { | ||
data = querystring.parse(data) | ||
return ( | ||
data && | ||
data.t === 'event' && | ||
data.tid === GA_ID && | ||
data.ec === GA_SITE && | ||
data.el === SYSTEM && | ||
(!event || data.ea === event) && | ||
(!user || data.uid == user.id) | ||
) | ||
} catch (e) { | ||
return false | ||
} | ||
} | ||
function validateGaQuery(event, user) { | ||
return function (queryObject) { | ||
if (!queryObject) return false | ||
return validateGaData(queryObject, event, user); | ||
} | ||
} | ||
function validateGaBody(event, user) { | ||
@@ -69,11 +93,3 @@ return function (bodyString) { | ||
data = querystring.parse(data) | ||
return ( | ||
data && | ||
data.t === 'event' && | ||
data.tid === GA_ID && | ||
data.ec === GA_SITE && | ||
data.el === SYSTEM && | ||
(!event || data.ea === event) && | ||
(!user || data.uid == user.id) | ||
) | ||
return validateGaData(data, event, user); | ||
} catch (e) { | ||
@@ -99,2 +115,12 @@ return false | ||
acc.push(mock.create(browserOpts)) | ||
// On the latest vendor ga client always sends the first | ||
// request on `/j/collect` and all the data are on the | ||
// query string instead of the body | ||
var initialRequestOpts = _.clone(options) | ||
initialRequestOpts.endpoint = '/j' + options.endpoint | ||
delete initialRequestOpts.filterBody | ||
initialRequestOpts.filterQuery = validateGaQuery(options.event, options.user) | ||
acc.push(mock.create(initialRequestOpts)) | ||
return acc | ||
@@ -101,0 +127,0 @@ }, []) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
73359
1453
1