New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

electron-google-analytics

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-google-analytics - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

2

package.json
{
"name": "electron-google-analytics",
"version": "0.0.4",
"version": "0.0.5",
"description": "A library to implement Google Analytics in desktop apps.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

### Google Analytics - [Measurement Protocol API](https://developers.google.com/analytics/devguides/collection/protocol/v1/)
![travis-ci](https://travis-ci.org/vacu/electron-google-analytics.svg?branch=master)
The main purpose of this was to be used with [Electron](http://electron.atom.io/) built apps.

@@ -62,2 +65,35 @@

* Transaction
`Analytics#transaction(trnID, { trnAffil, trnRev, trnShip, trnTax, currCode } = {}, clientID)`
```javascript
return analytics.transaction(123).then((response) => {
return response;
}).catch((err) => {
return err;
});
```
* Social
`Analytics#social(socialAction, socialNetwork, socialTarget, clientID)`
```javascript
return analytics.social('like', 'facebook', 'home').then((response) => {
return response;
}).catch((err) => {
return err;
});
```
* Exception
`Analytics#exception(exDesc, exFatal, clientID)`
```javascript
return analytics.exception('IOException', 1).then((response) => {
return response;
}).catch((err) => {
return err;
});
```
* Send (for everything else for now)

@@ -64,0 +100,0 @@

@@ -76,3 +76,3 @@ const request = require('request');

screen(appName, appVer, appID, appInstallerID, screenName, clientID) {
let params = {
const params = {
an: appName,

@@ -89,2 +89,62 @@ av: appVer,

/**
* Send a "transaction" request
*
* @param {string} trnID Transaction ID
* @param {string} trnAffil Transaction affiliation
* @param {string} trnRev Transaction Revenue
* @param {Number} trnShip Transaction shipping
* @param {Number} trnTax Transaction tax
* @param {string} currCode Currency code
* @param {string} clientID uuidV4
*
* @return {Promise}
*/
transaction(trnID, { trnAffil, trnRev, trnShip, trnTax, currCode } = {}, clientID) {
let params = { ti: trnID };
if (trnAffil) params['ta'] = trnAffil;
if (trnRev) params['tr'] = trnRev;
if (trnShip) params['ts'] = trnShip;
if (trnTax) params['tt'] = trnTax;
if (currCode) params['cu'] = currCode;
return this.send('transaction', params, clientID);
}
/**
* Send a "social" request
*
* @param {string} socialAction Social Action
* @param {string} socialNetwork Social Network
* @param {string} socialTarget Social Target
* @param {string} clientID uuidV4
*
* @return {Promise}
*/
social(socialAction, socialNetwork, socialTarget, clientID) {
const params = {
sa: socialAction,
sn: socialNetwork,
st: socialTarget
};
return this.send('social', params, clientID);
}
/**
* Sned a "exception" request
*
* @param {string} exDesc Exception description
* @param {Number} exFatal Exception is fatal?
* @param {string} clientID uuidV4
*
* @return {Promise}
*/
exception(exDesc, exFatal, clientID) {
const params = { exd: exDesc, exf: exFatal };
return this.send('exception', params, clientID);
}
/**
* Send a request to google-analytics

@@ -91,0 +151,0 @@ *

@@ -42,2 +42,32 @@ import chai from 'chai';

it('should send a transaction request', function() {
const analytics = new Analytics(trackingID, { debug: true });
return analytics.transaction(123).then((response) => {
return expect(response).to.have.property('clientID');
}).catch((err) => {
return expect(err).to.be.empty;
});
});
it('should send a social request', function() {
const analytics = new Analytics(trackingID, { debug: true });
return analytics.social('like', 'facebook', 'home').then((response) => {
return expect(response).to.have.property('clientID');
}).catch((err) => {
return expect(err).to.be.empty;
});
});
it('should send a social request', function() {
const analytics = new Analytics(trackingID, { debug: true });
return analytics.exception('IOException', 1).then((response) => {
return expect(response).to.have.property('clientID');
}).catch((err) => {
return expect(err).to.be.empty;
});
});
it('should send a custom request', function() {

@@ -88,2 +118,32 @@ const analytics = new Analytics(trackingID, { debug: true });

it('should fail sending a transaction request', function() {
const analytics = new Analytics('', { debug: true });
return analytics.transaction(123).then((response) => {
return expect(response).to.be.empty;
}).catch((err) => {
return expect(err).to.not.be.empty;
});
});
it('should fail sending a social request', function() {
const analytics = new Analytics('', { debug: true });
return analytics.social('like', 'facebook', 'home').then((response) => {
return expect(response).to.be.empty;
}).catch((err) => {
return expect(err).to.not.be.empty;
});
});
it('should fail sending a social request', function() {
const analytics = new Analytics('', { debug: true });
return analytics.exception('IOException', 1).then((response) => {
return expect(response).to.be.empty;
}).catch((err) => {
return expect(err).to.not.be.empty;
});
});
it('should fail sending a custom request', function() {

@@ -90,0 +150,0 @@ const analytics = new Analytics('', { debug: true });

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