amplitude_flutter 1.1.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 95

amplitude_flutter #

pub package

The Official Amplitude Flutter plugin. Used to track events with Amplitude.

Getting Started #

To use this plugin, add amplitude_flutter as a dependency in your pubspec.yaml file.

Find the API key for your Amplitude project under your project settings.

Import package:amplitude_flutter/amplitude_flutter.dart, and instantiate AmplitudeFlutter with your API key.

In the example below - replace the string API_KEY with your API Key.

In addition, a Config object can be passed as a constructor argument for additional options. NOTE: This plugin's methods should only be called from the main isolate.

Adding Carrier Information #

You can set an option in the config object titled getCarrierInfo to retreive carrier name for a device. This is the ( Config). This object can be passed as a constructor argument for additional options.

If you set getCarrierInfo to true - recipients on Android devices will see a dialog box asking them for perimssion . This dialog will say allow app to make and manage phone calls. This is a message sent from the android operating system for the READ_PHONE_STATE permission and carrier info is grouped into this. If the user denies permission - carrier information will not be retrieved. The new android operating systems require asking a user for permission before retrieving this information.

By default the Config will set getCarrierInfo will default to false.

And example can be found here Example.

Example #

import 'package:amplitude_flutter/amplitude_flutter.dart';

// replace 'API_KEY' with your project's API_KEY
Future<void> example() async {
  final AmplitudeFlutter analytics = AmplitudeFlutter('API KEY');

  // set this user's id
  analytics.setUserId('abc123');

  // log an event
  analytics.logEvent(name: 'add_friend');

  // Log events with event properties
  analytics.logEvent(name: 'add_friend', properties: { 'event_properties': { 'key': 'value' }});

  // identify a user
  final Identify identify = Identify()
    ..set('cohort', 'Test A')
    ..setOnce('completed_onboarding', 'true')
    ..add('login_count', 1)
    ..append('tags', 'new tag')
    ..unset('demo_user');

  analytics.identify(identify);

  // Amplitude Accounts [https://amplitude.zendesk.com/hc/en-us/articles/115001765532-Accounts] methods:
  // add a user to a group
  analytics.setGroup('orgId', 15);

  // change properties of a group
  analytics.groupIdentify('orgId', 15, Identify()..set('account_manager', 456));

  // emit an event associated with a group
  analytics.logEvent('Demo Released', properties: { 'groups': { 'orgId': 15 } });

  // Log revenue
  final Revenue revenue = Revenue()
    ..setPrice(23.23)
    ..setQuantity(3)
    ..setProductId('widget1')

  analytics.logRevenue(revenue);
}

1.1.5 #

  • Include language property when reporting events.

1.1.4 #

  • Updated to use androidx for Android.

1.1.3 #

  • Fix a problem that dart documentation can't be generated on pub.dev

1.1.2 #

  • Made changes to support the new Android plugins API (>= 1.12 Flutter SDK).
  • Updated Android example application with v2 Android embedding.

1.1.1 #

  • Migrated from AppLifecycleState.suspending to AppLifecycleState.detached. Cause suspending is deprecated. Thanks @otopba for fixing it.
  • Fixed the possible crash while other permission is requested by other libraries.

1.1.0 #

  • add device_manufacturer info
  • add ability to retrieve carrier info
  • add config option to turn on and off retrieving carrier info

1.0.1 #

  • Wait for device info to be available before sending events

1.0.0 #

  • Send event_id with payloads
  • Add application version to events
  • Limit stored events

0.2.0 #

  • Add setUserId()
  • Add a sequence_id sent with events
  • Config option to opt out of tracking
  • Example app changes

0.1.0 #

  • Adds revenue tracking.
  • Catch errors from platform channels.

0.0.2 #

  • Fixes bug where default session timeout was not set.
  • Persist events to sqlite database.
  • Refactor to use service provider class to simplify dependency injection in test.
  • Add group identify functionality.
  • Retry posting events.
  • Flush event buffer every 30s.
  • Retry posting events when payload is too large.
  • Include uuid for events.
  • Include library version for events.

0.0.1+1 #

  • Fixes serialization bug preventing events from sending.

0.0.1 #

  • Implements logEvent and identify functionality.

example/README.md

amplitude_flutter_example #

Demonstrates how to use the amplitude_flutter plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

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

Use this package as a library

1. Depend on it

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


dependencies:
  amplitude_flutter: ^1.1.5

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:amplitude_flutter/amplitude_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
89
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
95
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
crypto ^2.0.6 2.1.4
device_info ^0.4.0+1 0.4.1+4
flutter 0.0.0
http ^0.12.0+2 0.12.0+4
package_info ^0.4.0+3 0.4.0+13
path ^1.6.4 1.6.4
sqflite ^1.1.5 1.2.0
uuid ^2.0.1 2.0.4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
http_parser 3.1.3
meta 1.1.8
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
synchronized 2.2.0
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
mockito 4.0.0