Repository navigation
feat: Accept tunnel: true in init to enable the managed tunnel
#25200
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
Open
+449
−30
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7cc3b00
feat: Accept `tunnel: true` in `init` to enable the managed tunnel
logaretm 4911924
feat: Explain a managed tunnel that nothing on the server answers
logaretm d138861
fix(core): Keep the managed tunnel warning out of production bundles
logaretm f651a97
fix(aws-serverless): Keep the managed tunnel when the Lambda extensio…
logaretm 36c4a1a
fix(core): Point Next.js users to `tunnelRoute` when the managed tunn…
logaretm 5d4afe9
feat(browser): Send directly to Sentry when nothing answers the manag…
logaretm 5ebb8e9
fix(browser): Normalize the managed tunnel's base path like the serve…
logaretm 1f23d5a
fix(browser): Keep the managed tunnel when Sentry answers 404 or 405 …
logaretm 36dfaab
fix(browser): Send directly when anything but the tunnel answers a ma…
logaretm f0b532c
ref(browser): Warn about a rejected DSN from the managed tunnel trans…
logaretm 6f1d9c9
ref(browser): Switch the managed tunnel to direct sends in one place
logaretm e6ff11a
test(browser): Drop the server-side tunnel match from the browser tun…
logaretm 695feb9
ref(browser): Trim the managed tunnel comments
logaretm a90bd51
fix(aws-serverless): Keep the Lambda extension for a relative tunnel …
logaretm 8d266b5
ref: Import the internal tunnel helpers under their `_INTERNAL_` names
logaretm a80ac61
ref: Narrow `tunnel` to the browser or server tunnel options per SDK
logaretm ba73fb1
feat(browser): Treat a relative tunnel path as a managed one and only…
logaretm ee14703
ref(browser): Fold the managed tunnel fallback into the fetch transport
logaretm 9f5229d
fix(browser): Resend to Sentry after the tunnel request leaves the ke…
logaretm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import type { BrowserTunnelOptions } from '@sentry/core'; | ||
| import { | ||
| debug, | ||
| getEnvelopeEndpointWithUrlEncodedAuth, | ||
| getTunnelPath, | ||
| makeDsn, | ||
| _INTERNAL_normalizeTunnelBasePath as normalizeTunnelBasePath, | ||
| } from '@sentry/core'; | ||
| import { DEBUG_BUILD } from '../debug-build'; | ||
| import type { BrowserOptions } from '../client'; | ||
|
|
||
| /** | ||
| * Resolves `tunnel: true`, a relative path or {@link BrowserTunnelOptions} to the managed tunnel's same-origin path. | ||
| */ | ||
| export function resolveBrowserTunnelOption( | ||
| options: BrowserOptions, | ||
| ): Pick<BrowserOptions, 'transportOptions'> & { tunnel: string | undefined } { | ||
| const { tunnel, dsn, transportOptions } = options; | ||
| if (!tunnel || (typeof tunnel === 'string' && !tunnel.startsWith('/'))) { | ||
| return { tunnel, transportOptions }; | ||
| } | ||
|
|
||
| const tunnelOptions: BrowserTunnelOptions = | ||
| tunnel === true ? {} : typeof tunnel === 'string' ? { path: tunnel } : tunnel; | ||
| const dsnComponents = dsn && makeDsn(dsn); | ||
| const tunnelPath = tunnelOptions.path ?? (dsnComponents && getTunnelPath(dsnComponents)); | ||
| if (!tunnelPath) { | ||
| return { tunnel: undefined, transportOptions }; | ||
| } | ||
|
|
||
| const basePath = normalizeTunnelBasePath(tunnelOptions.basePath); | ||
| const resolvedTunnel = `${basePath}${tunnelPath}${tunnelOptions.trailingSlash ? '/' : ''}`; | ||
|
|
||
| DEBUG_BUILD && debug.log(`Tunneling events to "${resolvedTunnel}"`); | ||
|
|
||
| return { | ||
| tunnel: resolvedTunnel, | ||
| transportOptions: { | ||
| ...transportOptions, | ||
| _tunnelFallbackUrl: dsnComponents | ||
| ? getEnvelopeEndpointWithUrlEncodedAuth(dsnComponents, undefined, options._metadata?.sdk) | ||
| : undefined, | ||
| }, | ||
| }; | ||
| } | ||
|
logaretm marked this conversation as resolved.
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.