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

feat(flags): add unleash to provider dropdowns and onboarding #82836

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
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
4 changes: 4 additions & 0 deletions static/app/components/events/featureFlags/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,21 @@ 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> = {
[ProviderOptions.LAUNCHDARKLY]:
'https://app.launchdarkly.com/settings/integrations/webhooks/new?q=Webhooks',
[ProviderOptions.UNLEASH]:
'https://docs.sentry.io/organization/integrations/feature-flag/unleash/#set-up-change-tracking',
[ProviderOptions.GENERIC]:
'https://docs.sentry.io/organization/integrations/feature-flag/generic/#set-up-change-tracking',
};
16 changes: 16 additions & 0 deletions static/app/gettingStartedDocs/javascript/javascript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ 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: `import { UnleashClient } from 'unleash-proxy-client';`,
integration: 'unleashIntegration(UnleashClient)',
sdkInit: `const unleash = new UnleashClient({
url: "https://<your-unleash-instance>/api/frontend",
clientKey: "<your-client-side-token>",
appName: "my-webapp",
});

unleash.start();

// Evaluate a flag with a default value. You may have to wait for your client to synchronize first.
unleash.isEnabled("test-flag");

Sentry.captureException(new Error("Something went wrong!"));`,
},
michellewzhang marked this conversation as resolved.
Show resolved Hide resolved
[IntegrationOptions.GENERIC]: {
importStatement: ``,
Expand Down
41 changes: 29 additions & 12 deletions static/app/gettingStartedDocs/python/python.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ type FlagImports = {

const FLAG_OPTION_TO_IMPORT: Record<IntegrationOptions, FlagImports> = {
[IntegrationOptions.LAUNCHDARKLY]: {
module: 'launchdarkly',
module: 'integrations.launchdarkly',
integration: 'LaunchDarklyIntegration',
},
[IntegrationOptions.OPENFEATURE]: {
module: 'openfeature',
module: 'integrations.openfeature',
integration: 'OpenFeatureIntegration',
},
[IntegrationOptions.UNLEASH]: {
module: 'integrations.unleash',
integration: 'UnleashIntegration',
},
[IntegrationOptions.GENERIC]: {
module: 'feature_flags',
integration: 'FeatureFlagsIntegration',
integration: '',
},
};

Expand Down Expand Up @@ -184,7 +188,7 @@ export const performanceOnboarding: OnboardingConfig = {
),
language: 'python',
code: `
import sentry-sdk
import sentry_sdk

sentry_sdk.init(
dsn="${params.dsn.public}",
Expand Down Expand Up @@ -252,17 +256,30 @@ export const featureFlagOnboarding: OnboardingConfig = {
configure: ({featureFlagOptions = {integration: ''}, dsn}) => [
{
type: StepType.CONFIGURE,
description: tct('Add [name] to your integrations list.', {
name: (
<code>{`${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].integration}()`}</code>
),
}),
description:
featureFlagOptions.integration === IntegrationOptions.GENERIC
? `This provider doesn't use an integration. Simply initialize Sentry and import the API.`
: tct('Add [name] to your integrations list.', {
name: (
<code>{`${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].integration}()`}</code>
),
}),
configurations: [
{
language: 'python',
code: `
import sentry-sdk
from sentry_sdk.integrations.${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].module} import ${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].integration}
code:
featureFlagOptions.integration === IntegrationOptions.GENERIC
? `import sentry_sdk
from sentry_sdk.${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].module} import add_feature_flag

sentry_sdk.init(
dsn="${dsn.public}",
integrations=[
# your other integrations here
]
)`
: `import sentry_sdk
from sentry_sdk.${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].module} import ${FLAG_OPTION_TO_IMPORT[featureFlagOptions.integration].integration}

sentry_sdk.init(
dsn="${dsn.public}",
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 @@ -119,6 +119,7 @@ export default function NewProviderForm({
options={[
{value: 'LaunchDarkly', label: 'LaunchDarkly'},
{value: 'Generic', label: 'Generic'},
{value: 'Unleash', label: 'Unleash'},
]}
help={t(
'If you have already linked this provider, pasting a new secret will override the existing secret.'
Expand Down
Loading