Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ npx @sentry/migr8@latest

This will let you select which updates to run, and automatically update your code. Make sure to still review all code changes!

## Changed integration interface

In v8, integrations passed to a client will have an optional `setupOnce()` hook.
Currently, this hook is always present, but in v8 you will not be able to rely on this always existing anymore -
any integration _may_ have a `setup` and/or a `setupOnce` hook. Additionally, `setupOnce()` will not receive any arguments anymore.

This should not affect most people, but in the case that you are manually calling `integration.setupOnce()` right now,
make sure to guard it's existence properly.

## Deprecate `Hub`

The `Hub` has been a very important part of the Sentry SDK API up until now.
Expand Down
2 changes: 2 additions & 0 deletions packages/browser/src/integrations/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const breadcrumbsIntegration: IntegrationFn = (options: Partial<BreadcrumbsOptio

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
if (_options.console) {
addConsoleInstrumentationHandler(_getConsoleBreadcrumbHandler(client));
Expand Down
2 changes: 2 additions & 0 deletions packages/browser/src/integrations/dedupe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const dedupeIntegration: IntegrationFn = () => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(currentEvent) {
// We want to ignore any non-error type events, e.g. transactions or replays
// These should never be deduped, and also not be compared against as _previousEvent.
Expand Down
2 changes: 2 additions & 0 deletions packages/browser/src/integrations/httpcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const INTEGRATION_NAME = 'HttpContext';
const httpContextIntegration: IntegrationFn = () => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
preprocessEvent(event) {
// if none of the information we want exists, don't bother
if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {
Expand Down
2 changes: 2 additions & 0 deletions packages/browser/src/integrations/linkederrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const linkedErrorsIntegration: IntegrationFn = (options: LinkedErrorsOptions = {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
preprocessEvent(event, hint, client) {
const options = client.getOptions();

Expand Down
2 changes: 2 additions & 0 deletions packages/browser/src/profiling/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const INTEGRATION_NAME = 'BrowserProfiling';
const browserProfilingIntegration: IntegrationFn = () => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
const scope = getCurrentScope();

Expand Down
18 changes: 4 additions & 14 deletions packages/core/src/integration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Client, Event, EventHint, EventProcessor, Hub, Integration, IntegrationFn, Options } from '@sentry/types';
import type { Client, Event, EventHint, Integration, IntegrationFn, Options } from '@sentry/types';
import { arrayify, logger } from '@sentry/utils';

import { DEBUG_BUILD } from './debug-build';
Expand Down Expand Up @@ -171,26 +171,16 @@ export function convertIntegrationFnToClass<Fn extends IntegrationFn>(
fn: Fn,
): Integration & {
id: string;
new (...args: Parameters<Fn>): Integration &
ReturnType<Fn> & {
setupOnce: (addGlobalEventProcessor?: (callback: EventProcessor) => void, getCurrentHub?: () => Hub) => void;
};
new (...args: Parameters<Fn>): Integration & ReturnType<Fn>;
} {
return Object.assign(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function ConvertedIntegration(...rest: Parameters<Fn>) {
return {
// eslint-disable-next-line @typescript-eslint/no-empty-function
setupOnce: () => {},
...fn(...rest),
};
return fn(...rest);
},
{ id: name },
) as unknown as Integration & {
id: string;
new (...args: Parameters<Fn>): Integration &
ReturnType<Fn> & {
setupOnce: (addGlobalEventProcessor?: (callback: EventProcessor) => void, getCurrentHub?: () => Hub) => void;
};
new (...args: Parameters<Fn>): Integration & ReturnType<Fn>;
};
}
2 changes: 2 additions & 0 deletions packages/core/src/integrations/inboundfilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const INTEGRATION_NAME = 'InboundFilters';
const inboundFiltersIntegration: IntegrationFn = (options: Partial<InboundFiltersOptions>) => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event, _hint, client) {
const clientOptions = client.getOptions();
const mergedOptions = _mergeOptions(options, clientOptions);
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/integrations/linkederrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const linkedErrorsIntegration: IntegrationFn = (options: LinkedErrorsOptions = {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
preprocessEvent(event, hint, client) {
const options = client.getOptions();

Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/integrations/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const INTEGRATION_NAME = 'ModuleMetadata';
const moduleMetadataIntegration: IntegrationFn = () => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
if (typeof client.on !== 'function') {
return;
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/integrations/requestdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ const requestDataIntegration: IntegrationFn = (options: RequestDataIntegrationOp

return {
name: INTEGRATION_NAME,

// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event, _hint, client) {
// Note: In the long run, most of the logic here should probably move into the request data utility functions. For
// the moment it lives here, though, until https://github.com/getsentry/sentry-javascript/issues/5718 is addressed.
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/metrics/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const INTEGRATION_NAME = 'MetricsAggregator';
const metricsAggregatorIntegration: IntegrationFn = () => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client: BaseClient<ClientOptions>) {
client.metricsAggregator = new BrowserMetricsAggregator(client);
},
Expand Down
10 changes: 8 additions & 2 deletions packages/core/test/lib/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,10 @@ describe('addIntegration', () => {
describe('convertIntegrationFnToClass', () => {
/* eslint-disable deprecation/deprecation */
it('works with a minimal integration', () => {
const integrationFn = () => ({ name: 'testName' });
const integrationFn = () => ({
name: 'testName',
setupOnce: () => {},
});

const IntegrationClass = convertIntegrationFnToClass('testName', integrationFn);

Expand All @@ -663,7 +666,10 @@ describe('convertIntegrationFnToClass', () => {
});

it('works with options', () => {
const integrationFn = (_options: { num: number }) => ({ name: 'testName' });
const integrationFn = (_options: { num: number }) => ({
name: 'testName',
setupOnce: () => {},
});

const IntegrationClass = convertIntegrationFnToClass('testName', integrationFn);

Expand Down
2 changes: 2 additions & 0 deletions packages/deno/src/integrations/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ async function addDenoRuntimeContext(event: Event): Promise<Event> {
const denoContextIntegration: IntegrationFn = () => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event) {
return addDenoRuntimeContext(event);
},
Expand Down
2 changes: 2 additions & 0 deletions packages/deno/src/integrations/contextlines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const denoContextLinesIntegration: IntegrationFn = (options: ContextLinesOptions

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event) {
return addSourceContext(event, contextLines);
},
Expand Down
2 changes: 2 additions & 0 deletions packages/deno/src/integrations/globalhandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const globalHandlersIntegration: IntegrationFn = (options?: GlobalHandlersIntegr

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
if (_options.error) {
installGlobalErrorHandler(client);
Expand Down
2 changes: 2 additions & 0 deletions packages/deno/src/integrations/normalizepaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ const normalizePathsIntegration: IntegrationFn = () => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event) {
// This error.stack hopefully contains paths that traverse the app cwd
const error = new Error();
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/src/captureconsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const captureConsoleIntegration = ((options: CaptureConsoleOptions = {}) => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
if (!('console' in GLOBAL_OBJ)) {
return;
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/src/contextlines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const contextLinesIntegration: IntegrationFn = (options: ContextLinesOptions = {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event) {
return addSourceContext(event, contextLines);
},
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const debugIntegration = ((options: DebugOptions = {}) => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
if (!client.on) {
return;
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/src/dedupe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const dedupeIntegration = (() => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(currentEvent) {
// We want to ignore any non-error type events, e.g. transactions or replays
// These should never be deduped, and also not be compared against as _previousEvent.
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/src/extraerrordata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const extraErrorDataIntegration = ((options: Partial<ExtraErrorDataOptions> = {}

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event, hint) {
return _enhanceEventWithErrorData(event, hint, depth, captureErrorCause);
},
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/src/httpclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const httpClientIntegration = ((options: Partial<HttpClientOptions> = {}) => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client): void {
_wrapFetch(client, _options);
_wrapXHR(client, _options);
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/src/rewriteframes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ const rewriteFramesIntegration = ((options: RewriteFramesOptions = {}) => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(originalEvent) {
let processedEvent = originalEvent;

Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/src/sessiontiming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const sessionTimingIntegration = (() => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event) {
const now = Date.now();

Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const INTEGRATION_NAME = 'Transaction';
const transactionIntegration = (() => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event) {
const frames = _getFramesFromEvent(event);

Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/integrations/anr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const INTEGRATION_NAME = 'Anr';
const anrIntegration = ((options: Partial<Options> = {}) => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client: NodeClient) {
if (NODE_VERSION.major < 16 || (NODE_VERSION.major === 16 && NODE_VERSION.minor < 17)) {
throw new Error('ANR detection requires Node 16.17.0 or later');
Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/integrations/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const INTEGRATION_NAME = 'Console';
const consoleIntegration = (() => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
addConsoleInstrumentationHandler(({ args, level }) => {
if (getClient() !== client) {
Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/integrations/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ const contextIntegration = ((options: ContextOptions = {}) => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event) {
return addContext(event);
},
Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/integrations/contextlines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const contextLinesIntegration = ((options: ContextLinesOptions = {}) => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event) {
return addSourceContext(event, contextLines);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ export const localVariablesAsync: IntegrationFn = (options: Options = {}) => {

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client: NodeClient) {
const clientOptions = client.getOptions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ export const localVariablesSync: IntegrationFn = (

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client: NodeClient) {
const clientOptions = client.getOptions();

Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/integrations/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ function _getModules(): { [key: string]: string } {
const modulesIntegration = (() => {
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
processEvent(event) {
event.modules = {
...event.modules,
Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/integrations/onuncaughtexception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const onUncaughtExceptionIntegration = ((options: Partial<OnUncaughtExceptionOpt

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client: NodeClient) {
global.process.on('uncaughtException', makeErrorHandler(client, _options));
},
Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/integrations/onunhandledrejection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const onUnhandledRejectionIntegration = ((options: Partial<OnUnhandledRejectionO

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
global.process.on('unhandledRejection', makeUnhandledPromiseHandler(client, { mode }));
},
Expand Down
2 changes: 2 additions & 0 deletions packages/node/src/integrations/spotlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {}

return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
setup(client) {
if (typeof process === 'object' && process.env && process.env.NODE_ENV !== 'development') {
logger.warn("[Spotlight] It seems you're not in dev mode. Do you really want to have Spotlight enabled?");
Expand Down
Loading