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(getting-started-docs): Source SDK version from sentry release registry #54943

Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
48b3f36
ref(getting-started-docs): Source sdks version from sentry release re…
priscilawebdev Aug 14, 2023
81f6537
Merge branch 'master' into priscila/feat/getting-started-docs-source-…
priscilawebdev Aug 14, 2023
f2d7b9f
make prop optional
priscilawebdev Aug 14, 2023
7a9d428
add description to hook
priscilawebdev Aug 14, 2023
51a106f
Update static/app/gettingStartedDocs/rust/rust.tsx
priscilawebdev Aug 14, 2023
23db940
Merge branch 'master' into priscila/feat/getting-started-docs-source-…
priscilawebdev Aug 14, 2023
b77a116
cr feedback
priscilawebdev Aug 14, 2023
6caa12d
Merge branch 'master' into priscila/feat/getting-started-docs-source-…
priscilawebdev Aug 17, 2023
3a38a69
cr feedback
priscilawebdev Aug 17, 2023
ec5d7c7
cr feedback
priscilawebdev Aug 17, 2023
0f05f3c
remove test code
priscilawebdev Aug 17, 2023
5a54ead
fix tsc error
priscilawebdev Aug 17, 2023
d063924
Merge branch 'master' into priscila/feat/getting-started-docs-source-…
priscilawebdev Aug 17, 2023
1f34c19
cr feedback
priscilawebdev Aug 17, 2023
eea3f51
revert new changes
priscilawebdev Aug 17, 2023
8d91175
Merge branch 'master' into priscila/feat/getting-started-docs-source-…
priscilawebdev Aug 17, 2023
bd3397b
Matej cr feedback
priscilawebdev Aug 17, 2023
dfe77c2
checking cross-origin error
priscilawebdev Aug 17, 2023
c4f5750
ref(onboarding-docs): Use api/0/ endpoint for fetching the release re…
ArthurKnaus Aug 18, 2023
2e267da
fix(onboarding-docs): Use release registry data in spring-boot docs
ArthurKnaus Aug 18, 2023
5afbc0c
Merge remote-tracking branch 'origin/master' into priscila/feat/getti…
ArthurKnaus Aug 18, 2023
00f6df1
Merge branch 'master' into priscila/feat/getting-started-docs-source-…
ArthurKnaus Aug 18, 2023
6b71ee2
fix(onboarding-docs): Use registry package version in spring doc links
ArthurKnaus Aug 18, 2023
567a081
Merge branch 'master' into priscila/feat/getting-started-docs-source-…
ArthurKnaus Aug 18, 2023
711c511
Remove 'loading' state from url
ArthurKnaus Aug 18, 2023
1c098b3
Update static/app/components/onboarding/gettingStartedDoc/useSourcePa…
matejminar Aug 18, 2023
5ec155f
fix test
matejminar Aug 18, 2023
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
@@ -1,6 +1,7 @@
import {useEffect, useState} from 'react';

import LoadingIndicator from 'sentry/components/loadingIndicator';
import {useSourcePackageRegistries} from 'sentry/components/onboarding/gettingStartedDoc/useSourcePackageRegistries';
import {ProductSolution} from 'sentry/components/onboarding/productSelection';
import {PlatformKey} from 'sentry/data/platformCategories';
import type {Organization, PlatformIntegration, Project, ProjectKey} from 'sentry/types';
Expand All @@ -22,6 +23,7 @@ export type ModuleProps = {
organization?: Organization;
platformKey?: PlatformKey;
projectId?: Project['id'];
sourcePackageRegistries?: ReturnType<typeof useSourcePackageRegistries>;
};

