init static method

Future<void> init({
  1. required String dsn,
  2. AppRunner? runner,
  3. bool enable = true,
  4. BeforeSendCallback? beforeSendCallback,
})

初始化

Implementation

static Future<void> init({
  required String dsn,
  AppRunner? runner,
  bool enable = true,
  BeforeSendCallback? beforeSendCallback,
}) async {
  FutureOr<SentryEvent?> callback(SentryEvent event, Hint hint) async {
    if (enable && !isDev) {
      return beforeSendCallback?.call(event, hint);
    }
    return null;
  }

  await Sentry.init(
    (options) {
      options.dsn = enable
          ? dsn
          : 'https://c4fb50c137134764a44e95016ec946bc@o446222.ingest.sentry.io/6477389';
      options.beforeSend = callback;
      options.tracesSampleRate = 1;
    },
    appRunner: runner,
  );
}