Skip to content

Commit 44df2a2

Browse files
committed
utilizing hashId
1 parent 719b283 commit 44df2a2

File tree

2 files changed

+44
-31
lines changed

2 files changed

+44
-31
lines changed

dist/breinify-api.js

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13437,39 +13437,52 @@ dependencyScope.jQuery = $;;
1343713437
continue;
1343813438
}
1343913439

13440-
// get the value
13441-
var value = params[knownParam];
13440+
// handle the parameter
13441+
_privates.handleGetParameter(knownParam, params[knownParam], knownParams[knownParam]);
13442+
}
13443+
},
1344213444

13443-
// parse it and make sure it was parseable
13444-
var parsedValue = _privates.parseGetParameter(knownParam, value);
13445-
if (parsedValue === null) {
13446-
continue;
13445+
handleGetParameter: function(name, value, overrides) {
13446+
13447+
// parse it and make sure it was parseable
13448+
var parsedValue = _privates.parseGetParameter(name, value);
13449+
if (parsedValue === null) {
13450+
return;
13451+
}
13452+
13453+
var combinedValue = $.extend({
13454+
'user': {},
13455+
'activity': {
13456+
'category': null,
13457+
'description': null,
13458+
'tags': {}
1344713459
}
13460+
}, parsedValue, overrides);
1344813461

13449-
var combinedValue = $.extend({
13450-
'user': {},
13451-
'activity': {
13452-
'category': null,
13453-
'description': null,
13454-
'tags': {}
13455-
}
13456-
}, parsedValue, knownParams[knownParam]);
13457-
13458-
/*
13459-
* Sends an activity to the Breinify server.
13460-
*
13461-
* @param user {object} the user-information
13462-
* @param type {string|null} the type of activity
13463-
* @param category {string|null} the category (can be null or undefined)
13464-
* @param description {string|null} the description for the activity
13465-
* @param tags {object} added the change to pass in tags
13466-
* @param sign {boolean|null} true if a signature should be added (needs the secret to be configured - not recommended in open systems), otherwise false (can be null or undefined)
13467-
* @param onReady {function|null} function to be executed after triggering the activity
13468-
*/
13469-
var user = combinedValue.user;
13470-
var activity = combinedValue.activity;
13471-
Breinify.activity(user, activity.type, activity.category, activity.description, activity.tags, null, null);
13462+
// calculate a hash as unique identifier
13463+
var hashId = BreinifyUtil.md5(JSON.stringify(combinedValue));
13464+
if (BreinifyUtil.cookie.check(hashId)) {
13465+
return;
1347213466
}
13467+
13468+
/*
13469+
* Sends an activity to the Breinify server.
13470+
*
13471+
* @param user {object} the user-information
13472+
* @param type {string|null} the type of activity
13473+
* @param category {string|null} the category (can be null or undefined)
13474+
* @param description {string|null} the description for the activity
13475+
* @param tags {object} added the change to pass in tags
13476+
* @param sign {boolean|null} true if a signature should be added (needs the secret to be configured - not recommended in open systems), otherwise false (can be null or undefined)
13477+
* @param onReady {function|null} function to be executed after triggering the activity
13478+
*/
13479+
var user = combinedValue.user;
13480+
var activity = combinedValue.activity;
13481+
Breinify.activity(user, activity.type, activity.category, activity.description, activity.tags, null, function() {
13482+
13483+
// mark it as successfully sent
13484+
BreinifyUtil.cookie.set(hashId, true);
13485+
});
1347313486
},
1347413487

1347513488
parseGetParameter: function (name, value) {

0 commit comments

Comments
 (0)