Build Status Coverage Status Pub Version Pub Likes Pub popularity Flutter Platform

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


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.


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;
        bool canHandle(AnalyticAction action) => action is MyAnalyticAction;
        void perform(MyAnalyticAction action) {
            _service.send(action.key, action.value);
  3. Add performer to the service:

        final analyticService = DefaultAnalyticService();




Add analytics to your pubspec.yaml file:

  analytics: $currentVersion$

At this moment, the current version of analytics is analytics version.


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


To report your issues, submit directly in the Issues section.


If you would like to contribute to the package (e.g. by improving the documentation, fixing a bug or adding a cool new feature), please read 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.



Apache License, Version 2.0