-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Add API class to help with endpoints #1459
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
Conversation
| } else { | ||
| dsn = new DSN(this.options.dsn); | ||
| // We do nothing in case there is no DSN | ||
| return { status: Status.Skipped }; |
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.
It'd be nice to provide a reason why we skip some of the events and use logger to let user know about it
packages/core/src/api.ts
Outdated
| const dsn = this.dsnObject; | ||
| const auth = { | ||
| sentry_key: dsn.user, | ||
| sentry_secret: '', |
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 drop it already?
packages/core/src/api.ts
Outdated
| } | ||
|
|
||
| /** Returns a string with auth headers in the url to the store endpoint. */ | ||
| public getStoreEndpoint(urlEncodedHeader: boolean = false): string { |
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.
Ughh... can't we just create a new method for this? I really don't like using boolean arguments to functions, as for people not using typescript, it provides no meaning before they dive into source code
| const dsn = this.dsnObject; | ||
| const header = [`Sentry sentry_version=${SENTRY_API_VERSION}`]; | ||
| header.push(`sentry_timestamp=${new Date().getTime()}`); | ||
| header.push(`sentry_client=${clientName}/${clientVersion}`); |
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.
here we use sentry_client and above we used sentry_version. We should unify it somehow.
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.
not really sure what you mean, we need sentry_client for sending a POST.
packages/core/src/api.ts
Outdated
| public getReportDialogEndpoint(dialogOptions: { [key: string]: any }): string { | ||
| const dsn = this.dsnObject; | ||
| const endpoint = `${this.getBaseUrl()}${dsn.path ? `/${dsn.path}` : ''}/api/embed/error-page/`; | ||
| if (dialogOptions) { |
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.
you can skip it and make dialogOptions = {} a default
| // Auth is intentionally sent as part of query string (NOT as custom HTTP header) | ||
| // to avoid preflight CORS requests | ||
| return `${endpoint}?${urlEncode(auth)}`; | ||
| this.url = new API(this.options.dsn).getStoreEndpoint(); |
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.
You default to false, but this url actually need headers (another reason to make it a separate method :p)
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.
Good catch, thx
Codecov Report
@@ Coverage Diff @@
## master #1459 +/- ##
==========================================
- Coverage 79.24% 72.61% -6.64%
==========================================
Files 50 41 -9
Lines 2024 1245 -779
Branches 466 237 -229
==========================================
- Hits 1604 904 -700
+ Misses 409 331 -78
+ Partials 11 10 -1Continue to review full report at Codecov.
|
No description provided.