Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add extension
  • Loading branch information
marandaneto committed Dec 5, 2022
commit 13124533c313d6b4ba737908e1a05639a806e327
1 change: 1 addition & 0 deletions file/lib/sentry_file.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export 'src/sentry_file.dart';
export 'src/sentry_file_extension.dart';
15 changes: 15 additions & 0 deletions file/lib/src/sentry_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ import 'package:sentry/sentry.dart';

typedef Callback<T> = FutureOr<T> Function();

/// The Sentry wrapper for the File implementation that starts a span
/// out of the active transaction in the scope.
/// The span is started before the operation is executed and finished after.
/// Example:
///
/// ```dart
/// final file = File('test.txt');
/// final sentryFile = SentryFile(file);
/// // span starts
/// await sentryFile.writeAsString('Hello World');
/// // span finishes
/// ```
///
/// All the copy, create, delete, open, rename, read, and write operations are
/// supported.
class SentryFile implements File {
SentryFile(
this._file, {
Expand Down
24 changes: 24 additions & 0 deletions file/lib/src/sentry_file_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'dart:io';

import '../sentry_file.dart';

extension SentryFileExtension on File {
/// The Sentry wrapper for the File implementation that starts a span
/// out of the active transaction in the scope.
/// The span is started before the operation is executed and finished after.
/// Example:
///
/// ```dart
/// final file = File('test.txt');
/// final sentryFile = file.sentryTrace();
/// // span starts
/// await sentryFile.writeAsString('Hello World');
/// // span finishes
/// ```
///
/// All the copy, create, delete, open, rename, read, and write operations are
/// supported.
SentryFile sentryTrace() {
return SentryFile(this);
}
}