|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 |
|
206 | | - // get the value |
207 | | - var value = params[knownParam]; |
| 206 | + // handle the parameter |
| 207 | + _privates.handleGetParameter(knownParam, params[knownParam], knownParams[knownParam]); |
| 208 | + } |
| 209 | + }, |
208 | 210 |
|
209 | | - // parse it and make sure it was parseable |
210 | | - var parsedValue = _privates.parseGetParameter(knownParam, value); |
211 | | - if (parsedValue === null) { |
212 | | - continue; |
| 211 | + handleGetParameter: function(name, value, overrides) { |
| 212 | + |
| 213 | + // parse it and make sure it was parseable |
| 214 | + var parsedValue = _privates.parseGetParameter(name, value); |
| 215 | + if (parsedValue === null) { |
| 216 | + return; |
| 217 | + } |
| 218 | + |
| 219 | + var combinedValue = $.extend({ |
| 220 | + 'user': {}, |
| 221 | + 'activity': { |
| 222 | + 'category': null, |
| 223 | + 'description': null, |
| 224 | + 'tags': {} |
213 | 225 | } |
| 226 | + }, parsedValue, overrides); |
214 | 227 |
|
215 | | - var combinedValue = $.extend({ |
216 | | - 'user': {}, |
217 | | - 'activity': { |
218 | | - 'category': null, |
219 | | - 'description': null, |
220 | | - 'tags': {} |
221 | | - } |
222 | | - }, parsedValue, knownParams[knownParam]); |
223 | | - |
224 | | - /* |
225 | | - * Sends an activity to the Breinify server. |
226 | | - * |
227 | | - * @param user {object} the user-information |
228 | | - * @param type {string|null} the type of activity |
229 | | - * @param category {string|null} the category (can be null or undefined) |
230 | | - * @param description {string|null} the description for the activity |
231 | | - * @param tags {object} added the change to pass in tags |
232 | | - * @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) |
233 | | - * @param onReady {function|null} function to be executed after triggering the activity |
234 | | - */ |
235 | | - var user = combinedValue.user; |
236 | | - var activity = combinedValue.activity; |
237 | | - Breinify.activity(user, activity.type, activity.category, activity.description, activity.tags, null, null); |
| 228 | + // calculate a hash as unique identifier |
| 229 | + var hashId = BreinifyUtil.md5(JSON.stringify(combinedValue)); |
| 230 | + if (BreinifyUtil.cookie.check(hashId)) { |
| 231 | + return; |
238 | 232 | } |
| 233 | + |
| 234 | + /* |
| 235 | + * Sends an activity to the Breinify server. |
| 236 | + * |
| 237 | + * @param user {object} the user-information |
| 238 | + * @param type {string|null} the type of activity |
| 239 | + * @param category {string|null} the category (can be null or undefined) |
| 240 | + * @param description {string|null} the description for the activity |
| 241 | + * @param tags {object} added the change to pass in tags |
| 242 | + * @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) |
| 243 | + * @param onReady {function|null} function to be executed after triggering the activity |
| 244 | + */ |
| 245 | + var user = combinedValue.user; |
| 246 | + var activity = combinedValue.activity; |
| 247 | + Breinify.activity(user, activity.type, activity.category, activity.description, activity.tags, null, function() { |
| 248 | + |
| 249 | + // mark it as successfully sent |
| 250 | + BreinifyUtil.cookie.set(hashId, true); |
| 251 | + }); |
239 | 252 | }, |
240 | 253 |
|
241 | 254 | parseGetParameter: function (name, value) { |
|
0 commit comments