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

fix(ats): add proguard rule for ODPEvent #456

Merged
merged 3 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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")
}
}
}

}