Skip to content

Commit 1b9a948

Browse files
author
Vignesh Raja
authored
Release version 1.3.0 (#64)
2 parents 9fb24fa + 8c2479d commit 1b9a948

File tree

116 files changed

+571
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+571
-388
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,71 @@
1+
## 1.3.0
2+
3+
January 17, 2017
4+
5+
- Add `onEventTracked` listener
6+
- Change `getVariableFloat` to `getVariableDouble`
7+
- Persist experiment and variation IDs instead of keys in the `UserProfile`
8+
19
## 1.2.0
210

11+
December 15, 2016
12+
313
- Change position of `activateExperiment` parameter in the method signatures of `getVariableString`, `getVariableBoolean`, `getVariableInteger`, and `getVariableFloat`
414
- Change `UserExperimentRecord` to `UserProfile`
515
- Add support for IP anonymization
616
- Add `NotificationListener` for SDK events
717

818
## 1.1.0
919

20+
December 8, 2016
21+
1022
- Add support for live variables
1123

1224
## 1.0.3
1325

26+
November 28, 2016
27+
1428
- Remove extraneous log message in `AsyncEventHandler`
1529
- Add `jackson-annotations` as a compiled dependency
1630

1731
## 1.0.2
1832

33+
October 5, 2016
34+
1935
- Gracefully handle datafile that doesn't contain required fields
2036

2137
## 1.0.1
2238

39+
October 5, 2016
40+
2341
- Allow for configurability of `clientEngine` and `clientVersion` through `Optimizely.Builder`
2442
- Remove ppid query string from V1 events
2543

2644
## 1.0.0
2745

46+
October 3, 2016
47+
2848
- Introduce support for Full Stack projects in Optimizely X with no breaking changes from previous version
2949
- Update whitelisting to take precedence over audience condition evaluation
3050
- Introduce more graceful exception handling in instantiation and core methods
3151

3252
## 0.1.71
3353

54+
September 19, 2016
55+
3456
- Add support for v2 backend endpoint and datafile
3557

3658
## 0.1.70
3759

60+
August 29, 2016
61+
3862
- Add a `UserExperimentRecord` interface
3963
- Implementors will get a chance to save and restore activations during bucketing
4064
- Can be used to make bucketing persistent or to keep a bucketing history
4165
- Pass implementations to `Optimizely.Builder#withUserExperimentRecord(UserExperimentRecord)` when creating `Optimizely` instances
4266

4367
## 0.1.68
4468

69+
July 26, 2016
70+
4571
- Beta release of the Java SDK for server-side testing

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md).
8989

