-
-
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 7 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 |
---|---|---|
|
@@ -243,7 +243,10 @@ type ClientOptions = { | |
* The base URL path to prepend to API request URIs. | ||
*/ | ||
baseUrl?: string; | ||
|
||
/** | ||
* Credentials policy to apply to each request | ||
*/ | ||
credentials?: RequestCredentials; | ||
/** | ||
* Base set of headers to apply to each request | ||
*/ | ||
|
@@ -265,6 +268,7 @@ export class Client { | |
baseUrl: string; | ||
activeRequests: Record<string, Request>; | ||
headers: HeadersInit; | ||
credentials?: RequestCredentials; | ||
|
||
static JSON_HEADERS = { | ||
Accept: 'application/json; charset=utf-8', | ||
|
@@ -275,6 +279,7 @@ export class Client { | |
this.baseUrl = options.baseUrl ?? '/api/0'; | ||
this.headers = options.headers ?? Client.JSON_HEADERS; | ||
this.activeRequests = {}; | ||
this.credentials = options.credentials ?? 'include'; | ||
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. This was creating a problem related to accessing data from another source (cross-origin issue) while trying to get information from the sentry release registry. With this update, we can now pass a custom |
||
} | ||
|
||
wrapCallback<T extends any[]>( | ||
|
@@ -459,7 +464,7 @@ export class Client { | |
method, | ||
body, | ||
headers, | ||
credentials: 'include', | ||
credentials: this.credentials, | ||
signal: aborter?.signal, | ||
}); | ||
|
||
|
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. Can we also split this into its own PR, would like to get @vuluongj20's eyes on this |
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 {isLoading, data, error} = useApiQuery<ReleaseRegistrySdk>( | ||
priscilawebdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
['https://release-registry.services.sentry.io/sdks'], | ||
{ | ||
staleTime: Infinity, | ||
}, | ||
API_CLIENT | ||
); | ||
|
||
useEffect(() => { | ||
if (error) { | ||
handleXhrErrorResponse('Failed to fetch sentry release registry', error); | ||
} | ||
}, [error]); | ||
priscilawebdev marked this conversation as resolved.
Show resolved
Hide resolved
priscilawebdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return { | ||
isLoading, | ||
data, | ||
}; | ||
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. Why not just return the entire response from
priscilawebdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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,11 @@ https://github.com/getsentry/sentry-cocoa.git | |
</p> | ||
), | ||
language: 'swift', | ||
loading: 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?.data?.['sentry.cocoa']?.version ?? '8.9.3' | ||
}"), | ||
`, | ||
}, | ||
], | ||
|
@@ -183,8 +187,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.
can we split this out into a diff PR?
This has a bit of security implications here so we probably want to review this on it's own