Skip to content

Commit

Permalink
fix(ats): add proguard rule for ODPEvent (#456)
Browse files Browse the repository at this point in the history
* add proguard rule for ODPEvent

* clean up

* clean up
  • Loading branch information
jaeopt authored May 8, 2023
1 parent 7b74992 commit c66a3d4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
2 changes: 2 additions & 0 deletions proguard-rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
-keepclassmembers class com.optimizely.ab.config.** {
*;
}
# Keep Payload classes that get sent to the ODP server
-keep class com.optimizely.ab.odp.ODPEvent { *; }

# Keep Payload classes that get sent to Optimizely's backend
-keep class com.optimizely.ab.event.internal.payload.** { *; }
Expand Down
6 changes: 6 additions & 0 deletions test-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ android {
unitTests.returnDefaultValues = true
}
buildTypes {
debug {
// enable proguard for debug mode (keep both of these to detect issues while testing)
minifyEnabled true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright 2016-2021, Optimizely, Inc. and contributors *
* Copyright 2016-2021, 2023 Optimizely, Inc. and contributors *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright 2020, 2022, Optimizely, Inc. and contributors *
* Copyright 2020, 2022-2023, Optimizely, Inc. and contributors *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
Expand Down Expand Up @@ -90,9 +90,9 @@ static public void samplesAll(Context context) {
samplesForDoc_NotificatonListener(context);
samplesForDoc_OlderVersions(context);
samplesForDoc_ForcedDecision(context);
samplesForDoc_ODP(context);
}


static public void samplesForDecide(Context context) {
// this default-options will be applied to all following decide calls.
List<OptimizelyDecideOption> defaultDecideOptions = Arrays.asList(OptimizelyDecideOption.DISABLE_DECISION_EVENT);
Expand Down Expand Up @@ -859,4 +859,16 @@ static public void samplesForDoc_ForcedDecision(Context context) {
success = user.removeAllForcedDecisions();
}

}
static public void samplesForDoc_ODP(Context context) {
OptimizelyManager optimizelyManager = OptimizelyManager.builder().withSDKKey("VivZyCGPHY369D4z8T9yG").build(context);
optimizelyManager.initialize(context, null, (OptimizelyClient client) -> {
OptimizelyUserContext userContext = client.createUserContext("user_123");
userContext.fetchQualifiedSegments((status) -> {
Log.d("Optimizely", "[ODP] segments = " + userContext.getQualifiedSegments());
OptimizelyDecision optDecision = userContext.decide("odp-flag-1");
Log.d("Optimizely", "[ODP] decision = " + optDecision.toString());
});
});
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright 2022, Optimizely, Inc. and contributors *
* Copyright 2022-2023, Optimizely, Inc. and contributors *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
Expand Down Expand Up @@ -76,6 +76,7 @@ object APISamplesInKotlin {
samplesForDoc_NotificatonListener(context)
samplesForDoc_OlderVersions(context)
samplesForDoc_ForcedDecision(context)
samplesForDoc_ODP(context)
}

fun samplesForDecide(context: Context) {
Expand Down Expand Up @@ -828,6 +829,19 @@ object APISamplesInKotlin {
success = user.removeAllForcedDecisions()
}

fun samplesForDoc_ODP(context: Context?) {
val optimizelyManager =
OptimizelyManager.builder().withSDKKey("VivZyCGPHY369D4z8T9yG").build(context)
optimizelyManager.initialize(context!!, null) { client: OptimizelyClient ->
val userContext = client.createUserContext("user_123")
userContext!!.fetchQualifiedSegments { status: Boolean? ->
Log.d("Optimizely", "[ODP] segments = " + userContext.qualifiedSegments)
val optDecision = userContext.decide("odp-flag-1")
Log.d("Optimizely", "[ODP] decision = $optDecision")
}
}
}

}


0 comments on commit c66a3d4

Please sign in to comment.