Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Sentry: Add resolved url tag#600
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
0539a051d000ada2cf6142d0b9a87e1519e16b6857File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { GetServerSideProps } from 'next'; | ||
| import { logAsync } from '@ifixit/helpers'; | ||
| import { setSentryPageContext } from '@ifixit/sentry'; | ||
| export function serverSidePropsWrapper<T>( | ||
| getServerSidePropsInternal: GetServerSideProps<T> | ||
| ): GetServerSideProps<T> { | ||
| return async (context) => { | ||
| return logAsync('getServerSideProps', () => | ||
| getServerSidePropsInternal(context) | ||
| ).catch((err) => { | ||
| setSentryPageContext(context); | ||
| throw err; | ||
| }); | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,6 @@ | ||||||||||||||||||
| import { GetServerSidePropsContext } from 'next'; | ||||||||||||||||||
| export function urlFromContext(context: GetServerSidePropsContext): string { | ||||||||||||||||||
| const protocol = context.req.headers.referer?.split('://')[0] || 'https'; | ||||||||||||||||||
| return `${protocol}://${context.req.headers.host}${context.resolvedUrl}`; | ||||||||||||||||||
| } | ||||||||||||||||||
Comment on lines
+3
to
+6
Member 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. You could use the actual URL object. I know you may toString it later, but the class may be nice down the road
Suggested change
ContributorAuthor 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 agree, but we use string urls throughout most of this app unfortunately, so this would be a more siginificant refactor if we were to do it right. I'd rather leave it to another pull. | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "extends": "@ifixit/tsconfig/base.json", | ||
| "extends": "@ifixit/tsconfig/react-library.json", | ||
| "include": ["."], | ||
| "exclude": ["dist", "build", "node_modules"] | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
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.
FYI I didn't include this in
@ifixit/helpers/nextjsbecause doing so would cause a cyclic dependency between@ifixit/sentryand@ifixit/helpers.