8000 ref(nextjs): Remove `initDecider` (#3359) · szechyjs/sentry-javascript@db74d74 · GitHub
[go: up one dir, main page]

Skip to content

Commit db74d74

Browse files
ref(nextjs): Remove initDecider (getsentry#3359)
1 parent 9d96e00 commit db74d74

File tree

6 files changed

+30
-145
lines changed

6 files changed

+30
-145
lines changed

packages/nextjs/src/index.client.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { configureScope, init as reactInit } from '@sentry/react';
22

3-
import { InitDecider } from './utils/initDecider';
43
import { MetadataBuilder } from './utils/metadataBuilder';
54
import { NextjsOptions } from './utils/nextjsOptions';
65

@@ -10,16 +9,8 @@ export * from '@sentry/react';
109
export function init(options: NextjsOptions): void {
1110
const metadataBuilder = new MetadataBuilder(options, ['nextjs', 'react']);
1211
metadataBuilder.addSdkMetadata();
13-
const initDecider = new InitDecider(options);
14-
if (initDecider.shouldInitSentry()) {
15-
reactInit(options);
16-
configureScope(scope => {
17-
scope.setTag('runtime', 'browser');
18-
});
19-
} else {
20-
// eslint-disable-next-line no-console
21-
console.warn('[Sentry] Detected a non-production environment. Not initializing Sentry.');
22-
// eslint-disable-next-line no-console
23-
console.warn('[Sentry] To use Sentry also in development set `dev: true` in the options.');
24-
}
12+
reactInit(options);
13+
configureScope(scope => {
14+
scope.setTag('runtime', 'browser');
15+
});
2516
}

packages/nextjs/src/index.server.ts

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { RewriteFrames } from '@sentry/integrations';
22
import { configureScope, init as nodeInit } from '@sentry/node';
33

4-
import { InitDecider } from './utils/initDecider';
54
import { MetadataBuilder } from './utils/metadataBuilder';
65
import { NextjsOptions } from './utils/nextjsOptions';
76

@@ -17,33 +16,25 @@ const SOURCEMAP_FILENAME_REGEX = /^.*\/.next\//;
1716
export function init(options: NextjsOptions): void {
1817
const metadataBuilder = new MetadataBuilder(options, ['nextjs', 'node']);
1918
metadataBuilder.addSdkMetadata();
20-
const initDecider = new InitDecider(options);
21-
if (initDecider.shouldInitSentry()) {
22-
nodeInit({
23-
...options,
24-
// TODO: handle use cases when users provide integrations
25-
integrations: [
26-
new RewriteFrames({
27-
iteratee: frame => {
28-
try {
29-
if (frame.filename) {
30-
frame.filename = frame.filename.replace(SOURCEMAP_FILENAME_REGEX, 'app:///_next/');
31-
}
32-
} catch {
33-
//
19+
nodeInit({
20+
...options,
21+
// TODO: handle use cases when users provide integrations
22+
integrations: [
23+
new RewriteFrames({
24+
iteratee: frame => {
25+
try {
26+
if (frame.filename) {
27+
frame.filename = frame.filename.replace(SOURCEMAP_FILENAME_REGEX, 'app:///_next/');
3428
}
35-
return frame;
36-
},
37-
}),
38-
],
39-
});
40-
configureScope(scope => {
41-
scope.setTag('runtime', 'node');
42-
});
43-
} else {
44-
// eslint-disable-next-line no-console
45-
console.warn('[Sentry] Detected a non-production environment. Not initializing Sentry.');
46-
// eslint-disable-next-line no-console
47-
console.warn('[Sentry] To use Sentry also in development set `dev: true` in the options.');
48-
}
29+
} catch {
30+
//
31+
}
32+
return frame;
33+
},
34+
}),
35+
],
36+
});
37+
configureScope(scope => {
38+
scope.setTag('runtime', 'node');
39+
});
4940
}

packages/nextjs/src/utils/initDecider.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

packages/nextjs/src/utils/nextjsOptions.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,5 @@ import { BrowserOptions } from '@sentry/react';
33
import { Options } from '@sentry/types';
44

55
export interface NextjsOptions extends Options, BrowserOptions, NodeOptions {
6-
/**
7-
* A flag enabling the initialization of the SDK in development and other
8-
* non-production environments. By default, the SDK is only initialised in
9-
* production.
10-
*/
11-
dev?: boolean;
6+
// Add Next.js specific options here
127
}

packages/nextjs/test/initDecider.test.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

packages/nextjs/test/sample.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('sample test', () => {
2+
test('true is truthy', () => {
3+
expect(true).toBeTruthy();
4+
});
5+
});

0 commit comments

Comments
 (0)
0