Skip to content

Commit 74b8cda

Browse files
authored
Merge pull request #75 from launchdarkly/1.6.1
Prepare 1.6.1
2 parents 63ed7b1 + 3f8a068 commit 74b8cda

File tree

7 files changed

+76
-9
lines changed

7 files changed

+76
-9
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/node:6-browsers
6+
steps:
7+
- checkout
8+
- run: npm install
9+
- run: mkdir -p reports/junit
10+
- run:
11+
command: npm test
12+
environment:
13+
JUNIT_REPORT_PATH: "./reports/junit/"
14+
JUNIT_REPORT_NAME: "js-test-results.xml"
15+
- store_test_results:
16+
path: reports/junit/
17+
- store_artifacts:
18+
path: reports/junit/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
**/junit.xml
23
npm-debug.log
34
node_modules
45
dist

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to the LaunchDarkly client-side JavaScript SDK will be documented in this file. This
44
project adheres to [Semantic Versioning](http://semver.org).
55

6+
## [1.6.1] - 2018-03-30
7+
### Fixed
8+
- The SDK now polls the URL for changes if (and only if) there are page view goals,to ensure it is accurately reporting page views.
9+
610
## [1.6.0] - 2018-03-28
711
### Changed
812
- Added support for a future update to LaunchDarkly that will deliver individual feature flag changes over the streaming connection as they occur, rather than requiring the client to re-request all flags for each change.

karma.conf.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ module.exports = function(config) {
1010
'tests.webpack.js': [ 'webpack', 'sourcemap' ]
1111
},
1212

13-
reporters: ['mocha'],
13+
reporters: ['mocha', 'junit'],
1414

15+
junitReporter: {
16+
outputDir: process.env.JUNIT_REPORT_PATH || '.',
17+
outputFile: process.env.JUNIT_REPORT_NAME || 'junit.xml',
18+
useBrowserName: false
19+
},
20+
1521
frameworks: ['mocha', 'chai', 'sinon'],
1622

1723
browsers: ['Chrome'],

package-lock.json

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ldclient-js",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "LaunchDarkly SDK for JavaScript",
55
"author": "LaunchDarkly <[email protected]>",
66
"license": "Apache-2.0",
@@ -31,6 +31,7 @@
3131
"karma": "0.13.22",
3232
"karma-chai": "0.1.0",
3333
"karma-chrome-launcher": "1.0.1",
34+
"karma-junit-reporter": "1.2.0",
3435
"karma-mocha": "1.0.1",
3536
"karma-mocha-reporter": "2.0.4",
3637
"karma-phantomjs-launcher": "0.2.1",

src/index.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ function initialize(env, user, options) {
2929
var localStorageKey;
3030
var goals;
3131
var subscribedToChangeEvents;
32+
var locationWatcher;
3233

3334
var readyEvent = 'ready';
3435
var changeEvent = 'change';
3536

3637
var flushInterval = 2000;
38+
var locationWatcherInterval = 300;
3739

3840
var seenRequests = {};
3941

@@ -422,13 +424,32 @@ function initialize(env, user, options) {
422424
}
423425
}
424426

425-
function attachHistoryListeners() {
427+
function watchLocation(interval, callback) {
428+
var previousUrl = location.href;
429+
var currentUrl;
430+
431+
function checkUrl() {
432+
currentUrl = location.href;
433+
434+
if (currentUrl !== previousUrl) {
435+
previousUrl = currentUrl;
436+
callback();
437+
}
438+
}
439+
440+
function poll(fn, interval) {
441+
fn();
442+
setTimeout(function() {
443+
poll(fn, interval);
444+
}, interval);
445+
}
446+
447+
poll(checkUrl, interval);
448+
426449
if (!!(window.history && history.pushState)) {
427-
window.removeEventListener('popstate',refreshGoalTracker);
428-
window.addEventListener('popstate', refreshGoalTracker);
450+
window.addEventListener('popstate', checkUrl);
429451
} else {
430-
window.removeEventListener('hashchange', refreshGoalTracker);
431-
window.addEventListener('hashchange', refreshGoalTracker);
452+
window.addEventListener('hashchange', checkUrl);
432453
}
433454
}
434455

@@ -439,7 +460,7 @@ function initialize(env, user, options) {
439460
if (g && g.length > 0) {
440461
goals = g;
441462
goalTracker = GoalTracker(goals, sendGoalEvent);
442-
attachHistoryListeners();
463+
watchLocation(locationWatcherInterval, refreshGoalTracker);
443464
}
444465
});
445466

0 commit comments

Comments
 (0)