File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { getCurrentHub } from '@sentry/core' ;
1
2
import { Event , EventProcessor , Integration } from '@sentry/types' ;
2
3
import { addContextToFrame } from '@sentry/utils' ;
3
4
import { readFile } from 'fs' ;
4
5
import { LRUMap } from 'lru_map' ;
5
6
7
+ import { NodeClient } from '../client' ;
8
+
6
9
const FILE_CONTENT_CACHE = new LRUMap < string , string | null > ( 100 ) ;
7
10
8
11
function readTextFileAsync ( path : string ) : Promise < string > {
@@ -44,12 +47,17 @@ export class ContextLines implements Integration {
44
47
* @inheritDoc
45
48
*/
46
49
public setupOnce ( addGlobalEventProcessor : ( callback : EventProcessor ) => void ) : void {
50
+ if ( this . _options . frameContextLines == undefined ) {
51
+ const initOptions = getCurrentHub ( ) . getClient < NodeClient > ( ) ?. getOptions ( ) ;
52
+ this . _options . frameContextLines = initOptions ?. frameContextLines ;
53
+ }
54
+
47
55
addGlobalEventProcessor ( event => this . addToEvent ( event ) ) ;
48
56
}
49
57
50
58
/** Processes an event and adds context lines */
51
59
public async addToEvent ( event : Event ) : Promise < Event > {
52
- const contextLines = this . _options . frameContextLines != undefined ? this . _options . frameContextLines : 7 ;
60
+ const contextLines = this . _options . frameContextLines == undefined ? 7 : this . _options . frameContextLines ;
53
61
54
62
const frames = event . exception ?. values ?. [ 0 ] . stacktrace ?. frames ;
55
63
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ export interface NodeOptions extends Options {
20
20
/** HTTPS proxy certificates path */
21
21
caCerts ?: string ;
22
22
23
+ /** Sets the number of context lines for each frame when loading a file. */
24
+ frameContextLines ?: number ;
25
+
23
26
/** Callback that is executed when a fatal global error occurs. */
24
27
onFatalError ?( error : Error ) : void ;
25
28
}
You can’t perform that action at this time.
0 commit comments