sentry_file 6.19.0 icon indicating copy to clipboard operation
sentry_file: ^6.19.0 copied to clipboard

An integration which adds support for performance tracing for dart.io.File.


Sentry integration for dart.io.File #

packagebuildpublikespopularitypub points
sentry_filebuildpub packagelikespopularitypub points

Usage

  • Sign up for a Sentry.io account and get a DSN at https://sentry.io.

  • Follow the installing instructions on pub.flutter-io.cn.

  • Initialize the Sentry SDK using the DSN issued by Sentry.io.

  • Set Up Performance.

import 'package:sentry/sentry.dart';
import 'package:sentry_file/sentry_file.dart';
import 'dart:io';

Future<void> main() async {
  // or SentryFlutter.init
  await Sentry.init(
    (options) {
      options.dsn = 'https://example@sentry.io/example';
      // To set a uniform sample rate
      options.tracesSampleRate = 1.0;
    },
    appRunner: runApp, // Init your App.
  );
}

Future<void> runApp() async {
  final file = File('my_file.txt');
  // Call the Sentry extension method to wrap up the File
  final sentryFile = file.sentryTrace();

  // Start a transaction if there's no active transaction
  final transaction = Sentry.startTransaction(
    'MyFileExample',
    'file',
    bindToScope: true,
  );

  // create the File
  await sentryFile.create();
  // Write some content
  await sentryFile.writeAsString('Hello World');
  // Read the content
  final text = await sentryFile.readAsString();

  print(text);

  // Delete the file
  await sentryFile.delete();

  // Finish the transaction
  await transaction.finish(status: SpanStatus.ok());

  await Sentry.close();
}

Resources

  • Documentation
  • Forum
  • Discord
  • Stack Overflow
  • Twitter Follow
1
likes
140
pub points
18%
popularity

Publisher

verified publisher iconsentry.io

An integration which adds support for performance tracing for dart.io.File.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

meta, sentry

More

Packages that depend on sentry_file