Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leek

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leek - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

62

lib/leek.js

@@ -8,2 +8,3 @@ 'use strict';

chalk = require('chalk'),
inquirer = require('inquirer'),
debounce = require('lodash').debounce;

@@ -42,6 +43,6 @@

Leek.prototype._save = debounce(function(eventType, message) {
Leek.prototype._save = debounce(function(eventType, meta) {
var cp = fork(path.join(__dirname, 'send.js'));
cp.send({ leekConfig: this._getConfigObject(), eventType: eventType, message: message });
cp.send({ leekConfig: this._getConfigObject(), eventType: eventType, meta: meta });
cp.unref();

@@ -55,3 +56,3 @@ cp.disconnect();

return provider.apply(this, arguments);
}
};

@@ -67,3 +68,3 @@ Leek.prototype._getConfigObject = function() {

Leek.prototype.track = function() {
Leek.prototype._track = function(eventType, meta) {
if (this.silent) {

@@ -78,37 +79,34 @@ return;

this._queue[Date.now() + '|' + path] = path;
this._save('appview');
this._save(eventType, meta);
};
Leek.prototype.trackError = function(message) {
if (this.silent) {
return;
}
var path = [].map.call(arguments, function(arg) {
return String(arg).trim();
}).join(' ');
this._queue[Date.now() + '|' + path] = path;
this._save('exception', message);
Leek.prototype.track = function(name, message) {
this._track('appview', {
name: name,
message: message
});
};
/*
trackError
ec: 'ACTION',
ea: 'deACTION',
el: 'laction',
utc: 'rebuild time',
utv: 'live reload',
utt: 200,
utl: 'broccoli',
*/
Leek.prototype.trackRebuild = function() {
Leek.prototype.trackError = function(description, fatal) {
this._track('exception', {
description: description,
fatal: fatal
});
};
Leek.prototype.trackCommand = function() {
Leek.prototype.trackTiming = function(category, variable, value) {
this._track('timing', {
category: category,
variable: variable,
value: value
});
};
Leek.prototype.trackFlag = function() {
Leek.prototype.trackEvent = function(name, category, label, value) {
this._track('event', {
name: name,
category: category,
label: label,
value: value
});
};

@@ -134,4 +132,4 @@

}.bind(this));
}
};
module.exports = Leek;
'use strict';
module.exports = function(id, path, eventType, message) {
var now = Date.now(),
params = {
v: 1, // GA API version
t: eventType, // event type
aip: 1, // anonymize IP
tid: this.trackingCode,
cid: this.clientId,
an: this.name,
av: this.version,
cd: path + '[' + this.version + ']',
qt: now - parseInt(id, 10), // queue time - delta (ms) between now and track time
z: now // cache busting
};
var getAppViewObject = function() {
var now = Date.now(),
args = [].slice.call(arguments),
id = args.slice(2, 3)[0],
meta = args.slice(1, 2)[0];
return { url: 'http://www.google-analytics.com/collect', qs: params };
console.log(meta.name + ' ' + meta.message)
console.log(this.name + ' ' + this.version)
console.log(id)
return {
v: 1,
t: 'appview',
aip: 1,
tid: this.trackingCode,
cid: this.clientId,
an: this.name,
av: this.version,
cd: meta.name + ' ' + meta.message,
qt: now - parseInt(id, 10),
z: now
};
};
var getExceptionObject = function() {
var now = Date.now();
return {
v: 1,
t: 'exception',
aip: 1,
tid: this.trackingCode,
cid: this.clientId,
an: this.name,
av: this.version,
exd: path,
exf: true,
qt: now - parseInt(id, 10),
z: now
};
};
var getTimingObject = function() {
var now = Date.now();
return {
v: 1,
t: 'timing',
aip: 1,
tid: this.trackingCode,
cid: this.clientId,
an: this.name,
av: this.version,
utc: 'rebuild time',
utv: 'live reload',
utt: 200,
utl: 'broccoli',
qt: now - parseInt(id, 10),
z: now
};
};
var getEventObject = function() {
var now = Date.now(),
args = [].slice.call(arguments),
id = args.slice(2, 3)[0],
meta = args.slice(1, 2)[0];
return { v: 1,
t: 'event',
aip: 1,
tid: this.trackingCode,
cid: this.clientId,
an: this.name,
av: this.version,
ec: meta.category,
ea: meta.name,
el: meta.value,
ev: meta.label,
qt: now - parseInt(id, 10),
z: now
};
};
var adapters = {
appview: function() {
return { url: 'http://www.google-analytics.com/collect', qs: getAppViewObject.apply(this, arguments) };
},
exception: function() {
return { url: 'http://www.google-analytics.com/collect', qs: getExceptionObject.apply(this, arguments) };
},
timing: function() {
return { url: 'http://www.google-analytics.com/collect', qs: getTimingObject.apply(this, arguments) };
},
event: function() {
return { url: 'http://www.google-analytics.com/collect', qs: getEventObject.apply(this, arguments) };
}
};
module.exports = function(eventType) {
return adapters[eventType].apply(this, arguments);
};

@@ -21,3 +21,3 @@ 'use strict';

request(leek._getRequest(id, path, configObject.eventType, configObject.message), function(error) {
request(leek._getRequest(configObject.eventType, configObject.meta, id, path), function(error) {
if (error) {

@@ -24,0 +24,0 @@ return cb(error);

{
"name": "leek",
"description": "GA tracking",
"version": "0.0.2",
"version": "0.0.3",
"keywords": ["stats", "google", "analytics", "track", "metrics"],

@@ -6,0 +6,0 @@ "author": {

@@ -5,8 +5,30 @@ ## Leek

### Features
Track Error via Events:
+ track errors/exceptions
+ rebuilds (timings)
+ installation (new/init)
+ commands used
+ flags used
```javascript
var Leek = require('./lib/leek'),
leek = new Leek({
trackingCode: 'xx-xxxxxxxx-x',
name: 'my-nifty-package',
version: '1.0.1'
});
try {
throw new Error('ZOMG FIX ME')
} catch(e) {
leek.trackEvent('my-nifty-package show pony', 'Exception', e.message, e.stack);
}
```
Track command hits:
```javascript
var Leek = require('./lib/leek'),
leek = new Leek({
trackingCode: 'xx-xxxxxxxx-x',
name: 'my-nifty-package',
version: '1.0.1'
});
leek.track('my-nifty-package show pony', 'pony is here');
```

@@ -8,6 +8,2 @@ var Leek = require('./lib/leek'),

try {
throw new Error('ZOMG FIX ME')
} catch(e) {
leek.track('ember build', e.stack, e.message);
}
leek.track('ember build', 'stuff');

@@ -58,5 +58,4 @@ 'use strict';

assert.ok(leek.trackError);
assert.ok(leek.trackRebuild);
assert.ok(leek.trackCommand);
assert.ok(leek.trackFlag);
assert.ok(leek.trackTiming);
assert.ok(leek.trackEvent);
});

@@ -72,3 +71,5 @@

assert.ok(leek._getConfigObject);
assert.ok(leek._track);
assert.ok(leek._getRequest);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc