|
49 | 49 | group: 4, |
50 | 50 | optional: false |
51 | 51 | }); |
| 52 | + attributes.add('SESSIONID', { |
| 53 | + name: 'sessionId', |
| 54 | + group: 5, |
| 55 | + optional: false |
| 56 | + }); |
52 | 57 | attributes.add('additional', { |
53 | 58 | validate: function (value) { |
54 | 59 | return typeof value === 'undefined' || $.isPlainObject(value); |
|
103 | 108 |
|
104 | 109 | // set the user-agent to a default value if there isn't one yet |
105 | 110 | if (instance.read('userAgent') === null) { |
106 | | - instance.add('userAgent', navigator.userAgent); |
| 111 | + var userAgent = navigator.userAgent; |
| 112 | + |
| 113 | + if (!BreinifyUtil.isEmpty(userAgent)) { |
| 114 | + instance.add('userAgent', userAgent); |
| 115 | + } |
107 | 116 | } |
108 | 117 |
|
109 | 118 | // set the referrer to a default value if there isn't one yet |
110 | 119 | if (instance.read('referrer') === null) { |
111 | | - instance.add('referrer', document.referrer); |
| 120 | + var referrer = document.referrer; |
| 121 | + |
| 122 | + if (!BreinifyUtil.isEmpty(referrer)) { |
| 123 | + instance.add('referrer', referrer); |
| 124 | + } |
| 125 | + } |
| 126 | + |
| 127 | + // also add the current URL if not provided |
| 128 | + if (instance.read('url') === null) { |
| 129 | + var url = window.location.href; |
| 130 | + |
| 131 | + if (!BreinifyUtil.isEmpty(url)) { |
| 132 | + instance.add('url', url); |
| 133 | + } |
112 | 134 | } |
113 | 135 |
|
114 | 136 | // try to set the location if there isn't one yet |
|
135 | 157 | var instance = this; |
136 | 158 |
|
137 | 159 | _privates.resolveGeoLocation(function (location) { |
138 | | - instance.add('location', location); |
| 160 | + if (!BreinifyUtil.isEmpty(location)) { |
| 161 | + instance.add('location', location); |
| 162 | + } |
139 | 163 |
|
140 | 164 | if ($.isFunction(onReady)) { |
141 | 165 | onReady(instance); |
|
191 | 215 | if (!attributes.is(attribute)) { |
192 | 216 | throw new Error('The attribute "' + attribute + '" is not supported by a user.'); |
193 | 217 | } else if (attribute === BreinifyUser.ATTRIBUTES.EMAIL) { |
194 | | - this.reset(attribute); |
| 218 | + this.reset(BreinifyUser.ATTRIBUTES.MD5EMAIL); |
195 | 219 |
|
196 | | - //noinspection JSUnresolvedFunction |
197 | | - this.set(BreinifyUser.ATTRIBUTES.MD5EMAIL, BreinifyUtil.md5(value)); |
| 220 | + if (!BreinifyUtil.isEmpty(value)) { |
| 221 | + //noinspection JSUnresolvedFunction |
| 222 | + this.set(BreinifyUser.ATTRIBUTES.MD5EMAIL, BreinifyUtil.md5(value)); |
| 223 | + } |
198 | 224 | } else if (attribute === BreinifyUser.ATTRIBUTES.MD5EMAIL) { |
199 | 225 | var email = this.get(BreinifyUser.ATTRIBUTES.EMAIL); |
200 | 226 |
|
|
209 | 235 | this._user = {}; |
210 | 236 | } |
211 | 237 |
|
212 | | - this._user[attribute] = value; |
| 238 | + // if the attribute is an empty value, we reset it |
| 239 | + if (BreinifyUtil.isEmpty(value)) { |
| 240 | + this.reset(attribute); |
| 241 | + } else { |
| 242 | + this._user[attribute] = value; |
| 243 | + } |
213 | 244 | }, |
214 | 245 |
|
215 | 246 | reset: function (attribute) { |
|
0 commit comments