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

universal-analytics

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

universal-analytics - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

22

lib/index.js

@@ -34,5 +34,5 @@

this._context = context || {};
this.tid = tid || this.options.tid;
this.cid = this._determineCid(cid, this.options.cid);
this.cid = this._determineCid(cid, this.options.cid, (this.options.strictCidFormat !== false));
}

@@ -393,8 +393,16 @@

var id;
for (var i = 0; i < args.length; i++) {
id = utils.ensureValidCid(args[i]);
if (id !== false) return id;
if (id != null) this._log("Warning! Invalid UUID format '" + args[i] + "'");
var lastItem = args.length-1;
var strict = args[lastItem];
if (strict) {
for (var i = 0; i < lastItem; i++) {
id = utils.ensureValidCid(args[i]);
if (id !== false) return id;
if (id != null) this._log("Warning! Invalid UUID format '" + args[i] + "'");
}
} else {
for (var i = 0; i < lastItem; i++) {
if (args[i]) return args[i];
}
}
return uuid.v4()
return uuid.v4();
},

@@ -401,0 +409,0 @@

{
"name": "universal-analytics",
"version": "0.3.0",
"version": "0.3.1",
"description": "A node module for Google's Universal Analytics tracking",

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

@@ -42,4 +42,8 @@ universal-analytics

Starting with Universal Analytics, a UUID v4 is the preferred user ID format. It is therefor necessary to provide a UUID of such type to `universal-analytics`.
Starting with Universal Analytics, a UUID v4 is the preferred user ID format. It is therefor necessary to provide a UUID of such type to `universal-analytics`. However you can force custom user ID, passing `strictCidFormat: false` in the options:
```javascript
var visitor = ua('UA-XXXX-XX', 'CUSTOM_USERID_1', {strictCidFormat: false});
```
Tracking a pageview without much else is now very simple:

@@ -46,0 +50,0 @@

@@ -65,3 +65,3 @@

should.not.exist(visitor.tid)
visitor.should.not.have.properties('tid')
utils.isUuid(visitor.cid).should.equal(true, "A valid random UUID should have been generated")

@@ -84,3 +84,38 @@ visitor.options.should.eql(options)

it("should generate new cid (UUID) if provided one is in wrong format", function () {
var options = {
tid: "UA-XXXXX-XX",
cid: "custom-format-cid"
};
var next = sinon.spy(uuid, 'v4')
var visitor = ua(options);
next.calledOnce.should.equal(true, "next() should've been called once")
var generatedCid = next.returnValues[0]
uuid.v4.restore()
visitor.cid.should.not.equal(options.cid)
visitor.cid.should.equal(generatedCid)
});
it("should accept custom cid format when strictCidFormat is false", function () {
var options = {
tid: "UA-XXXXX-XX",
cid: "custom-format-cid",
strictCidFormat: false
};
var next = sinon.spy(uuid, 'v4')
var visitor = ua(options);
next.called.should.equal(false, "next() should't be called")
uuid.v4.restore()
visitor.cid.should.equal(options.cid)
});
describe("#debug", function () {

@@ -87,0 +122,0 @@

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