Skip to content

Commit 3a546cc

Browse files
authored
Merge pull request #39 from launchdarkly/maleko/update-stream-url
Updated stream url
2 parents 64d8691 + 65ea29b commit 3a546cc

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ function sendGoalEvent(kind, goal) {
6767
url: window.location.href,
6868
creationDate: (new Date()).getTime()
6969
};
70-
70+
7171
if (kind === 'click') {
7272
event.selector = goal.selector;
7373
}
74-
74+
7575
return events.enqueue(event);
7676
}
7777

@@ -87,15 +87,15 @@ function identify(user, hash, onDone) {
8787

8888
function variation(key, defaultValue) {
8989
var value;
90-
90+
9191
if (flags && flags.hasOwnProperty(key)) {
9292
value = flags[key] === null ? defaultValue : flags[key];
9393
} else {
9494
value = defaultValue;
9595
}
96-
96+
9797
sendFlagEvent(key, value, defaultValue);
98-
98+
9999
return value;
100100
}
101101

@@ -117,7 +117,7 @@ function track(key, data) {
117117
if (typeof key !== 'string') {
118118
throw 'Event key must be a string';
119119
}
120-
120+
121121
events.enqueue({
122122
kind: 'custom',
123123
key: key,
@@ -138,7 +138,7 @@ function connectStream() {
138138
function updateSettings(settings) {
139139
var changes;
140140
var keys;
141-
141+
142142
if (!settings) { return; }
143143

144144
changes = utils.modifications(flags, settings);
@@ -156,7 +156,7 @@ function updateSettings(settings) {
156156
});
157157

158158
emitter.emit(changeEvent, changes);
159-
159+
160160
keys.forEach(function(key) {
161161
sendFlagEvent(key, changes[key].current);
162162
});
@@ -216,19 +216,19 @@ function initialize(env, user, options) {
216216
hash = options.hash;
217217
baseUrl = options.baseUrl || 'https://app.launchdarkly.com';
218218
eventsUrl = options.eventsUrl || 'https://events.launchdarkly.com';
219-
streamUrl = options.streamUrl || 'https://stream.launchdarkly.com';
219+
streamUrl = options.streamUrl || 'https://clientstream.launchdarkly.com';
220220
stream = Stream(streamUrl, environment);
221221
events = EventProcessor(eventsUrl + '/a/' + environment + '.gif');
222222
emitter = EventEmitter();
223223
ident = Identity(user, sendIdentifyEvent);
224224
requestor = Requestor(baseUrl, environment);
225225
localStorageKey = lsKey(environment, ident.getUser());
226-
226+
227227
if (typeof options.bootstrap === 'object') {
228228
// Emitting the event here will happen before the consumer
229229
// can register a listener, so defer to next tick.
230230
setTimeout(function() { emitter.emit(readyEvent); }, 0);
231-
}
231+
}
232232
else if (typeof(options.bootstrap) === 'string' && options.bootstrap.toUpperCase() === 'LOCALSTORAGE' && typeof(Storage) !== 'undefined') {
233233
useLocalStorage = true;
234234
// check if localstorage data is corrupted, if so clear it
@@ -240,7 +240,7 @@ function initialize(env, user, options) {
240240

241241
if (flags === null) {
242242
requestor.fetchFlagSettings(ident.getUser(), hash, function(err, settings) {
243-
flags = settings;
243+
flags = settings;
244244
settings && localStorage.setItem(localStorageKey, JSON.stringify(flags));
245245
emitter.emit(readyEvent);
246246
});
@@ -260,15 +260,15 @@ function initialize(env, user, options) {
260260
emitter.emit(readyEvent);
261261
});
262262
}
263-
263+
264264
requestor.fetchGoals(function(err, g) {
265265
if (err) {/* TODO */}
266266
if (g && g.length > 0) {
267267
goals = g;
268268
goalTracker = GoalTracker(goals, sendGoalEvent);
269269
}
270270
});
271-
271+
272272
function start() {
273273
setTimeout(function tick() {
274274
events.flush(ident.getUser());
@@ -281,23 +281,23 @@ function initialize(env, user, options) {
281281
} else {
282282
start();
283283
}
284-
284+
285285
window.addEventListener('beforeunload', function() {
286286
events.flush(ident.getUser(), true);
287287
});
288-
288+
289289
function refreshGoalTracker() {
290290
if (goalTracker) {
291291
goalTracker.dispose();
292292
}
293293
if (goals && goals.length) {
294294
goalTracker = GoalTracker(goals, sendGoalEvent);
295-
}
295+
}
296296
}
297297

298298
if (goals && goals.length > 0) {
299299
if (!!(window.history && history.pushState)) {
300-
window.addEventListener('popstate', refreshGoalTracker);
300+
window.addEventListener('popstate', refreshGoalTracker);
301301
} else {
302302
window.addEventListener('hashchange', refreshGoalTracker);
303303
}

0 commit comments

Comments
 (0)