-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref(grouping): remove line and column numbers from similar issues stacktrace diff #97536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import type {ExceptionValue, Frame} from 'sentry/types/event'; | |
import type {StacktraceType} from 'sentry/types/stacktrace'; | ||
import {defined} from 'sentry/utils'; | ||
|
||
function getJavaScriptFrame(frame: Frame): string { | ||
function getJavaScriptFrame(frame: Frame, includeLocation = true): string { | ||
let result = ''; | ||
if (defined(frame.function)) { | ||
result += ' at ' + frame.function + '('; | ||
|
@@ -15,17 +15,17 @@ function getJavaScriptFrame(frame: Frame): string { | |
} else if (defined(frame.module)) { | ||
result += frame.module; | ||
} | ||
if (defined(frame.lineNo) && frame.lineNo >= 0) { | ||
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) { | ||
result += ':' + frame.lineNo; | ||
} | ||
if (defined(frame.colNo) && frame.colNo >= 0) { | ||
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) { | ||
result += ':' + frame.colNo; | ||
} | ||
result += ')'; | ||
return result; | ||
} | ||
|
||
function getRubyFrame(frame: Frame): string { | ||
function getRubyFrame(frame: Frame, includeLocation = true): string { | ||
let result = ' from '; | ||
if (defined(frame.filename)) { | ||
result += frame.filename; | ||
|
@@ -34,10 +34,10 @@ function getRubyFrame(frame: Frame): string { | |
} else { | ||
result += '?'; | ||
} | ||
if (defined(frame.lineNo) && frame.lineNo >= 0) { | ||
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) { | ||
result += ':' + frame.lineNo; | ||
} | ||
if (defined(frame.colNo) && frame.colNo >= 0) { | ||
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) { | ||
result += ':' + frame.colNo; | ||
} | ||
if (defined(frame.function)) { | ||
|
@@ -46,12 +46,17 @@ function getRubyFrame(frame: Frame): string { | |
return result; | ||
} | ||
|
||
function getPHPFrame(frame: Frame, idx: number): string { | ||
function getPHPFrame(frame: Frame, idx: number, includeLocation = true): string { | ||
const funcName = frame.function === 'null' ? '{main}' : frame.function; | ||
return `#${idx} ${frame.filename || frame.module}(${frame.lineNo}): ${funcName}`; | ||
let result = `#${idx} ${frame.filename || frame.module}`; | ||
if (includeLocation && defined(frame.lineNo) && frame.lineNo >= 0) { | ||
result += `(${frame.lineNo})`; | ||
} | ||
result += `: ${funcName}`; | ||
return result; | ||
} | ||
|
||
function getPythonFrame(frame: Frame): string { | ||
function getPythonFrame(frame: Frame, includeLocation = true): string { | ||
let result = ''; | ||
if (defined(frame.filename)) { | ||
result += ' File "' + frame.filename + '"'; | ||
|
@@ -60,10 +65,10 @@ function getPythonFrame(frame: Frame): string { | |
} else { | ||
result += ' ?'; | ||
} | ||
if (defined(frame.lineNo) && frame.lineNo >= 0) { | ||
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) { | ||
result += ', line ' + frame.lineNo; | ||
} | ||
if (defined(frame.colNo) && frame.colNo >= 0) { | ||
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) { | ||
result += ', col ' + frame.colNo; | ||
} | ||
if (defined(frame.function)) { | ||
|
@@ -79,7 +84,7 @@ function getPythonFrame(frame: Frame): string { | |
return result; | ||
} | ||
|
||
export function getJavaFrame(frame: Frame): string { | ||
export function getJavaFrame(frame: Frame, includeLocation = true): string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function is only called in this file and in tests, lets make includeLocation a required parameter and update the tests. I'd do the same with the other functions. Adding a test in |
||
let result = ' at'; | ||
|
||
if (defined(frame.module)) { | ||
|
@@ -90,15 +95,19 @@ export function getJavaFrame(frame: Frame): string { | |
} | ||
if (defined(frame.filename)) { | ||
result += '(' + frame.filename; | ||
if (defined(frame.lineNo) && frame.lineNo >= 0) { | ||
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) { | ||
result += ':' + frame.lineNo; | ||
} | ||
result += ')'; | ||
} | ||
return result; | ||
} | ||
|
||
function getDartFrame(frame: Frame, frameIdxFromEnd: number): string { | ||
function getDartFrame( | ||
frame: Frame, | ||
frameIdxFromEnd: number, | ||
includeLocation = true | ||
): string { | ||
let result = ` #${frameIdxFromEnd}`; | ||
|
||
if (frame.function === '<asynchronous suspension>') { | ||
|
@@ -112,10 +121,10 @@ function getDartFrame(frame: Frame, frameIdxFromEnd: number): string { | |
result += ' ('; | ||
|
||
result += frame.absPath; | ||
if (defined(frame.lineNo) && frame.lineNo >= 0) { | ||
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) { | ||
result += ':' + frame.lineNo; | ||
} | ||
if (defined(frame.colNo) && frame.colNo >= 0) { | ||
if (defined(frame.colNo) && frame.colNo >= 0 && includeLocation) { | ||
result += ':' + frame.colNo; | ||
} | ||
|
||
|
@@ -129,7 +138,7 @@ function ljust(str: string, len: number) { | |
return str + new Array(Math.max(0, len - str.length) + 1).join(' '); | ||
} | ||
|
||
function getNativeFrame(frame: Frame): string { | ||
function getNativeFrame(frame: Frame, includeLocation = true): string { | ||
let result = ' '; | ||
if (defined(frame.package)) { | ||
result += ljust(trimPackage(frame.package), 20); | ||
|
@@ -140,7 +149,7 @@ function getNativeFrame(frame: Frame): string { | |
result += ' ' + (frame.function || frame.symbolAddr); | ||
if (defined(frame.filename)) { | ||
result += ' (' + frame.filename; | ||
if (defined(frame.lineNo) && frame.lineNo >= 0) { | ||
if (defined(frame.lineNo) && frame.lineNo >= 0 && includeLocation) { | ||
result += ':' + frame.lineNo; | ||
} | ||
result += ')'; | ||
|
@@ -169,40 +178,42 @@ function getFrame( | |
frame: Frame, | ||
frameIdx: number, | ||
frameIdxFromEnd: number, | ||
platform: string | undefined | ||
platform: string | undefined, | ||
includeLocation = true | ||
): string { | ||
if (frame.platform) { | ||
platform = frame.platform; | ||
} | ||
switch (platform) { | ||
case 'javascript': | ||
return getJavaScriptFrame(frame); | ||
return getJavaScriptFrame(frame, includeLocation); | ||
case 'ruby': | ||
return getRubyFrame(frame); | ||
return getRubyFrame(frame, includeLocation); | ||
case 'php': | ||
return getPHPFrame(frame, frameIdx); | ||
return getPHPFrame(frame, frameIdx, includeLocation); | ||
case 'python': | ||
return getPythonFrame(frame); | ||
return getPythonFrame(frame, includeLocation); | ||
case 'java': | ||
return getJavaFrame(frame); | ||
return getJavaFrame(frame, includeLocation); | ||
case 'dart': | ||
return getDartFrame(frame, frameIdxFromEnd); | ||
return getDartFrame(frame, frameIdxFromEnd, includeLocation); | ||
case 'objc': | ||
// fallthrough | ||
case 'cocoa': | ||
// fallthrough | ||
case 'native': | ||
return getNativeFrame(frame); | ||
return getNativeFrame(frame, includeLocation); | ||
default: | ||
return getPythonFrame(frame); | ||
return getPythonFrame(frame, includeLocation); | ||
} | ||
} | ||
|
||
export default function displayRawContent( | ||
data: StacktraceType | null, | ||
platform?: string, | ||
exception?: ExceptionValue, | ||
hasSimilarityEmbeddingsFeature = false | ||
hasSimilarityEmbeddingsFeature = false, | ||
includeLocation = true | ||
) { | ||
const rawFrames = data?.frames || []; | ||
|
||
|
@@ -214,7 +225,13 @@ export default function displayRawContent( | |
: rawFrames; | ||
|
||
const frames = framesToUse.map((frame, frameIdx) => | ||
getFrame(frame, frameIdx, framesToUse.length - frameIdx - 1, platform) | ||
getFrame( | ||
frame, | ||
frameIdx, | ||
framesToUse.length - frameIdx - 1, | ||
platform, | ||
includeLocation | ||
) | ||
); | ||
|
||
if (platform !== 'python') { | ||
|
Uh oh!
There was an error while loading. Please reload this page.