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

ref(onboarding): Expose DSN object (#75969)

Expose the whole `dsn` object in the doc parameters, so all the entries
can be accessed if necessary.

Part of https://github.com/getsentry/sentry/issues/71733
ArthurKnaus 7 месяцев назад
Родитель
Сommit
a816a82b4b

+ 0 - 3
static/app/components/feedback/feedbackOnboarding/feedbackOnboardingLayout.tsx

@@ -12,7 +12,6 @@ import {space} from 'sentry/styles/space';
 import useOrganization from 'sentry/utils/useOrganization';
 
 export function FeedbackOnboardingLayout({
-  cdn,
   docsConfig,
   dsn,
   platformKey,
@@ -34,7 +33,6 @@ export function FeedbackOnboardingLayout({
     const doc = docsConfig[configType] ?? docsConfig.onboarding;
 
     const docParams: DocsParams<any> = {
-      cdn,
       dsn,
       organization,
       platformKey,
@@ -62,7 +60,6 @@ export function FeedbackOnboardingLayout({
       steps: [...doc.install(docParams), ...doc.configure(docParams)],
     };
   }, [
-    cdn,
     docsConfig,
     dsn,
     isLoadingRegistry,

+ 0 - 2
static/app/components/feedback/feedbackOnboarding/sidebar.tsx

@@ -201,7 +201,6 @@ function OnboardingContent({currentProject}: {currentProject: Project}) {
     isLoading,
     docs: newDocs,
     dsn,
-    cdn,
   } = useLoadGettingStarted({
     platform:
       showJsFrameworkInstructions && !crashReportOnboarding
@@ -344,7 +343,6 @@ function OnboardingContent({currentProject}: {currentProject: Project}) {
       <FeedbackOnboardingLayout
         docsConfig={newDocs}
         dsn={dsn}
-        cdn={cdn}
         activeProductSelection={[]}
         platformKey={currentPlatform.id}
         projectId={currentProject.id}

+ 2 - 6
static/app/components/onboarding/gettingStartedDoc/onboardingLayout.tsx

@@ -23,7 +23,7 @@ import {
 } from 'sentry/components/onboarding/productSelection';
 import {t} from 'sentry/locale';
 import {space} from 'sentry/styles/space';
-import type {PlatformKey, Project} from 'sentry/types';
+import type {PlatformKey, Project, ProjectKey} from 'sentry/types';
 import useOrganization from 'sentry/utils/useOrganization';
 
 const ProductSelectionAvailabilityHook = HookOrDefault({
@@ -33,12 +33,11 @@ const ProductSelectionAvailabilityHook = HookOrDefault({
 
 export type OnboardingLayoutProps = {
   docsConfig: Docs<any>;
-  dsn: string;
+  dsn: ProjectKey['dsn'];
   platformKey: PlatformKey;
   projectId: Project['id'];
   projectSlug: Project['slug'];
   activeProductSelection?: ProductSolution[];
-  cdn?: string;
   configType?: ConfigType;
   newOrg?: boolean;
 };
@@ -46,7 +45,6 @@ export type OnboardingLayoutProps = {
 const EMPTY_ARRAY: never[] = [];
 
 export function OnboardingLayout({
-  cdn,
   docsConfig,
   dsn,
   platformKey,
@@ -66,7 +64,6 @@ export function OnboardingLayout({
     const doc = docsConfig[configType] ?? docsConfig.onboarding;
 
     const docParams: DocsParams<any> = {
-      cdn,
       dsn,
       organization,
       platformKey,
@@ -97,7 +94,6 @@ export function OnboardingLayout({
       nextSteps: doc.nextSteps?.(docParams) || [],
     };
   }, [
-    cdn,
     activeProductSelection,
     docsConfig,
     dsn,

+ 1 - 2
static/app/components/onboarding/gettingStartedDoc/sdkDocumentation.tsx

@@ -28,7 +28,7 @@ export function SdkDocumentation({
   configType,
   organization,
 }: SdkDocumentationProps) {
-  const {isLoading, isError, dsn, cdn, docs, refetch} = useLoadGettingStarted({
+  const {isLoading, isError, dsn, docs, refetch} = useLoadGettingStarted({
     orgSlug: organization.slug,
     projSlug: projectSlug,
     platform,
@@ -73,7 +73,6 @@ export function SdkDocumentation({
     <OnboardingLayout
       docsConfig={docs}
       dsn={dsn}
-      cdn={cdn}
       activeProductSelection={activeProductSelection}
       newOrg={newOrg}
       platformKey={platform.id}

+ 2 - 3
static/app/components/onboarding/gettingStartedDoc/types.ts

@@ -1,6 +1,6 @@
 import type {StepProps} from 'sentry/components/onboarding/gettingStartedDoc/step';
 import type {ReleaseRegistrySdk} from 'sentry/components/onboarding/gettingStartedDoc/useSourcePackageRegistries';
-import type {Organization, PlatformKey, Project} from 'sentry/types';
+import type {Organization, PlatformKey, Project, ProjectKey} from 'sentry/types';
 
 type GeneratorFunction<T, Params> = (params: Params) => T;
 type WithGeneratorProperties<T extends Record<string, any>, Params> = {
@@ -36,7 +36,7 @@ export type SelectedPlatformOptions<
 export interface DocsParams<
   PlatformOptions extends BasePlatformOptions = BasePlatformOptions,
 > {
-  dsn: string;
+  dsn: ProjectKey['dsn'];
   isFeedbackSelected: boolean;
   isPerformanceSelected: boolean;
   isProfilingSelected: boolean;
@@ -47,7 +47,6 @@ export interface DocsParams<
   projectId: Project['id'];
   projectSlug: Project['slug'];
   sourcePackageRegistries: {isLoading: boolean; data?: ReleaseRegistrySdk};
-  cdn?: string;
   feedbackOptions?: {
     email?: boolean;
     name?: boolean;

+ 3 - 3
static/app/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding.tsx

@@ -127,7 +127,7 @@ const getCrashReportModalSnippetJavaScript = params => [
         language: 'html',
         code: `<script>
   Sentry.init({
-    dsn: "${params.dsn}",
+    dsn: "${params.dsn.public}",
     beforeSend(event, hint) {
       // Check if it is an exception, and if so, show the report dialog
       if (event.exception && event.event_id) {
@@ -187,7 +187,7 @@ const getGenericScript = params => [
     value: 'html',
     language: 'html',
     code: `<script>
-  Sentry.init({ dsn: "${params.dsn}" });
+  Sentry.init({ dsn: "${params.dsn.public}" });
   Sentry.showReportDialog({
     eventId: "{{ event_id }}",
   });
@@ -297,7 +297,7 @@ export const getCrashReportPHPInstallStep = params => [
             language: 'html',
             code: `<?php if (\Sentry\SentrySdk::getCurrentHub()->getLastEventId()) { ?>
 <script>
-  Sentry.init({ dsn: "${params.dsn}" });
+  Sentry.init({ dsn: "${params.dsn.public}" });
   Sentry.showReportDialog({
     eventId:
       "<?php echo \Sentry\SentrySdk::getCurrentHub()->getLastEventId(); ?>",

+ 9 - 9
static/app/components/onboarding/gettingStartedDoc/utils/metricsOnboarding.tsx

@@ -12,7 +12,7 @@ import {getInstallConfig as getNodeInstallConfig} from 'sentry/utils/gettingStar
 
 const getJSConfigureSnippet = (params: DocsParams) => `
 Sentry.init({
-  dsn: "${params.dsn}",
+  dsn: "${params.dsn.public}",
   // Only needed for SDK versions < 8.0.0
   // integrations: [
   //   Sentry.metrics.metricsAggregatorIntegration(),
@@ -150,7 +150,7 @@ const getJSMetricsOnboardingVerify = ({docsLink}: {docsLink: string}) => [
 
 const getJSServerConfigureSnippet = (params: DocsParams) => `
 Sentry.init({
-  dsn: "${params.dsn}",
+  dsn: "${params.dsn.public}",
   // Only needed for SDK versions < 8.0.0
   // _experiments: {
   //   metricsAggregator: true,
@@ -229,7 +229,7 @@ const getJvmKotlinConfigureSnippet = (params: DocsParams) => `
 import io.sentry.Sentry
 
 Sentry.init(this) { options ->
-  options.dsn = "${params.dsn}",
+  options.dsn = "${params.dsn.public}",
   options.enableMetrics = true
 }`;
 
@@ -237,7 +237,7 @@ const getJvmJavaConfigureSnippet = (params: DocsParams) => `
 import io.sentry.Sentry;
 
 Sentry.init(this, options -> {
-  options.setDsn("${params.dsn}");
+  options.setDsn("${params.dsn.public}");
   options.setEnableMetrics(true);
 });`;
 
@@ -245,7 +245,7 @@ const getAndroidKotlinConfigureSnippet = (params: DocsParams) => `
 import io.sentry.android.core.SentryAndroid
 
 SentryAndroid.init(this) { options ->
-  options.dsn = "${params.dsn}",
+  options.dsn = "${params.dsn.public}",
   options.enableMetrics = true
 }`;
 
@@ -253,14 +253,14 @@ const getAndroidJavaConfigureSnippet = (params: DocsParams) => `
 import io.sentry.android.core.SentryAndroid;
 
 SentryAndroid.init(this, options -> {
-  options.setDsn("${params.dsn}");
+  options.setDsn("${params.dsn.public}");
   options.setEnableMetrics(true);
 });`;
 
 const getAndroidXmlConfigureSnippet = (params: DocsParams) => `
 <manifest>
     <application>
-        <meta-data android:name="io.sentry.dsn" android:value="${params.dsn}" />
+        <meta-data android:name="io.sentry.dsn" android:value="${params.dsn.public}" />
         <meta-data android:name="io.sentry.enable-metrics" android:value="true" />
     </application>
 </manifest>`;
@@ -562,7 +562,7 @@ const getPythonConfigureSnippet = (params: DocsParams) => `
 import sentry_sdk
 
 sentry_sdk.init(
-  dsn="${params.dsn}",
+  dsn="${params.dsn.public}",
   # ...
 )`;
 
@@ -678,7 +678,7 @@ export const getPythonMetricsOnboarding = ({
 const getDotnetConfigureSnippet = (params: DocsParams) => `
 SentrySdk.Init(options =>
 {
-  options.Dsn = "${params.dsn}";
+  options.Dsn = "${params.dsn.public}";
   options.ExperimentalMetrics = new ExperimentalMetricsOptions
   {
     EnableCodeLocations = true

+ 3 - 5
static/app/components/onboarding/gettingStartedDoc/utils/useLoadGettingStarted.tsx

@@ -6,7 +6,7 @@ import {
   feedbackOnboardingPlatforms,
   replayPlatforms,
 } from 'sentry/data/platformCategories';
-import type {Organization, PlatformIntegration, Project} from 'sentry/types';
+import type {Organization, PlatformIntegration, Project, ProjectKey} from 'sentry/types';
 import {getPlatformPath} from 'sentry/utils/gettingStartedDocs/getPlatformPath';
 import {useProjectKeys} from 'sentry/utils/useProjectKeys';
 
@@ -23,9 +23,8 @@ export function useLoadGettingStarted({
   orgSlug,
   projSlug,
 }: Props): {
-  cdn: string | undefined;
   docs: Docs<any> | null;
-  dsn: string | undefined;
+  dsn: ProjectKey['dsn'] | undefined;
   isError: boolean;
   isLoading: boolean;
   refetch: () => void;
@@ -72,7 +71,6 @@ export function useLoadGettingStarted({
     isLoading: projectKeys.isLoading || module === undefined,
     isError: projectKeys.isError,
     docs: module === 'none' ? null : module?.default ?? null,
-    dsn: projectKeys.data?.[0]?.dsn.public,
-    cdn: projectKeys.data?.[0]?.dsn.cdn,
+    dsn: projectKeys.data?.[0]?.dsn,
   };
 }

+ 1 - 2
static/app/components/profiling/profilingOnboardingSidebar.tsx

@@ -217,7 +217,7 @@ interface ProfilingOnboardingContentProps {
 }
 
 function ProfilingOnboardingContent(props: ProfilingOnboardingContentProps) {
-  const {isLoading, isError, dsn, cdn, docs, refetch} = useLoadGettingStarted({
+  const {isLoading, isError, dsn, docs, refetch} = useLoadGettingStarted({
     orgSlug: props.organization.slug,
     projSlug: props.projectSlug,
     platform: props.platform,
@@ -259,7 +259,6 @@ function ProfilingOnboardingContent(props: ProfilingOnboardingContentProps) {
   }
 
   const docParams: DocsParams<any> = {
-    cdn,
     dsn,
     organization: props.organization,
     platformKey: props.platform.id,

+ 0 - 3
static/app/components/replaysOnboarding/replayOnboardingLayout.tsx

@@ -11,7 +11,6 @@ import ReplayConfigToggle from 'sentry/components/replaysOnboarding/replayConfig
 import useOrganization from 'sentry/utils/useOrganization';
 
 export function ReplayOnboardingLayout({
-  cdn,
   docsConfig,
   dsn,
   platformKey,
@@ -30,7 +29,6 @@ export function ReplayOnboardingLayout({
     const doc = docsConfig[configType] ?? docsConfig.onboarding;
 
     const docParams: DocsParams<any> = {
-      cdn,
       dsn,
       organization,
       platformKey,
@@ -62,7 +60,6 @@ export function ReplayOnboardingLayout({
       nextSteps: doc.nextSteps?.(docParams) || [],
     };
   }, [
-    cdn,
     docsConfig,
     dsn,
     isLoadingRegistry,

Некоторые файлы не были показаны из-за большого количества измененных файлов