Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare 5.2.0 release #100

Closed
wants to merge 303 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
303 commits
Select commit Hold shift + click to select a range
9491e16
lint
eli-darkly Dec 12, 2019
c9e7d7e
Merge branch 'eb/ch57741/wrapper-desc' into eb/ch57741/diagnostic-wra…
eli-darkly Dec 12, 2019
2610fc7
lint
eli-darkly Dec 12, 2019
fd7e2bb
remove image-loading logic from common code, replace it with an abstr…
eli-darkly Dec 12, 2019
0f28ba9
Merge branch 'eb/ch57741/wrapper-desc' into eb/ch59034/no-image-loading
eli-darkly Dec 12, 2019
f40f19b
Merge branch 'eb/ch59034/no-image-loading' into eb/ch57741/diagnostic…
eli-darkly Dec 12, 2019
5bdb140
Merge branch 'master' into diagnostic-events
eli-darkly Dec 12, 2019
fedb366
Merge branch 'eb/ch57741/diagnostic-wrapper' into diagnostic-events
eli-darkly Dec 12, 2019
385cbcd
add validation for options.streaming
eli-darkly Dec 12, 2019
2affe2f
Merge branch 'eb/ch57741/wrapper-desc' into eb/ch59034/no-image-loading
eli-darkly Dec 12, 2019
9e653e8
typo
eli-darkly Dec 12, 2019
c88839c
rm unused params
eli-darkly Dec 12, 2019
6f50448
merge from public after release
LaunchDarklyCI Dec 13, 2019
b4e0bfd
typo in comment
eli-darkly Dec 13, 2019
c5494b1
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Dec 13, 2019
6ef084a
Merge pull request #14 from launchdarkly/eb/ch57741/wrapper-desc
eli-darkly Dec 13, 2019
f3815bc
Merge pull request #15 from launchdarkly/eb/ch59034/no-image-loading
eli-darkly Dec 13, 2019
32d767f
misc fixes to merged code from external PR
eli-darkly Dec 13, 2019
7d4f67d
merge from public after release
LaunchDarklyCI Dec 13, 2019
3ba6e27
add event payload ID header
eli-darkly Jan 14, 2020
d9499df
Merge pull request #16 from launchdarkly/eb/ch61092/payload-id
eli-darkly Jan 15, 2020
a670c7f
merge from public after release
LaunchDarklyCI Jan 15, 2020
547b309
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Jan 30, 2020
15b5072
npm audit fix
eli-darkly Jan 30, 2020
6294b02
change exact dependencies to best-compatible
eli-darkly Jan 30, 2020
f190577
Merge pull request #17 from launchdarkly/eb/ch63559/relax-deps
eli-darkly Feb 1, 2020
7068968
merge from public after release
LaunchDarklyCI Feb 1, 2020
8c42690
standardize linting
eli-darkly Feb 11, 2020
f838fb3
disallow "window" and "document"
eli-darkly Feb 11, 2020
5064c3b
Merge branch 'master' into diagnostic-events
eli-darkly Feb 11, 2020
ade0261
Merge pull request #18 from launchdarkly/eb/ch65303/linting
eli-darkly Feb 11, 2020
8db5bc2
Merge branch 'diagnostic-events'
eli-darkly Feb 11, 2020
b4affad
improve diag event tests + debug logging
eli-darkly Feb 12, 2020
a01e65f
misc cleanup
eli-darkly Feb 12, 2020
7862b29
Merge pull request #19 from launchdarkly/eb/ch57741/diag-tests-fixes
eli-darkly Feb 12, 2020
4140b85
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Feb 12, 2020
20c655d
fix updating secure mode hash with identify()
eli-darkly Feb 13, 2020
8bf67c4
Merge pull request #20 from launchdarkly/eb/ch65728/identify-hash
eli-darkly Feb 13, 2020
ad44049
merge from public after release
LaunchDarklyCI Feb 13, 2020
232a404
don't omit streamInits.failed when it's false
eli-darkly Feb 14, 2020
bafa8da
Merge pull request #21 from launchdarkly/eb/ch65817/diag-explicit-false
eli-darkly Feb 14, 2020
ab182f0
merge from public after release
LaunchDarklyCI Feb 14, 2020
f954124
clean up init state logic, prevent unhandled rejections
eli-darkly Mar 5, 2020
78db776
lint
eli-darkly Mar 5, 2020
3136564
Merge pull request #22 from launchdarkly/eb/ch68119/init-state-error
eli-darkly Mar 6, 2020
bd3f238
merge from public after release
LaunchDarklyCI Mar 6, 2020
54099c8
less strict matching of json content-type header
eli-darkly Mar 18, 2020
e4c792c
Merge pull request #23 from launchdarkly/eb/ch69815/content-type
eli-darkly Mar 18, 2020
c610ffd
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Mar 18, 2020
5a323d8
merge from public after release
LaunchDarklyCI Mar 18, 2020
c974e2c
remove unsafe usage of hasOwnProperty
eli-darkly Mar 18, 2020
f5177c7
Merge pull request #24 from launchdarkly/eb/ch69855/has-own-property
eli-darkly Mar 18, 2020
93ee649
merge from public after release
LaunchDarklyCI Mar 18, 2020
e7ee64a
console logger must tolerate console object not always existing
eli-darkly Mar 30, 2020
c2402de
Merge pull request #25 from launchdarkly/eb/ch71507/no-console
eli-darkly Mar 31, 2020
68f359b
merge from public after release
LaunchDarklyCI Mar 31, 2020
a84b943
fix double initialization of diagnostics manager
eli-darkly May 1, 2020
14134c9
Merge pull request #26 from launchdarkly/eb/ch75557/extra-diagnostics
eli-darkly May 1, 2020
bdc9335
merge from public after release
LaunchDarklyCI May 1, 2020
5aac8a2
fix TypeScript declaration for track() and add more TS compilation te…
eli-darkly May 13, 2020
ca937d3
merge from public after release
LaunchDarklyCI May 13, 2020
fc3a857
remove startsWith usage (#28)
bwoskow-ld Jul 10, 2020
88125a7
merge from public after release
LaunchDarklyCI Jul 10, 2020
b572761
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Aug 5, 2020
1359aaf
prevent poll caused by a stream ping from overwriting later poll for …
eli-darkly Sep 12, 2020
b18f56f
merge from public after release
LaunchDarklyCI Sep 14, 2020
a6037a5
upgrade jest dependency and transitive yargs-parser dependency (#30)
bwoskow-ld Oct 15, 2020
bcb1573
Add null to LDEvaluationDetail.reason type (#31)
msiadak Oct 15, 2020
924213f
Merge branch 'contrib' of github.com:launchdarkly/js-sdk-common
bwoskow-ld Oct 15, 2020
88e42fb
Revert "Add null to LDEvaluationDetail.reason type (#31)"
bwoskow-ld Oct 16, 2020
6c26507
Revert "Add null to LDEvaluationDetail.reason type (#31)"
bwoskow-ld Oct 16, 2020
5125396
Merge branch 'contrib' of github.com:launchdarkly/js-sdk-common
bwoskow-ld Oct 16, 2020
b0f9c53
nullable evaluation reason (#32)
bwoskow-ld Nov 17, 2020
fdd97ee
merge from public after release
LaunchDarklyCI Nov 17, 2020
48bee4d
adding alias event functionality (#33)
bwoskow-ld Jan 20, 2021
7845b9a
set stream read timeout
eli-darkly Jan 26, 2021
f68c5b5
Merge pull request #35 from launchdarkly/eb/ch73764/stream-read-timeout
eli-darkly Jan 26, 2021
b36bb51
merge from public after release
LaunchDarklyCI Jan 26, 2021
efc11b0
Merge branch 'alias' of github.com:launchdarkly/js-sdk-common-private
bwoskow-ld Jan 27, 2021
b53732c
merge from public after release
LaunchDarklyCI Jan 27, 2021
a6ad9c8
Add prepare script (#34)
bwoskow-ld Jan 27, 2021
3911145
add a missing typescript verification (#36)
bwoskow-ld Jan 28, 2021
63c2ddd
Removed the guides link
bwoskow-ld Feb 3, 2021
fea10ae
Merge branch 'master' of github.com:launchdarkly/js-sdk-common into c…
bwoskow-ld Feb 9, 2021
4a5d31c
Correct doc link (#36)
sinchang Feb 9, 2021
72e9801
Merge branch 'contrib' of github.com:launchdarkly/js-sdk-common
bwoskow-ld Feb 9, 2021
0f83533
Fix typo in LDClient.on jsdoc (#37)
Doesntmeananything Mar 18, 2021
b493884
Merge branch 'contrib' of github.com:launchdarkly/js-sdk-common
bwoskow-ld Mar 18, 2021
94400df
add inlineUsersInEvents option in TypeScript (#37)
eli-darkly Apr 1, 2021
8d396dd
merge from public after release
LaunchDarklyCI Apr 1, 2021
4dfbc45
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
bwoskow-ld May 11, 2021
bb60a02
Filter private attributes on debug event users. Send variation for de…
gwhelanLD Jun 7, 2021
aef52df
Merge pull request #38 from launchdarkly/gw/ch110704/debug-private-attrs
gwhelanLD Jun 7, 2021
d7fc275
Merge remote-tracking branch 'public/master'
gwhelanLD Jun 8, 2021
717322a
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Aug 13, 2021
3b2ff6c
update uuid package version (#39)
eli-darkly Aug 23, 2021
c7b2645
merge from public after release
Aug 23, 2021
e05d244
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
bwoskow-ld Sep 21, 2021
8689021
use Releaser v2 config + newer CI image
eli-darkly Sep 21, 2021
75380ab
Merge pull request #40 from launchdarkly/eb/ch118712/releaser-v2
eli-darkly Sep 21, 2021
fe2bd87
First half, add the type, create the new options, add the new util me…
louis-launchdarkly Sep 24, 2021
d3cb835
Second half, call the tranform util method before calling any HTTP re…
louis-launchdarkly Sep 24, 2021
80f3098
Update the transform to work on a copy of headers instead of mutating it
louis-launchdarkly Sep 29, 2021
decda5f
add comments about removing custom event warning logic in the future
eli-darkly Oct 13, 2021
c0ab7c6
Merge pull request #42 from launchdarkly/eb/sc-124547/deprecate-goals…
eli-darkly Oct 13, 2021
f3b4a9a
revert updating of UUID dependency (#43)
eli-darkly Oct 15, 2021
98f9a86
Merge branch 'master' into lc/sc108033/add-lazily-evaluated-header
eli-darkly Oct 15, 2021
b508c75
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Oct 15, 2021
37af758
Merge branch 'master' into lc/sc108033/add-lazily-evaluated-header
eli-darkly Oct 15, 2021
b4294d8
Merge pull request #41 from launchdarkly/lc/sc108033/add-lazily-evalu…
louis-launchdarkly Oct 15, 2021
97c39ea
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Oct 15, 2021
455d381
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Oct 15, 2021
0444a31
merge from public after release
Oct 15, 2021
6edc3f6
better error handling for local storage operations (#44)
eli-darkly Jan 10, 2022
6fb8de6
add basic logger similar to server-side Node SDK (#45)
eli-darkly Jan 11, 2022
20bfe46
fix exports and add validation of custom logger (#46)
eli-darkly Jan 14, 2022
1f2076e
remove typedoc.js file that interferes with Releaser's docs build
eli-darkly Jan 14, 2022
52bc2af
update typescript version
eli-darkly Jan 14, 2022
00c0649
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Jan 15, 2022
9474648
add maintenance branch
eli-darkly Jan 15, 2022
c26d831
remove deprecated things (#48)
eli-darkly Jan 15, 2022
cf9ec23
fix EvaluationDetail.reason to be nullable so we can get rid of NonNu…
eli-darkly Jan 15, 2022
ca4468b
re-bump uuid package (#50)
eli-darkly Jan 15, 2022
0ef060e
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Jan 15, 2022
edf5c7a
use regular User-Agent header name unless overridden by js-client-sdk…
eli-darkly Jan 19, 2022
89c7a41
switch to publishing js-sdk-common as a regular Node module (#51)
eli-darkly Jan 20, 2022
59a9edc
fix CI
eli-darkly Jan 21, 2022
4e499a3
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Jan 21, 2022
02895b1
remove `version` constant which can't be exported from js-sdk-common …
eli-darkly Jan 26, 2022
90098a2
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Jan 26, 2022
7da82bb
Merge branch 'master' of github.com:launchdarkly/js-sdk-common
eli-darkly Jan 26, 2022
7b665ca
merge from public after release
Jan 26, 2022
d1b2875
catch errors in JSON parsing of stream data (#54)
eli-darkly Feb 17, 2022
df351a6
merge from public after release
Feb 17, 2022
7618644
backport sc-142333 fix
eli-darkly Feb 17, 2022
c2e5f5d
prepare 3.5.1 release (#63)
LaunchDarklyReleaseBot Feb 17, 2022
a736e46
Releasing version 3.5.1
Feb 17, 2022
b71603e
rm obsolete file to fix merge
eli-darkly Feb 17, 2022
a945a0c
Merge branch '3.x' of github.com:launchdarkly/js-sdk-common into 3.x
eli-darkly Feb 17, 2022
b6d90c7
Releasing version 3.5.1
Feb 17, 2022
ac38b52
merge from public after release
Feb 17, 2022
1cdbfd6
Migrate context code (#56)
kinyoklion Apr 8, 2022
b8f4b61
Migrate attribute reference code from node. (#57)
kinyoklion Apr 8, 2022
1922560
Add U2C types and make minimal adjustments for type changes. (#58)
kinyoklion Apr 18, 2022
8173212
make URL path concatenation work right whether base URL has a trailin…
eli-darkly Apr 18, 2022
ef919f0
Update event format and filtering for contexts. (#59)
kinyoklion Apr 18, 2022
2d65bc6
Update persistence of generated keys for transient contexts. (#60)
kinyoklion Apr 18, 2022
ea13ce5
Implement support for application tags. (#55)
kinyoklion Apr 20, 2022
3398942
Fix typing of LDOptionsBase. (#63)
kinyoklion Apr 21, 2022
c810e6f
Implement application tags for 3.x. (#62)
kinyoklion Apr 21, 2022
d3680b4
Merge branch '3.x'
eli-darkly Apr 21, 2022
088198c
lint
eli-darkly Apr 21, 2022
6f1feeb
merge from public after release
Apr 21, 2022
b58db4d
Add a line to refer to sendEventsOnlyForVariation
louis-launchdarkly Apr 22, 2022
ce963b3
Rename additional items. Functions, comments, variables. (#64)
kinyoklion Apr 22, 2022
3f01976
Merge pull request #65 from launchdarkly/lc/sc-151042/enhance-allFlag…
louis-launchdarkly Apr 22, 2022
784be57
don't include deleted flags in allFlags (#66)
eli-darkly Apr 29, 2022
8db6ad7
Clear last seen cache on identity change. (#67)
kinyoklion May 4, 2022
075f8e7
Merge branch 'main' of github.com:launchdarkly/js-sdk-common
eli-darkly May 7, 2022
7915ede
Enforce 64 character limit for tag value. (#68)
kinyoklion May 16, 2022
0df97d6
merge from public after release
Jun 7, 2022
97130dd
Rename transient back to anonymous. (#70)
kinyoklion Aug 8, 2022
2d7056b
[sc-160947] Switch to partial URL encoding. (#72)
kinyoklion Sep 7, 2022
06d1457
Remove the last seen cache, deprecate allowFrequentDuplicateEvents. (…
kinyoklion Sep 28, 2022
c6ca9d2
Update with changes from main, remove frequent duplicate events optio…
kinyoklion Sep 28, 2022
26dd615
merge from public after release
Oct 3, 2022
c8685e8
Inspector proposal V2. (#71)
kinyoklion Oct 12, 2022
803a63a
merge from public after release
Oct 17, 2022
aefe3d3
Fix invoking flagUsed. (#77)
kinyoklion Oct 17, 2022
50bee67
merge from public after release
Oct 17, 2022
095ce98
Port jitter and backoff. (#79) (#81)
kinyoklion Oct 19, 2022
1ce97b2
Update U2C branch with inspection interfaces. (#80)
kinyoklion Oct 20, 2022
364237c
Merge jitter/backoff to 5.0. (#85)
kinyoklion Oct 20, 2022
65783f7
Merge: Remove flatmap (#84)
kinyoklion Oct 20, 2022
b27d298
remove flatMap usage to support older browsers (#82)
kinyoklion Oct 20, 2022
b2e09b8
merge from public after release
Oct 20, 2022
1a71cd6
Remove support for secondary attribute. (#86)
kinyoklion Oct 27, 2022
6f5b8b0
[sc-176610] Import messages specifically from './messages' not '.'. (…
kinyoklion Nov 15, 2022
439d552
Update with changes from main. (#88)
kinyoklion Nov 15, 2022
dd74a95
Update comments for U2C. (#89)
kinyoklion Nov 16, 2022
379df8b
Fixes from contract tests. (#90)
kinyoklion Nov 18, 2022
eb8a0b2
Resolve conflicts.
kinyoklion Nov 18, 2022
45f46c4
Remove deprecation code.
kinyoklion Nov 18, 2022
7b78315
Merge pull request #93 from launchdarkly/rlamb/resolve-conflicts
kinyoklion Nov 18, 2022
0f8b889
[sc-177798] Export getContextKeys function for reuse
yusinto Nov 23, 2022
c38ff9a
Added unit tests
yusinto Nov 28, 2022
644e80c
Moved getContextKeys to context.js
yusinto Nov 28, 2022
fea0032
Update EventProcessor.js
yusinto Nov 28, 2022
54ce6b6
Ignore null and empty string keys. Added more tests.
yusinto Nov 28, 2022
dbff33c
Added warnings if kind is null or ''
yusinto Nov 28, 2022
e5071fc
Merge pull request #94 from launchdarkly/yus/sc-177798/export-getcont…
yusinto Nov 28, 2022
ac24f9d
Added types for getContextKeys
yusinto Nov 28, 2022
9aa9036
Update test-types.ts
yusinto Nov 28, 2022
58e8f98
Merge pull request #95 from launchdarkly/yus/sc-177975/export-type-de…
yusinto Nov 28, 2022
18bb860
Port event summarizer from node. (#97)
kinyoklion Nov 29, 2022
c7d25d9
Fix handling of results from sendingEvents. (#98)
kinyoklion Nov 29, 2022
455ae53
[sc-178144] Undefined case versus typeof. (#99)
kinyoklion Nov 29, 2022
50954a7
Fix copy/paste doc comment. (#96)
kinyoklion Nov 30, 2022
5eabfd8
[sc-178313] Replace minor instances of user
yusinto Nov 30, 2022
c5015ca
More replacements.
yusinto Nov 30, 2022
629b112
Update InspectorManager-test.js
yusinto Nov 30, 2022
453e255
Update utils-test.js
yusinto Nov 30, 2022
ab1403d
Adding kind to context for tests
yusinto Nov 30, 2022
4e2dfc7
Merge pull request #100 from launchdarkly/yus/sc-178313/prep-common-s…
yusinto Nov 30, 2022
f4642ea
Merge pull request #101 from launchdarkly/5.0
yusinto Nov 30, 2022
7f8419b
Revert to create maintenance branch. (#103)
kinyoklion Nov 30, 2022
fcb31f3
Restore U2C functionality. (#104)
kinyoklion Nov 30, 2022
bca5ea2
Update release config for 5.x (#102)
kinyoklion Nov 30, 2022
ef2b0eb
merge from public after release
Dec 1, 2022
55b0845
Ensure all types are exported in typings.d.ts. (#105)
kinyoklion Jan 10, 2023
ec97df5
merge from public after release
Jan 10, 2023
8002a41
fix: Remove option chaining. (#106)
kinyoklion Feb 15, 2023
6d682e8
merge from public after release
Feb 15, 2023
b61e915
fix: Make key optional on LDContext common. (#107)
kinyoklion Mar 21, 2023
be4863b
merge from public after release
Mar 21, 2023
6f4d5f2
Updates daily flag count
ember-stevens Jun 8, 2023
e0ef6f7
[sc-205159] Update README with current number of flags served (#108)
ember-stevens Jun 8, 2023
47edf8e
Add file CODEOWNERS
ld-repository-standards[bot] Jun 26, 2023
37a1c12
Add file CODEOWNERS (#109)
kparkinson-ld Jun 26, 2023
0ca4133
fix: remove httpAllowsPost and httpFallbackPing and collaterals
yusinto Jul 18, 2023
851ba2f
fix: remove httpAllowsPost and httpFallbackPing and collaterals (#110)
yusinto Jul 19, 2023
9ae59b4
Updates metrics and Experimentation language
ember-stevens Aug 16, 2023
b91dec3
Update typings.d.ts
ember-stevens Aug 16, 2023
4f114d7
[sc-213100] Clarify that "goals" are the same as "metrics" (#111)
ember-stevens Aug 23, 2023
69a7bc8
fix: Update sendEvents call site to expect an object instead of an ar…
keelerm84 Jan 23, 2024
170bb30
feat: Always inline contexts for feature events (#112)
keelerm84 Jan 23, 2024
9a0e38e
feat: Redact anonymous attributes within feature events (#113)
keelerm84 Jan 23, 2024
156132e
fix: Pin dev version of node to compatible types. (#116)
kinyoklion Mar 19, 2024
1308ca9
merge from public after release
Mar 19, 2024
5b2c4b7
chore: Added timedPromise and new error type.
yusinto Apr 17, 2024
245cf84
Update index.js
yusinto Apr 17, 2024
6dc69a0
fix: Prettified.
yusinto Apr 17, 2024
6b206e8
fix: Fixed default import and tests. Update prettier.
yusinto Apr 18, 2024
39d7e77
chore: Added unit tests. Fixed logger error. Revert exports to cjs.
yusinto Apr 18, 2024
a954727
fix: Fixed broken unit tests. Update Jest to 26.
yusinto Apr 18, 2024
1e2b274
chore: Ran prettier.
yusinto Apr 18, 2024
075e010
feat: Added timeout arg to wait functions.
yusinto Apr 18, 2024
bc23dc9
Update index.js
yusinto Apr 19, 2024
6fb1c5c
Update LDClient-timeout-test.js
yusinto Apr 19, 2024
d3ad064
chore: Added timeout comments.
yusinto Apr 22, 2024
a74b718
fix: Revert waitUntilReady timeout.
yusinto Apr 22, 2024
bc1cfb2
fix: Make timeout optional.
yusinto Apr 22, 2024
6a45c07
fix: Log a warning when a metric value is not numeric. (#118)
kinyoklion Apr 26, 2024
38b7396
fix: Replace evaluationExplanations with evaluationReasons.
yusinto Apr 26, 2024
8758bf8
fix: Replace evaluationExplanations with evaluationReasons. (#119)
yusinto Apr 26, 2024
995c750
Update typings.d.ts
yusinto Apr 27, 2024
e28abe9
Update typings.d.ts
yusinto Apr 27, 2024
521cb27
feat: Add timeout to waitForInitialization. (#117)
yusinto Apr 27, 2024
b0ac58d
chore: Do not log errors in timeout test to stderr. (#120)
kinyoklion Apr 30, 2024
690fdb9
fix: Code needs to be commonjs not esm. (#121)
kinyoklion Apr 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"eslint-formatter-pretty": "^1.3.0",
"eslint-plugin-babel": "^5.0.0",
"eslint-plugin-prettier": "^2.6.0",
"jest": "^25.5.4",
"jest": "^26.6.3",
"jsdom": "^11.11.0",
"launchdarkly-js-test-helpers": "1.1.0",
"prettier": "1.11.1",
"prettier": "1.19.1",
"readline-sync": "^1.4.9",
"typescript": "~4.4.4"
},
Expand Down
4 changes: 2 additions & 2 deletions src/ContextFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function ContextFilter(config) {
filtered._meta = filtered._meta || {};
// If any private attributes started with '/' we need to convert them to references, otherwise the '/' will
// cause the literal to incorrectly be treated as a reference.
filtered._meta.privateAttributes = user.privateAttributeNames.map(
literal => (literal.startsWith('/') ? AttributeReference.literalToReference(literal) : literal)
filtered._meta.privateAttributes = user.privateAttributeNames.map(literal =>
literal.startsWith('/') ? AttributeReference.literalToReference(literal) : literal
);
}

Expand Down
5 changes: 4 additions & 1 deletion src/__tests__/EventProcessor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { MockEventSender } from './testUtils';
// tests; here, we use a mock EventSender.

describe.each([
[{ key: 'userKey', name: 'Red' }, { key: 'userKey', kind: 'user', _meta: { redactedAttributes: ['/name'] } }],
[
{ key: 'userKey', name: 'Red' },
{ key: 'userKey', kind: 'user', _meta: { redactedAttributes: ['/name'] } },
],
[
{ kind: 'user', key: 'userKey', name: 'Red' },
{ key: 'userKey', kind: 'user', _meta: { redactedAttributes: ['/name'] } },
Expand Down
5 changes: 4 additions & 1 deletion src/__tests__/EventSummarizer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ describe('EventSummarizer', () => {
key1: {
contextKinds: ['user'],
default: 111,
counters: [{ variation: 0, value: 100, version: 11, count: 1 }, { value: 111, version: 11, count: 2 }],
counters: [
{ variation: 0, value: 100, version: 11, count: 1 },
{ value: 111, version: 11, count: 2 },
],
},
};
expect(data.features).toEqual(expectedFeatures);
Expand Down
12 changes: 12 additions & 0 deletions src/__tests__/LDClient-events-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,18 @@ describe('LDClient events', () => {
});
});

it('does warn when a metric value is non-numeric', async () => {
await withClientAndEventProcessor(user, {}, async client => {
await client.waitForInitialization();

client.track('known', undefined, '12');
expect(platform.testing.logger.output.warn).toEqual([
'The track function was called with a non-numeric "metricValue" (string), ' +
'only numeric metric values are supported.',
]);
});
});

it('emits an error when tracking a non-string custom event', async () => {
await withClientAndEventProcessor(user, {}, async client => {
await client.waitForInitialization();
Expand Down
67 changes: 67 additions & 0 deletions src/__tests__/LDClient-timeout-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
jest.mock('../InitializationState', () => jest.fn());
jest.mock('../timedPromise', () => jest.fn());

import { initialize } from '../index';
import InitializationState from '../InitializationState';
import timedPromise from '../timedPromise';
import * as stubPlatform from './stubPlatform';

const createHangingPromise = () =>
new Promise(() => {
// never resolves
});

describe('timeout', () => {
let ldc;
let mockGetInitializationPromise;
let mockGetReadyPromise;

beforeEach(() => {
mockGetInitializationPromise = jest.fn();
mockGetReadyPromise = jest.fn();
timedPromise.mockImplementation(() => Promise.reject(new Error('timed out')));
InitializationState.mockImplementation(() => ({
getInitializationPromise: mockGetInitializationPromise,
getReadyPromise: mockGetReadyPromise,
signalFailure: jest.fn(),
}));
mockGetInitializationPromise.mockImplementation(createHangingPromise);
mockGetReadyPromise.mockImplementation(createHangingPromise);
({ client: ldc } = initialize(
'abc',
{ kind: 'user', key: 'test-user' },
{
logger: stubPlatform.logger(),
},
{}
));
});

afterEach(() => {
jest.resetAllMocks();
});

it('waitForInitialization timeout', async () => {
const p = ldc.waitForInitialization();
await expect(p).rejects.toThrow(/timed out/);
});

it('waitForInitialization succeeds', async () => {
timedPromise.mockImplementation(createHangingPromise);
mockGetInitializationPromise.mockImplementation(() => Promise.resolve('success'));

const p = ldc.waitForInitialization();

await expect(p).resolves.toEqual('success');
});

it('waitForInitialization succeeds with custom timeout', async () => {
timedPromise.mockImplementation(createHangingPromise);
mockGetInitializationPromise.mockImplementation(() => Promise.resolve('success'));

const p = ldc.waitForInitialization(10);

await expect(p).resolves.toEqual('success');
expect(timedPromise).toBeCalledWith(10, 'waitForInitialization');
});
});
10 changes: 8 additions & 2 deletions src/__tests__/diagnosticEvents-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ describe('DiagnosticsManager', () => {
const expectedStatsForPeriodicEvent1 = {
droppedEvents: 1,
eventsInLastBatch: 2,
streamInits: [{ timestamp: 1001, durationMillis: 100 }, { timestamp: 1002, failed: true, durationMillis: 500 }],
streamInits: [
{ timestamp: 1001, durationMillis: 100 },
{ timestamp: 1002, failed: true, durationMillis: 500 },
],
};
const expectedStatsForPeriodicEvent2 = {
droppedEvents: 0,
Expand Down Expand Up @@ -392,7 +395,10 @@ describe('DiagnosticsManager', () => {
dataSinceDate: storedStats.dataSinceDate,
droppedEvents: 2,
eventsInLastBatch: 3,
streamInits: [{ timestamp: 1000, durationMillis: 500 }, { timestamp: 1001, durationMillis: 501 }],
streamInits: [
{ timestamp: 1000, durationMillis: 500 },
{ timestamp: 1001, durationMillis: 501 },
],
});
expect(firstEvent.creationDate).toBeGreaterThanOrEqual(timeBeforeStart);
});
Expand Down
2 changes: 2 additions & 0 deletions src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const LDInvalidEventKeyError = createCustomError('LaunchDarklyInvalidEventKeyErr
const LDInvalidArgumentError = createCustomError('LaunchDarklyInvalidArgumentError');
const LDFlagFetchError = createCustomError('LaunchDarklyFlagFetchError');
const LDInvalidDataError = createCustomError('LaunchDarklyInvalidDataError');
const LDTimeoutError = createCustomError('LaunchDarklyTimeoutError');

function isHttpErrorRecoverable(status) {
if (status >= 400 && status < 500) {
Expand All @@ -35,5 +36,6 @@ module.exports = {
LDInvalidArgumentError,
LDInvalidDataError,
LDFlagFetchError,
LDTimeoutError,
isHttpErrorRecoverable,
};
4 changes: 2 additions & 2 deletions src/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function getLDHeaders(platform, options) {
if (tagKeys.length) {
h['x-launchdarkly-tags'] = tagKeys
.sort()
.map(
key => (Array.isArray(tags[key]) ? tags[key].sort().map(value => `${key}/${value}`) : [`${key}/${tags[key]}`])
.map(key =>
Array.isArray(tags[key]) ? tags[key].sort().map(value => `${key}/${value}`) : [`${key}/${tags[key]}`]
)
.reduce((flattened, item) => flattened.concat(item), [])
.join(' ');
Expand Down
19 changes: 18 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ const errors = require('./errors');
const messages = require('./messages');
const { checkContext, getContextKeys } = require('./context');
const { InspectorTypes, InspectorManager } = require('./InspectorManager');
const timedPromise = require('./timedPromise');

const changeEvent = 'change';
const internalChangeEvent = 'internal-change';
const waitTimeout = 5;

// This is called by the per-platform initialize functions to create the base client object that we
// may also extend with additional behavior. It returns an object with these properties:
Expand Down Expand Up @@ -365,6 +367,9 @@ function initialize(env, context, specifiedOptions, platform, extraOptionDefs) {
emitter.maybeReportError(new errors.LDInvalidEventKeyError(messages.unknownCustomEventKey(key)));
return;
}
if (metricValue !== undefined && typeof metricValue !== 'number') {
logger.warn(messages.invalidMetricValue(typeof metricValue));
}

// The following logic was used only for the JS browser SDK (js-client-sdk) and
// is no longer needed as of version 2.9.13 of that SDK. The other client-side
Expand Down Expand Up @@ -772,8 +777,20 @@ function initialize(env, context, specifiedOptions, platform, extraOptionDefs) {
return flags;
}

function waitForInitialization(timeout = waitTimeout) {
const slow = initializationStateTracker.getInitializationPromise();
const timed = timedPromise(timeout, 'waitForInitialization');

return Promise.race([timed, slow]).catch(e => {
if (e.message.includes('timed out')) {
logger.error(`waitForInitialization error: ${e}`);
}
throw e;
});
}

const client = {
waitForInitialization: () => initializationStateTracker.getInitializationPromise(),
waitForInitialization,
waitUntilReady: () => initializationStateTracker.getReadyPromise(),
identify: identify,
getContext: getContext,
Expand Down
4 changes: 4 additions & 0 deletions src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ const invalidTagValue = name => `Config option "${name}" must only contain lette

const tagValueTooLong = name => `Value of "${name}" was longer than 64 characters and was discarded.`;

const invalidMetricValue = badType =>
`The track function was called with a non-numeric "metricValue" (${badType}), only numeric metric values are supported.`;

module.exports = {
bootstrapInvalid,
bootstrapOldFormat,
Expand Down Expand Up @@ -219,6 +222,7 @@ module.exports = {
invalidData,
invalidInspector,
invalidKey,
invalidMetricValue,
invalidContext,
invalidTagValue,
localStorageUnavailable,
Expand Down
17 changes: 17 additions & 0 deletions src/timedPromise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { LDTimeoutError } = require('./errors');

/**
* Returns a promise which errors after t seconds.
*
* @param t Timeout in seconds.
* @param taskName Name of task being timed for logging and error reporting.
*/
function timedPromise(t, taskName) {
return new Promise((_res, reject) => {
setTimeout(() => {
const e = `${taskName} timed out after ${t} seconds.`;
reject(new LDTimeoutError(e));
}, t * 1000);
});
}
module.exports = timedPromise;
Loading