Skip to content

Commit 1551b95

Browse files
committed
move tracing enablement check to tracing package
1 parent ee08ff0 commit 1551b95

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

packages/gatsby/gatsby-browser.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const Sentry = require('@sentry/react');
22
const Tracing = require('@sentry/tracing');
3-
const Utils = require('@sentry/utils')
43

54
exports.onClientEntry = function(_, pluginParams) {
65
if (pluginParams === undefined) {
@@ -9,7 +8,7 @@ exports.onClientEntry = function(_, pluginParams) {
98

109
const integrations = [...(pluginParams.integrations || [])];
1110

12-
if (Utils.hasTracingEnabled(pluginParams) && !integrations.some(ele => ele.name === 'BrowserTracing')) {
11+
if (Tracing.hasTracingEnabled(pluginParams) && !integrations.some(ele => ele.name === 'BrowserTracing')) {
1312
integrations.push(new Tracing.Integrations.BrowserTracing(pluginParams.browserTracingOptions));
1413
}
1514

packages/gatsby/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
},
2828
"dependencies": {
2929
"@sentry/react": "5.22.3",
30-
"@sentry/tracing": "5.22.3",
31-
"@sentry/utils": "5.22.3"
30+
"@sentry/tracing": "5.22.3"
3231
},
3332
"peerDependencies": {
3433
"gatsby": "*"

packages/tracing/src/hubextensions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
dynamicRequire,
55
extractNodeRequestData,
66
getGlobalObject,
7-
hasTracingEnabled,
87
isInstanceOf,
98
isNodeEnv,
109
logger,
@@ -13,6 +12,7 @@ import {
1312
import { registerErrorInstrumentation } from './errors';
1413
import { IdleTransaction } from './idletransaction';
1514
import { Transaction } from './transaction';
15+
import { hasTracingEnabled } from './utils';
1616

1717
/** Returns all trace headers that are currently on the top scope. */
1818
function traceHeaders(this: Hub): { [key: string]: string } {

packages/tracing/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ export { SpanStatus } from './spanstatus';
1414
addExtensionMethods();
1515

1616
export { addExtensionMethods };
17+
18+
export * from './utils';

packages/tracing/src/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Options } from '@sentry/types';
2+
3+
/**
4+
* Determines if tracing is currently enabled.
5+
*
6+
* Tracing is enabled when at least one of `tracesSampleRate` and `tracesSampler` is defined in the SDK config.
7+
*/
8+
export function hasTracingEnabled(options: Options): boolean {
9+
return 'tracesSampleRate' in options || 'tracesSampler' in options;
10+
}

packages/utils/src/misc.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { Event, Integration, Options, StackFrame, WrappedFunction } from '@sentry/types';
2+
import { Event, Integration, StackFrame, WrappedFunction } from '@sentry/types';
33

44
import { dynamicRequire, isNodeEnv } from './node';
55
import { snipLine } from './string';
@@ -375,12 +375,3 @@ export function addContextToFrame(lines: string[], frame: StackFrame, linesOfCon
375375
.slice(Math.min(sourceLine + 1, maxLines), sourceLine + 1 + linesOfContext)
376376
.map((line: string) => snipLine(line, 0));
377377
}
378-
379-
/**
380-
* Determines if tracing is currently enabled.
381-
*
382-
* Tracing is enabled when at least one of `tracesSampleRate` and `tracesSampler` is defined in the SDK config.
383-
*/
384-
export function hasTracingEnabled(options: Options): boolean {
385-
return !!options.tracesSampleRate || !!options.tracesSampler;
386-
}

0 commit comments

Comments
 (0)