Skip to content

Commit a8b0660

Browse files
committed
fix: improve in-app detection
1 parent e280b87 commit a8b0660

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Revision history for Sentry-SDK
33

44
{{$NEXT}}
55

6+
- Fixed app detection.
7+
68
1.3.7 2024-11-18 15:54:49 CET
79

810
- Fixed app detection.

lib/Sentry/Stacktrace/Frame.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ has _source_file_registry => sub { Sentry::SourceFileRegistry->new };
1212
has _home => sub { Mojo::Home->new->detect };
1313

1414
sub _is_in_app ($self) {
15-
return
16-
$self->filename !~ /\.cpan\//
17-
&& index($self->filename, $Config{siteprefix}) == -1
18-
&& index($self->filename, $self->_home) > -1;
15+
return substr($self->filename, 0, 1) ne '/'
16+
|| ( $self->filename !~ /\.cpan\//
17+
&& index($self->filename, $Config{siteprefix}) == -1
18+
&& index($self->filename, $self->_home) > -1);
1919
}
2020

2121
sub _map_file_to_context ($self) {

t/stacktrace-frame.t

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ describe 'Sentry::Stacktrace::Frame' => sub {
4444
ok !$frame_json->{in_app};
4545
};
4646

47+
it 'correctly identifies local frames as in-app' => sub {
48+
$frame->filename('lib/My/Module.pm');
49+
$frame_json = Mojo::JSON::decode_json Mojo::JSON::encode_json $frame;
50+
ok $frame_json->{in_app};
51+
};
52+
4753
it 'has file context' => sub {
4854
is $frame_json->{pre_context}, 'pre context';
4955
is $frame_json->{context_line}, 'context line';

0 commit comments

Comments
 (0)