-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(solidstart): Add
browserTracingIntegration
by default
- Loading branch information
1 parent
f452423
commit 411942d
Showing
2 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,17 +1,42 @@ | ||
import { applySdkMetadata } from '@sentry/core'; | ||
import type { BrowserOptions } from '@sentry/solid'; | ||
import { init as initSolidSDK } from '@sentry/solid'; | ||
import type { Client } from '@sentry/types'; | ||
import { | ||
browserTracingIntegration, | ||
getDefaultIntegrations as getDefaultSolidIntegrations, | ||
init as initSolidSDK, | ||
} from '@sentry/solid'; | ||
import type { Client, Integration } from '@sentry/types'; | ||
|
||
// Treeshakable guard to remove all code related to tracing | ||
declare const __SENTRY_TRACING__: boolean; | ||
|
||
/** | ||
* Initializes the client side of the Solid Start SDK. | ||
*/ | ||
export function init(options: BrowserOptions): Client | undefined { | ||
const opts = { | ||
defaultIntegrations: getDefaultIntegrations(options), | ||
...options, | ||
}; | ||
|
||
applySdkMetadata(opts, 'solidstart', ['solidstart', 'solid']); | ||
|
||
return initSolidSDK(opts); | ||
} | ||
|
||
function getDefaultIntegrations(options: BrowserOptions): Integration[] { | ||
// This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false", | ||
// in which case everything inside will get tree-shaken away | ||
const integrations = getDefaultSolidIntegrations(options); | ||
|
||
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) { | ||
// We add the default BrowserTracingIntegration here always. | ||
// We can do this, even if `solidRouterBrowserTracingIntegration` is | ||
// supplied as integration in `init` by users because it will win | ||
// over the default integration by virtue of having the same | ||
// `BrowserTracing` integration name and being added later. | ||
integrations.push(browserTracingIntegration()); | ||
} | ||
|
||
return integrations; | ||
} |
This file contains 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