getsentry / getsentry/sentry-dart

Add rewrite frames integration

Open
#2,111 6 comments 0 reactions 0 assignees View on GitHub
Dart Errors Improvement
Dominant language
Dart
Stars
873
Forks
299
Avg merge
2d 7h
Merged PRs (30d)
30

Description

We could add a rewrite frames integration similar to [javascript]() that allows users to manipulate the frames in a specific way before sending them off.

### Examples of what it would solve

Relates to [https://github.com/getsentry/sentry-dart-plugin/pull/222]()

When users provide a `urlPrefix` with `sentry-dart-plugin` and `sentry-cli`, stack traces are not resolved correctly, as the path cant be found.

the stack trace abs path is `"http://localhost: 8900/main.dart`.
the uploaded file is `~/foo/main.dart` -> doesn't match

so you would need to rewrite the abs_path to the uploaded file to include the prefix.

With a rewrite frame integration it would be easy to do that.

### Alternatives

Use beforeSend code snippet

```dart
beforeSendCallback: (event, hint) async {
final exceptions = event.exceptions?.map((exception) {
final stackTrace = exception.stackTrace;
if (stackTrace != null) {
final frames = stackTrace.frames.map((frame) {
const baseUrl = 'https://example.com/';
final modifiedAbsPath = frame.absPath?.replaceFirst(baseUrl, '${baseUrl}my_prefix/');
return frame.copyWith(absPath: modifiedAbsPath);
}).toList();
return exception.copyWith(stackTrace: SentryStackTrace(frames: frames));
}
return exception;
}).toList() ?? [];
return event.copyWith(exceptions: exceptions);
});
```

### Demand

Please upvote if you are interested in such an integration

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.