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

fix(integrations): correct domain in the install link (#57463)

Fixes this mismatch between an org selected for integration and the
current org (in the URL):
<img width="810" alt="image"
src="https://github.com/getsentry/sentry/assets/1127549/20d130c0-9457-47cf-a9b7-b4fe566e82ee">

The install link should contain `https://sentry.sentry.io` in this case.

---------

Co-authored-by: Evan Purkhiser <evanpurkhiser@gmail.com>
Alexander Tarasov 1 год назад
Родитель
Сommit
1f180c4d80

+ 5 - 0
static/app/utils.tsx

@@ -339,3 +339,8 @@ export function escapeDoubleQuotes(str: string) {
 export function generateBaseControlSiloUrl() {
   return ConfigStore.get('links').sentryUrl || '';
 }
+
+export function generateOrgSlugUrl(orgSlug) {
+  const sentryDomain = window.__initialData.links.sentryUrl.split('/')[2];
+  return `${window.location.protocol}//${orgSlug}.${sentryDomain}${window.location.pathname}`;
+}

+ 3 - 3
static/app/views/integrationOrganizationLink/index.tsx

@@ -14,7 +14,7 @@ import LoadingIndicator from 'sentry/components/loadingIndicator';
 import NarrowLayout from 'sentry/components/narrowLayout';
 import {t, tct} from 'sentry/locale';
 import {Integration, IntegrationProvider, Organization} from 'sentry/types';
-import {generateBaseControlSiloUrl} from 'sentry/utils';
+import {generateBaseControlSiloUrl, generateOrgSlugUrl} from 'sentry/utils';
 import {IntegrationAnalyticsKey} from 'sentry/utils/analytics/integrations';
 import {
   getIntegrationFeatureGate,
@@ -183,7 +183,7 @@ export default class IntegrationOrganizationLink extends DeprecatedAsyncView<
     // Github uses a different installation flow with the installationId as a parameter
     // We have to wrap our installation button with AddIntegration so we can get the
     // addIntegrationWithInstallationId callback.
-    // if we don't hve an installationId, we need to use the finishInstallation callback.
+    // if we don't have an installationId, we need to use the finishInstallation callback.
     return (
       <IntegrationFeatures organization={organization} features={featuresComponents}>
         {({disabled}) => (
@@ -234,7 +234,7 @@ export default class IntegrationOrganizationLink extends DeprecatedAsyncView<
                 {organization: <strong>{organization.slug}</strong>}
               )}
             </p>
-            <InstallLink>{window.location.href}</InstallLink>
+            <InstallLink>{generateOrgSlugUrl(selectedOrgSlug)}</InstallLink>
           </Alert>
         )}
 

+ 2 - 2
static/app/views/sentryAppExternalInstallation/index.tsx

@@ -12,7 +12,7 @@ import SentryAppDetailsModal from 'sentry/components/modals/sentryAppDetailsModa
 import NarrowLayout from 'sentry/components/narrowLayout';
 import {t, tct} from 'sentry/locale';
 import {Organization, SentryApp, SentryAppInstallation} from 'sentry/types';
-import {generateBaseControlSiloUrl} from 'sentry/utils';
+import {generateBaseControlSiloUrl, generateOrgSlugUrl} from 'sentry/utils';
 import {trackIntegrationAnalytics} from 'sentry/utils/integrationUtil';
 import {addQueryParamsToExistingUrl} from 'sentry/utils/queryString';
 import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView';
@@ -204,7 +204,7 @@ export default class SentryAppExternalInstallation extends DeprecatedAsyncView<
               {organization: <strong>{organization.slug}</strong>}
             )}
           </p>
-          <InstallLink>{window.location.href}</InstallLink>
+          <InstallLink>{generateOrgSlugUrl(selectedOrgSlug)}</InstallLink>
         </Alert>
       );
     }