Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

prepare 4.8.0 release #170

Merged
merged 283 commits into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
283 commits
Select commit Hold shift + click to select a range
cc42ed6
Merge pull request #86 from launchdarkly/eb/disable-fossa
eli-darkly Aug 16, 2018
e4ae9cb
add evaluation reasons to allFlagsState()
eli-darkly Aug 16, 2018
de8b9e7
Merge branch 'master' into explanation
eli-darkly Aug 16, 2018
80f7197
Merge branch 'explanation' into eb/ch21386/all-flags-state-with-reasons
eli-darkly Aug 16, 2018
7e91572
rm duplicated test
eli-darkly Aug 16, 2018
a0dcfa7
add error explanation for malformed flags
eli-darkly Aug 16, 2018
712bed4
add tests for more error conditions
eli-darkly Aug 16, 2018
564db86
change options to be more enum-like
eli-darkly Aug 17, 2018
e29c2e0
version 4.2.2 (#88)
eli-darkly Aug 17, 2018
91f9cb2
add option to select only client-side flags in allFlagsState()
eli-darkly Aug 17, 2018
b0f034e
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Aug 17, 2018
a060bcc
fix comment
eli-darkly Aug 17, 2018
8939c8b
serialize FeatureFlagsState to a JsonElement, not a string
eli-darkly Aug 20, 2018
78611fb
rm unused import
eli-darkly Aug 20, 2018
8200e44
edit comment
eli-darkly Aug 20, 2018
bb20933
use custom Gson serializer
eli-darkly Aug 21, 2018
b82f58b
Merge branch 'eb/ch21386/all-flags-state-without-reasons' into eb/ch1…
eli-darkly Aug 21, 2018
20b2914
Merge pull request #85 from launchdarkly/eb/ch21386/all-flags-state-w…
eli-darkly Aug 22, 2018
190cdb9
add tests for JSON serialization of evaluation reasons
eli-darkly Aug 22, 2018
e90f90b
Merge pull request #87 from launchdarkly/eb/malformed-flag-error
eli-darkly Aug 22, 2018
bc5033a
Merge pull request #89 from launchdarkly/eb/ch12124/filter-client-sid…
eli-darkly Aug 22, 2018
b8b6a5b
Merge branch 'all-flags-state' into explanation
eli-darkly Aug 22, 2018
e35d149
Merge branch 'explanation' into eb/ch21386/all-flags-state-with-reasons
eli-darkly Aug 22, 2018
38f01cc
Merge branch 'explanation' into eb/reason-json-tests
eli-darkly Aug 22, 2018
8f90c71
misc cleanup
eli-darkly Aug 23, 2018
ccaddda
don't keep evaluating prerequisites if one fails
eli-darkly Aug 23, 2018
1d20039
Merge branch 'eb/single-prereq-failure' into eb/reason-json-tests
eli-darkly Aug 23, 2018
9a00c07
avoid some inappropriate uses of Guava's ImmutableMap
eli-darkly Aug 23, 2018
d026e18
make map & set in the User immutable
eli-darkly Aug 23, 2018
18ed2d6
fix default value logic
eli-darkly Aug 24, 2018
ab503e8
Merge pull request #94 from launchdarkly/eb/default-values
eli-darkly Aug 25, 2018
1de786b
Merge pull request #93 from launchdarkly/eb/immutable-maps
eli-darkly Aug 25, 2018
e9a31d0
Merge branch 'all-flags-state' into eb/ch21386/all-flags-state-with-r…
eli-darkly Aug 25, 2018
7de5305
Merge pull request #92 from launchdarkly/eb/single-prereq-failure
eli-darkly Aug 25, 2018
001f2e3
Merge pull request #91 from launchdarkly/eb/reason-json-tests
eli-darkly Aug 25, 2018
648a2e6
Merge pull request #90 from launchdarkly/eb/ch21386/all-flags-state-w…
eli-darkly Aug 25, 2018
4b98e50
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Aug 27, 2018
d21466c
javadoc fix
eli-darkly Aug 27, 2018
98cb3a6
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Aug 27, 2018
e0a41a5
make LDUser serialize correctly as JSON and add more test coverage
eli-darkly Aug 29, 2018
6abbb22
preserve prerequisite flag value in event even if flag was off
eli-darkly Aug 29, 2018
c18a1e1
more test coverage for requesting values of different types
eli-darkly Aug 29, 2018
aa38e77
Merge pull request #95 from launchdarkly/eb/ch22890/user-json
eli-darkly Sep 4, 2018
61effc7
Merge pull request #96 from launchdarkly/eb/ch22995/prereq-off
eli-darkly Sep 4, 2018
897aa62
Merge pull request #97 from launchdarkly/eb/ch23009/numeric-types
eli-darkly Sep 4, 2018
74834fe
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Sep 6, 2018
df6bde2
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Sep 6, 2018
00ad428
send correct event schema version
eli-darkly Sep 11, 2018
5573750
Merge pull request #98 from launchdarkly/eb/ch23827/event-version
eli-darkly Sep 11, 2018
af55687
merge from public after release
LaunchDarklyCI Sep 11, 2018
7c24d76
new option for sending less bootstrap data based on event tracking st…
eli-darkly Sep 26, 2018
41e429b
Merge pull request #99 from launchdarkly/eb/ch24449/less-bootstrap-data
eli-darkly Oct 1, 2018
4f9278b
merge from public after release
LaunchDarklyCI Oct 2, 2018
dcdad5e
change Gradle build to fix pom
eli-darkly Oct 13, 2018
5bba52a
misc build fixes
eli-darkly Oct 13, 2018
8af7519
misc fixes
eli-darkly Oct 14, 2018
2faeeb3
fix John's email
eli-darkly Oct 15, 2018
d2b8db0
Merge pull request #100 from launchdarkly/eb/ch13581/fix-pom
eli-darkly Oct 15, 2018
4a7d402
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Oct 17, 2018
d79ef2f
fix build so jar signatures will be published
eli-darkly Oct 18, 2018
e2021c9
Merge pull request #101 from launchdarkly/eb/fix-signing
eli-darkly Oct 18, 2018
352622c
merge from public after release
LaunchDarklyCI Oct 18, 2018
3ed7349
add file data source to Java SDK
eli-darkly Oct 19, 2018
e8ac5cc
formatting
eli-darkly Oct 19, 2018
071e0fc
formatting
eli-darkly Oct 19, 2018
5ad29f3
clarify comment
eli-darkly Oct 23, 2018
90e1bce
add link in readme
eli-darkly Oct 24, 2018
a607be1
Merge pull request #102 from launchdarkly/eb/ch25272/file-data-source
eli-darkly Oct 24, 2018
be41326
comment correction
eli-darkly Oct 24, 2018
2a3ead4
test that flags loaded from a file actually work
eli-darkly Oct 25, 2018
0e4ce02
add comment link
eli-darkly Oct 25, 2018
ca9fb99
Merge pull request #103 from launchdarkly/eb/ch25272/extra-test
eli-darkly Oct 26, 2018
bb5ef20
fix link URL
eli-darkly Oct 26, 2018
ff545df
merge from public after release
LaunchDarklyCI Oct 26, 2018
70d6a4e
added fossa build step
pkaeding Nov 16, 2018
e52c72f
empty commit
pkaeding Nov 16, 2018
e98f673
moved workflow filter definition
pkaeding Nov 16, 2018
e8c95aa
fixed docker image reference for fossa
pkaeding Nov 16, 2018
c481f30
give up on fossa-cli docker image
pkaeding Nov 16, 2018
cffdea7
added fossa.yml config
pkaeding Nov 16, 2018
6df4a6c
use v1 of fossa config?
pkaeding Nov 16, 2018
a2d8e0b
iterate on fossa config
pkaeding Nov 16, 2018
03ffa5d
run fossa init
pkaeding Nov 16, 2018
4c17f04
adapted fossa setup after seeing pr from fossa engineer
pkaeding Nov 17, 2018
fcbf66b
fixed sed command for fossa config
pkaeding Nov 17, 2018
5059856
removed sed nonsense since it isn't necessary
pkaeding Nov 17, 2018
fc24db5
let fossa figure out the sha, rather than passing it in from a circle…
pkaeding Nov 17, 2018
f04728d
Merge pull request #104 from launchdarkly/pk/ch26807/fix-fossa-integr…
pkaeding Nov 17, 2018
279a6b7
log stream errors as WARN, not ERROR
eli-darkly Nov 19, 2018
1c16129
publish test jar for shared tests
eli-darkly Nov 19, 2018
f92927c
add feature store support classes and use them in Redis
eli-darkly Nov 19, 2018
fa56386
comments
eli-darkly Nov 19, 2018
416c7dd
fix test
eli-darkly Nov 19, 2018
cc5efed
generate OSGi manifests semi-manually
eli-darkly Nov 20, 2018
94db999
fix build script so file data source package isn't shaded
eli-darkly Nov 20, 2018
7854de7
remove hard-coded package names, detect them from dependencies
eli-darkly Nov 20, 2018
1eb7084
don't try to access build products during configuration phase
eli-darkly Nov 20, 2018
facf198
comments
eli-darkly Nov 20, 2018
42f4329
Merge pull request #107 from launchdarkly/eb/fix-files-package
eli-darkly Nov 20, 2018
3668c38
Merge pull request #105 from launchdarkly/eb/ch19880/log-level
eli-darkly Nov 22, 2018
eeb2e20
merge from public after release
LaunchDarklyCI Nov 22, 2018
7203861
Merge pull request #106 from launchdarkly/eb/feature-store-support
eli-darkly Nov 22, 2018
beb8a1d
minor javadoc fixes
eli-darkly Nov 22, 2018
37d7b0b
misc changes for test support
eli-darkly Nov 22, 2018
64765c2
test fix
eli-darkly Nov 22, 2018
ee9b4c7
Merge branch 'master' into eb/ch15431/osgi
eli-darkly Nov 22, 2018
e82efc2
auto-discovery of imports and exports for shaded jars
eli-darkly Nov 22, 2018
4a26f93
add OSGi manifest to thin jar + misc refactoring
eli-darkly Nov 22, 2018
a997086
describe jar distributions
eli-darkly Nov 22, 2018
67cf59b
update other reference to version in readme
eli-darkly Nov 22, 2018
13aaa3a
Merge branch 'master' into eb/ch15431/osgi
eli-darkly Nov 22, 2018
f7f0d9a
rm Twisted
eli-darkly Nov 22, 2018
e66c590
misc fixes to jar configuration
eli-darkly Nov 23, 2018
9e33f90
add CI job to verify that we can build the jars
eli-darkly Nov 23, 2018
4515199
CI fix
eli-darkly Nov 23, 2018
da41de7
CI fix
eli-darkly Nov 23, 2018
d00d59e
CI fix
eli-darkly Nov 23, 2018
ead2f9b
CI fix
eli-darkly Nov 23, 2018
38255ca
skip signing jars in CI
eli-darkly Nov 23, 2018
6a0871d
CI fix
eli-darkly Nov 23, 2018
c0be7b2
CI fix
eli-darkly Nov 23, 2018
6aa4fde
add basic packaging tests
eli-darkly Nov 24, 2018
25a8f8b
install make
eli-darkly Nov 24, 2018
f18c50b
verify that every subpackage in the SDK source code exists in the jars
eli-darkly Nov 24, 2018
5f6d9be
remove OSGi support for now
eli-darkly Nov 24, 2018
cc3b7b1
Revert "remove OSGi support for now"
eli-darkly Nov 24, 2018
ca324bf
misc improvements for OSGi build and testing
eli-darkly Nov 24, 2018
7ac7320
ensure that temp dir is created
eli-darkly Nov 24, 2018
9cfda83
comment
eli-darkly Nov 24, 2018
50dd76a
add vendor attribute
eli-darkly Nov 24, 2018
8caab84
misc reorganization + comments
eli-darkly Nov 24, 2018
97caed8
comment
eli-darkly Nov 24, 2018
8f53730
simplify test app build
eli-darkly Nov 24, 2018
10c8264
improvements to OSGi test app
eli-darkly Nov 24, 2018
88843a5
more accurate way of discovering packages from OSGi jars
eli-darkly Nov 24, 2018
e3f3197
OSGi test fixes
eli-darkly Nov 24, 2018
a3612b7
simplify things using some library code
eli-darkly Nov 24, 2018
2779298
more specific logic for property switch
eli-darkly Dec 4, 2018
1b4b345
Merge pull request #108 from launchdarkly/eb/ch15431/basic-packaging-…
eli-darkly Dec 4, 2018
3d15da9
Merge branch 'master' into eb/ch15431/osgi
eli-darkly Dec 4, 2018
8d690f0
Merge pull request #109 from launchdarkly/eb/ch15431/osgi
eli-darkly Dec 7, 2018
1c1af79
better abstraction of caching parameters
eli-darkly Dec 7, 2018
79a758e
fix doc comment
eli-darkly Dec 7, 2018
e088858
comment
eli-darkly Dec 7, 2018
f7f6bbe
javadoc fixes
eli-darkly Dec 7, 2018
a478796
better use of static instances
eli-darkly Dec 7, 2018
95b352d
use newer methods in test
eli-darkly Dec 7, 2018
7d38880
Merge pull request #110 from launchdarkly/eb/cache-parameters
eli-darkly Dec 7, 2018
9931858
add readme text about DNS cache
eli-darkly Dec 8, 2018
9caea4c
copyedit
eli-darkly Dec 8, 2018
30cad56
add Electron link
eli-darkly Dec 8, 2018
d44bf0e
simplify method signatures + some test fixes
eli-darkly Dec 10, 2018
59b56f5
Merge pull request #112 from launchdarkly/eb/feature-store-support-2
eli-darkly Dec 10, 2018
4f27eab
Merge pull request #111 from launchdarkly/eb/ch28024/dns-ttl-readme
eli-darkly Dec 11, 2018
c453aac
misc API cleanup
eli-darkly Dec 13, 2018
b17a239
use EventSource snapshot prior to release
eli-darkly Dec 13, 2018
e02d97c
use EventSource 1.9.0
eli-darkly Dec 13, 2018
f4413fb
fix broken unit test
eli-darkly Dec 13, 2018
4332550
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Dec 13, 2018
d5d822f
implement dependency ordering for feature store data
eli-darkly Jan 8, 2019
746bf56
fix accidental deletion
eli-darkly Jan 8, 2019
b5677ef
simplify ordering logic
eli-darkly Jan 9, 2019
d72c680
Merge pull request #113 from launchdarkly/eb/ch29197/dependency-ordering
eli-darkly Jan 12, 2019
3151b34
javadoc fix
eli-darkly Jan 14, 2019
2eb0faa
merge from public after release
LaunchDarklyCI Jan 14, 2019
d874798
reset changelog - release error
eli-darkly Jan 15, 2019
f4f1853
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Jan 15, 2019
b1b66d9
merge from public after release
LaunchDarklyCI Jan 15, 2019
0464fc8
add pipeline
hroederld Feb 5, 2019
23ae1ba
Merge pull request #114 from launchdarkly/hr/azure
hroederld Feb 5, 2019
91c846b
fix tool download for packaging tests
eli-darkly Feb 5, 2019
67beb27
Merge pull request #115 from launchdarkly/eb/ch31401/felix-test
eli-darkly Feb 5, 2019
9326cf5
add experimentation event overrides for rules and fallthrough
eli-darkly Feb 20, 2019
4a54961
fix test case
eli-darkly Feb 20, 2019
29716e6
Merge pull request #116 from launchdarkly/eb/ch32302/experimentation-…
eli-darkly Feb 20, 2019
67f4498
perform orderly shutdown of event processor if it dies; process queue…
eli-darkly Feb 21, 2019
3d7ab6b
still need to be able to wait on a shutdown message when closing
eli-darkly Feb 21, 2019
4d4c37b
Merge pull request #117 from launchdarkly/eb/ch32404/event-processor-…
eli-darkly Feb 21, 2019
52cd895
use long ints in summary event counters
eli-darkly Feb 21, 2019
082d2d4
Merge pull request #118 from launchdarkly/eb/ch25963/long-counters
eli-darkly Feb 21, 2019
1c49f9b
Revert "Merge pull request #116 from launchdarkly/eb/ch32302/experime…
eli-darkly Feb 21, 2019
9f3eac2
merge from public after release
LaunchDarklyCI Feb 21, 2019
5d208ae
track or identify without a valid user shouldn't send an event
eli-darkly Feb 22, 2019
c6cee01
Merge pull request #119 from launchdarkly/eb/ch32176/no-user-no-event
eli-darkly Feb 22, 2019
c84852d
Merge commit '4791702a70d4d70b8dcab4283131aa09652fa998'
eli-darkly Mar 13, 2019
f48fcaf
bump eventsource version so we're no longer getting JSR305 annotations
eli-darkly Mar 21, 2019
5f75259
remove special shading rule for javax annotations
eli-darkly Mar 21, 2019
cd1f8d8
Merge pull request #120 from launchdarkly/eb/ch34379/no-jsr305
eli-darkly Mar 21, 2019
d769aa4
merge from public after release
LaunchDarklyCI Mar 22, 2019
ebc6099
Removed .fossa.yml, removed fossa job from circleci, removed fossa ba…
torchhound Mar 29, 2019
221c10d
extract gradle properties clarification to separate PR
bwoskow-ld Apr 1, 2019
c0d7e5f
Merge pull request #123 from launchdarkly/bw/ch35262/gradle-propertie…
bwoskow-ld Apr 1, 2019
69ee4ed
Merge pull request #122 from launchdarkly/jc/remove-fossa
torchhound Apr 1, 2019
1e17dad
add optional metric value to track()
eli-darkly Apr 13, 2019
5a0313b
add test
eli-darkly Apr 13, 2019
855e8c0
update method description
eli-darkly Apr 16, 2019
be2f93a
Merge pull request #124 from launchdarkly/eb/ch32302/metric-value
eli-darkly Apr 16, 2019
bbe805b
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
bwoskow-ld Apr 26, 2019
157a709
artifact/repository rename + doc update (#125)
bwoskow-ld May 1, 2019
20573f6
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
bwoskow-ld May 1, 2019
345506d
merge from public after release
LaunchDarklyCI May 1, 2019
786e432
Adding properties back to fix the latest failure in the java restwrap…
bwoskow-ld May 2, 2019
3a8fdf6
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
bwoskow-ld May 2, 2019
139f083
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
bwoskow-ld May 3, 2019
d5cca57
change mirror used to get felix (#127)
bwoskow-ld May 21, 2019
8c7cb63
Add circleci jobs for supported java versions (#128)
bwoskow-ld May 21, 2019
2cd6c19
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
bwoskow-ld May 21, 2019
d7a7dae
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
bwoskow-ld May 21, 2019
ad3de4c
merge from public after release
LaunchDarklyCI May 21, 2019
bb188bd
rename inputChannel and buffer to inbox and outbox
eli-darkly Jul 8, 2019
822dbaa
drop events if inbox is full
eli-darkly Jul 8, 2019
0af23e5
revert unintentional change
eli-darkly Jul 8, 2019
8c689d6
use a volatile boolean instead of an AtomicBoolean
eli-darkly Jul 8, 2019
d2f52f9
comment
eli-darkly Jul 8, 2019
50ae974
Merge pull request #129 from launchdarkly/eb/ch32404/full-event-inbox
eli-darkly Jul 10, 2019
d2b8e94
merge from public after release
LaunchDarklyCI Jul 10, 2019
633f45d
Merge branch 'master' into experiment
eli-darkly Jul 10, 2019
d7f1724
deprecate samplingInterval
eli-darkly Aug 1, 2019
da03425
add password to Redis builder
eli-darkly Aug 1, 2019
b90ea52
Merge pull request #131 from launchdarkly/eb/ch38635/deprecate-sampling
eli-darkly Aug 1, 2019
fd5dcda
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Aug 1, 2019
1a8f40f
add polling mode tests and end-to-end streaming test
eli-darkly Aug 2, 2019
e70355a
revise custom TLS config implementation, add tests
eli-darkly Aug 2, 2019
b9aa701
rm test code
eli-darkly Aug 2, 2019
a6209c0
rm unused
eli-darkly Aug 2, 2019
7cddd94
change test cert properties for Azure compatibility
eli-darkly Aug 2, 2019
37c456e
Merge pull request #132 from launchdarkly/eb/ch45321/polling-tests
eli-darkly Aug 2, 2019
2ebf254
Merge pull request #133 from launchdarkly/eb/ch44325/tls-config
eli-darkly Aug 2, 2019
03a4dc2
Merge branch 'master' into eb/ch41263/redis-password
eli-darkly Aug 2, 2019
b4f9054
add Redis builder options for password, TLS, database
eli-darkly Aug 2, 2019
450868e
revert debugging changes
eli-darkly Aug 2, 2019
f59392c
Merge pull request #134 from launchdarkly/eb/ch41263/redis-password
eli-darkly Aug 2, 2019
0ffa58f
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Aug 3, 2019
facd40a
Merge branch 'master' into experiment
eli-darkly Aug 19, 2019
1bce52e
update doc comment for track() with metric
eli-darkly Aug 19, 2019
52868d2
inline doc link
eli-darkly Aug 19, 2019
d47af12
avoid concurrency problem with date parser for event responses
eli-darkly Aug 19, 2019
9e5606c
Merge pull request #135 from launchdarkly/eb/ch32302/track-comment
eli-darkly Aug 19, 2019
cdb18be
revert accidental deletion, fix test
eli-darkly Aug 19, 2019
6bdf490
Merge pull request #136 from launchdarkly/eb/ch46731/events-parse-error
eli-darkly Aug 19, 2019
c80e585
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
eli-darkly Aug 19, 2019
4789513
typo
eli-darkly Aug 19, 2019
43e2d2b
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
eli-darkly Aug 19, 2019
8c678e5
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
eli-darkly Aug 19, 2019
06b2390
merge from public after release
LaunchDarklyCI Aug 19, 2019
ff2890d
Merge branch 'master' into experiment
eli-darkly Aug 20, 2019
87da949
add tests and doc comments about float->int rounding
eli-darkly Sep 6, 2019
71970ae
Merge pull request #137 from launchdarkly/eb/ch48416/rounding
eli-darkly Sep 9, 2019
c18bc85
Merge branch 'master' into experiment
eli-darkly Sep 19, 2019
db30229
Revert "Revert "Merge pull request #116 from launchdarkly/eb/ch32302/…
eli-darkly Sep 27, 2019
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
8 changes: 7 additions & 1 deletion src/main/java/com/launchdarkly/client/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ public Event(long creationDate, LDUser user) {
public static final class Custom extends Event {
final String key;
final JsonElement data;
final Double metricValue;

public Custom(long timestamp, String key, LDUser user, JsonElement data) {
public Custom(long timestamp, String key, LDUser user, JsonElement data, Double metricValue) {
super(timestamp, user);
this.key = key;
this.data = data;
this.metricValue = metricValue;
}

public Custom(long timestamp, String key, LDUser user, JsonElement data) {
this(timestamp, key, user, data, null);
}
}

Expand Down
65 changes: 55 additions & 10 deletions src/main/java/com/launchdarkly/client/EventFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ abstract class EventFactory {
protected abstract long getTimestamp();
protected abstract boolean isIncludeReasons();

public Event.FeatureRequest newFeatureRequestEvent(FeatureFlag flag, LDUser user, JsonElement value,
Integer variationIndex, EvaluationReason reason, JsonElement defaultValue, String prereqOf) {
boolean requireExperimentData = isExperiment(flag, reason);
return new Event.FeatureRequest(
getTimestamp(),
flag.getKey(),
user,
flag.getVersion(),
variationIndex,
value,
defaultValue,
prereqOf,
requireExperimentData || flag.isTrackEvents(),
flag.getDebugEventsUntilDate(),
(requireExperimentData || isIncludeReasons()) ? reason : null,
false
);
}

public Event.FeatureRequest newFeatureRequestEvent(FeatureFlag flag, LDUser user, EvaluationDetail<JsonElement> result, JsonElement defaultVal) {
return new Event.FeatureRequest(getTimestamp(), flag.getKey(), user, flag.getVersion(),
result == null ? null : result.getVariationIndex(), result == null ? null : result.getValue(),
defaultVal, null, flag.isTrackEvents(), flag.getDebugEventsUntilDate(),
isIncludeReasons() ? result.getReason() : null, false);
return newFeatureRequestEvent(flag, user, result == null ? null : result.getValue(),
result == null ? null : result.getVariationIndex(), result == null ? null : result.getReason(),
defaultVal, null);
}

public Event.FeatureRequest newDefaultFeatureRequestEvent(FeatureFlag flag, LDUser user, JsonElement defaultValue,
Expand All @@ -31,25 +49,52 @@ public Event.FeatureRequest newUnknownFeatureRequestEvent(String key, LDUser use

public Event.FeatureRequest newPrerequisiteFeatureRequestEvent(FeatureFlag prereqFlag, LDUser user, EvaluationDetail<JsonElement> result,
FeatureFlag prereqOf) {
return new Event.FeatureRequest(getTimestamp(), prereqFlag.getKey(), user, prereqFlag.getVersion(),
result == null ? null : result.getVariationIndex(), result == null ? null : result.getValue(),
null, prereqOf.getKey(), prereqFlag.isTrackEvents(), prereqFlag.getDebugEventsUntilDate(),
isIncludeReasons() ? result.getReason() : null, false);
return newFeatureRequestEvent(prereqFlag, user, result == null ? null : result.getValue(),
result == null ? null : result.getVariationIndex(), result == null ? null : result.getReason(),
null, prereqOf.getKey());
}

public Event.FeatureRequest newDebugEvent(Event.FeatureRequest from) {
return new Event.FeatureRequest(from.creationDate, from.key, from.user, from.version, from.variation, from.value,
from.defaultVal, from.prereqOf, from.trackEvents, from.debugEventsUntilDate, from.reason, true);
}

public Event.Custom newCustomEvent(String key, LDUser user, JsonElement data) {
return new Event.Custom(getTimestamp(), key, user, data);
public Event.Custom newCustomEvent(String key, LDUser user, JsonElement data, Double metricValue) {
return new Event.Custom(getTimestamp(), key, user, data, metricValue);
}

public Event.Identify newIdentifyEvent(LDUser user) {
return new Event.Identify(getTimestamp(), user);
}

private boolean isExperiment(FeatureFlag flag, EvaluationReason reason) {
if (reason == null) {
// doesn't happen in real life, but possible in testing
return false;
}
switch (reason.getKind()) {
case FALLTHROUGH:
return flag.isTrackEventsFallthrough();
case RULE_MATCH:
if (!(reason instanceof EvaluationReason.RuleMatch)) {
// shouldn't be possible
return false;
}
EvaluationReason.RuleMatch rm = (EvaluationReason.RuleMatch)reason;
int ruleIndex = rm.getRuleIndex();
// Note, it is OK to rely on the rule index rather than the unique ID in this context, because the
// FeatureFlag that is passed to us here *is* necessarily the same version of the flag that was just
// evaluated, so we cannot be out of sync with its rule list.
if (ruleIndex >= 0 && ruleIndex < flag.getRules().size()) {
Rule rule = flag.getRules().get(ruleIndex);
return rule.isTrackEvents();
}
return false;
default:
return false;
}
}

public static class DefaultEventFactory extends EventFactory {
private final boolean includeReasons;

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/launchdarkly/client/EventOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ static final class Custom extends EventOutputWithTimestamp {
private final String userKey;
private final LDUser user;
private final JsonElement data;
private final Double metricValue;

Custom(long creationDate, String key, String userKey, LDUser user, JsonElement data) {
Custom(long creationDate, String key, String userKey, LDUser user, JsonElement data, Double metricValue) {
super("custom", creationDate);
this.key = key;
this.userKey = userKey;
this.user = user;
this.data = data;
this.metricValue = metricValue;
}
}

Expand Down Expand Up @@ -174,7 +176,8 @@ private EventOutput createOutputEvent(Event e) {
return new EventOutput.Custom(ce.creationDate, ce.key,
inlineUsers ? null : userKey,
inlineUsers ? e.user : null,
ce.data);
ce.data,
ce.metricValue);
} else if (e instanceof Event.Index) {
return new EventOutput.Index(e.creationDate, e.user);
} else {
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/launchdarkly/client/FeatureFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class FeatureFlag implements VersionedData {
private List<JsonElement> variations;
private boolean clientSide;
private boolean trackEvents;
private boolean trackEventsFallthrough;
private Long debugEventsUntilDate;
private boolean deleted;

Expand All @@ -37,7 +38,8 @@ class FeatureFlag implements VersionedData {

FeatureFlag(String key, int version, boolean on, List<Prerequisite> prerequisites, String salt, List<Target> targets,
List<Rule> rules, VariationOrRollout fallthrough, Integer offVariation, List<JsonElement> variations,
boolean clientSide, boolean trackEvents, Long debugEventsUntilDate, boolean deleted) {
boolean clientSide, boolean trackEvents, boolean trackEventsFallthrough,
Long debugEventsUntilDate, boolean deleted) {
this.key = key;
this.version = version;
this.on = on;
Expand All @@ -50,6 +52,7 @@ class FeatureFlag implements VersionedData {
this.variations = variations;
this.clientSide = clientSide;
this.trackEvents = trackEvents;
this.trackEventsFallthrough = trackEventsFallthrough;
this.debugEventsUntilDate = debugEventsUntilDate;
this.deleted = deleted;
}
Expand Down Expand Up @@ -167,6 +170,10 @@ public boolean isTrackEvents() {
return trackEvents;
}

public boolean isTrackEventsFallthrough() {
return trackEventsFallthrough;
}

public Long getDebugEventsUntilDate() {
return debugEventsUntilDate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FeatureFlagBuilder {
private List<JsonElement> variations = new ArrayList<>();
private boolean clientSide;
private boolean trackEvents;
private boolean trackEventsFallthrough;
private Long debugEventsUntilDate;
private boolean deleted;

Expand All @@ -40,6 +41,7 @@ class FeatureFlagBuilder {
this.variations = f.getVariations();
this.clientSide = f.isClientSide();
this.trackEvents = f.isTrackEvents();
this.trackEventsFallthrough = f.isTrackEventsFallthrough();
this.debugEventsUntilDate = f.getDebugEventsUntilDate();
this.deleted = f.isDeleted();
}
Expand Down Expand Up @@ -103,6 +105,11 @@ FeatureFlagBuilder trackEvents(boolean trackEvents) {
this.trackEvents = trackEvents;
return this;
}

FeatureFlagBuilder trackEventsFallthrough(boolean trackEventsFallthrough) {
this.trackEventsFallthrough = trackEventsFallthrough;
return this;
}

FeatureFlagBuilder debugEventsUntilDate(Long debugEventsUntilDate) {
this.debugEventsUntilDate = debugEventsUntilDate;
Expand All @@ -116,6 +123,6 @@ FeatureFlagBuilder deleted(boolean deleted) {

FeatureFlag build() {
return new FeatureFlag(key, version, on, prerequisites, salt, targets, rules, fallthrough, offVariation, variations,
clientSide, trackEvents, debugEventsUntilDate, deleted);
clientSide, trackEvents, trackEventsFallthrough, debugEventsUntilDate, deleted);
}
}
21 changes: 12 additions & 9 deletions src/main/java/com/launchdarkly/client/LDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,28 @@ public LDClient(String sdkKey, LDConfig config) {
public boolean initialized() {
return updateProcessor.initialized();
}


@Override
public void track(String eventName, LDUser user) {
track(eventName, user, null);
}

@Override
public void track(String eventName, LDUser user, JsonElement data) {
if (isOffline()) {
return;
}
if (user == null || user.getKey() == null) {
logger.warn("Track called with null user or null user key!");
} else {
eventProcessor.sendEvent(EventFactory.DEFAULT.newCustomEvent(eventName, user, data));
eventProcessor.sendEvent(EventFactory.DEFAULT.newCustomEvent(eventName, user, data, null));
}
}

@Override
public void track(String eventName, LDUser user) {
if (isOffline()) {
return;
public void track(String eventName, LDUser user, JsonElement data, double metricValue) {
if (user == null || user.getKey() == null) {
logger.warn("Track called with null user or null user key!");
} else {
eventProcessor.sendEvent(EventFactory.DEFAULT.newCustomEvent(eventName, user, data, metricValue));
}
track(eventName, user, null);
}

@Override
Expand Down
33 changes: 28 additions & 5 deletions src/main/java/com/launchdarkly/client/LDClientInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,35 @@ public interface LDClientInterface extends Closeable {
*
* @param eventName the name of the event
* @param user the user that performed the event
* @param data a JSON object containing additional data associated with the event
*/
void track(String eventName, LDUser user, JsonElement data);
void track(String eventName, LDUser user);

/**
* Tracks that a user performed an event.
* Tracks that a user performed an event, and provides additional custom data.
*
* @param eventName the name of the event
* @param user the user that performed the event
* @param data a JSON object containing additional data associated with the event; may be null
*/
void track(String eventName, LDUser user);
void track(String eventName, LDUser user, JsonElement data);

/**
* Tracks that a user performed an event, and provides an additional numeric value for custom metrics.
* <p>
* As of this version’s release date, the LaunchDarkly service does not support the {@code metricValue}
* parameter. As a result, calling this overload of {@code track} will not yet produce any different
* behavior from calling {@link #track(String, LDUser, JsonElement)} without a {@code metricValue}.
* Refer to the <a href="https://docs.launchdarkly.com/docs/java-sdk-reference#section-track">SDK reference guide</a> for the latest status.
*
* @param eventName the name of the event
* @param user the user that performed the event
* @param data a JSON object containing additional data associated with the event; may be null
* @param metricValue a numeric value used by the LaunchDarkly experimentation feature in numeric custom
* metrics. Can be omitted if this event is used by only non-numeric metrics. This field will also be
* returned as part of the custom event for Data Export.
* @since 4.8.0
*/
void track(String eventName, LDUser user, JsonElement data, double metricValue);

/**
* Registers the user.
Expand Down Expand Up @@ -80,7 +98,9 @@ public interface LDClientInterface extends Closeable {

/**
* Calculates the integer value of a feature flag for a given user.
*
* <p>
* If the flag variation has a numeric value that is not an integer, it is rounded toward zero (truncated).
*
* @param featureKey the unique key for the feature flag
* @param user the end user requesting the flag
* @param defaultValue the default value of the flag
Expand Down Expand Up @@ -134,6 +154,9 @@ public interface LDClientInterface extends Closeable {
* Calculates the value of a feature flag for a given user, and returns an object that describes the
* way the value was determined. The {@code reason} property in the result will also be included in
* analytics events, if you are capturing detailed event data for this flag.
* <p>
* If the flag variation has a numeric value that is not an integer, it is rounded toward zero (truncated).
*
* @param featureKey the unique key for the feature flag
* @param user the end user requesting the flag
* @param defaultValue the default value of the flag
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/com/launchdarkly/client/Rule.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,36 @@
class Rule extends VariationOrRollout {
private String id;
private List<Clause> clauses;
private boolean trackEvents;

// We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation
Rule() {
super();
}

Rule(String id, List<Clause> clauses, Integer variation, Rollout rollout) {
Rule(String id, List<Clause> clauses, Integer variation, Rollout rollout, boolean trackEvents) {
super(variation, rollout);
this.id = id;
this.clauses = clauses;
this.trackEvents = trackEvents;
}

Rule(String id, List<Clause> clauses, Integer variation, Rollout rollout) {
this(id, clauses, variation, rollout, false);
}

String getId() {
return id;
}

Iterable<Clause> getClauses() {
return clauses;
}

boolean isTrackEvents() {
return trackEvents;
}

boolean matchesUser(FeatureStore store, LDUser user) {
for (Clause clause : clauses) {
if (!clause.matchesUser(store, user)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ public void nonTrackedEventsAreSummarized() throws Exception {
public void customEventIsQueuedWithUser() throws Exception {
JsonObject data = new JsonObject();
data.addProperty("thing", "stuff");
Event.Custom ce = EventFactory.DEFAULT.newCustomEvent("eventkey", user, data);
double metric = 1.5;
Event.Custom ce = EventFactory.DEFAULT.newCustomEvent("eventkey", user, data, metric);

try (MockWebServer server = makeStartedServer(eventsSuccessResponse())) {
try (DefaultEventProcessor ep = new DefaultEventProcessor(SDK_KEY, baseConfig(server).build())) {
Expand All @@ -396,7 +397,7 @@ public void customEventIsQueuedWithUser() throws Exception {
public void customEventCanContainInlineUser() throws Exception {
JsonObject data = new JsonObject();
data.addProperty("thing", "stuff");
Event.Custom ce = EventFactory.DEFAULT.newCustomEvent("eventkey", user, data);
Event.Custom ce = EventFactory.DEFAULT.newCustomEvent("eventkey", user, data, null);

try (MockWebServer server = makeStartedServer(eventsSuccessResponse())) {
LDConfig config = baseConfig(server).inlineUsersInEvents(true).build();
Expand All @@ -413,7 +414,7 @@ public void customEventCanContainInlineUser() throws Exception {
public void userIsFilteredInCustomEvent() throws Exception {
JsonObject data = new JsonObject();
data.addProperty("thing", "stuff");
Event.Custom ce = EventFactory.DEFAULT.newCustomEvent("eventkey", user, data);
Event.Custom ce = EventFactory.DEFAULT.newCustomEvent("eventkey", user, data, null);

try (MockWebServer server = makeStartedServer(eventsSuccessResponse())) {
LDConfig config = baseConfig(server).inlineUsersInEvents(true).allAttributesPrivate(true).build();
Expand Down Expand Up @@ -644,6 +645,7 @@ private Matcher<JsonElement> isFeatureEvent(Event.FeatureRequest sourceEvent, Fe
);
}

@SuppressWarnings("unchecked")
private Matcher<JsonElement> isCustomEvent(Event.Custom sourceEvent, JsonElement inlineUser) {
return allOf(
hasJsonProperty("kind", "custom"),
Expand All @@ -653,7 +655,9 @@ private Matcher<JsonElement> isCustomEvent(Event.Custom sourceEvent, JsonElement
hasJsonProperty("userKey", sourceEvent.user.getKeyAsString()),
(inlineUser != null) ? hasJsonProperty("user", inlineUser) :
hasJsonProperty("user", nullValue(JsonElement.class)),
hasJsonProperty("data", sourceEvent.data)
hasJsonProperty("data", sourceEvent.data),
(sourceEvent.metricValue == null) ? hasJsonProperty("metricValue", nullValue(JsonElement.class)) :
hasJsonProperty("metricValue", sourceEvent.metricValue.doubleValue())
);
}

Expand Down
Loading