Comparing version 0.0.15 to 0.0.16
'use strict'; | ||
var os = require('os'); | ||
var debug = require('debug')('leek:get-version'); | ||
var map = { | ||
darwin: { | ||
'14.0.0': 'OSX Yosemite', | ||
'14.0': 'OSX Yosemite', | ||
@@ -34,6 +36,16 @@ '13.4.0': 'OSX Mavericks', | ||
function getVersion(platform, release) { | ||
var result; | ||
if (!map[platform]) { | ||
return platform + ' ' + release; | ||
result = platform + ' ' + release; | ||
} else { | ||
var p = os.platform(); | ||
var r = os.release(); | ||
result = map[p][r] || ' ' + p + ' ' + r; | ||
} | ||
return map[os.platform()][os.release()]; | ||
debug('getVersion platform:%s release:%s output:', platform, release, result); | ||
return result; | ||
} | ||
@@ -40,0 +52,0 @@ |
@@ -9,3 +9,4 @@ 'use strict'; | ||
md5 = require('./md5'), | ||
extend = require('lodash').extend; | ||
extend = require('lodash').extend, | ||
debug = require('debug')('leek'); | ||
@@ -26,3 +27,8 @@ function Leek(options) { | ||
this.trackingCode = options.trackingCode; | ||
this.name = options.name || ''; | ||
this.name = options.name; | ||
if (this.name === undefined) { | ||
throw new Error('You need to specify name, this should be a unique identifier for the current client'); | ||
} | ||
this.globalName = options.globalName; | ||
@@ -32,2 +38,11 @@ this.clientId = this.globalName + md5(this.name); | ||
this.silent = options.silent || process.env.DISABLE_LEEK; | ||
debug('initialize %o', { | ||
trackingCode: this.trackingCode, | ||
name: this.name, | ||
globalName: this.globalName, | ||
clientId: this.clientId, | ||
version: this.version, | ||
silent: this.silent | ||
}); | ||
} | ||
@@ -41,2 +56,3 @@ | ||
Leek.prototype._enqueue = function(eventType, meta) { | ||
debug('enqueue eventType:%s silent:%o payload:%o', eventType, this.silent, meta); | ||
if (this.silent) { | ||
@@ -53,2 +69,3 @@ return Promise.resolve(); | ||
debug('request %o', params); | ||
return request(params); | ||
@@ -55,0 +72,0 @@ }; |
'use strict'; | ||
var debug = require('debug')('leek:provider'); | ||
var getAppViewObject = function() { | ||
var now = Date.now(), | ||
args = [].slice.call(arguments), | ||
type = args.slice(0, 1)[0], | ||
id = args.slice(2, 3)[0], | ||
meta = args.slice(1, 2)[0]; | ||
var now = Date.now(); | ||
var type = arguments[0]; | ||
var meta = arguments[1]; | ||
var id = arguments[2]; | ||
return { | ||
var payload = { | ||
v: 1, | ||
@@ -18,16 +18,21 @@ t: type, | ||
av: this.version, | ||
cd: meta.message + ' ' + meta.platform + ', node ' + meta.version, | ||
cd: meta.message, | ||
cd1: meta.platform,// os version | ||
cd2: meta.version, // node version | ||
qt: now - parseInt(id, 10), | ||
z: now | ||
}; | ||
debug('getAppViewObject %o', payload); | ||
return payload; | ||
}; | ||
var getExceptionObject = function() { | ||
var now = Date.now(), | ||
args = [].slice.call(arguments), | ||
type = args.slice(0, 1)[0], | ||
id = args.slice(2, 3)[0], | ||
meta = args.slice(1, 2)[0]; | ||
var now = Date.now(); | ||
var type = arguments[0]; | ||
var meta = arguments[1]; | ||
var id = arguments[2]; | ||
return { | ||
var payload = { | ||
v: 1, | ||
@@ -40,2 +45,5 @@ t: type, | ||
av: this.version, | ||
cd1: meta.platform,// os version | ||
cd2: meta.version, // node version | ||
exd: meta.description + ' ' + meta.platform + ', node ' + meta.version, | ||
@@ -46,12 +54,15 @@ exf: meta.fatal, | ||
}; | ||
debug('getExceptionObject %o', payload); | ||
return payload; | ||
}; | ||
var getTimingObject = function() { | ||
var now = Date.now(), | ||
args = [].slice.call(arguments), | ||
type = args.slice(0, 1)[0], | ||
id = args.slice(2, 3)[0], | ||
meta = args.slice(1, 2)[0]; | ||
var now = Date.now(); | ||
var type = arguments[0]; | ||
var meta = arguments[1]; | ||
var id = arguments[2]; | ||
return { | ||
var payload = { | ||
v: 1, | ||
@@ -68,15 +79,21 @@ t: type, | ||
utl: meta.label, | ||
cd1: meta.platform,// os version | ||
cd2: meta.version, // node version | ||
qt: now - parseInt(id, 10), | ||
z: now | ||
}; | ||
debug('getTimingObject %o', payload); | ||
return payload; | ||
}; | ||
var getEventObject = function() { | ||
var now = Date.now(), | ||
args = [].slice.call(arguments), | ||
type = args.slice(0, 1)[0], | ||
id = args.slice(2, 3)[0], | ||
meta = args.slice(1, 2)[0]; | ||
var now = Date.now(); | ||
var type = arguments[0]; | ||
var meta = arguments[1]; | ||
var id = arguments[2]; | ||
return { | ||
var payload = { | ||
v: 1, | ||
@@ -93,5 +110,10 @@ t: type, | ||
ev: meta.label, | ||
cd1: meta.platform,// os version | ||
cd2: meta.version, // node version | ||
qt: now - parseInt(id, 10), | ||
z: now | ||
}; | ||
debug('getEventObject %o', payload); | ||
return payload; | ||
}; | ||
@@ -101,12 +123,24 @@ | ||
appview: function() { | ||
return { url: 'https://ssl.google-analytics.com/collect', qs: getAppViewObject.apply(this, arguments) }; | ||
return { | ||
url: 'https://ssl.google-analytics.com/collect', | ||
qs: getAppViewObject.apply(this, arguments) | ||
}; | ||
}, | ||
exception: function() { | ||
return { url: 'https://ssl.google-analytics.com/collect', qs: getExceptionObject.apply(this, arguments) }; | ||
return { | ||
url: 'https://ssl.google-analytics.com/collect', | ||
qs: getExceptionObject.apply(this, arguments) | ||
}; | ||
}, | ||
timing: function() { | ||
return { url: 'https://ssl.google-analytics.com/collect', qs: getTimingObject.apply(this, arguments) }; | ||
return { | ||
url: 'https://ssl.google-analytics.com/collect', | ||
qs: getTimingObject.apply(this, arguments) | ||
}; | ||
}, | ||
event: function() { | ||
return { url: 'https://ssl.google-analytics.com/collect', qs: getEventObject.apply(this, arguments) }; | ||
return { | ||
url: 'https://ssl.google-analytics.com/collect', | ||
qs: getEventObject.apply(this, arguments) | ||
}; | ||
} | ||
@@ -116,3 +150,7 @@ }; | ||
module.exports = function(eventType) { | ||
return adapters[eventType].apply(this, arguments); | ||
var adapter = adapters[eventType].apply(this, arguments); | ||
debug('eventType: %s url: %s', eventType, adapter.url); | ||
return adapter; | ||
}; |
{ | ||
"name": "leek", | ||
"description": "GA tracking", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"keywords": [ | ||
@@ -24,5 +24,7 @@ "stats", | ||
"dependencies": { | ||
"rsvp": "^3.0.6", | ||
"debug": "^2.1.0", | ||
"lodash": "^2.4.1", | ||
"request": "^2.27.0", | ||
"lodash": "^2.4.1" | ||
"rewire": "^2.1.3", | ||
"rsvp": "^3.0.6" | ||
}, | ||
@@ -29,0 +31,0 @@ "devDependencies": { |
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
19986
638
5
+ Addeddebug@^2.1.0
+ Addedrewire@^2.1.3
+ Addeddebug@2.6.9(transitive)
+ Addedms@2.0.0(transitive)
+ Addedpsl@1.13.0(transitive)
+ Addedrewire@2.5.2(transitive)
- Removedpsl@1.12.0(transitive)