搜索插件、代码仓与 APP 分类

插件详情v2.0.3

analytics

用于处理分析服务的接口。该库旨在统一处理各种分析服务。

AndroidiOSmacOSWindowsLinux
近 30 天下载
821
喜欢数
43
Pub 分数
150

安装插件

flutter pub add analytics

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

分析包为在Flutter平台上集成和管理多个分析服务提供了一个统一的接口。该包旨在简化用户行为和应用性能的跟踪,抽象了不同分析提供商之间的差异,使开发者能够无缝切换或同时使用多个服务。该库支持Android、iOS、macOS、Windows和Linux,非常适合需要一致数据收集的跨平台应用。它通过单一API实现事件记录、用户属性跟踪和会话管理。

适合场景

  • 跨平台分析集成
  • 跨多个提供商的统一事件跟踪
  • 用户行为监控
  • 应用性能测量
  • A/B测试数据收集

主要特点

  • 平台无关的分析接口
  • 对多种分析后端的支持
  • 跨平台的一致性 API
  • 轻松切换服务
  • 事件和用户属性跟踪

适合对象

  • 开发跨平台应用的开发者
  • 使用多个分析工具的团队
  • 需要灵活分析配置的项目
  • 需要详细用户洞察的应用
  • 初创公司尽早标准化分析

使用建议

  • 需要设置各个分析提供商
  • 可能会因添加依赖项而增加应用大小
  • 取决于提供方特定的实现细节
  • 需要谨慎处理隐私和同意
  • 受限于底层提供方支持的功能

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Analytics

Made by Surf 🏄‍♂️🏄‍♂️🏄‍♂️

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

Overview

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 AnalyticStrategy.
  • AnalyticActionPerformer - an interface for analytic action performers. This class is an abstract base class for analytic strategies.
  • AnalyticStrategy — a class that provides a special way to send an analytical action. To create a custom analytic strategy, you should extend this class and implement the performAction method.
  • AnalyticService — a class that provides a way to send analytic action using a set of analytic strategies. To use this class, you should create an instance of it with a set of analytic strategies, and then call the performAction method to send analytic action.

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 analytic strategy:

    class MyAnalyticStrategy
        extends AnalyticStrategy<MyAnalyticAction> {
        final SomeAnalyticsApi _analyticsApi;
    
        SomeAnalyticsApi(this._analyticsApi);
    
        @override
        void performAction(MyAnalyticAction action) {
            _analyticsApi.send(action.key, action.value);
        }
    }
    
  3. Create an AnalyticService with your strategy:

    final analyticService = AnalyticService.withStrategies({
        MyAnalyticStrategy(analytics),
    });
    

Usage:

    analyticService.performAction(ButtonPressedAction());

Installation

Add analytics to your pubspec.yaml file:

dependencies:
  analytics: $currentVersion$

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

Migrating from 1.x.x to 2.x.x

1.x.x

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

Starting from version 2.0.0, sending an event to a specific analytics service is implemented using strategies. The AnalyticService class stores these strategies. Implement analytics strategies using the AnalyticStrategy egy class.

    final analyticService = AnalyticService.withStrategies({
        MyAnalyticStrategy(analytics),
    });

Changelog

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

Issues

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

Contribute

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.

Telegram

License

Apache License, Version 2.0

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目