|
112 | 112 | return _config.all();
|
113 | 113 | };
|
114 | 114 |
|
| 115 | + /** |
| 116 | + * Method to create a valid current unix timestamp. |
| 117 | + * @returns {number} the current unix timestamp (based on the system time) |
| 118 | + */ |
| 119 | + Breinify.unixTimestamp = function () { |
| 120 | + return Math.floor(new Date().getTime() / 1000); |
| 121 | + }; |
| 122 | + |
115 | 123 | /**
|
116 | 124 | * Sends an activity to the Breinify server.
|
117 | 125 | *
|
118 | 126 | * @param user {object} the user-information
|
119 | 127 | * @param type {string|null} the type of activity
|
120 | 128 | * @param category {string|null} the category (can be null or undefined)
|
121 | 129 | * @param description {string|null} the description for the activity
|
| 130 | + * @param tags {object} added the change to pass in tags |
122 | 131 | * @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)
|
123 | 132 | * @param onReady {function|null} function to be executed after triggering the activity
|
124 | 133 | */
|
125 |
| - Breinify.activity = function (user, type, category, description, sign, onReady) { |
| 134 | + Breinify.activity = function (user, type, category, description, tags, sign, onReady) { |
126 | 135 |
|
127 |
| - Breinify.activityUser(user, type, category, description, sign, function (data) { |
| 136 | + Breinify.activityUser(user, type, category, description, tags, sign, function (data) { |
128 | 137 | var url = _config.get(ATTR_CONFIG.URL) + _config.get(ATTR_CONFIG.ACTIVITY_ENDPOINT);
|
129 | 138 | _privates.ajax(url, data, onReady, onReady);
|
130 | 139 | });
|
131 | 140 | };
|
132 | 141 |
|
133 |
| - /** |
134 |
| - * Method to create a valid current unix timestamp. |
135 |
| - * @returns {number} the current unix timestamp (based on the system time) |
136 |
| - */ |
137 |
| - Breinify.unixTimestamp = function () { |
138 |
| - return Math.floor(new Date().getTime() / 1000); |
139 |
| - }; |
140 |
| - |
141 | 142 | /**
|
142 | 143 | * Creates a user instance and executes the specified method.
|
143 | 144 | *
|
144 | 145 | * @param user {object} the user-information
|
145 | 146 | * @param type {string|null} the type of activity
|
146 | 147 | * @param category {string|null} the category (can be null or undefined)
|
147 | 148 | * @param description {string|null} the description for the activity
|
| 149 | + * @param tags {object} added the change to pass in tags |
148 | 150 | * @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)
|
149 | 151 | * @param onReady {function|null} function to be executed after successful user creation
|
150 | 152 | */
|
151 |
| - Breinify.activityUser = function (user, type, category, description, sign, onReady) { |
| 153 | + Breinify.activityUser = function (user, type, category, description, tags, sign, onReady) { |
152 | 154 |
|
153 | 155 | var _onReady = function (user) {
|
154 | 156 | if ($.isFunction(onReady)) {
|
|
168 | 170 | type = typeof type === 'undefined' || type === null ? null : type;
|
169 | 171 | category = typeof category === 'undefined' || category === null ? _config.get(ATTR_CONFIG.CATEGORY) : category;
|
170 | 172 | description = typeof description === 'undefined' || description === null ? null : description;
|
| 173 | + tags = BreinifyUtil.isSimpleObject(tags) ? tags : null; |
171 | 174 | sign = typeof sign === 'boolean' ? sign : false;
|
172 | 175 |
|
173 | 176 | // get the other values needed
|
|
191 | 194 | 'activity': {
|
192 | 195 | 'type': type,
|
193 | 196 | 'category': category,
|
194 |
| - 'description': description |
| 197 | + 'description': description, |
| 198 | + 'tags': tags |
195 | 199 | },
|
196 | 200 |
|
197 | 201 | 'apiKey': _config.get(ATTR_CONFIG.API_KEY),
|
|
0 commit comments