// Loads the component containing the documentation for the specified platform
Expand All @@ -33,6 +35,8 @@ export function SdkDocumentation({
organization,
projectId,
}: SdkDocumentationProps) {
const sourcePackageRegistries = useSourcePackageRegistries(organization);

const [module, setModule] = useState<null | {
default: React.ComponentType<ModuleProps>;
}>(null);
Expand Down Expand Up @@ -95,6 +99,7 @@ export function SdkDocumentation({
}

const {default: GettingStartedDoc} = module;

return (
<GettingStartedDoc
dsn={projectKeys[0].dsn.public}
Expand All @@ -103,6 +108,7 @@ export function SdkDocumentation({
platformKey={platform?.id}
organization={organization}
projectId={projectId}
sourcePackageRegistries={sourcePackageRegistries}
/>
);
}
7 changes: 7 additions & 0 deletions static/app/components/onboarding/gettingStartedDoc/step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ type ConfigurationType = {
* A callback to be invoked when the configuration is selected and copied to the clipboard
*/
onSelectAndCopy?: () => void;
/**
* Whether or not the configuration or parts of it are currently being loaded
*/
partialLoading?: boolean;
};

interface BaseStepProps {
Expand Down Expand Up @@ -79,6 +83,7 @@ function getConfiguration({
additionalInfo,
onCopy,
onSelectAndCopy,
partialLoading,
}: ConfigurationType) {
return (
<Configuration>
Expand All @@ -89,6 +94,8 @@ function getConfiguration({
language={language}
onCopy={onCopy}
onSelectAndCopy={onSelectAndCopy}
hideCopyButton={partialLoading}
disableUserSelection={partialLoading}
>
{language === 'javascript'
? beautify.js(code, {indent_size: 2, e4x: true})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {useEffect} from 'react';

import {Organization} from 'sentry/types';
import {handleXhrErrorResponse} from 'sentry/utils/handleXhrErrorResponse';
import {useApiQuery} from 'sentry/utils/queryClient';

type ReleaseRegistrySdk = Record<
string,
{
canonical: string;
main_docs_url: string;
name: string;
package_url: string;
repo_url: string;
version: string;
}
>;

/**
* Fetches the release registry list for SDKs
*/
export function useSourcePackageRegistries(organization: Organization) {
const releaseRegistrySdk = useApiQuery<ReleaseRegistrySdk>(
[`/${organization.slug}/sdks/`],
matejminar marked this conversation as resolved.
Show resolved Hide resolved
{
staleTime: Infinity,
}
);

useEffect(() => {
if (releaseRegistrySdk.error) {
handleXhrErrorResponse(
'Failed to fetch sentry release registry',
releaseRegistrySdk.error
);
}
}, [releaseRegistrySdk.error]);

return releaseRegistrySdk;
}
29 changes: 23 additions & 6 deletions static/app/gettingStartedDocs/android/android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {t, tct} from 'sentry/locale';
// Configuration Start
export const steps = ({
dsn,
}: {
dsn?: string;
} = {}): LayoutProps['steps'] => [
sourcePackageRegistries,
}: Partial<
Pick<ModuleProps, 'dsn' | 'sourcePackageRegistries'>
> = {}): LayoutProps['steps'] => [
{
type: StepType.INSTALL,
description: (
Expand All @@ -28,10 +29,16 @@ export const steps = ({
configurations: [
{
language: 'groovy',
partialLoading: sourcePackageRegistries?.isLoading,
code: `
plugins {
id "com.android.application" // should be in the same module
id "io.sentry.android.gradle" version "3.12.0"
id "io.sentry.android.gradle" version "${
sourcePackageRegistries?.isLoading
? t('\u2026loading')
: sourcePackageRegistries?.data?.['sentry.java.android.gradle-plugin']?.version ??
'3.12.0'
}"
}
`,
},
Expand Down Expand Up @@ -139,8 +146,18 @@ export const nextSteps = [
];
// Configuration End

export function GettingStartedWithAndroid({dsn, ...props}: ModuleProps) {
return <Layout steps={steps({dsn})} nextSteps={nextSteps} {...props} />;
export function GettingStartedWithAndroid({
dsn,
sourcePackageRegistries,
...props
}: ModuleProps) {
return (
<Layout
steps={steps({dsn, sourcePackageRegistries})}
nextSteps={nextSteps}
{...props}
/>
);
}

export default GettingStartedWithAndroid;
28 changes: 22 additions & 6 deletions static/app/gettingStartedDocs/apple/apple-ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {t, tct} from 'sentry/locale';
// Configuration Start
export const steps = ({
dsn,
}: {
dsn?: string;
} = {}): LayoutProps['steps'] => [
sourcePackageRegistries,
}: Partial<
Pick<ModuleProps, 'dsn' | 'sourcePackageRegistries'>
> = {}): LayoutProps['steps'] => [
{
type: StepType.INSTALL,
description: (
Expand Down Expand Up @@ -44,8 +45,13 @@ https://github.com/getsentry/sentry-cocoa.git
</p>
),
language: 'swift',
partialLoading: sourcePackageRegistries?.isLoading,
code: `
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.9.3"),
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "${
sourcePackageRegistries?.isLoading
? t('\u2026loading')
: sourcePackageRegistries?.data?.['sentry.cocoa']?.version ?? '8.9.3'
}"),
`,
},
],
Expand Down Expand Up @@ -231,8 +237,18 @@ export const nextSteps = [
];
// Configuration End

export function GettingStartedWithIos({dsn, ...props}: ModuleProps) {
return <Layout steps={steps({dsn})} nextSteps={nextSteps} {...props} />;
export function GettingStartedWithIos({
dsn,
sourcePackageRegistries,
...props
}: ModuleProps) {
return (
<Layout
steps={steps({dsn, sourcePackageRegistries})}
nextSteps={nextSteps}
{...props}
/>
);
}

export default GettingStartedWithIos;
28 changes: 22 additions & 6 deletions static/app/gettingStartedDocs/apple/apple-macos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {t, tct} from 'sentry/locale';
// Configuration Start
export const steps = ({
dsn,
}: {
dsn?: string;
} = {}): LayoutProps['steps'] => [
sourcePackageRegistries,
}: Partial<
Pick<ModuleProps, 'dsn' | 'sourcePackageRegistries'>
> = {}): LayoutProps['steps'] => [
{
type: StepType.INSTALL,
description: (
Expand Down Expand Up @@ -44,8 +45,13 @@ https://github.com/getsentry/sentry-cocoa.git
</p>
),
language: 'swift',
partialLoading: sourcePackageRegistries?.isLoading,
code: `
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.9.3"),
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "${
sourcePackageRegistries?.isLoading
? t('\u2026loading')
: sourcePackageRegistries?.data?.['sentry.cocoa']?.version ?? '8.9.3'
}"),
`,
},
],
Expand Down Expand Up @@ -183,8 +189,18 @@ export const nextSteps = [
];
// Configuration End

export function GettingStartedWithMacos({dsn, ...props}: ModuleProps) {
return <Layout steps={steps({dsn})} nextSteps={nextSteps} {...props} />;
export function GettingStartedWithMacos({
dsn,
sourcePackageRegistries,
...props
}: ModuleProps) {
return (
<Layout
steps={steps({dsn, sourcePackageRegistries})}
nextSteps={nextSteps}
{...props}
/>
);
}

export default GettingStartedWithMacos;
28 changes: 22 additions & 6 deletions static/app/gettingStartedDocs/apple/apple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {t, tct} from 'sentry/locale';
// Configuration Start
export const steps = ({
dsn,
}: {
dsn?: string;
} = {}): LayoutProps['steps'] => [
sourcePackageRegistries,
}: Partial<
Pick<ModuleProps, 'dsn' | 'sourcePackageRegistries'>
> = {}): LayoutProps['steps'] => [
{
type: StepType.INSTALL,
description: (
Expand Down Expand Up @@ -44,8 +45,13 @@ https://github.com/getsentry/sentry-cocoa.git
</p>
),
language: 'swift',
partialLoading: sourcePackageRegistries?.isLoading,
code: `
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "8.9.3"),
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "${
sourcePackageRegistries?.isLoading
? t('\u2026loading')
: sourcePackageRegistries?.data?.['sentry.cocoa']?.version ?? '8.9.3'
}"),
`,
},
],
Expand Down Expand Up @@ -183,8 +189,18 @@ export const nextSteps = [
];
// Configuration End

export function GettingStartedWithApple({dsn, ...props}: ModuleProps) {
return <Layout steps={steps({dsn})} nextSteps={nextSteps} {...props} />;
export function GettingStartedWithApple({
dsn,
sourcePackageRegistries,
...props
}: ModuleProps) {
return (
<Layout
steps={steps({dsn, sourcePackageRegistries})}
nextSteps={nextSteps}
{...props}
/>
);
}

export default GettingStartedWithApple;
4 changes: 1 addition & 3 deletions static/app/gettingStartedDocs/capacitor/capacitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import {t, tct} from 'sentry/locale';
// Configuration Start
export const steps = ({
dsn,
}: {
dsn?: string;
} = {}): LayoutProps['steps'] => [
}: Partial<Pick<ModuleProps, 'dsn'>> = {}): LayoutProps['steps'] => [
{
type: StepType.INSTALL,
description: t(
Expand Down
4 changes: 1 addition & 3 deletions static/app/gettingStartedDocs/cordova/cordova.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import {t, tct} from 'sentry/locale';
// Configuration Start
export const steps = ({
dsn,
}: {
dsn?: string;
} = {}): LayoutProps['steps'] => [
}: Partial<Pick<ModuleProps, 'dsn'>> = {}): LayoutProps['steps'] => [
{
type: StepType.INSTALL,
description: t('Install our SDK using the cordova command:'),
Expand Down
22 changes: 16 additions & 6 deletions static/app/gettingStartedDocs/dart/dart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {t, tct} from 'sentry/locale';
// Configuration Start
export const steps = ({
dsn,
}: {
dsn?: string;
} = {}): LayoutProps['steps'] => [
sourcePackageRegistries,
}: Partial<
Pick<ModuleProps, 'dsn' | 'sourcePackageRegistries'>
> = {}): LayoutProps['steps'] => [
{
type: StepType.INSTALL,
description: (
Expand All @@ -25,9 +26,14 @@ export const steps = ({
configurations: [
{
language: 'yml',
partialLoading: sourcePackageRegistries?.isLoading,
code: `
dependencies:
sentry: ^7.8.0
sentry: ^${
sourcePackageRegistries?.isLoading
? t('\u2026loading')
: sourcePackageRegistries?.data?.['sentry.dart']?.version ?? '7.8.0'
}
`,
},
],
Expand Down Expand Up @@ -162,8 +168,12 @@ Future<void> processOrderBatch(ISentrySpan span) async {
];
// Configuration End

export function GettingStartedWithDart({dsn, ...props}: ModuleProps) {
return <Layout steps={steps({dsn})} {...props} />;
export function GettingStartedWithDart({
dsn,
sourcePackageRegistries,
...props
}: ModuleProps) {
return <Layout steps={steps({dsn, sourcePackageRegistries})} {...props} />;
}

export default GettingStartedWithDart;
Loading