-
-
Notifications
You must be signed in to change notification settings - Fork 461
feat(flags): Implement LaunchDarkly Integrations #4917
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
Merged
+823
−0
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
134996c
Implement OpenFeature Integration
adinauer 92753c7
use evaluation context
adinauer 1efe8bd
Format code
getsentry-bot 9b9b025
add missing mentions
adinauer 58f4219
api; register as integration and package
adinauer 509c675
changelog
adinauer 33023d2
Merge branch 'main' into feat/openfeature-integration
adinauer 1d8442a
replace hard coded dependency
adinauer c6720ef
Add launchdarkly integrations
adinauer fbc578c
Merge branch 'main' into feat/launchdarkly
adinauer da4f526
changelog
adinauer 6189f26
issue templates and readme
adinauer 290a79d
remove comments from build gradle files
adinauer 7c626d7
convert to java
adinauer 43721c2
Merge branch 'main' into feat/launchdarkly
adinauer 6f4d088
remove kotlin from build.gradle
adinauer 6f2d7b0
add tests
adinauer bb5a023
Format code
getsentry-bot 0874d7a
Merge branch 'main' into feat/launchdarkly
adinauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
sentry-launchdarkly-android/api/sentry-launchdarkly-android.api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| public final class io/sentry/launchdarkly/android/BuildConfig { | ||
| public static final field BUILD_TYPE Ljava/lang/String; | ||
| public static final field DEBUG Z | ||
| public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String; | ||
| public static final field SENTRY_LAUNCHDARKLY_ANDROID_SDK_NAME Ljava/lang/String; | ||
| public static final field VERSION_NAME Ljava/lang/String; | ||
| public fun <init> ()V | ||
| } | ||
|
|
||
| public final class io/sentry/launchdarkly/android/SentryLaunchDarklyAndroidHook : com/launchdarkly/sdk/android/integrations/Hook { | ||
| public fun <init> ()V | ||
| public fun <init> (Lio/sentry/IScopes;)V | ||
| public fun afterEvaluation (Lcom/launchdarkly/sdk/android/integrations/EvaluationSeriesContext;Ljava/util/Map;Lcom/launchdarkly/sdk/EvaluationDetail;)Ljava/util/Map; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| plugins { | ||
| id("com.android.library") | ||
| alias(libs.plugins.kotlin.android) | ||
| jacoco | ||
| alias(libs.plugins.jacoco.android) | ||
| alias(libs.plugins.gradle.versions) | ||
| } | ||
|
|
||
| android { | ||
| compileSdk = libs.versions.compileSdk.get().toInt() | ||
| namespace = "io.sentry.launchdarkly.android" | ||
|
|
||
| defaultConfig { | ||
| minSdk = libs.versions.minSdk.get().toInt() | ||
|
|
||
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
|
|
||
| // for AGP 4.1 | ||
| buildConfigField("String", "VERSION_NAME", "\"${project.version}\"") | ||
| buildConfigField( | ||
| "String", | ||
| "SENTRY_LAUNCHDARKLY_ANDROID_SDK_NAME", | ||
| "\"${Config.Sentry.SENTRY_LAUNCHDARKLY_ANDROID_SDK_NAME}\"", | ||
| ) | ||
| } | ||
|
|
||
| buildTypes { | ||
| getByName("debug") { consumerProguardFiles("proguard-rules.pro") } | ||
| getByName("release") { consumerProguardFiles("proguard-rules.pro") } | ||
| } | ||
|
|
||
| kotlin { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 } | ||
|
|
||
| testOptions { | ||
| animationsDisabled = true | ||
| unitTests.apply { | ||
| isReturnDefaultValues = true | ||
| isIncludeAndroidResources = true | ||
| } | ||
| } | ||
|
|
||
| lint { | ||
| warningsAsErrors = true | ||
| checkDependencies = true | ||
|
|
||
| // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks. | ||
| checkReleaseBuilds = false | ||
| } | ||
|
|
||
| buildFeatures { buildConfig = true } | ||
|
|
||
| androidComponents.beforeVariants { | ||
| it.enable = !Config.Android.shouldSkipDebugVariant(it.buildType) | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| api(projects.sentry) | ||
|
|
||
| compileOnly(libs.launchdarkly.android) | ||
| compileOnly(libs.jetbrains.annotations) | ||
|
|
||
| // tests | ||
| testImplementation(projects.sentry) | ||
| testImplementation(projects.sentryTestSupport) | ||
| testImplementation(kotlin(Config.kotlinStdLib, Config.kotlinStdLibVersionAndroid)) | ||
| testImplementation(libs.androidx.test.ext.junit) | ||
| testImplementation(libs.kotlin.test.junit) | ||
| testImplementation(libs.mockito.kotlin) | ||
| testImplementation(libs.mockito.inline) | ||
| testImplementation(libs.launchdarkly.android) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ##---------------Begin: proguard configuration for LaunchDarkly Android ---------- | ||
|
|
||
| # To ensure that stack traces is unambiguous | ||
| # https://developer.android.com/studio/build/shrink-code#decode-stack-trace | ||
| -keepattributes LineNumberTable,SourceFile | ||
|
|
||
| ##---------------End: proguard configuration for LaunchDarkly Android ---------- | ||
|
|
||
|
|
70 changes: 70 additions & 0 deletions
70
...y-android/src/main/java/io/sentry/launchdarkly/android/SentryLaunchDarklyAndroidHook.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package io.sentry.launchdarkly.android; | ||
|
|
||
| import com.launchdarkly.sdk.EvaluationDetail; | ||
| import com.launchdarkly.sdk.LDValue; | ||
| import com.launchdarkly.sdk.LDValueType; | ||
| import com.launchdarkly.sdk.android.integrations.EvaluationSeriesContext; | ||
| import com.launchdarkly.sdk.android.integrations.Hook; | ||
| import io.sentry.IScopes; | ||
| import io.sentry.ScopesAdapter; | ||
| import io.sentry.SentryIntegrationPackageStorage; | ||
| import io.sentry.SentryLevel; | ||
| import io.sentry.util.IntegrationUtils; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| public final class SentryLaunchDarklyAndroidHook extends Hook { | ||
| private final IScopes scopes; | ||
|
|
||
| static { | ||
| SentryIntegrationPackageStorage.getInstance() | ||
| .addPackage("maven:io.sentry:sentry-launchdarkly-android", BuildConfig.VERSION_NAME); | ||
| } | ||
|
|
||
| public SentryLaunchDarklyAndroidHook() { | ||
| this(ScopesAdapter.getInstance()); | ||
| } | ||
|
|
||
| public SentryLaunchDarklyAndroidHook(final @NotNull IScopes scopes) { | ||
| super("SentryLaunchDarklyAndroidHook"); | ||
| this.scopes = Objects.requireNonNull(scopes, "Scopes are required"); | ||
| addPackageAndIntegrationInfo(); | ||
| } | ||
|
|
||
| private void addPackageAndIntegrationInfo() { | ||
| IntegrationUtils.addIntegrationToSdkVersion("LaunchDarkly-Android"); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String, Object> afterEvaluation( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is a public method anyway, we could write a test which mimics the |
||
| final EvaluationSeriesContext seriesContext, | ||
| final Map<String, Object> seriesData, | ||
| final EvaluationDetail<LDValue> evaluationDetail) { | ||
| if (evaluationDetail == null || seriesContext == null) { | ||
| return seriesData; | ||
| } | ||
|
|
||
| try { | ||
| final @Nullable String flagKey = seriesContext.flagKey; | ||
| final @Nullable LDValue value = evaluationDetail.getValue(); | ||
|
|
||
| if (flagKey == null || value == null) { | ||
| return seriesData; | ||
| } | ||
|
|
||
| if (LDValueType.BOOLEAN.equals(value.getType())) { | ||
| final boolean flagValue = value.booleanValue(); | ||
| scopes.addFeatureFlag(flagKey, flagValue); | ||
| } | ||
| } catch (final Exception e) { | ||
| scopes | ||
| .getOptions() | ||
| .getLogger() | ||
| .log(SentryLevel.ERROR, "Failed to capture feature flag evaluation", e); | ||
| } | ||
|
|
||
| return seriesData; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.