Skip to content

Commit 994f6b8

Browse files
committed
added temporaldata
1 parent 6670ced commit 994f6b8

File tree

6 files changed

+28
-62
lines changed

6 files changed

+28
-62
lines changed

dist/breinify-api.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13165,7 +13165,7 @@ dependencyScope.jQuery = $;;
1316513165
return dimension + unixTimestamp + dimensions.length;
1316613166
},
1316713167

13168-
generateTemporalDataMessage: function (localDateTime, timezone, unixTimestamp) {
13168+
generateTemporalDataMessage: function (unixTimestamp, localDateTime, timezone) {
1316913169
var paraLocalDateTime = typeof localDateTime === 'undefined' || localDateTime === null ? "" : localDateTime;
1317013170
var paraTimezone = typeof timezone === 'undefined' || timezone === null ? "" : timezone;
1317113171

@@ -13351,7 +13351,12 @@ dependencyScope.jQuery = $;;
1335113351
// might be a different secret
1335213352
var secret = _config.get(ATTR_CONFIG.SECRET);
1335313353
if (typeof secret === 'string') {
13354+
var localDateTime = user.read('localDateTime');
13355+
var timezone = user.read('timezone');
13356+
1335413357
var message = _privates.generateTemporalDataMessage(unixTimestamp, localDateTime, timezone);
13358+
console.log(message);
13359+
console.log( _config.get(ATTR_CONFIG.SECRET));
1335513360
signature = _privates.determineSignature(message, _config.get(ATTR_CONFIG.SECRET))
1335613361
} else {
1335713362
_onReady(null);
@@ -13506,9 +13511,6 @@ dependencyScope.jQuery = $;;
1350613511
onReady();
1350713512
}
1350813513
};
13509-
Breinify.unixTimestamp = function () {
13510-
return Math.floor(new Date().getTime() / 1000);
13511-
};
1351213514
Breinify.UTL = {
1351313515
loc: {
1351413516
params: function () { return []; },
@@ -13534,6 +13536,9 @@ dependencyScope.jQuery = $;;
1353413536
select: function() { return null; },
1353513537
texts: function() { return []; },
1353613538
text: function() { return null; },
13539+
unixTimestamp: function () {
13540+
return Math.floor(new Date().getTime() / 1000);
13541+
},
1353713542
setText: function() {},
1353813543
md5: function () { return null; },
1353913544
isEmpty: function() { return false; },

dist/breinify-api.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ <h1>Current Configuration</h1>
317317
}
318318

319319
var temporalData = function () {
320-
Breinify.temporalData({}, null, function (data) {
320+
Breinify.temporalData({}, false, function (data) {
321321

322322
var $template = $('#temporal-data-template');
323323

specs/Breinify-spec.js

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Breinify', function () {
4343
});
4444

4545
//noinspection JSCheckFunctionSignatures
46-
Breinify.unixTimestamp = function () {
46+
Breinify.UTL.unixTimestamp = function () {
4747
return 1451962516;
4848
};
4949
Breinify.activityUser({
@@ -60,76 +60,32 @@ describe('Breinify', function () {
6060
expect(data.activity.category).toBe('other');
6161
//noinspection JSUnresolvedFunction
6262
expect(data.signature).toBe('rsXU0ozhfzieNLA2jQs2h2e4sz2+qHGxbgSYyfWr5EM=');
63-
done();
64-
});
65-
});
66-
67-
it('invokes the temporalDataUser', function (done) {
68-
Breinify.setConfig({
69-
'apiKey': '41B2-F48C-156A-409A-B465-317F-A0B4-E0E8'
70-
});
71-
72-
//noinspection JSCheckFunctionSignatures
73-
Breinify.unixTimestamp = function () {
74-
return 1451962516;
75-
};
76-
// user, timezone, localDateTime, sign, onReady)
77-
Breinify.temporalDataUser({
78-
email: 'email@sample.com'
79-
}, null, null, false, function (data) {
80-
81-
//noinspection JSUnresolvedFunction
82-
expect(data.apiKey).toBe('41B2-F48C-156A-409A-B465-317F-A0B4-E0E8');
83-
//noinspection JSUnresolvedFunction
84-
expect(data.unixTimestamp).toBe(1451962516);
8563

8664
done();
8765
});
8866
});
8967

90-
it('invokes the temporalData request', function (done) {
91-
Breinify.setConfig({
92-
'apiKey': '41B2-F48C-156A-409A-B465-317F-A0B4-E0E8'
93-
});
94-
95-
//noinspection JSCheckFunctionSignatures
96-
Breinify.unixTimestamp = function () {
97-
return 1451962516;
98-
};
99-
Breinify.temporalData({
100-
email: 'email@sample.com'
101-
}, null, null, false, function (data) {
102-
103-
//noinspection JSUnresolvedFunction
104-
//expect(data.apiKey).toBe('41B2-F48C-156A-409A-B465-317F-A0B4-E0E8');
105-
//noinspection JSUnresolvedFunction
106-
//expect(data.unixTimestamp).toBe(1451962516);
107-
108-
done();
109-
});
110-
});
111-
112-
it('invokes the temporalDataUser request', function (done) {
68+
//noinspection JSUnresolvedFunction
69+
it('creates the correct temporal data request instance', function (done) {
11370
Breinify.setConfig({
71+
'url': 'https://api.breinify.com',
11472
'apiKey': '41B2-F48C-156A-409A-B465-317F-A0B4-E0E8'
11573
});
11674

11775
//noinspection JSCheckFunctionSignatures
118-
Breinify.unixTimestamp = function () {
76+
Breinify.UTL.unixTimestamp = function () {
11977
return 1451962516;
12078
};
121-
// user, timezone, localDateTime, sign, onReady)
122-
Breinify.temporalDataUser({
123-
email: 'email@sample.com'
124-
}, null, null, false, function (data) {
79+
Breinify.temporalDataUser({}, false, function (data) {
12580

12681
//noinspection JSUnresolvedFunction
12782
expect(data.apiKey).toBe('41B2-F48C-156A-409A-B465-317F-A0B4-E0E8');
12883
//noinspection JSUnresolvedFunction
12984
expect(data.unixTimestamp).toBe(1451962516);
85+
//noinspection JSUnresolvedFunction
86+
expect(data.timezone).not.toBeNull();
13087

13188
done();
13289
});
13390
});
134-
13591
});

src/Breinify.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
return dimension + unixTimestamp + dimensions.length;
7373
},
7474

75-
generateTemporalDataMessage: function (localDateTime, timezone, unixTimestamp) {
75+
generateTemporalDataMessage: function (unixTimestamp, localDateTime, timezone) {
7676
var paraLocalDateTime = typeof localDateTime === 'undefined' || localDateTime === null ? "" : localDateTime;
7777
var paraTimezone = typeof timezone === 'undefined' || timezone === null ? "" : timezone;
7878

@@ -258,7 +258,12 @@
258258
// might be a different secret
259259
var secret = _config.get(ATTR_CONFIG.SECRET);
260260
if (typeof secret === 'string') {
261+
var localDateTime = user.read('localDateTime');
262+
var timezone = user.read('timezone');
263+
261264
var message = _privates.generateTemporalDataMessage(unixTimestamp, localDateTime, timezone);
265+
console.log(message);
266+
console.log( _config.get(ATTR_CONFIG.SECRET));
262267
signature = _privates.determineSignature(message, _config.get(ATTR_CONFIG.SECRET))
263268
} else {
264269
_onReady(null);

src/snippets/suffix-global.js.snippet

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@
5353
onReady();
5454
}
5555
};
56-
Breinify.unixTimestamp = function () {
57-
return Math.floor(new Date().getTime() / 1000);
58-
};
5956
Breinify.UTL = {
6057
loc: {
6158
params: function () { return []; },
@@ -81,6 +78,9 @@
8178
select: function() { return null; },
8279
texts: function() { return []; },
8380
text: function() { return null; },
81+
unixTimestamp: function () {
82+
return Math.floor(new Date().getTime() / 1000);
83+
},
8484
setText: function() {},
8585
md5: function () { return null; },
8686
isEmpty: function() { return false; },

0 commit comments

Comments
 (0)