analytics 1.0.0 copy "analytics: ^1.0.0" to clipboard
analytics: ^1.0.0 copied to clipboard

outdated

Interface for working with analytic services. The library is supposed to unify work with various analytic services.

Analytics #

Build Status Coverage Status Pub Version Pub Likes Flutter Platform

This package is part of the SurfGear toolkit made by Surf.

Description #

Interface for working with analytic services.
The library is supposed to unify work with various analytic services. The main actors are:

  • AnalyticAction — any action that is valuable for analytics. Usually it is a "button pressed" or "screen opened" type of event but the main criterion is a possibility to be handled by AnalyticActionPerformer.
  • AnalyticActionPerformer — a performer of specific actions used to incapsulate work with a certain analytics service. Typically implemented by transforming AnalyticAction into a required format as well as calling send() of a third-party library.
  • AnalyticService — a unified entry point for several AnalyticActionPerformers.

Example #

The easiest interaction with the library is as follows:

  1. Determine the actions that ought to be recorded in the analytics service:

    class MyAnalyticAction implements AnalyticAction {
        final String key;
        final String value;
    
        MyAnalyticAction(this.key, this.value);
    }
    
    class ButtonPressedAction extends MyAnalyticAction {
        ButtonPressedAction() : super("button_pressed", null);
    }
    
    class ScreenOpenedAction extends MyAnalyticAction {
        ScreenOpenedAction({String param}) : super("screen_opened", param);
    }
    
  2. Implement action performer:

    class MyAnalyticActionPerformer
        implements AnalyticActionPerformer<MyAnalyticAction> {
        final SomeAnalyticService _service;
    
        MyAnalyticActionPerformer(this._service);
    
        @override
        bool canHandle(AnalyticAction action) => action is MyAnalyticAction;
    
        @override
        void perform(MyAnalyticAction action) {
            _service.send(action.key, action.value);
        }
    }
    
  3. Add performer to the service:

        final analyticService = DefaultAnalyticService();
        analyticService.addActionPerformer(
            MyAnalyticActionPerformer(SomeAnalyticService()),
        );
    

Usage:

    analyticService.performAction(ButtonPressedAction());

Installation #

Add analytics to your pubspec.yaml file:

dependencies:
  analytics: ^1.0.0

Changelog #

All notable changes to this project will be documented in this file.

Issues #

For issues, file directly in the main SurfGear repo.

Contribute #

If you would like to contribute to the package (e.g. by improving the documentation, solving a bug or adding a cool new feature), please review our contribution guide first and send us your pull request.

Your PRs are always welcome.

How to reach us #

Please feel free to ask any questions about this package. Join our community chat on Telegram. We speak English and Russian.

Telegram

License #

Apache License, Version 2.0

37
likes
0
pub points
83%
popularity

Publisher

verified publishersurf.ru

Interface for working with analytic services. The library is supposed to unify work with various analytic services.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

logger

More

Packages that depend on analytics