appmetrica_sdk 0.0.4+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 83

appmetrica_sdk #

pub package CircleCI

A Flutter plugin for Yandex AppMetrica SDK.

Usage #

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

Example #

import 'dart:async';

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

import 'package:appmetrica_sdk/appmetrica_sdk.dart';

void main() async {
  /// Initializing the AppMetrica SDK.
  await AppmetricaSdk()
      .activate(apiKey: 'db2206ed-c61a-43aa-b95c-6912f60bd25e');

  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  String _libraryVersion = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initLibrarayVersionState() async {
    String libraryVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      libraryVersion = await AppmetricaSdk().getLibraryVersion();
    } on PlatformException {
      libraryVersion = 'Failed to get library version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) {
      return;
    }

    setState(() {
      _libraryVersion = libraryVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(
              title: const Text('Plugin example app'),
            ),
            body: Container(
              padding: const EdgeInsets.all(8),
              child: Center(
                child: Column(
                  children: <Widget>[
                    Container(
                      child: Text(
                          'AppMetrica SDK Library version: $_libraryVersion\n'),
                    ),
                    RaisedButton(
                      child: const Text('Send a custom event'),
                      onPressed: () {
                        /// Sending a custom event without nested parameters.
                        AppmetricaSdk().reportEvent(name: 'Updates installed');
                      },
                    ),
                    RaisedButton(
                      child: const Text(
                          'Send a custom event with nested parameters'),
                      onPressed: () {
                        /// Sending a custom event with nested parameters.
                        AppmetricaSdk().reportEvent(
                            name: 'Current app statistics',
                            attributes: <String, dynamic>{
                              'Application': 'com.company.myapp.awesomeapp',
                              'Audience': 1000000000,
                              'Product price in €': 10000000.99,
                              'nested map': <String, dynamic>{
                                'strategies': 'Age of Empires',
                              },
                            });
                      },
                    ),
                    RaisedButton(
                      child: const Text('Send user profile attributes'),
                      onPressed: () {
                        /// Sending profile custom string attribute.
                        AppmetricaSdk().reportUserProfileCustomString(
                            key: 'string_attribute', value: 'string');

                        /// Sending profile custom number attribute.
                        AppmetricaSdk().reportUserProfileCustomNumber(
                            key: 'number_attribute', value: 55);

                        /// Sending profile custom boolean attribute.
                        AppmetricaSdk().reportUserProfileCustomBoolean(
                            key: 'boolean_attribute', value: true);

                        /// Sending profile custom attribute of the counter type.
                        AppmetricaSdk().reportUserProfileCustomCounter(
                            key: 'counter_attribute', delta: 1);

                        /// Sets the ID of the user profile. Required for predefined
                        /// profile attributes like Name or Notifications enabled.
                        AppmetricaSdk().setUserProfileID(userProfileID: 'id');

                        /// Sending profile predefined user name attribute.
                        AppmetricaSdk()
                            .reportUserProfileUserName(userName: 'John');

                        /// Sending profile predefined NotificationsEnabled attribute.
                        AppmetricaSdk().reportUserProfileNotificationsEnabled(
                            notificationsEnabled: true);
                      },
                    ),
                  ],
                ),
              ),
            )));
  }
}

Documentation #

Common documentation available on AppMetrica official site.

Bugs or Requests #

If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on GitHub and we'll look into it. Pull request are also welcome.

0.0.4+1 #

  • Upgrade AppMetrica SDK for iOS (3.8.2). Fixed an issue #2 with "helper" command line tool in dynamic frameworks.

0.0.4 #

  • Upgrade AppMetrica SDK (Android 3.7.2/iOS 3.8.0).
  • Add sendEventsBuffer function. Sends stored events from the buffer.
  • Android only. Add maxReportsInDatabaseCount activation parameter - maximum number of events that can be stored in the database on the phone before being sent to AppMetrica.

0.0.3 #

  • Add setUserProfileID function (required for predefined profile attributes).
  • Update example code.
  • Upgrade dependencies.

0.0.2+1 #

  • iOS polishing.
  • Update readme.

0.0.2 #

  • Add crash reporting flag.
  • Cleanup.

0.0.1 #

  • Initial release. Based on C++ version of Appmetrica SDK integration for Cocos2d-x.

example/README.md

appmetrica_sdk_example #

Demonstrates how to use the appmetrica_sdk 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:
  appmetrica_sdk: ^0.0.4+1

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:appmetrica_sdk/appmetrica_sdk.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
69
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]
83
Learn more about scoring.

We analyzed this package on Oct 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

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
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test