Skip to content

Commit

Permalink
feat(flags): add unleash to provider dropdowns and onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
michellewzhang committed Jan 2, 2025
1 parent 1b28d1d commit de8fcb3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
import {hasEveryAccess} from 'sentry/components/acl/access';
import Alert from 'sentry/components/alert';
import {Button} from 'sentry/components/button';
import {PROVIDER_OPTION_TO_URLS} from 'sentry/components/events/featureFlags/utils';
import {
PROVIDER_OPTION_TO_URLS,
ProviderOptions,
} from 'sentry/components/events/featureFlags/utils';
import Input from 'sentry/components/input';
import ExternalLink from 'sentry/components/links/externalLink';
import TextCopyInput from 'sentry/components/textCopyInput';
Expand Down Expand Up @@ -114,9 +117,13 @@ export default function OnboardingIntegrationSection({
</SubSection>
<SubSection>
<div>
{t(
"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."
)}
{provider === ProviderOptions.UNLEASH
? t(
`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.`
)
: t(
"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."
)}
</div>
<InputTitle>{t('Secret')}</InputTitle>
<InputArea>
Expand Down
5 changes: 4 additions & 1 deletion static/app/components/events/featureFlags/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,19 @@ export const sortedFlags = ({
export enum ProviderOptions {
LAUNCHDARKLY = 'LaunchDarkly',
GENERIC = 'Generic',
UNLEASH = 'Unleash',
}

export enum IntegrationOptions {
LAUNCHDARKLY = 'LaunchDarkly',
OPENFEATURE = 'OpenFeature',
GENERIC = 'Generic',
UNLEASH = 'Unleash',
}

export const PROVIDER_OPTION_TO_URLS: Record<ProviderOptions, string | undefined> = {
export const PROVIDER_OPTION_TO_URLS: Record<ProviderOptions, string> = {
[ProviderOptions.LAUNCHDARKLY]:
'https://app.launchdarkly.com/settings/integrations/webhooks/new?q=Webhooks',
[ProviderOptions.GENERIC]: 'DOCS LINK TODO',
[ProviderOptions.UNLEASH]: 'DOCS LINK TODO',
};
5 changes: 5 additions & 0 deletions static/app/gettingStartedDocs/javascript/javascript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ client.addHooks(new Sentry.OpenFeatureIntegrationHook());
// Evaluating flags will record the result on the Sentry client.
const result = client.getBooleanValue('my-flag', false);`,
},
[IntegrationOptions.UNLEASH]: {
importStatement: `TODO`,
integration: 'TODO',
sdkInit: `TODO`,
},
[IntegrationOptions.GENERIC]: {
importStatement: ``,
integration: 'featureFlagsIntegration()',
Expand Down
27 changes: 26 additions & 1 deletion static/app/gettingStartedDocs/python/python.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const FLAG_OPTION_TO_IMPORT: Record<IntegrationOptions, FlagImports> = {
module: 'openfeature',
integration: 'OpenFeatureIntegration',
},
[IntegrationOptions.UNLEASH]: {
module: 'unleash',
integration: 'UnleashIntegration',
},
[IntegrationOptions.GENERIC]: {
module: 'featureflags',
integration: 'FeatureFlagsIntegration',
Expand Down Expand Up @@ -263,13 +267,34 @@ export const featureFlagOnboarding: OnboardingConfig = {
code: `
import sentry-sdk
from sentry_sdk.integrations.${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].module} import ${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].integration}
${
featureFlagOptions.integration === 'Unleash'
? `from UnleashClient import UnleashClient
unleash_client = UnleashClient(
url="<Unleash server URL>/api/", # "http://localhost:4242/api/" if you are self-hosting Unleash.
app_name="my-app", # Identifies your app in the Unleash UI.
custom_headers={
# See https://docs.getunleash.io/how-to/how-to-create-api-tokens
"Authorization": os.environ["UNLEASH_CLIENT_API_TOKEN"]
}
)
unleash_integration = UnleashIntegration(unleash_client)
sentry_sdk.init(
dsn="${dsn.public}",
integrations=[unleash_integration],
)`
: `
sentry_sdk.init(
dsn="${dsn.public}",
integrations=[
${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].integration}(),
]
)`,
)`
}
`,
},
],
},
Expand Down
1 change: 1 addition & 0 deletions static/app/views/settings/featureFlags/newProviderForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default function NewProviderForm({
name="provider"
options={[
{value: 'LaunchDarkly', label: 'LaunchDarkly'},
{value: 'Unleash', label: 'Unleash'},
{value: 'Generic', label: 'Custom'},
]}
help={t(
Expand Down

0 comments on commit de8fcb3

Please sign in to comment.