crashops 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 60

CrashOps Plugin for Flutter #

License: MIT

This Flutter plugin helps to bridge with the CrashOps native SDK. CrashOps SDK helps you monitor your Flutter app's native crashes (we will add support for Flutter errors as well in the future versions).

Installation #

Easiest to install, it's a plug n' play plugin. All you need to do is add this dependency ("crashops_flutter") and the SDK will automatically start monitoring after each application launch.

Install by adding crashops to your pubspec.yaml file, for example:

dependencies:
  flutter:
    sdk: flutter
...
  crashops: any
...

Usage #

<TODO: Add informative instructions>

Don't have Flutter yet? #

plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

TODO #

Go live :)

Our SDK is still under development, stay tuned: CrashOps.com

0.0.1 #

  • First version ever - it's a plug n' play plugin that initiates our native SDK, it will simply wait for app crash and report on next app lunch. The client ID may be supplied via code or the config file (for more info see our docs).

0.0.2 #

  • Renamed: "crashops_flutter" => "crashops". Added plain test.

0.0.3 #

  • Improving plugin by following "pub.dev" analysis recommendations

example/lib/main.dart

import 'dart:async';
import 'dart:io';

import 'package:crashops/crashops.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  // Catching errors in Flutter actually depends on the Flutter developer.
  // We simply store it in our servers and will let you know.
  var onError = FlutterError.onError;
  CrashOps crashOps = CrashOps();
  FlutterError.onError = (FlutterErrorDetails details) {
    crashOps.onError(details);
    FlutterError.dumpErrorToConsole(details, forceReport: false);
    if (onError != null && FlutterError.dumpErrorToConsole != onError) {
      onError(details);
    }
  };

  // From: https://flutter.dev/docs/cookbook/maintenance/error-reporting
  runZoned(() {
    runApp(MyApp());
  }, onError: (error, stackTrace) {
    // This catches also Dart errors, not only Flutter errors.
    // More details here: https://github.com/flutter/flutter/issues/11206
    crashOps.onError(error, stackTrace);

    if (error is FlutterErrorDetails) {
      FlutterErrorDetails details = error;

      FlutterError.dumpErrorToConsole(details, forceReport: false);
      if (onError != null && FlutterError.dumpErrorToConsole != onError) {
        onError(details);
      }
    }
  });
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final CrashOps crashOps = CrashOps();
  bool _isCrashOpsEnabled;

  @override
  void initState() {
    super.initState();

    crashOps.isEnabledInDebugMode = true;

    try {
      // Platform messages may fail, so we use a try/catch PlatformException.
      crashOps.setClientId(
          "the-client-id-you-received-from-crashops-customer-support");
      crashOps.setMetadata({"yo": "that's my awesome app!"});
    } on PlatformException {
      print("Error!");
    }
  }

  @override
  Widget build(BuildContext context) {
    // Platform messages are asynchronous, so we initialize in an async method.
    if (_isCrashOpsEnabled == null) {
      crashOps.isEnabled.then((isOn) {
        _isCrashOpsEnabled = isOn;
        setState(() {});
      });

      return Container();
    }

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('CrashOps plugin example host app'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text('Running on: ${Platform.operatingSystem}\n'),
              RaisedButton(
                onPressed: () async {
                  _isCrashOpsEnabled = await crashOps.isEnabled;
                  bool didUpdate =
                      await crashOps.setEnabled(!_isCrashOpsEnabled);
//                  didUpdate = await crashOps.setClientId("perry");
//                  didUpdate = await crashOps.setMetadata({"yo": "perry"});

                  print("didUpdate: $didUpdate");

                  if (didUpdate) {
                    _isCrashOpsEnabled = await crashOps.isEnabled;
                    setState(() {});
                  }
                },
                child: Text(_isCrashOpsEnabled ? "enabled" : "disabled"),
              ),
              RaisedButton(
                onPressed: () async {
                  String nullString;
                  print(nullString.split("nonce").toString());
                },
                child: Text("cause problem! 😱"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  crashops: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:crashops/crashops.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
24
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
60
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/crashops.dart.

Run flutter format to format lib/crashops.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
stack_trace ^1.9.3 1.9.3
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test