Просмотр исходного кода

ref(flags): add generic provider onboarding (#82387)

### settings page 

now we have a 'generic' option in the dropdown:
<img width="966" alt="SCR-20250107-jves"
src="https://github.com/user-attachments/assets/33831a63-652d-4fef-8f73-71c81ea7bbc9"
/>
<img width="985" alt="SCR-20250107-jvhn"
src="https://github.com/user-attachments/assets/139ded9b-4408-412a-a374-1b49232f0093"
/>



### python onboarding 

<img width="470" alt="SCR-20250107-jvqt"
src="https://github.com/user-attachments/assets/e8967cfd-aa69-4108-8f46-61d20f33a5ac"
/>

### js onboarding

<img width="465" alt="SCR-20250107-jvxt"
src="https://github.com/user-attachments/assets/d31925c0-4ff4-4069-876b-f63652351c6a"
/>


closes https://github.com/getsentry/team-replay/issues/518
Michelle Zhang 2 месяцев назад
Родитель
Сommit
e080c66260

+ 2 - 2
static/app/components/events/featureFlags/featureFlagOnboardingSidebar.tsx

@@ -157,8 +157,8 @@ function OnboardingContent({
     return window.location.hash;
   }, []);
   const skipConfig = ORIGINAL_HASH === FLAG_HASH_SKIP_CONFIG;
-  const openFeatureProviders = [ProviderOptions.LAUNCHDARKLY];
-  const sdkProviders = [ProviderOptions.LAUNCHDARKLY];
+  const openFeatureProviders = Object.values(ProviderOptions);
+  const sdkProviders = Object.values(ProviderOptions);
 
   // First dropdown: OpenFeature providers
   const openFeatureProviderOptions = openFeatureProviders.map(provider => {

+ 3 - 1
static/app/components/events/featureFlags/onboardingIntegrationSection.tsx

@@ -98,7 +98,9 @@ export default function OnboardingIntegrationSection({
           <div>
             {tct(
               "Create a webhook integration with your [link:feature flag service]. When you do so, you'll need to enter a URL, which you can find below.",
-              {link: <ExternalLink href={PROVIDER_OPTION_TO_URLS[provider]} />}
+              {
+                link: <ExternalLink href={PROVIDER_OPTION_TO_URLS[provider]} />,
+              }
             )}
           </div>
           <InputTitle>{t('Webhook URL')}</InputTitle>

+ 5 - 1
static/app/components/events/featureFlags/utils.tsx

@@ -115,14 +115,18 @@ export const sortedFlags = ({
 
 export enum ProviderOptions {
   LAUNCHDARKLY = 'LaunchDarkly',
+  GENERIC = 'Generic',
 }
 
 export enum IntegrationOptions {
   LAUNCHDARKLY = 'LaunchDarkly',
   OPENFEATURE = 'OpenFeature',
+  GENERIC = 'Generic',
 }
 
-export const PROVIDER_OPTION_TO_URLS: Record<ProviderOptions, string> = {
+export const PROVIDER_OPTION_TO_URLS: Record<ProviderOptions, string | undefined> = {
   [ProviderOptions.LAUNCHDARKLY]:
     'https://app.launchdarkly.com/settings/integrations/webhooks/new?q=Webhooks',
+  [ProviderOptions.GENERIC]:
+    'https://docs.sentry.io/organization/integrations/feature-flag/generic/#set-up-change-tracking',
 };

+ 13 - 0
static/app/gettingStartedDocs/javascript/javascript.tsx

@@ -93,6 +93,19 @@ client.addHooks(new Sentry.OpenFeatureIntegrationHook());
 // Evaluating flags will record the result on the Sentry client.
 const result = client.getBooleanValue('my-flag', false);`,
   },
+  [IntegrationOptions.GENERIC]: {
+    importStatement: ``,
+    integration: 'featureFlagsIntegration()',
+    sdkInit: `const flagsIntegration = Sentry.getClient()?.getIntegrationByName<Sentry.FeatureFlagsIntegration>('FeatureFlags');
+
+if (flagsIntegration) {
+  flagsIntegration.addFeatureFlag('test-flag', false);
+} else {
+  // Something went wrong, check your DSN and/or integrations
+}
+
+Sentry.captureException(new Error('Something went wrong!'));`,
+  },
 };
 
 const isAutoInstall = (params: Params) =>

+ 4 - 0
static/app/gettingStartedDocs/python/python.tsx

@@ -31,6 +31,10 @@ const FLAG_OPTION_TO_IMPORT: Record<IntegrationOptions, FlagImports> = {
     module: 'openfeature',
     integration: 'OpenFeatureIntegration',
   },
+  [IntegrationOptions.GENERIC]: {
+    module: 'feature_flags',
+    integration: 'FeatureFlagsIntegration',
+  },
 };
 
 const getInstallSnippet = () => `pip install --upgrade sentry-sdk`;

+ 0 - 1
static/app/views/settings/featureFlags/index.spec.tsx

@@ -49,7 +49,6 @@ describe('OrganizationFeatureFlagsIndex', function () {
 
     await waitForElementToBeRemoved(() => screen.queryByTestId('loading-indicator'));
 
-    // Then list
     expect(screen.getByText('launchdarkly')).toBeInTheDocument();
     expect(screen.getByText('openfeature')).toBeInTheDocument();
 

+ 4 - 1
static/app/views/settings/featureFlags/newProviderForm.tsx

@@ -116,7 +116,10 @@ export default function NewProviderForm({
         value={selectedProvider}
         placeholder={t('Select a provider')}
         name="provider"
-        options={[{value: 'LaunchDarkly', label: 'LaunchDarkly'}]}
+        options={[
+          {value: 'LaunchDarkly', label: 'LaunchDarkly'},
+          {value: 'Generic', label: 'Generic'},
+        ]}
         help={t(
           'If you have already linked this provider, pasting a new secret will override the existing secret.'
         )}