9090
## License
9191
```
92-
Copyright 2017, Optimizely
92+
Copyright 2016, Optimizely
9393
9494
Licensed under the Apache License, Version 2.0 (the "License");
9595
you may not use this file except in compliance with the License.

core-api/build.gradle

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
/*
2-
* Copyright 2017, Optimizely
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
plugins {
18-
id 'de.fuerstenau.buildconfig' version '1.1.7'
19-
}
20-
211
dependencies {
222
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
233
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: jacksonVersion
@@ -32,16 +12,10 @@ dependencies {
3212
provided group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion, optional
3313
}
3414

35-
apply plugin: 'de.fuerstenau.buildconfig'
36-
apply plugin: 'maven-publish'
37-
38-
buildConfig {
39-
appName = 'core-api'
40-
version = rootProject.version
15+
task generateVersionFile {
16+
// add the build version information into a file that'll go into the distribution
17+
ext.buildVersion = new File(projectDir, "src/main/resources/optimizely-build-version")
18+
buildVersion.text = version
4119
}
4220

43-
sourceSets {
44-
main {
45-
java.srcDir "${buildDir}/gen/buildconfig/src/main/"
46-
}
47-
}
21+
build.finalizedBy(generateVersionFile)

core-api/src/jmh/java/com/optimizely/ab/BenchmarkUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.

core-api/src/jmh/java/com/optimizely/ab/OptimizelyBenchmark.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.

core-api/src/jmh/java/com/optimizely/ab/OptimizelyBuilderBenchmark.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.

core-api/src/jmh/resources/benchmark.properties

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
#
2-
# Copyright 2017, Optimizely
3-
#
4-
# Licensed under the Apache License, Version 2.0 (the "License");
5-
# you may not use this file except in compliance with the License.
6-
# You may obtain a copy of the License at
7-
#
8-
# http://www.apache.org/licenses/LICENSE-2.0
9-
#
10-
# Unless required by applicable law or agreed to in writing, software
11-
# distributed under the License is distributed on an "AS IS" BASIS,
12-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
# See the License for the specific language governing permissions and
14-
# limitations under the License.
15-
#
16-
171
datafilePathTemplate=config/profiling-test-data-%d-experiments.json
182
activateGroupExperimentUserIdPropTemplate=activateGroupExperiment%dExperimentsUserId
193
activateGroupExperiment10ExperimentsUserId=no
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
<!--
2-
~ Copyright 2017, Optimizely
3-
~
4-
~ Licensed under the Apache License, Version 2.0 (the "License");
5-
~ you may not use this file except in compliance with the License.
6-
~ You may obtain a copy of the License at
7-
~
8-
~ http://www.apache.org/licenses/LICENSE-2.0
9-
~
10-
~ Unless required by applicable law or agreed to in writing, software
11-
~ distributed under the License is distributed on an "AS IS" BASIS,
12-
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
~ See the License for the specific language governing permissions and
14-
~ limitations under the License.
15-
-->
16-
171
<configuration>
182
<root level="warn"/>
193
</configuration>

core-api/src/main/java/com/optimizely/ab/Optimizely.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -32,6 +33,7 @@
3233
import com.optimizely.ab.error.RaiseExceptionErrorHandler;
3334
import com.optimizely.ab.event.EventHandler;
3435
import com.optimizely.ab.event.LogEvent;
36+
import com.optimizely.ab.event.internal.BuildVersionInfo;
3537
import com.optimizely.ab.event.internal.EventBuilder;
3638
import com.optimizely.ab.event.internal.EventBuilderV1;
3739
import com.optimizely.ab.event.internal.EventBuilderV2;
@@ -256,6 +258,9 @@ private void track(@Nonnull String eventName,
256258
} catch (Exception e) {
257259
logger.error("Unexpected exception in event dispatcher", e);
258260
}
261+
262+
notificationBroadcaster.broadcastEventTracked(eventName, userId, attributes, eventValue,
263+
conversionEvent);
259264
}
260265

261266
//======== live variable getters ========//
@@ -350,24 +355,24 @@ private void track(@Nonnull String eventName,
350355
return null;
351356
}
352357

353-
public @Nullable Float getVariableFloat(@Nonnull String variableKey,
354-
@Nonnull String userId,
355-
boolean activateExperiment) throws UnknownLiveVariableException {
356-
return getVariableFloat(variableKey, userId, Collections.<String, String>emptyMap(), activateExperiment);
358+
public @Nullable Double getVariableDouble(@Nonnull String variableKey,
359+
@Nonnull String userId,
360+
boolean activateExperiment) throws UnknownLiveVariableException {
361+
return getVariableDouble(variableKey, userId, Collections.<String, String>emptyMap(), activateExperiment);
357362
}
358363

359-
public @Nullable Float getVariableFloat(@Nonnull String variableKey,
360-
@Nonnull String userId,
361-
@Nonnull Map<String, String> attributes,
362-
boolean activateExperiment)
364+
public @Nullable Double getVariableDouble(@Nonnull String variableKey,
365+
@Nonnull String userId,
366+
@Nonnull Map<String, String> attributes,
367+
boolean activateExperiment)
363368
throws UnknownLiveVariableException {
364369

365370
String variableValueString = getVariableString(variableKey, userId, attributes, activateExperiment);
366371
if (variableValueString != null) {
367372
try {
368-
return Float.parseFloat(variableValueString);
373+
return Double.parseDouble(variableValueString);
369374
} catch (NumberFormatException e) {
370-
logger.error("Variable value \"{}\" for live variable \"{}\" is not a float.", variableValueString,
375+
logger.error("Variable value \"{}\" for live variable \"{}\" is not a double.", variableValueString,
371376
variableKey);
372377
}
373378
}
@@ -691,7 +696,7 @@ public Optimizely build() throws ConfigParseException {
691696
}
692697

693698
if (clientVersion == null) {
694-
clientVersion = BuildConfig.VERSION;
699+
clientVersion = BuildVersionInfo.VERSION;
695700
}
696701

697702
if (eventBuilder == null) {

core-api/src/main/java/com/optimizely/ab/OptimizelyRuntimeException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.

core-api/src/main/java/com/optimizely/ab/UnknownEventTypeException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.

core-api/src/main/java/com/optimizely/ab/UnknownExperimentException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.

core-api/src/main/java/com/optimizely/ab/UnknownLiveVariableException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.

core-api/src/main/java/com/optimizely/ab/annotations/VisibleForTesting.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.

core-api/src/main/java/com/optimizely/ab/bucketing/Bucketer.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/*
2-
* Copyright 2017, Optimizely
1+
/**
2+
*
3+
* Copyright 2016, Optimizely and contributors
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -113,17 +114,18 @@ private Variation bucketToVariation(@Nonnull Experiment experiment,
113114

114115
// If a user profile instance is present then check it for a saved variation
115116
if (userProfile != null) {
116-
String variationKey = userProfile.lookup(userId, experimentKey);
117-
if (variationKey != null) {
117+
String variationId = userProfile.lookup(userId, experimentId);
118+
if (variationId != null) {
119+
Variation savedVariation = projectConfig
120+
.getExperimentIdMapping()
121+
.get(experimentId)
122+
.getVariationIdToVariationMap()
123+
.get(variationId);
118124
logger.info("Returning previously activated variation \"{}\" of experiment \"{}\" "
119125
+ "for user \"{}\" from user profile.",
120-
variationKey, experimentKey, userId);
126+
savedVariation.getKey(), experimentKey, userId);
121127
// A variation is stored for this combined bucket id
122-
return projectConfig
123-
.getExperimentIdMapping()
124-
.get(experimentId)
125-
.getVariationKeyToVariationMap()
126-
.get(variationKey);
128+
return savedVariation;
127129
} else {
128130
logger.info("No previously activated variation of experiment \"{}\" "
129131
+ "for user \"{}\" found in user profile.",
@@ -141,18 +143,18 @@ private Variation bucketToVariation(@Nonnull Experiment experiment,
141143
if (bucketedVariationId != null) {
142144
Variation bucketedVariation = experiment.getVariationIdToVariationMap().get(bucketedVariationId);
143145
String variationKey = bucketedVariation.getKey();
144-
logger.info("User \"{}\" is in variation \"{}\" of experiment \"{}\".", userId, variationKey,
146+
logger.info("User \"{}\" is in variation \"{}\" of experiment \"{}\".", userId, variationKey,
145147
experimentKey);
146148

147149
// If a user profile is present give it a variation to store
148150
if (userProfile != null) {
149-
boolean saved = userProfile.save(userId, experiment.getKey(), variationKey);
151+
boolean saved = userProfile.save(userId, experimentId, bucketedVariationId);
150152
if (saved) {
151153
logger.info("Saved variation \"{}\" of experiment \"{}\" for user \"{}\".",
152-
variationKey, experimentKey, userId);
154+
bucketedVariationId, experimentId, userId);
153155
} else {
154156
logger.warn("Failed to save variation \"{}\" of experiment \"{}\" for user \"{}\".",
155-
variationKey, experimentKey, userId);
157+
bucketedVariationId, experimentId, userId);
156158
}
157159
}
158160

@@ -236,10 +238,10 @@ public void cleanUserProfiles() {
236238
Map<String, Map<String,String>> records = userProfile.getAllRecords();
237239
if (records != null) {
238240
for (Map.Entry<String,Map<String,String>> record : records.entrySet()) {
239-
for (String experimentKey : record.getValue().keySet()) {
240-
Experiment experiment = projectConfig.getExperimentKeyMapping().get(experimentKey);
241+
for (String experimentId : record.getValue().keySet()) {
242+
Experiment experiment = projectConfig.getExperimentIdMapping().get(experimentId);
241243
if (experiment == null || !experiment.isRunning()) {
242-
userProfile.remove(record.getKey(), experimentKey);
244+
userProfile.remove(record.getKey(), experimentId);
243245
}
244246
}
245247
}

0 commit comments

Comments
 (0)