Skip to content

Commit

Permalink
fix: Typo in constant name in @sentry/tracing
Browse files Browse the repository at this point in the history
defaultRequestInstrumentionOptions => defaultRequestInstrumentationOptions

The old name remains (temporarily?) for backwards compatibility, though
I suspect there is not much reason for user code to make reference to
that constant.
  • Loading branch information
rhcarvalho committed Nov 18, 2020
1 parent 73b9bbd commit 181af1c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/tracing/src/browser/browsertracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { extractTraceparentData, secToMs } from '../utils';
import { registerBackgroundTabDetection } from './backgroundtab';
import { MetricsInstrumentation } from './metrics';
import {
defaultRequestInstrumentionOptions,
defaultRequestInstrumentationOptions,
registerRequestInstrumentation,
RequestInstrumentationOptions,
} from './request';
Expand Down Expand Up @@ -90,7 +90,7 @@ const DEFAULT_BROWSER_TRACING_OPTIONS = {
routingInstrumentation: defaultRoutingInstrumentation,
startTransactionOnLocationChange: true,
startTransactionOnPageLoad: true,
...defaultRequestInstrumentionOptions,
...defaultRequestInstrumentationOptions,
};

/**
Expand Down Expand Up @@ -121,7 +121,7 @@ export class BrowserTracing implements Integration {
private readonly _emitOptionsWarning: boolean = false;

public constructor(_options?: Partial<BrowserTracingOptions>) {
let tracingOrigins = defaultRequestInstrumentionOptions.tracingOrigins;
let tracingOrigins = defaultRequestInstrumentationOptions.tracingOrigins;
// NOTE: Logger doesn't work in constructors, as it's initialized after integrations instances
if (
_options &&
Expand Down Expand Up @@ -152,7 +152,7 @@ export class BrowserTracing implements Integration {
'[Tracing] You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.',
);
logger.warn(
`[Tracing] We added a reasonable default for you: ${defaultRequestInstrumentionOptions.tracingOrigins}`,
`[Tracing] We added a reasonable default for you: ${defaultRequestInstrumentationOptions.tracingOrigins}`,
);
}

Expand Down
6 changes: 4 additions & 2 deletions packages/tracing/src/browser/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,19 @@ export interface XHRData {
endTimestamp?: number;
}

export const defaultRequestInstrumentionOptions: RequestInstrumentationOptions = {
export const defaultRequestInstrumentationOptions: RequestInstrumentationOptions = {
traceFetch: true,
traceXHR: true,
tracingOrigins: DEFAULT_TRACING_ORIGINS,
};
// deprecated, exported for backwards-compatibility
export const defaultRequestInstrumentionOptions = defaultRequestInstrumentationOptions;

/** Registers span creators for xhr and fetch requests */
export function registerRequestInstrumentation(_options?: Partial<RequestInstrumentationOptions>): void {
// eslint-disable-next-line @typescript-eslint/unbound-method
const { traceFetch, traceXHR, tracingOrigins, shouldCreateSpanForRequest } = {
...defaultRequestInstrumentionOptions,
...defaultRequestInstrumentationOptions,
..._options,
};

Expand Down
10 changes: 5 additions & 5 deletions packages/tracing/test/browser/browsertracing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getHeaderContext,
getMetaContent,
} from '../../src/browser/browsertracing';
import { defaultRequestInstrumentionOptions } from '../../src/browser/request';
import { defaultRequestInstrumentationOptions } from '../../src/browser/request';
import { defaultRoutingInstrumentation } from '../../src/browser/router';
import * as hubExtensions from '../../src/hubextensions';
import { DEFAULT_IDLE_TIMEOUT, IdleTransaction } from '../../src/idletransaction';
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('BrowserTracing', () => {
routingInstrumentation: defaultRoutingInstrumentation,
startTransactionOnLocationChange: true,
startTransactionOnPageLoad: true,
...defaultRequestInstrumentionOptions,
...defaultRequestInstrumentationOptions,
});
});

Expand Down Expand Up @@ -131,7 +131,7 @@ describe('BrowserTracing', () => {
});

expect(warnSpy).toHaveBeenCalledTimes(2);
expect(inst.options.tracingOrigins).toEqual(defaultRequestInstrumentionOptions.tracingOrigins);
expect(inst.options.tracingOrigins).toEqual(defaultRequestInstrumentationOptions.tracingOrigins);
});

it('warns and uses default tracing origins if empty array given', () => {
Expand All @@ -141,7 +141,7 @@ describe('BrowserTracing', () => {
});

expect(warnSpy).toHaveBeenCalledTimes(2);
expect(inst.options.tracingOrigins).toEqual(defaultRequestInstrumentionOptions.tracingOrigins);
expect(inst.options.tracingOrigins).toEqual(defaultRequestInstrumentationOptions.tracingOrigins);
});

it('warns and uses default tracing origins if tracing origins are not defined', () => {
Expand All @@ -151,7 +151,7 @@ describe('BrowserTracing', () => {
});

expect(warnSpy).toHaveBeenCalledTimes(2);
expect(inst.options.tracingOrigins).toEqual(defaultRequestInstrumentionOptions.tracingOrigins);
expect(inst.options.tracingOrigins).toEqual(defaultRequestInstrumentationOptions.tracingOrigins);
});

it('sets tracing origins if provided and does not warn', () => {
Expand Down

0 comments on commit 181af1c

Please sign in to comment.