Skip to content

Commit 9bb41df

Browse files
authored
feat(node): Use includeLocalVariables option to enable LocalVariables integration (#6874)
1 parent 6bf1964 commit 9bb41df

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const Sentry = require('@sentry/node');
33

44
Sentry.init({
55
dsn: 'https://[email protected]/1337',
6-
_experiments: { includeStackLocals: true },
6+
includeLocalVariables: true,
77
beforeSend: event => {
88
// eslint-disable-next-line no-console
99
console.log(JSON.stringify(event));

packages/node/src/integrations/localvariables.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
import type {
2-
ClientOptions,
3-
Event,
4-
EventProcessor,
5-
Exception,
6-
Hub,
7-
Integration,
8-
StackFrame,
9-
StackParser,
10-
} from '@sentry/types';
1+
import type { Event, EventProcessor, Exception, Hub, Integration, StackFrame, StackParser } from '@sentry/types';
112
import type { Debugger, InspectorNotification, Runtime, Session } from 'inspector';
123
import { LRUMap } from 'lru_map';
134

5+
import type { NodeClientOptions } from '../types';
6+
147
export interface DebugSession {
158
/** Configures and connects to the debug session */
169
configureAndConnect(onPause: (message: InspectorNotification<Debugger.PausedEventDataType>) => void): void;
@@ -198,9 +191,9 @@ export class LocalVariables implements Integration {
198191
/** Setup in a way that's easier to call from tests */
199192
private _setup(
200193
addGlobalEventProcessor: (callback: EventProcessor) => void,
201-
clientOptions: ClientOptions | undefined,
194+
clientOptions: NodeClientOptions | undefined,
202195
): void {
203-
if (this._session && clientOptions?._experiments?.includeStackLocals) {
196+
if (this._session && clientOptions?.includeLocalVariables) {
204197
this._session.configureAndConnect(ev =>
205198
this._handlePaused(clientOptions.stackParser, ev as InspectorNotification<PausedExceptionEvent>),
206199
);

packages/node/src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ export interface BaseNodeOptions {
1111
/** Sets an optional server name (device name) */
1212
serverName?: string;
1313

14+
/**
15+
* Include local variables with stack traces.
16+
*
17+
* Requires the `LocalVariables` integration.
18+
*/
19+
includeLocalVariables?: boolean;
20+
1421
// TODO (v8): Remove this in v8
1522
/**
1623
* @deprecated Moved to constructor options of the `Http` integration.

packages/node/test/integrations/localvariables.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('LocalVariables', () => {
114114
const localVariables = new LocalVariables({}, session);
115115
const options = getDefaultNodeClientOptions({
116116
stackParser: defaultStackParser,
117-
_experiments: { includeStackLocals: true },
117+
includeLocalVariables: true,
118118
});
119119

120120
let eventProcessor: EventProcessor | undefined;
@@ -210,7 +210,7 @@ describe('LocalVariables', () => {
210210
const localVariables = new LocalVariables({}, session);
211211
const options = getDefaultNodeClientOptions({
212212
stackParser: defaultStackParser,
213-
_experiments: { includeStackLocals: true },
213+
includeLocalVariables: true,
214214
});
215215

216216
(localVariables as unknown as LocalVariablesPrivate)._setup(_ => {}, options);
@@ -232,7 +232,6 @@ describe('LocalVariables', () => {
232232
const localVariables = new LocalVariables({}, session);
233233
const options = getDefaultNodeClientOptions({
234234
stackParser: defaultStackParser,
235-
_experiments: { includeStackLocals: false },
236235
});
237236

238237
let eventProcessor: EventProcessor | undefined;
@@ -250,7 +249,6 @@ describe('LocalVariables', () => {
250249
const localVariables = new LocalVariables({}, undefined);
251250
const options = getDefaultNodeClientOptions({
252251
stackParser: defaultStackParser,
253-
_experiments: { includeStackLocals: false },
254252
});
255253

256254
let eventProcessor: EventProcessor | undefined;
@@ -272,7 +270,7 @@ describe('LocalVariables', () => {
272270
const localVariables = new LocalVariables({}, session);
273271
const options = getDefaultNodeClientOptions({
274272
stackParser: defaultStackParser,
275-
_experiments: { includeStackLocals: true },
273+
includeLocalVariables: true,
276274
});
277275

278276
(localVariables as unknown as LocalVariablesPrivate)._setup(_ => {}, options);

0 commit comments

Comments
 (0)