Skip to main content

codeskop_tracker 0.4.0 copy "codeskop_tracker: ^0.4.0" to clipboard
codeskop_tracker: ^0.4.0 copied to clipboard

Codeskop SDK Flutter plugin — captures Dart and native failures and forwards them to the Codeskop ingest backend.

example/lib/main.dart

import 'package:codeskop_tracker/codeskop_tracker.dart';
import 'package:flutter/material.dart';

/// Codeskop Flutter plugin example. Boots the SDK inside a guarded zone (so uncaught
/// Dart errors are captured), initializes it against the ingest backend, and offers
/// buttons to exercise the capture paths: a handled Dart exception and an uncaught
/// Dart error. Native crashes underneath Flutter are captured by the native SDK itself.
void main() {
  Codeskop.runGuarded(() async {
    await Codeskop.init(
      apiKey: const String.fromEnvironment('CODESKOP_KEY', defaultValue: 'cs_test_pk_replace'),
      endpoint: const String.fromEnvironment('CODESKOP_ENDPOINT', defaultValue: 'https://api.codeskop.com'),
    );
    await Codeskop.identify('u_example');
    runApp(const ExampleApp());
  });
}

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Codeskop Example',
      // Named routes become `screen` events (with previous_screen added natively).
      navigatorObservers: [CodeskopNavigatorObserver()],
      home: Scaffold(
        appBar: AppBar(title: const Text('Codeskop Tracker')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () {
                  try {
                    throw StateError('handled example exception');
                  } catch (e, s) {
                    Codeskop.recordError(e, s, fatal: false);
                  }
                },
                child: const Text('Record handled exception'),
              ),
              ElevatedButton(
                // Mobile has no automatic tap capture: track the taps that matter.
                onPressed: () => Codeskop.track('login_failed',
                    properties: {'method': 'password', 'reason': 'invalid_password'},
                    category: 'identity'),
                child: const Text('Track login_failed (identity)'),
              ),
              ElevatedButton(
                onPressed: () => throw Exception('uncaught async Dart error'),
                child: const Text('Throw uncaught Dart error'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
483
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Codeskop SDK Flutter plugin — captures Dart and native failures and forwards them to the Codeskop ingest backend.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on codeskop_tracker

Packages that implement codeskop_tracker