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

balena-universal-gosquared

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balena-universal-gosquared - npm Package Compare versions

Comparing version 1.0.0-1-x-3f734b3dc3e310ee9cd678e1f0f6b349848c554e to 1.0.0-1-x-c55a24d93997d971e6a1f2264a121cfa84b8a48c

build/browser.js

3

CHANGELOG.md

@@ -10,2 +10,5 @@ # Change Log

* Switch to native promises [Pagan Gazzard]
* Add linting [Pagan Gazzard]
* Add type checking [Pagan Gazzard]
* Rename to balena [Pagan Gazzard]

@@ -12,0 +15,0 @@

20

package.json
{
"name": "balena-universal-gosquared",
"version": "1.0.0-1-x-3f734b3dc3e310ee9cd678e1f0f6b349848c554e",
"version": "1.0.0-1-x-c55a24d93997d971e6a1f2264a121cfa84b8a48c",
"description": "A CommonJS wrapper for both Node.js and browser (async) version of goSquared Analytics library",
"main": "src/node.js",
"browser": "src/browser.js",
"scripts": {},
"main": "build/node.js",
"browser": "build/browser.js",
"scripts": {
"lint": "balena-lint -e js -e ts --typescript src/browser.js src/gs-loader.d.ts src/node.js",
"lint-fix": "balena-lint -e js -e ts --typescript --fix src/browser.js src/gs-loader.d.ts src/node.js",
"test": "npm run lint",
"prepare": "tsc"
},
"keywords": [],

@@ -12,3 +17,2 @@ "author": "Craig Mulligan <craig@balena.io>",

"dependencies": {
"bluebird": "^3.4.7",
"gosquared": "3.1.0"

@@ -20,3 +24,7 @@ },

},
"homepage": "https://github.com/balena-io-modules/balena-universal-gosquared"
"homepage": "https://github.com/balena-io-modules/balena-universal-gosquared",
"devDependencies": {
"@balena/lint": "^5.1.0",
"typescript": "^3.9.6"
}
}

@@ -1,50 +0,56 @@

require('./gs-loader')
require('./gs-loader');
var Promise = require('bluebird')
var TRACKER_NAME = 'balenaAnalytics'
var TRACKER_NAME = 'balenaAnalytics';
module.exports = function (gosquaredId, apiKey, debug) {
var loggedIn = false
var booted = false
module.exports = function (gosquaredId, _apiKey, debug) {
var loggedIn = false;
var booted = false;
return {
boot: function() {
if (booted) return
boot: function () {
if (booted) {
return;
}
// automatically track pageviews in debug mode
window._gs(gosquaredId, TRACKER_NAME, debug)
window._gs(gosquaredId, TRACKER_NAME, debug);
// switch on tracking on local host in debug mode
window._gs(TRACKER_NAME + '.set', 'trackLocal', debug)
booted = true
window._gs(TRACKER_NAME + '.set', 'trackLocal', debug);
booted = true;
},
anonLogin: function () {
this.boot()
this.boot();
},
login: function (userId) {
if (!userId) throw new Error('userId required call .login')
if (!booted) this.boot()
if (!userId) {
throw new Error('userId required call .login');
}
if (!booted) {
this.boot();
}
window._gs(TRACKER_NAME + '.identify', {
id: userId
})
id: userId,
});
loggedIn = true
loggedIn = true;
},
logout: function () {
if (booted && loggedIn) {
window._gs(TRACKER_NAME + '.unidentify')
loggedIn = false
window._gs(TRACKER_NAME + '.unidentify');
loggedIn = false;
}
},
track: function (prefix, type, data) {
this.boot()
return Promise.fromCallback(function (callback) {
if (type === 'Page Visit') {
window._gs(TRACKER_NAME + '.track', data.url || window.location.pathname)
} else {
window._gs(TRACKER_NAME + '.event', '[' + prefix + '] ' + type, data)
}
callback()
})
this.boot();
if (type === 'Page Visit') {
window._gs(
TRACKER_NAME + '.track',
data.url || window.location.pathname,
);
} else {
window._gs(TRACKER_NAME + '.event', '[' + prefix + '] ' + type, data);
}
return Promise.resolve();
},
}
}
};
};

@@ -1,36 +0,44 @@

var Promise = require('bluebird')
var GoSquared = require('gosquared')
var GoSquared = require('gosquared');
module.exports = function(gosquaredId, apiKey, debug) {
var goSquared
module.exports = function (gosquaredId, apiKey, _debug) {
var goSquared;
return {
boot: function() {
if (goSquared) return
boot: function () {
if (goSquared) {
return;
}
goSquared = new GoSquared({
api_key: apiKey,
site_token: gosquaredId
})
site_token: gosquaredId,
});
},
anonLogin: function() {
this.boot()
anonLogin: function () {
this.boot();
},
login: function(userId) {
if (!goSquared) this.boot()
login: function (userId) {
if (!goSquared) {
this.boot();
}
goSquared = goSquared.createPerson(userId)
goSquared = goSquared.createPerson(userId);
},
logout: function() {
goSquared = null
logout: function () {
goSquared = null;
},
track: function(prefix, type, data) {
track: function (prefix, type, data) {
// if called before `login` create an event without user attached.
this.boot()
return Promise.fromCallback(function (callback) {
this.boot();
return new Promise(function (resolve, reject) {
// node sdk doesn't support pageviews so no conditional here.
// https://www.gosquared.com/docs/api/tracking/pageview/node/
goSquared.trackEvent('[' + prefix + '] ' + type, data, callback)
})
}
}
}
goSquared.trackEvent('[' + prefix + '] ' + type, data, (err, result) => {
if (err) {
return reject(err)
}
resolve(result);
});
});
},
};
};
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