@@ -67,11 +67,11 @@ function sendGoalEvent(kind, goal) {
67
67
url : window . location . href ,
68
68
creationDate : ( new Date ( ) ) . getTime ( )
69
69
} ;
70
-
70
+
71
71
if ( kind === 'click' ) {
72
72
event . selector = goal . selector ;
73
73
}
74
-
74
+
75
75
return events . enqueue ( event ) ;
76
76
}
77
77
@@ -87,15 +87,15 @@ function identify(user, hash, onDone) {
87
87
88
88
function variation ( key , defaultValue ) {
89
89
var value ;
90
-
90
+
91
91
if ( flags && flags . hasOwnProperty ( key ) ) {
92
92
value = flags [ key ] === null ? defaultValue : flags [ key ] ;
93
93
} else {
94
94
value = defaultValue ;
95
95
}
96
-
96
+
97
97
sendFlagEvent ( key , value , defaultValue ) ;
98
-
98
+
99
99
return value ;
100
100
}
101
101
@@ -117,7 +117,7 @@ function track(key, data) {
117
117
if ( typeof key !== 'string' ) {
118
118
throw 'Event key must be a string' ;
119
119
}
120
-
120
+
121
121
events . enqueue ( {
122
122
kind : 'custom' ,
123
123
key : key ,
@@ -138,7 +138,7 @@ function connectStream() {
138
138
function updateSettings ( settings ) {
139
139
var changes ;
140
140
var keys ;
141
-
141
+
142
142
if ( ! settings ) { return ; }
143
143
144
144
changes = utils . modifications ( flags , settings ) ;
@@ -156,7 +156,7 @@ function updateSettings(settings) {
156
156
} ) ;
157
157
158
158
emitter . emit ( changeEvent , changes ) ;
159
-
159
+
160
160
keys . forEach ( function ( key ) {
161
161
sendFlagEvent ( key , changes [ key ] . current ) ;
162
162
} ) ;
@@ -216,19 +216,19 @@ function initialize(env, user, options) {
216
216
hash = options . hash ;
217
217
baseUrl = options . baseUrl || 'https://app.launchdarkly.com' ;
218
218
eventsUrl = options . eventsUrl || 'https://events.launchdarkly.com' ;
219
- streamUrl = options . streamUrl || 'https://stream .launchdarkly.com' ;
219
+ streamUrl = options . streamUrl || 'https://clientstream .launchdarkly.com' ;
220
220
stream = Stream ( streamUrl , environment ) ;
221
221
events = EventProcessor ( eventsUrl + '/a/' + environment + '.gif' ) ;
222
222
emitter = EventEmitter ( ) ;
223
223
ident = Identity ( user , sendIdentifyEvent ) ;
224
224
requestor = Requestor ( baseUrl , environment ) ;
225
225
localStorageKey = lsKey ( environment , ident . getUser ( ) ) ;
226
-
226
+
227
227
if ( typeof options . bootstrap === 'object' ) {
228
228
// Emitting the event here will happen before the consumer
229
229
// can register a listener, so defer to next tick.
230
230
setTimeout ( function ( ) { emitter . emit ( readyEvent ) ; } , 0 ) ;
231
- }
231
+ }
232
232
else if ( typeof ( options . bootstrap ) === 'string' && options . bootstrap . toUpperCase ( ) === 'LOCALSTORAGE' && typeof ( Storage ) !== 'undefined' ) {
233
233
useLocalStorage = true ;
234
234
// check if localstorage data is corrupted, if so clear it
@@ -240,7 +240,7 @@ function initialize(env, user, options) {
240
240
241
241
if ( flags === null ) {
242
242
requestor . fetchFlagSettings ( ident . getUser ( ) , hash , function ( err , settings ) {
243
- flags = settings ;
243
+ flags = settings ;
244
244
settings && localStorage . setItem ( localStorageKey , JSON . stringify ( flags ) ) ;
245
245
emitter . emit ( readyEvent ) ;
246
246
} ) ;
@@ -260,15 +260,15 @@ function initialize(env, user, options) {
260
260
emitter . emit ( readyEvent ) ;
261
261
} ) ;
262
262
}
263
-
263
+
264
264
requestor . fetchGoals ( function ( err , g ) {
265
265
if ( err ) { /* TODO */ }
266
266
if ( g && g . length > 0 ) {
267
267
goals = g ;
268
268
goalTracker = GoalTracker ( goals , sendGoalEvent ) ;
269
269
}
270
270
} ) ;
271
-
271
+
272
272
function start ( ) {
273
273
setTimeout ( function tick ( ) {
274
274
events . flush ( ident . getUser ( ) ) ;
@@ -281,23 +281,23 @@ function initialize(env, user, options) {
281
281
} else {
282
282
start ( ) ;
283
283
}
284
-
284
+
285
285
window . addEventListener ( 'beforeunload' , function ( ) {
286
286
events . flush ( ident . getUser ( ) , true ) ;
287
287
} ) ;
288
-
288
+
289
289
function refreshGoalTracker ( ) {
290
290
if ( goalTracker ) {
291
291
goalTracker . dispose ( ) ;
292
292
}
293
293
if ( goals && goals . length ) {
294
294
goalTracker = GoalTracker ( goals , sendGoalEvent ) ;
295
- }
295
+ }
296
296
}
297
297
298
298
if ( goals && goals . length > 0 ) {
299
299
if ( ! ! ( window . history && history . pushState ) ) {
300
- window . addEventListener ( 'popstate' , refreshGoalTracker ) ;
300
+ window . addEventListener ( 'popstate' , refreshGoalTracker ) ;
301
301
} else {
302
302
window . addEventListener ( 'hashchange' , refreshGoalTracker ) ;
303
303
}
0 commit comments