File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
packages/browser/src/integrations Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ import type { Event , EventProcessor , Integration } from '@sentry/types' ;
2
+
3
+ interface ContextLinesOptions {
4
+ /**
5
+ * Sets the number of context lines for each frame when loading a file.
6
+ * Defaults to 7.
7
+ *
8
+ * Set to 0 to disable loading and inclusion of source files.
9
+ **/
10
+ frameContextLines ?: number ;
11
+ }
12
+
13
+ /**
14
+ * Collects source context lines around the line of a stackframe
15
+ * This integration only works for stack frames pointing to JS that's directly embedded
16
+ * in HTML files.
17
+ * It DOES NOT work for stack frames pointing to JS files that are loaded by the browser.
18
+ * For frames pointing to files, context lines are added during ingestino and symbolication
19
+ * by attempting to download the JS files to the Sentry backend.
20
+ */
21
+ export class ContextLines implements Integration {
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ public static id : string = 'ContextLines' ;
26
+
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ public name : string = ContextLines . id ;
31
+
32
+ public constructor (
33
+ private readonly _options : ContextLinesOptions = {
34
+ frameContextLines : 0 ,
35
+ } ,
36
+ ) { }
37
+
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ public setupOnce ( addGlobalEventProcessor : ( callback : EventProcessor ) => void ) : void {
42
+ addGlobalEventProcessor ( event => this . addSourceContext ( event ) ) ;
43
+ }
44
+
45
+ /** Processes an event and adds context lines */
46
+ public addSourceContext ( event : Event ) : Event {
47
+ return event ;
48
+ }
49
+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ export { Breadcrumbs } from './breadcrumbs';
4
4
export { LinkedErrors } from './linkederrors' ;
5
5
export { HttpContext } from './httpcontext' ;
6
6
export { Dedupe } from './dedupe' ;
7
+ export { ContextLines } from './contextlines' ;
You can’t perform that action at this time.
0 commit comments