nativescript 9.1.0-alpha.5 → 9.1.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/mobile/android/android-emulator-services.js +11 -3
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/universal-analytics/.travis.yml +11 -0
- package/node_modules/universal-analytics/AcceptableParams.md +757 -0
- package/node_modules/universal-analytics/HISTORY.md +170 -0
- package/node_modules/universal-analytics/Makefile +5 -0
- package/node_modules/universal-analytics/README.md +651 -0
- package/node_modules/universal-analytics/index.js +2 -0
- package/node_modules/universal-analytics/lib/config.js +171 -0
- package/node_modules/universal-analytics/lib/index.js +563 -0
- package/node_modules/universal-analytics/lib/request.js +73 -0
- package/node_modules/universal-analytics/lib/utils.js +29 -0
- package/node_modules/universal-analytics/package.json +33 -0
- package/node_modules/universal-analytics/test/_enqueue.js +144 -0
- package/node_modules/universal-analytics/test/event.js +346 -0
- package/node_modules/universal-analytics/test/exception.js +233 -0
- package/node_modules/universal-analytics/test/index.js +141 -0
- package/node_modules/universal-analytics/test/item.js +550 -0
- package/node_modules/universal-analytics/test/middleware.js +119 -0
- package/node_modules/universal-analytics/test/mocha.opts +3 -0
- package/node_modules/universal-analytics/test/pageview.js +286 -0
- package/node_modules/universal-analytics/test/send.js +232 -0
- package/node_modules/universal-analytics/test/set.js +68 -0
- package/node_modules/universal-analytics/test/timing.js +363 -0
- package/node_modules/universal-analytics/test/transaction.js +371 -0
- package/node_modules/uuid/LICENSE.md +9 -0
- package/node_modules/uuid/README.md +510 -0
- package/node_modules/uuid/dist/cjs/index.d.ts +15 -0
- package/node_modules/uuid/dist/cjs/index.js +31 -0
- package/node_modules/uuid/dist/cjs/max.d.ts +2 -0
- package/node_modules/uuid/dist/cjs/max.js +3 -0
- package/node_modules/uuid/dist/cjs/md5.d.ts +4 -0
- package/node_modules/uuid/dist/cjs/md5.js +13 -0
- package/node_modules/uuid/dist/cjs/native.d.ts +6 -0
- package/node_modules/uuid/dist/cjs/native.js +4 -0
- package/node_modules/uuid/dist/cjs/nil.d.ts +2 -0
- package/node_modules/uuid/dist/cjs/nil.js +3 -0
- package/node_modules/uuid/dist/cjs/package.json +1 -0
- package/node_modules/uuid/dist/cjs/parse.d.ts +2 -0
- package/node_modules/uuid/dist/cjs/parse.js +11 -0
- package/node_modules/uuid/dist/cjs/regex.d.ts +2 -0
- package/node_modules/uuid/dist/cjs/regex.js +3 -0
- package/node_modules/uuid/dist/cjs/rng.d.ts +1 -0
- package/node_modules/uuid/dist/cjs/rng.js +13 -0
- package/node_modules/uuid/dist/cjs/sha1.d.ts +4 -0
- package/node_modules/uuid/dist/cjs/sha1.js +13 -0
- package/node_modules/uuid/dist/cjs/stringify.d.ts +3 -0
- package/node_modules/uuid/dist/cjs/stringify.js +39 -0
- package/node_modules/uuid/dist/cjs/types.d.ts +21 -0
- package/node_modules/uuid/dist/cjs/types.js +2 -0
- package/node_modules/uuid/dist/cjs/uuid-bin.d.ts +1 -0
- package/node_modules/uuid/dist/cjs/uuid-bin.js +72 -0
- package/node_modules/uuid/dist/cjs/v1.d.ts +11 -0
- package/node_modules/uuid/dist/cjs/v1.js +87 -0
- package/node_modules/uuid/dist/cjs/v1ToV6.d.ts +2 -0
- package/node_modules/uuid/dist/cjs/v1ToV6.js +13 -0
- package/node_modules/uuid/dist/cjs/v3.d.ts +9 -0
- package/node_modules/uuid/dist/cjs/v3.js +14 -0
- package/node_modules/uuid/dist/cjs/v35.d.ts +7 -0
- package/node_modules/uuid/dist/cjs/v35.js +41 -0
- package/node_modules/uuid/dist/cjs/v4.d.ts +4 -0
- package/node_modules/uuid/dist/cjs/v4.js +29 -0
- package/node_modules/uuid/dist/cjs/v5.d.ts +9 -0
- package/node_modules/uuid/dist/cjs/v5.js +14 -0
- package/node_modules/uuid/dist/cjs/v6.d.ts +4 -0
- package/node_modules/uuid/dist/cjs/v6.js +19 -0
- package/node_modules/uuid/dist/cjs/v6ToV1.d.ts +2 -0
- package/node_modules/uuid/dist/cjs/v6ToV1.js +13 -0
- package/node_modules/uuid/dist/cjs/v7.d.ts +9 -0
- package/node_modules/uuid/dist/cjs/v7.js +69 -0
- package/node_modules/uuid/dist/cjs/validate.d.ts +2 -0
- package/node_modules/uuid/dist/cjs/validate.js +7 -0
- package/node_modules/uuid/dist/cjs/version.d.ts +2 -0
- package/node_modules/uuid/dist/cjs/version.js +10 -0
- package/node_modules/uuid/dist/cjs-browser/index.d.ts +15 -0
- package/node_modules/uuid/dist/cjs-browser/index.js +31 -0
- package/node_modules/uuid/dist/cjs-browser/max.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/max.js +3 -0
- package/node_modules/uuid/dist/cjs-browser/md5.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/md5.js +137 -0
- package/node_modules/uuid/dist/cjs-browser/native.d.ts +4 -0
- package/node_modules/uuid/dist/cjs-browser/native.js +4 -0
- package/node_modules/uuid/dist/cjs-browser/nil.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/nil.js +3 -0
- package/node_modules/uuid/dist/cjs-browser/package.json +1 -0
- package/node_modules/uuid/dist/cjs-browser/parse.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/parse.js +11 -0
- package/node_modules/uuid/dist/cjs-browser/regex.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/regex.js +3 -0
- package/node_modules/uuid/dist/cjs-browser/rng.d.ts +1 -0
- package/node_modules/uuid/dist/cjs-browser/rng.js +14 -0
- package/node_modules/uuid/dist/cjs-browser/sha1.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/sha1.js +72 -0
- package/node_modules/uuid/dist/cjs-browser/stringify.d.ts +3 -0
- package/node_modules/uuid/dist/cjs-browser/stringify.js +39 -0
- package/node_modules/uuid/dist/cjs-browser/types.d.ts +21 -0
- package/node_modules/uuid/dist/cjs-browser/types.js +2 -0
- package/node_modules/uuid/dist/cjs-browser/uuid-bin.d.ts +1 -0
- package/node_modules/uuid/dist/cjs-browser/uuid-bin.js +72 -0
- package/node_modules/uuid/dist/cjs-browser/v1.d.ts +11 -0
- package/node_modules/uuid/dist/cjs-browser/v1.js +87 -0
- package/node_modules/uuid/dist/cjs-browser/v1ToV6.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/v1ToV6.js +13 -0
- package/node_modules/uuid/dist/cjs-browser/v3.d.ts +9 -0
- package/node_modules/uuid/dist/cjs-browser/v3.js +14 -0
- package/node_modules/uuid/dist/cjs-browser/v35.d.ts +7 -0
- package/node_modules/uuid/dist/cjs-browser/v35.js +41 -0
- package/node_modules/uuid/dist/cjs-browser/v4.d.ts +4 -0
- package/node_modules/uuid/dist/cjs-browser/v4.js +29 -0
- package/node_modules/uuid/dist/cjs-browser/v5.d.ts +9 -0
- package/node_modules/uuid/dist/cjs-browser/v5.js +14 -0
- package/node_modules/uuid/dist/cjs-browser/v6.d.ts +4 -0
- package/node_modules/uuid/dist/cjs-browser/v6.js +19 -0
- package/node_modules/uuid/dist/cjs-browser/v6ToV1.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/v6ToV1.js +13 -0
- package/node_modules/uuid/dist/cjs-browser/v7.d.ts +9 -0
- package/node_modules/uuid/dist/cjs-browser/v7.js +69 -0
- package/node_modules/uuid/dist/cjs-browser/validate.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/validate.js +7 -0
- package/node_modules/uuid/dist/cjs-browser/version.d.ts +2 -0
- package/node_modules/uuid/dist/cjs-browser/version.js +10 -0
- package/node_modules/uuid/dist/esm/bin/uuid +2 -0
- package/node_modules/uuid/dist/esm/index.d.ts +15 -0
- package/node_modules/uuid/dist/esm/index.js +14 -0
- package/node_modules/uuid/dist/esm/max.d.ts +2 -0
- package/node_modules/uuid/dist/esm/max.js +1 -0
- package/node_modules/uuid/dist/esm/md5.d.ts +4 -0
- package/node_modules/uuid/dist/esm/md5.js +11 -0
- package/node_modules/uuid/dist/esm/native.d.ts +6 -0
- package/node_modules/uuid/dist/esm/native.js +2 -0
- package/node_modules/uuid/dist/esm/nil.d.ts +2 -0
- package/node_modules/uuid/dist/esm/nil.js +1 -0
- package/node_modules/uuid/dist/esm/parse.d.ts +2 -0
- package/node_modules/uuid/dist/esm/parse.js +9 -0
- package/node_modules/uuid/dist/esm/regex.d.ts +2 -0
- package/node_modules/uuid/dist/esm/regex.js +1 -0
- package/node_modules/uuid/dist/esm/rng.d.ts +1 -0
- package/node_modules/uuid/dist/esm/rng.js +10 -0
- package/node_modules/uuid/dist/esm/sha1.d.ts +4 -0
- package/node_modules/uuid/dist/esm/sha1.js +11 -0
- package/node_modules/uuid/dist/esm/stringify.d.ts +3 -0
- package/node_modules/uuid/dist/esm/stringify.js +35 -0
- package/node_modules/uuid/dist/esm/types.d.ts +21 -0
- package/node_modules/uuid/dist/esm/types.js +1 -0
- package/node_modules/uuid/dist/esm/uuid-bin.d.ts +1 -0
- package/node_modules/uuid/dist/esm/uuid-bin.js +70 -0
- package/node_modules/uuid/dist/esm/v1.d.ts +11 -0
- package/node_modules/uuid/dist/esm/v1.js +83 -0
- package/node_modules/uuid/dist/esm/v1ToV6.d.ts +2 -0
- package/node_modules/uuid/dist/esm/v1ToV6.js +10 -0
- package/node_modules/uuid/dist/esm/v3.d.ts +9 -0
- package/node_modules/uuid/dist/esm/v3.js +9 -0
- package/node_modules/uuid/dist/esm/v35.d.ts +7 -0
- package/node_modules/uuid/dist/esm/v35.js +36 -0
- package/node_modules/uuid/dist/esm/v4.d.ts +4 -0
- package/node_modules/uuid/dist/esm/v4.js +27 -0
- package/node_modules/uuid/dist/esm/v5.d.ts +9 -0
- package/node_modules/uuid/dist/esm/v5.js +9 -0
- package/node_modules/uuid/dist/esm/v6.d.ts +4 -0
- package/node_modules/uuid/dist/esm/v6.js +17 -0
- package/node_modules/uuid/dist/esm/v6ToV1.d.ts +2 -0
- package/node_modules/uuid/dist/esm/v6ToV1.js +10 -0
- package/node_modules/uuid/dist/esm/v7.d.ts +9 -0
- package/node_modules/uuid/dist/esm/v7.js +65 -0
- package/node_modules/uuid/dist/esm/validate.d.ts +2 -0
- package/node_modules/uuid/dist/esm/validate.js +5 -0
- package/node_modules/uuid/dist/esm/version.d.ts +2 -0
- package/node_modules/uuid/dist/esm/version.js +8 -0
- package/node_modules/uuid/dist/esm-browser/index.d.ts +15 -0
- package/node_modules/uuid/dist/esm-browser/index.js +14 -0
- package/node_modules/uuid/dist/esm-browser/max.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/max.js +1 -0
- package/node_modules/uuid/dist/esm-browser/md5.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/md5.js +135 -0
- package/node_modules/uuid/dist/esm-browser/native.d.ts +4 -0
- package/node_modules/uuid/dist/esm-browser/native.js +2 -0
- package/node_modules/uuid/dist/esm-browser/nil.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/nil.js +1 -0
- package/node_modules/uuid/dist/esm-browser/parse.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/parse.js +9 -0
- package/node_modules/uuid/dist/esm-browser/regex.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/regex.js +1 -0
- package/node_modules/uuid/dist/esm-browser/rng.d.ts +1 -0
- package/node_modules/uuid/dist/esm-browser/rng.js +11 -0
- package/node_modules/uuid/dist/esm-browser/sha1.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/sha1.js +70 -0
- package/node_modules/uuid/dist/esm-browser/stringify.d.ts +3 -0
- package/node_modules/uuid/dist/esm-browser/stringify.js +35 -0
- package/node_modules/uuid/dist/esm-browser/types.d.ts +21 -0
- package/node_modules/uuid/dist/esm-browser/types.js +1 -0
- package/node_modules/uuid/dist/esm-browser/uuid-bin.d.ts +1 -0
- package/node_modules/uuid/dist/esm-browser/uuid-bin.js +70 -0
- package/node_modules/uuid/dist/esm-browser/v1.d.ts +11 -0
- package/node_modules/uuid/dist/esm-browser/v1.js +83 -0
- package/node_modules/uuid/dist/esm-browser/v1ToV6.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/v1ToV6.js +10 -0
- package/node_modules/uuid/dist/esm-browser/v3.d.ts +9 -0
- package/node_modules/uuid/dist/esm-browser/v3.js +9 -0
- package/node_modules/uuid/dist/esm-browser/v35.d.ts +7 -0
- package/node_modules/uuid/dist/esm-browser/v35.js +36 -0
- package/node_modules/uuid/dist/esm-browser/v4.d.ts +4 -0
- package/node_modules/uuid/dist/esm-browser/v4.js +27 -0
- package/node_modules/uuid/dist/esm-browser/v5.d.ts +9 -0
- package/node_modules/uuid/dist/esm-browser/v5.js +9 -0
- package/node_modules/uuid/dist/esm-browser/v6.d.ts +4 -0
- package/node_modules/uuid/dist/esm-browser/v6.js +17 -0
- package/node_modules/uuid/dist/esm-browser/v6ToV1.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/v6ToV1.js +10 -0
- package/node_modules/uuid/dist/esm-browser/v7.d.ts +9 -0
- package/node_modules/uuid/dist/esm-browser/v7.js +65 -0
- package/node_modules/uuid/dist/esm-browser/validate.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/validate.js +5 -0
- package/node_modules/uuid/dist/esm-browser/version.d.ts +2 -0
- package/node_modules/uuid/dist/esm-browser/version.js +8 -0
- package/node_modules/uuid/package.json +132 -0
- package/package.json +8 -4
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
|
|
2
|
+
var qs = require("querystring");
|
|
3
|
+
var uuid = require("uuid");
|
|
4
|
+
var should = require("should");
|
|
5
|
+
var sinon = require("sinon");
|
|
6
|
+
var url = require("url");
|
|
7
|
+
|
|
8
|
+
var ua = require("../lib/index.js");
|
|
9
|
+
var utils = require("../lib/utils.js")
|
|
10
|
+
var config = require("../lib/config.js")
|
|
11
|
+
var request = require("../lib/request");
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
describe("ua", function () {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
describe("#_enqueue", function () {
|
|
18
|
+
|
|
19
|
+
var send;
|
|
20
|
+
|
|
21
|
+
beforeEach(function () {
|
|
22
|
+
send = sinon.stub(ua.Visitor.prototype, "send").callsArg(0);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(function () {
|
|
26
|
+
send.restore()
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should accept arguments (type)", function () {
|
|
30
|
+
var tid = "UA-XXXXX-XX";
|
|
31
|
+
var cid = uuid.v4();
|
|
32
|
+
var type = Math.random().toString()
|
|
33
|
+
|
|
34
|
+
var visitor = ua(tid, cid)._enqueue(type);
|
|
35
|
+
|
|
36
|
+
send.called.should.equal(false, "#send should not have been called without a callback");
|
|
37
|
+
|
|
38
|
+
visitor._queue.length.should.equal(1, "1 tracking call should have been enqueued");
|
|
39
|
+
|
|
40
|
+
visitor._queue[0].should.have.keys("v", "tid", "cid", "t")
|
|
41
|
+
visitor._queue[0].tid.should.equal(tid)
|
|
42
|
+
visitor._queue[0].cid.should.equal(cid)
|
|
43
|
+
visitor._queue[0].t.should.equal(type)
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should accept arguments (type, fn)", function () {
|
|
47
|
+
var tid = "UA-XXXXX-XX";
|
|
48
|
+
var cid = uuid.v4();
|
|
49
|
+
var type = Math.random().toString()
|
|
50
|
+
var fn = sinon.spy()
|
|
51
|
+
|
|
52
|
+
var visitor = ua(tid, cid)._enqueue(type, fn);
|
|
53
|
+
|
|
54
|
+
send.calledOnce.should.equal(true, "#send should have been called once");
|
|
55
|
+
|
|
56
|
+
visitor._queue.length.should.equal(1, "1 tracking call should have been enqueued");
|
|
57
|
+
|
|
58
|
+
visitor._queue[0].should.have.keys("v", "tid", "cid", "t")
|
|
59
|
+
visitor._queue[0].tid.should.equal(tid)
|
|
60
|
+
visitor._queue[0].cid.should.equal(cid)
|
|
61
|
+
visitor._queue[0].t.should.equal(type)
|
|
62
|
+
|
|
63
|
+
fn.calledOnce.should.equal(true, "callback should have been called once")
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should accept arguments (type, params)", function () {
|
|
67
|
+
var tid = "UA-XXXXX-XX";
|
|
68
|
+
var cid = uuid.v4();
|
|
69
|
+
var type = Math.random().toString()
|
|
70
|
+
var params = {foo: Math.random().toString()}
|
|
71
|
+
|
|
72
|
+
var visitor = ua(tid, cid)._enqueue(type, params);
|
|
73
|
+
|
|
74
|
+
send.called.should.equal(false, "#send should not have been called without a callback");
|
|
75
|
+
|
|
76
|
+
visitor._queue.length.should.equal(1, "1 tracking call should have been enqueued");
|
|
77
|
+
|
|
78
|
+
visitor._queue[0].should.have.keys("v", "tid", "cid", "t", "foo")
|
|
79
|
+
visitor._queue[0].tid.should.equal(tid)
|
|
80
|
+
visitor._queue[0].cid.should.equal(cid)
|
|
81
|
+
visitor._queue[0].foo.should.equal(params.foo);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("should add userId if present on the Visitor", function() {
|
|
85
|
+
var tid = "UA-XXXXX-XX";
|
|
86
|
+
var cid = uuid.v4();
|
|
87
|
+
var type = "type";
|
|
88
|
+
var uid = "user1";
|
|
89
|
+
var params = {}
|
|
90
|
+
|
|
91
|
+
var visitor = ua(tid, cid, { uid: uid})._enqueue(type, params);
|
|
92
|
+
|
|
93
|
+
visitor._queue[0].uid.should.equal(uid);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("should accept arguments (type, params, fn)", function () {
|
|
97
|
+
var tid = "UA-XXXXX-XX";
|
|
98
|
+
var cid = uuid.v4();
|
|
99
|
+
var type = Math.random().toString()
|
|
100
|
+
var params = {foo: Math.random().toString()}
|
|
101
|
+
var fn = sinon.spy()
|
|
102
|
+
|
|
103
|
+
var visitor = ua(tid, cid)._enqueue(type, params, fn);
|
|
104
|
+
|
|
105
|
+
send.calledOnce.should.equal(true, "#send should have been called once");
|
|
106
|
+
|
|
107
|
+
visitor._queue.length.should.equal(1, "1 tracking call should have been enqueued");
|
|
108
|
+
|
|
109
|
+
visitor._queue[0].should.have.keys("v", "tid", "cid", "t", "foo")
|
|
110
|
+
visitor._queue[0].tid.should.equal(tid)
|
|
111
|
+
visitor._queue[0].cid.should.equal(cid)
|
|
112
|
+
visitor._queue[0].foo.should.equal(params.foo);
|
|
113
|
+
|
|
114
|
+
fn.calledOnce.should.equal(true, "callback should have been called once")
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("should continue adding to the queue", function () {
|
|
118
|
+
var tid = "UA-XXXXX-XX";
|
|
119
|
+
var cid = uuid.v4();
|
|
120
|
+
var type = Math.random().toString()
|
|
121
|
+
|
|
122
|
+
var visitor = ua(tid, cid)
|
|
123
|
+
|
|
124
|
+
visitor._enqueue(type);
|
|
125
|
+
visitor._enqueue(type);
|
|
126
|
+
visitor._enqueue(type);
|
|
127
|
+
visitor._enqueue(type);
|
|
128
|
+
|
|
129
|
+
visitor._queue.length.should.equal(4, "4 tracking calls should have been enqueued");
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
|
|
2
|
+
var qs = require("querystring");
|
|
3
|
+
var uuid = require("uuid");
|
|
4
|
+
var should = require("should");
|
|
5
|
+
var sinon = require("sinon");
|
|
6
|
+
var url = require("url");
|
|
7
|
+
|
|
8
|
+
var ua = require("../lib/index.js");
|
|
9
|
+
var utils = require("../lib/utils.js")
|
|
10
|
+
var config = require("../lib/config.js")
|
|
11
|
+
var request = require("../lib/request");
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
describe("ua", function () {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
describe("#event", function () {
|
|
18
|
+
var _enqueue;
|
|
19
|
+
|
|
20
|
+
beforeEach(function () {
|
|
21
|
+
_enqueue = sinon.stub(ua.Visitor.prototype, "_enqueue", function () {
|
|
22
|
+
if (arguments.length === 3 && typeof arguments[2] === 'function') {
|
|
23
|
+
arguments[2]();
|
|
24
|
+
}
|
|
25
|
+
return this;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(function () {
|
|
30
|
+
_enqueue.restore()
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
it("should be available via the #e shortcut", function () {
|
|
35
|
+
var visitor = ua()
|
|
36
|
+
visitor.e.should.equal(visitor.event)
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
it("should accept arguments (category, action)", function () {
|
|
41
|
+
var category = Math.random().toString();
|
|
42
|
+
var action = Math.random().toString();
|
|
43
|
+
|
|
44
|
+
var visitor = ua()
|
|
45
|
+
|
|
46
|
+
var result = visitor.event(category, action);
|
|
47
|
+
|
|
48
|
+
visitor._context = result._context;
|
|
49
|
+
result.should.eql(visitor, "should return a visitor that is identical except for the context");
|
|
50
|
+
|
|
51
|
+
result.should.be.instanceof(ua.Visitor);
|
|
52
|
+
result._context.should.eql(_enqueue.args[0][1], "the pageview params should be persisted as the context of the visitor clone")
|
|
53
|
+
|
|
54
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
55
|
+
_enqueue.args[0][0].should.equal("event");
|
|
56
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea")
|
|
57
|
+
_enqueue.args[0][1].ec.should.equal(category);
|
|
58
|
+
_enqueue.args[0][1].ea.should.equal(action);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should accept arguments (category, action, fn)", function () {
|
|
62
|
+
var category = Math.random().toString();
|
|
63
|
+
var action = Math.random().toString();
|
|
64
|
+
var fn = sinon.spy()
|
|
65
|
+
|
|
66
|
+
ua().event(category, action, fn);
|
|
67
|
+
|
|
68
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
69
|
+
_enqueue.args[0][0].should.equal("event");
|
|
70
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea")
|
|
71
|
+
_enqueue.args[0][1].ec.should.equal(category);
|
|
72
|
+
_enqueue.args[0][1].ea.should.equal(action);
|
|
73
|
+
|
|
74
|
+
fn.calledOnce.should.equal(true, "callback should have been called once")
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should accept arguments (category, action, label)", function () {
|
|
78
|
+
var category = Math.random().toString();
|
|
79
|
+
var action = Math.random().toString();
|
|
80
|
+
var label = Math.random().toString();
|
|
81
|
+
|
|
82
|
+
ua().event(category, action, label);
|
|
83
|
+
|
|
84
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
85
|
+
_enqueue.args[0][0].should.equal("event");
|
|
86
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea", "el")
|
|
87
|
+
_enqueue.args[0][1].ec.should.equal(category);
|
|
88
|
+
_enqueue.args[0][1].ea.should.equal(action);
|
|
89
|
+
_enqueue.args[0][1].el.should.equal(label);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("should accept arguments (category, action, label, fn)", function () {
|
|
93
|
+
var category = Math.random().toString();
|
|
94
|
+
var action = Math.random().toString();
|
|
95
|
+
var label = Math.random().toString();
|
|
96
|
+
var fn = sinon.spy()
|
|
97
|
+
|
|
98
|
+
ua().event(category, action, label, fn);
|
|
99
|
+
|
|
100
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
101
|
+
_enqueue.args[0][0].should.equal("event");
|
|
102
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea", "el")
|
|
103
|
+
_enqueue.args[0][1].ec.should.equal(category);
|
|
104
|
+
_enqueue.args[0][1].ea.should.equal(action);
|
|
105
|
+
_enqueue.args[0][1].el.should.equal(label);
|
|
106
|
+
|
|
107
|
+
fn.calledOnce.should.equal(true, "callback should have been called once")
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("should accept arguments (category, action, label, value)", function () {
|
|
111
|
+
var category = Math.random().toString();
|
|
112
|
+
var action = Math.random().toString();
|
|
113
|
+
var label = Math.random().toString();
|
|
114
|
+
var value = Math.random();
|
|
115
|
+
|
|
116
|
+
ua().event(category, action, label, value);
|
|
117
|
+
|
|
118
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
119
|
+
_enqueue.args[0][0].should.equal("event");
|
|
120
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev")
|
|
121
|
+
_enqueue.args[0][1].ec.should.equal(category);
|
|
122
|
+
_enqueue.args[0][1].ea.should.equal(action);
|
|
123
|
+
_enqueue.args[0][1].el.should.equal(label);
|
|
124
|
+
_enqueue.args[0][1].ev.should.equal(value);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("should accept arguments (category, action, label, value, fn)", function () {
|
|
128
|
+
var category = Math.random().toString();
|
|
129
|
+
var action = Math.random().toString();
|
|
130
|
+
var label = Math.random().toString();
|
|
131
|
+
var value = Math.random();
|
|
132
|
+
var fn = sinon.spy()
|
|
133
|
+
|
|
134
|
+
ua().event(category, action, label, value, fn);
|
|
135
|
+
|
|
136
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
137
|
+
_enqueue.args[0][0].should.equal("event");
|
|
138
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev")
|
|
139
|
+
_enqueue.args[0][1].ec.should.equal(category);
|
|
140
|
+
_enqueue.args[0][1].ea.should.equal(action);
|
|
141
|
+
_enqueue.args[0][1].el.should.equal(label);
|
|
142
|
+
_enqueue.args[0][1].ev.should.equal(value);
|
|
143
|
+
|
|
144
|
+
fn.calledOnce.should.equal(true, "callback should have been called once")
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("should accept arguments (category, action, label, value, params, fn)", function () {
|
|
148
|
+
var category = Math.random().toString();
|
|
149
|
+
var action = Math.random().toString();
|
|
150
|
+
var label = Math.random().toString();
|
|
151
|
+
var value = Math.random();
|
|
152
|
+
var params = {"p": "/" + Math.random()}
|
|
153
|
+
var fn = sinon.spy()
|
|
154
|
+
|
|
155
|
+
ua().event(category, action, label, value, params, fn);
|
|
156
|
+
|
|
157
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
158
|
+
_enqueue.args[0][0].should.equal("event");
|
|
159
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev", "p")
|
|
160
|
+
_enqueue.args[0][1].ec.should.equal(category);
|
|
161
|
+
_enqueue.args[0][1].ea.should.equal(action);
|
|
162
|
+
_enqueue.args[0][1].el.should.equal(label);
|
|
163
|
+
_enqueue.args[0][1].ev.should.equal(value);
|
|
164
|
+
_enqueue.args[0][1].p.should.equal(params.p);
|
|
165
|
+
|
|
166
|
+
fn.calledOnce.should.equal(true, "callback should have been called once")
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("should accept arguments (params)", function () {
|
|
170
|
+
var params = {
|
|
171
|
+
ec: Math.random().toString(),
|
|
172
|
+
ea: Math.random().toString(),
|
|
173
|
+
el: Math.random().toString(),
|
|
174
|
+
ev: Math.random(),
|
|
175
|
+
"p": "/" + Math.random(),
|
|
176
|
+
"empty": null
|
|
177
|
+
}
|
|
178
|
+
var json = JSON.stringify(params)
|
|
179
|
+
|
|
180
|
+
ua().event(params);
|
|
181
|
+
|
|
182
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
183
|
+
_enqueue.args[0][0].should.equal("event");
|
|
184
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev", "p")
|
|
185
|
+
_enqueue.args[0][1].ec.should.equal(params.ec);
|
|
186
|
+
_enqueue.args[0][1].ea.should.equal(params.ea);
|
|
187
|
+
_enqueue.args[0][1].el.should.equal(params.el);
|
|
188
|
+
_enqueue.args[0][1].ev.should.equal(params.ev);
|
|
189
|
+
_enqueue.args[0][1].p.should.equal(params.p);
|
|
190
|
+
|
|
191
|
+
JSON.stringify(params).should.equal(json, "params should not have been modified")
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("should accept arguments (params, fn)", function () {
|
|
195
|
+
var params = {
|
|
196
|
+
ec: Math.random().toString(),
|
|
197
|
+
ea: Math.random().toString(),
|
|
198
|
+
el: Math.random().toString(),
|
|
199
|
+
ev: Math.random(),
|
|
200
|
+
"p": "/" + Math.random()
|
|
201
|
+
}
|
|
202
|
+
var fn = sinon.spy()
|
|
203
|
+
|
|
204
|
+
ua().event(params, fn);
|
|
205
|
+
|
|
206
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
207
|
+
_enqueue.args[0][0].should.equal("event");
|
|
208
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea", "el", "ev", "p")
|
|
209
|
+
_enqueue.args[0][1].ec.should.equal(params.ec);
|
|
210
|
+
_enqueue.args[0][1].ea.should.equal(params.ea);
|
|
211
|
+
_enqueue.args[0][1].el.should.equal(params.el);
|
|
212
|
+
_enqueue.args[0][1].ev.should.equal(params.ev);
|
|
213
|
+
_enqueue.args[0][1].p.should.equal(params.p);
|
|
214
|
+
|
|
215
|
+
fn.calledOnce.should.equal(true, "callback should have been called once")
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("should use the dp attribute as p for providing a event path", function () {
|
|
219
|
+
var params = {
|
|
220
|
+
ec: Math.random().toString(),
|
|
221
|
+
ea: Math.random().toString(),
|
|
222
|
+
"dp": "/" + Math.random(),
|
|
223
|
+
}
|
|
224
|
+
var json = JSON.stringify(params)
|
|
225
|
+
|
|
226
|
+
ua().event(params);
|
|
227
|
+
|
|
228
|
+
_enqueue.calledOnce.should.equal(true, "#_enqueue should have been called once");
|
|
229
|
+
_enqueue.args[0][0].should.equal("event");
|
|
230
|
+
_enqueue.args[0][1].should.have.keys("ec", "ea", "p")
|
|
231
|
+
_enqueue.args[0][1].ec.should.equal(params.ec);
|
|
232
|
+
_enqueue.args[0][1].ea.should.equal(params.ea);
|
|
233
|
+
_enqueue.args[0][1].p.should.equal(params.dp);
|
|
234
|
+
|
|
235
|
+
JSON.stringify(params).should.equal(json, "params should not have been modified")
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
it("should allow daisy-chaining and re-using parameters", function () {
|
|
240
|
+
var params = {
|
|
241
|
+
ec: Math.random().toString(),
|
|
242
|
+
ea: Math.random().toString(),
|
|
243
|
+
el: Math.random().toString(),
|
|
244
|
+
ev: Math.random()
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
ua().event(params).event()
|
|
248
|
+
|
|
249
|
+
_enqueue.calledTwice.should.equal(true, "#_enqueue should have been called twice, once for each event");
|
|
250
|
+
_enqueue.args[0][0].should.equal(_enqueue.args[1][0]);
|
|
251
|
+
_enqueue.args[0][1].ec.should.equal(_enqueue.args[1][1].ec);
|
|
252
|
+
_enqueue.args[0][1].ea.should.equal(_enqueue.args[1][1].ea);
|
|
253
|
+
_enqueue.args[0][1].el.should.equal(_enqueue.args[1][1].el);
|
|
254
|
+
_enqueue.args[0][1].ev.should.equal(_enqueue.args[1][1].ev);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
it("should extend and overwrite params when daisy-chaining", function () {
|
|
259
|
+
var params = {
|
|
260
|
+
ec: Math.random().toString(),
|
|
261
|
+
ea: Math.random().toString(),
|
|
262
|
+
el: Math.random().toString(),
|
|
263
|
+
ev: Math.random()
|
|
264
|
+
}
|
|
265
|
+
var category = Math.random().toString();
|
|
266
|
+
|
|
267
|
+
ua().event(params).event(category)
|
|
268
|
+
|
|
269
|
+
_enqueue.calledTwice.should.equal(true, "#_enqueue should have been called twice, once for each event");
|
|
270
|
+
_enqueue.args[0][0].should.equal(_enqueue.args[1][0]);
|
|
271
|
+
_enqueue.args[0][1].ea.should.equal(_enqueue.args[1][1].ea);
|
|
272
|
+
_enqueue.args[0][1].el.should.equal(_enqueue.args[1][1].el);
|
|
273
|
+
_enqueue.args[0][1].ev.should.equal(_enqueue.args[1][1].ev);
|
|
274
|
+
|
|
275
|
+
_enqueue.args[0][1].ec.should.equal(params.ec);
|
|
276
|
+
_enqueue.args[1][1].ec.should.equal(category);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it("should re-use the path when daisy-chained to a pageview", function () {
|
|
280
|
+
var path = "/" + Math.random()
|
|
281
|
+
var params = {
|
|
282
|
+
ec: Math.random().toString(),
|
|
283
|
+
ea: Math.random().toString(),
|
|
284
|
+
el: Math.random().toString(),
|
|
285
|
+
ev: Math.random()
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
ua().pageview(path).event(params).event(params);
|
|
289
|
+
|
|
290
|
+
_enqueue.calledThrice.should.equal(true, "#_enqueue should have been called twice, once for the pageview, once for the pageview");
|
|
291
|
+
|
|
292
|
+
_enqueue.args[1][1].p.should.equal(path)
|
|
293
|
+
_enqueue.args[2][1].p.should.equal(path)
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
it("should fail without event category", function () {
|
|
297
|
+
var fn = sinon.spy()
|
|
298
|
+
var action = Math.random().toString();
|
|
299
|
+
var visitor = ua()
|
|
300
|
+
|
|
301
|
+
var result = visitor.event(null, action, fn);
|
|
302
|
+
|
|
303
|
+
visitor._context = result._context;
|
|
304
|
+
result.should.eql(visitor, "should return a visitor that is identical except for the context");
|
|
305
|
+
|
|
306
|
+
result.should.be.instanceof(ua.Visitor);
|
|
307
|
+
result._context.should.eql({}, "the transaction params should not be persisted")
|
|
308
|
+
|
|
309
|
+
_enqueue.called.should.equal(false, "#_enqueue should have not been called once");
|
|
310
|
+
fn.calledOnce.should.equal(true, "callback should have been called once");
|
|
311
|
+
fn.args[0][0].should.be.instanceof(Error);
|
|
312
|
+
fn.thisValues[0].should.equal(visitor);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it("should fail without event action", function () {
|
|
316
|
+
var fn = sinon.spy()
|
|
317
|
+
var category = Math.random().toString();
|
|
318
|
+
var visitor = ua()
|
|
319
|
+
|
|
320
|
+
var result = visitor.event(category, null, fn);
|
|
321
|
+
|
|
322
|
+
visitor._context = result._context;
|
|
323
|
+
result.should.eql(visitor, "should return a visitor that is identical except for the context");
|
|
324
|
+
|
|
325
|
+
result.should.be.instanceof(ua.Visitor);
|
|
326
|
+
result._context.should.eql({}, "the transaction params should not be persisted")
|
|
327
|
+
|
|
328
|
+
_enqueue.called.should.equal(false, "#_enqueue should have not been called once");
|
|
329
|
+
fn.calledOnce.should.equal(true, "callback should have been called once");
|
|
330
|
+
fn.args[0][0].should.be.instanceof(Error);
|
|
331
|
+
fn.thisValues[0].should.equal(visitor);
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|