-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
ref(getting-started-docs): Source sdks version from sentry release registry #54675
Changes from all commits
48b3f36
81f6537
f2d7b9f
7a9d428
51a106f
23db940
b77a116
6caa12d
3a38a69
ec5d7c7
0f05f3c
5a54ead
d063924
1f34c19
eea3f51
8d91175
bd3397b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {useEffect} from 'react'; | ||
|
||
import {Client} from 'sentry/api'; | ||
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; | ||
} | ||
>; | ||
|
||
// This exists because /extensions/type/search API is not prefixed with | ||
// /api/0/, but the default API client on the abstract issue form is... | ||
const API_CLIENT = new Client({baseUrl: '', headers: {}, credentials: 'omit'}); | ||
|
||
/** | ||
* Fetches the release registry list for SDKs | ||
*/ | ||
export function useSourcePackageRegistries() { | ||
const releaseRegistrySdk = useApiQuery<ReleaseRegistrySdk>( | ||
['https://release-registry.services.sentry.io/sdks'], | ||
{ | ||
staleTime: Infinity, | ||
}, | ||
API_CLIENT | ||
); | ||
|
||
useEffect(() => { | ||
if (releaseRegistrySdk.error) { | ||
handleXhrErrorResponse( | ||
'Failed to fetch sentry release registry', | ||
releaseRegistrySdk.error | ||
); | ||
} | ||
}, [releaseRegistrySdk.error]); | ||
|
||
return releaseRegistrySdk; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'] => [ | ||
Comment on lines
+10
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wish we could simplify this. It's quite clunky, especially because we repeat it in lots of places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I talked to Arthur about it too... we should definitely simplify this, but would prefer to do that in a separate PR |
||
{ | ||
type: StepType.INSTALL, | ||
description: ( | ||
|
@@ -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' | ||
}"), | ||
`, | ||
}, | ||
], | ||
|
@@ -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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is meh but according to our slack discussion, we don't capture response errors out of the box as it was too noisy before and when we need to track them, we shall use
handleXhrErrorResponse