Skip to content

Commit 2a06e6f

Browse files
committed
add launchdarkly
1 parent 5785050 commit 2a06e6f

File tree

7 files changed

+278
-0
lines changed

7 files changed

+278
-0
lines changed

docs/organization/integrations/feature-flag/launchdarkly/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Sentry can track flag evaluations as they happen within your application. Flag
1313
To set up evaluation tracking, visit one of our supported languages pages:
1414
* [JavaScript](/platforms/javascript/configuration/integrations/launchdarkly/)
1515
* [Python](/platforms/python/integrations/feature-flags/launchdarkly/)
16+
* [Android](/platforms/android/integrations/launchdarkly/)
17+
* [Java](/platforms/java/integrations/launchdarkly/)
1618

1719
## Change Tracking
1820

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Set Up Feature Flags
3+
sidebar_title: Feature Flags
4+
sidebar_order: 7000
5+
description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log of feature flag changes, and reports any suspicious updates that may have caused an error.
6+
---
7+
8+
## Prerequisites
9+
10+
* You have the <PlatformLink to="/">Android SDK installed</PlatformLink>.
11+
12+
## Enable Evaluation Tracking
13+
14+
<PlatformContent includePath="feature-flags/evaluation-tracking-index" />
15+
16+
## Enable Change Tracking
17+
18+
<PlatformContent includePath="feature-flags/change-tracking-index" />
19+
20+
21+
22+
23+
24+
25+
26+
27+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: LaunchDarkly
3+
description: "Learn how to use Sentry with LaunchDarkly."
4+
---
5+
6+
The [LaunchDarkly](https://launchdarkly.com/) integration tracks feature flag evaluations produced by the LaunchDarkly SDK. These evaluations are held in memory and are sent to Sentry on error and transaction events. **At the moment, we only support boolean flag evaluations.**
7+
8+
## Install
9+
10+
To install use:
11+
12+
```groovy {tabTitle:Gradle}
13+
implementation 'io.sentry:sentry-launchdarkly-android:{{@inject packages.version('sentry.java.launchdarkly.android', '8.27.0') }}'
14+
```
15+
16+
For other dependency managers, check out the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-launchdarkly-android).
17+
18+
Before using this integration, you need to install and instrument the [LaunchDarkly Android SDK](https://docs.launchdarkly.com/sdk/client-side/android) in your app.
19+
20+
## Configure
21+
22+
Add `SentryLaunchDarklyAndroidHook` to your LaunchDarkly setup:
23+
24+
```java {6}
25+
import io.sentry.launchdarkly.android.SentryLaunchDarklyAndroidHook;
26+
27+
LDConfig config = new LDConfig.Builder(LDConfig.Builder.AutoEnvAttributes.Enabled)
28+
.mobileKey("mobile-key")
29+
.hooks(Components.hooks()
30+
.setHooks(Arrays.asList(new SentryLaunchDarklyAndroidHook())))
31+
.build();
32+
LDContext context = LDContext.create("context-key-123abc");
33+
LDClient client = LDClient.init(this.getApplication(), config, context, 0);
34+
```
35+
36+
```kotlin {6}
37+
import io.sentry.launchdarkly.android.SentryLaunchDarklyAndroidHook;
38+
39+
val config: LDConfig = LDConfig.Builder(LDConfig.Builder.AutoEnvAttributes.Enabled)
40+
.mobileKey("mobile-key")
41+
.hooks(Components.hooks()
42+
.setHooks(listOf(SentryLaunchDarklyAndroidHook())))
43+
.build()
44+
val context: LDContext = LDContext.create("context-key-123abc")
45+
val client: LDClient = LDClient.init(this.application, config, context, 0)
46+
```
47+
48+
## Verify
49+
50+
The integration is tested by evaluating a feature flag using your LaunchDarkly SDK before capturing an exception.
51+
52+
```java
53+
import com.launchdarkly.sdk.LDContext;
54+
import io.sentry.Sentry;
55+
56+
LDContext context = LDContext.create("example-context-key");
57+
58+
boolean flagValue = client.boolVariation("test-flag", false);
59+
60+
Sentry.captureException(new Exception("Something went wrong!"));
61+
```
62+
63+
```kotlin
64+
import com.launchdarkly.sdk.LDContext
65+
import io.sentry.Sentry
66+
67+
val context: LDContext = LDContext.create("example-context-key")
68+
69+
val flagValue: Boolean = client.boolVariation("test-flag", false)
70+
71+
Sentry.captureException(Exception("Something went wrong!"))
72+
```
73+
74+
Visit the Sentry website and confirm that your error event has recorded the feature flag "test-flag" and its value "false".
75+
76+
<PlatformContent includePath="feature-flags/next-steps" />
77+
78+
79+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Set Up Feature Flags
3+
sidebar_title: Feature Flags
4+
sidebar_order: 7000
5+
description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log of feature flag changes, and reports any suspicious updates that may have caused an error.
6+
---
7+
8+
## Prerequisites
9+
10+
* You have the <PlatformLink to="/">Java SDK installed</PlatformLink>.
11+
12+
## Enable Evaluation Tracking
13+
14+
<PlatformContent includePath="feature-flags/evaluation-tracking-index" />
15+
16+
## Enable Change Tracking
17+
18+
<PlatformContent includePath="feature-flags/change-tracking-index" />
19+
20+
21+
22+
23+
24+
25+
26+
27+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: LaunchDarkly
3+
description: "Learn how to use Sentry with LaunchDarkly."
4+
---
5+
6+
The [LaunchDarkly](https://launchdarkly.com/) integration tracks feature flag evaluations produced by the LaunchDarkly SDK. These evaluations are held in memory and are sent to Sentry on error and transaction events. **At the moment, we only support boolean flag evaluations.**
7+
8+
## Install
9+
10+
To install use:
11+
12+
```groovy {tabTitle:Gradle}
13+
implementation 'io.sentry:sentry-launchdarkly-server:{{@inject packages.version('sentry.java.launchdarkly.server', '8.27.0') }}'
14+
```
15+
16+
```xml {tabTitle:Maven}
17+
<dependency>
18+
<groupId>io.sentry</groupId>
19+
<artifactId>sentry-launchdarkly-server</artifactId>
20+
<version>{{@inject packages.version('sentry.java.launchdarkly.server', '8.27.0') }}</version>
21+
</dependency>
22+
```
23+
24+
```scala {tabTitle: SBT}
25+
libraryDependencies += "io.sentry" % "sentry-launchdarkly-server" % "{{@inject packages.version('sentry.java.launchdarkly.server', '8.27.0') }}"
26+
```
27+
28+
For other dependency managers, check out the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-launchdarkly-server).
29+
30+
Before using this integration, you need to install and instrument the [LaunchDarkly Java SDK](https://docs.launchdarkly.com/sdk/server-side/java) in your app.
31+
32+
## Configure
33+
34+
Add `SentryLaunchDarklyServerHook` to your LaunchDarkly setup:
35+
36+
```java {5}
37+
import io.sentry.launchdarkly.server.SentryLaunchDarklyServerHook;
38+
39+
LDConfig config = new LDConfig.Builder()
40+
.hooks(Components.hooks()
41+
.setHooks(Arrays.asList(new SentryLaunchDarklyServerHook())))
42+
.build();
43+
LDClient client = new LDClient("sdk-key", config);
44+
```
45+
46+
```kotlin {5}
47+
import io.sentry.launchdarkly.server.SentryLaunchDarklyServerHook
48+
49+
val config: LDConfig = LDConfig.Builder()
50+
.hooks(Components.hooks()
51+
.setHooks(listOf(SentryLaunchDarklyServerHook())))
52+
.build()
53+
val client: LDClient = LDClient("sdk-key", config)
54+
```
55+
56+
## Verify
57+
58+
The integration is tested by evaluating a feature flag using your LaunchDarkly SDK before capturing an exception.
59+
60+
```java
61+
import com.launchdarkly.sdk.LDContext;
62+
import io.sentry.Sentry;
63+
64+
LDContext context = LDContext.create("example-context-key");
65+
66+
boolean flagValue = client.boolVariation("test-flag", context, false);
67+
68+
Sentry.captureException(new Exception("Something went wrong!"));
69+
```
70+
71+
```kotlin
72+
import com.launchdarkly.sdk.LDContext
73+
import io.sentry.Sentry
74+
75+
val context: LDContext = LDContext.create("example-context-key")
76+
77+
val flagValue: Boolean = client.boolVariation("test-flag", context, false)
78+
79+
Sentry.captureException(Exception("Something went wrong!"))
80+
```
81+
82+
Visit the Sentry website and confirm that your error event has recorded the feature flag "test-flag" and its value "false".
83+
84+
<PlatformContent includePath="feature-flags/next-steps" />
85+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
If you use a third-party SDK to evaluate feature flags, you can enable a Sentry SDK integration to track those evaluations. Integrations are provider specific. Documentation for supported SDKs is listed below.
2+
3+
- [LaunchDarkly](/platforms/android/integrations/launchdarkly/)
4+
5+
### Generic API
6+
If you use an unsupported solution, you can use the generic API to manually track feature flag evaluations. These evaluations are held in memory and are sent to Sentry on error and transaction events. **At the moment, we only support boolean flag evaluations.**
7+
8+
```java
9+
import io.sentry.Sentry;
10+
11+
Sentry.addBreadcrumb(new Breadcrumb().setMessage("Feature flag evaluated"));
12+
Sentry.getCurrentScope().setTag("feature_flag.test-flag", "false");
13+
14+
Sentry.captureException(new Exception("Something went wrong!"));
15+
```
16+
17+
```kotlin
18+
import io.sentry.Sentry
19+
20+
Sentry.addBreadcrumb(Breadcrumb().apply { message = "Feature flag evaluated" })
21+
Sentry.getCurrentScope().setTag("feature_flag.test-flag", "false")
22+
23+
Sentry.captureException(Exception("Something went wrong!"))
24+
```
25+
26+
Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false".
27+
28+
29+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
If you use a third-party SDK to evaluate feature flags, you can enable a Sentry SDK integration to track those evaluations. Integrations are provider specific. Documentation for supported SDKs is listed below.
2+
3+
- [LaunchDarkly](/platforms/java/integrations/launchdarkly/)
4+
5+
### Generic API
6+
If you use an unsupported solution, you can use the generic API to manually track feature flag evaluations. These evaluations are held in memory and are sent to Sentry on error and transaction events. **At the moment, we only support boolean flag evaluations.**
7+
8+
```java
9+
import io.sentry.Sentry;
10+
11+
Sentry.addBreadcrumb(new Breadcrumb().setMessage("Feature flag evaluated"));
12+
Sentry.getCurrentScope().setTag("feature_flag.test-flag", "false");
13+
14+
Sentry.captureException(new Exception("Something went wrong!"));
15+
```
16+
17+
```kotlin
18+
import io.sentry.Sentry
19+
20+
Sentry.addBreadcrumb(Breadcrumb().apply { message = "Feature flag evaluated" })
21+
Sentry.getCurrentScope().setTag("feature_flag.test-flag", "false")
22+
23+
Sentry.captureException(Exception("Something went wrong!"))
24+
```
25+
26+
Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false".
27+
28+
29+

0 commit comments

Comments
 (0)