analytics_event_gen 0.1.2

  • Readme
  • Changelog
  • Installing
  • 62

analytics_events_gen #

An easy generator for tracking firebase analytics events via type safe methods.

Add to pubspec.yaml #

Check pub for the latest version: Pub

dependencies:
  # ...
  analytics_event_gen: 0.1.0
dev_dependencies:
  # include build_runner, only used for code generation.
  build_runner: ^1.6.5

Create AnalyticsEvents class: #

// analytics.dart

import 'package:analytics_event_gen/analytics_event_gen.dart';

// this file will be generated.
part 'analytics.g.dart';

class MyAnalyticsBloc {
  MyAnalyticsBloc() {
    // initialize generated events class implementation.
    // the generated code will simply transform the method name
    // into an `eventName` and pass it to your callback method.
    // you can then do whatever you want with it, e.g. send to 
    // firebase analytics.
    events.registerTracker((eventName, params) {
      FirebaseAnalytics().logEvent(name: event, parameters: params);
    });
  }
  
  final events = _$AnalyticsEvents();
}

abstract class AnalyticsEvents implements AnalyticsEventStubs {
  void trackMyUserInteraction({double myProp, String yourProp});
}

Run the build generator #

# For flutter projects
flutter pub pub run build_runner build --delete-conflicting-outputs

# For dart projects
pub run build_runner build --delete-conflicting-outputs

[0.1.2] #

  • Support for required arguments
  • Support for named arguments with default values.

[0.1.1+1] #

  • Also remove _track from event name.

[0.1.1] #

  • Separate analytics_event from the source generator analytics_event_gen

[0.1.0+1] #

  • Added example, more documentation.

[0.1.0] #

  • Filter out abstract methods.

[0.0.1] - Initial Release #

Use this package as a library

1. Depend on it

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


dependencies:
  analytics_event_gen: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:analytics_event_gen/analytics_event_gen.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
28
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]
62
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and analytics_event_gen.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
analytics_event >=0.1.2 <1.0.0 0.1.2
analyzer >=0.39.6 <1.0.0 0.39.13
build >=1.2.2 <2.0.0 1.3.0
built_collection >=4.3.2 <5.0.0 4.3.2
code_builder >=3.2.1 <4.0.0 3.4.0
dart_style >=1.3.4 <2.0.0 1.3.6
source_gen >=0.9.5 <1.0.0 0.9.6
Transitive dependencies
_fe_analyzer_shared 5.0.0
args 1.6.0
async 2.4.2
built_value 7.1.0
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
fixnum 0.10.11
glob 1.2.0
html 0.14.0+3
js 0.6.2
logging 0.11.4
matcher 0.12.9
meta 1.2.2 1.3.0-nullsafety
node_interop 1.1.1
node_io 1.1.1
package_config 1.9.3
path 1.7.0
pub_semver 1.4.4
quiver 2.1.3
source_span 1.7.0
stack_trace 1.9.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0 1.3.0-nullsafety
watcher 0.9.7+15
yaml 2.2.1
Dev dependencies
build_runner ^1.10.0
pedantic ^1.9.0 1.9.2