Skip to content

Commit 97068a6

Browse files
feat(flags): add unleash to provider dropdowns and onboarding
1 parent 1b28d1d commit 97068a6

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

static/app/components/events/featureFlags/onboardingIntegrationSection.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import {
99
import {hasEveryAccess} from 'sentry/components/acl/access';
1010
import Alert from 'sentry/components/alert';
1111
import {Button} from 'sentry/components/button';
12-
import {PROVIDER_OPTION_TO_URLS} from 'sentry/components/events/featureFlags/utils';
12+
import {
13+
PROVIDER_OPTION_TO_URLS,
14+
ProviderOptions,
15+
} from 'sentry/components/events/featureFlags/utils';
1316
import Input from 'sentry/components/input';
1417
import ExternalLink from 'sentry/components/links/externalLink';
1518
import TextCopyInput from 'sentry/components/textCopyInput';
@@ -114,9 +117,13 @@ export default function OnboardingIntegrationSection({
114117
</SubSection>
115118
<SubSection>
116119
<div>
117-
{t(
118-
"During the process of creating a webhook integration, you'll be given the option to sign the webhook. This is an auto-generated secret code that Sentry requires to verify requests from your feature flag service. Paste the secret below."
119-
)}
120+
{provider === ProviderOptions.UNLEASH
121+
? t(
122+
`During the process of creating a webhook integration, you'll be given the option to add an authorization header. This is a string (or "secret") that you choose so that Sentry can verify requests from your feature flag service. Paste your authorization string below.`
123+
)
124+
: t(
125+
"During the process of creating a webhook integration, you'll be given the option to sign the webhook. This is an auto-generated secret code that Sentry requires to verify requests from your feature flag service. Paste the secret below."
126+
)}
120127
</div>
121128
<InputTitle>{t('Secret')}</InputTitle>
122129
<InputArea>

static/app/components/events/featureFlags/utils.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,19 @@ export const sortedFlags = ({
116116
export enum ProviderOptions {
117117
LAUNCHDARKLY = 'LaunchDarkly',
118118
GENERIC = 'Generic',
119+
UNLEASH = 'Unleash',
119120
}
120121

121122
export enum IntegrationOptions {
122123
LAUNCHDARKLY = 'LaunchDarkly',
123124
OPENFEATURE = 'OpenFeature',
124125
GENERIC = 'Generic',
126+
UNLEASH = 'Unleash',
125127
}
126128

127-
export const PROVIDER_OPTION_TO_URLS: Record<ProviderOptions, string | undefined> = {
129+
export const PROVIDER_OPTION_TO_URLS: Record<ProviderOptions, string> = {
128130
[ProviderOptions.LAUNCHDARKLY]:
129131
'https://app.launchdarkly.com/settings/integrations/webhooks/new?q=Webhooks',
130132
[ProviderOptions.GENERIC]: 'DOCS LINK TODO',
133+
[ProviderOptions.UNLEASH]: 'DOCS LINK TODO',
131134
};

static/app/gettingStartedDocs/javascript/javascript.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ client.addHooks(new Sentry.OpenFeatureIntegrationHook());
9393
// Evaluating flags will record the result on the Sentry client.
9494
const result = client.getBooleanValue('my-flag', false);`,
9595
},
96+
[IntegrationOptions.UNLEASH]: {
97+
importStatement: `TODO`,
98+
integration: 'TODO',
99+
sdkInit: `TODO`,
100+
},
96101
[IntegrationOptions.GENERIC]: {
97102
importStatement: ``,
98103
integration: 'featureFlagsIntegration()',

static/app/gettingStartedDocs/python/python.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const FLAG_OPTION_TO_IMPORT: Record<IntegrationOptions, FlagImports> = {
3131
module: 'openfeature',
3232
integration: 'OpenFeatureIntegration',
3333
},
34+
[IntegrationOptions.UNLEASH]: {
35+
module: 'unleash',
36+
integration: 'UnleashIntegration',
37+
},
3438
[IntegrationOptions.GENERIC]: {
3539
module: 'featureflags',
3640
integration: 'FeatureFlagsIntegration',
@@ -263,13 +267,34 @@ export const featureFlagOnboarding: OnboardingConfig = {
263267
code: `
264268
import sentry-sdk
265269
from sentry_sdk.integrations.${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].module} import ${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].integration}
270+
${
271+
featureFlagOptions.integration === IntegrationOptions.UNLEASH
272+
? `from UnleashClient import UnleashClient
273+
274+
unleash_client = UnleashClient(
275+
url="<Unleash server URL>/api/", # "http://localhost:4242/api/" if you are self-hosting Unleash.
276+
app_name="my-app", # Identifies your app in the Unleash UI.
277+
custom_headers={
278+
# See https://docs.getunleash.io/how-to/how-to-create-api-tokens
279+
"Authorization": os.environ["UNLEASH_CLIENT_API_TOKEN"]
280+
}
281+
)
282+
283+
unleash_integration = UnleashIntegration(unleash_client)
266284
285+
sentry_sdk.init(
286+
dsn="${dsn.public}",
287+
integrations=[unleash_integration],
288+
)`
289+
: `
267290
sentry_sdk.init(
268291
dsn="${dsn.public}",
269292
integrations=[
270293
${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].integration}(),
271294
]
272-
)`,
295+
)`
296+
}
297+
`,
273298
},
274299
],
275300
},

static/app/views/settings/featureFlags/newProviderForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export default function NewProviderForm({
118118
name="provider"
119119
options={[
120120
{value: 'LaunchDarkly', label: 'LaunchDarkly'},
121+
{value: 'Unleash', label: 'Unleash'},
121122
{value: 'Generic', label: 'Custom'},
122123
]}
123124
help={t(

0 commit comments

Comments
 (0)