{"id":21748313,"url":"https://github.com/surfstudio/flutter-analytics","last_synced_at":"2025-04-13T07:13:29.451Z","repository":{"id":40369585,"uuid":"384332736","full_name":"surfstudio/flutter-analytics","owner":"surfstudio","description":"Made by Surf 🏄","archived":false,"fork":false,"pushed_at":"2024-04-17T15:31:38.000Z","size":201,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-13T07:13:22.184Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/surfstudio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-07-09T05:37:19.000Z","updated_at":"2024-04-10T08:31:29.000Z","dependencies_parsed_at":"2024-02-05T09:50:10.478Z","dependency_job_id":"37661078-a23a-4b01-bd8a-5dcab5bad1b4","html_url":"https://github.com/surfstudio/flutter-analytics","commit_stats":{"total_commits":72,"total_committers":6,"mean_commits":12.0,"dds":0.4722222222222222,"last_synced_commit":"46266dc75ba6a690505715bf61e474ac0ec75536"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surfstudio%2Fflutter-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surfstudio%2Fflutter-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surfstudio%2Fflutter-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surfstudio%2Fflutter-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/surfstudio","download_url":"https://codeload.github.com/surfstudio/flutter-analytics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675422,"owners_count":21143768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-26T08:13:01.872Z","updated_at":"2025-04-13T07:13:28.909Z","avatar_url":"https://github.com/surfstudio.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Analytics\n\n\u003cimg src=\"https://raw.githubusercontent.com/surfstudio/flutter-open-source/main/assets/logo_black.png#gh-light-mode-only\" width=\"200\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/surfstudio/flutter-open-source/main/assets/logo_white.png#gh-dark-mode-only\" width=\"200\"\u003e\n\nMade by [Surf 🏄‍♂️🏄‍♂️🏄‍♂️](https://surf.dev)\n\n[![Build Status](https://shields.io/github/actions/workflow/status/surfstudio/flutter-analytics/on_pull_request.yml?logo=github\u0026logoColor=white)](https://github.com/surfstudio/flutter-analytics)\n[![Coverage Status](https://img.shields.io/codecov/c/github/surfstudio/flutter-analytics?logo=codecov\u0026logoColor=white)](https://app.codecov.io/gh/surfstudio/flutter-analytics)\n[![Pub Version](https://img.shields.io/pub/v/analytics?logo=dart\u0026logoColor=white)](https://pub.dev/packages/analytics)\n[![Pub Likes](https://badgen.net/pub/likes/analytics)](https://pub.dev/packages/analytics)\n[![Pub popularity](https://badgen.net/pub/popularity/analytics)](https://pub.dev/packages/analytics/score)\n![Flutter Platform](https://badgen.net/pub/flutter-platform/analytics)\n\n## Overview\n\nInterface for working with analytic services.\nThe library is supposed to unify work with various analytic services. The main actors are:\n\n* **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`.\n* **AnalyticActionPerformer** - an interface for analytic action performers. This class is an abstract base class for analytic strategies.\n* **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.\n* **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.\n\n## Example\n\nThe easiest interaction with the library is as follows:\n\n1. Determine the actions that ought to be recorded in the analytics service:\n\n    ```dart\n    class MyAnalyticAction implements AnalyticAction {\n        final String key;\n        final String value;\n\n        MyAnalyticAction(this.key, this.value);\n    }\n\n    class ButtonPressedAction extends MyAnalyticAction {\n        ButtonPressedAction() : super(\"button_pressed\", null);\n    }\n\n    class ScreenOpenedAction extends MyAnalyticAction {\n        ScreenOpenedAction({String param}) : super(\"screen_opened\", param);\n    }\n    ```\n\n2. Implement analytic strategy:\n\n    ```dart\n    class MyAnalyticStrategy\n        extends AnalyticStrategy\u003cMyAnalyticAction\u003e {\n        final SomeAnalyticsApi _analyticsApi;\n\n        SomeAnalyticsApi(this._analyticsApi);\n\n        @override\n        void performAction(MyAnalyticAction action) {\n            _analyticsApi.send(action.key, action.value);\n        }\n    }\n    ```\n\n3. Create an AnalyticService with your strategy:\n\n    ```dart\n    final analyticService = AnalyticService.withStrategies({\n        MyAnalyticStrategy(analytics),\n    });\n    ```\n\nUsage:\n\n```dart\n    analyticService.performAction(ButtonPressedAction());\n```\n\n## Installation\n\nAdd `analytics` to your `pubspec.yaml` file:\n\n```yaml\ndependencies:\n  analytics: $currentVersion$\n```\n\n\u003cp\u003eAt this moment, the current version of \u003ccode\u003eanalytics\u003c/code\u003e is \u003ca href=\"https://pub.dev/packages/analytics\"\u003e\u003cimg style=\"vertical-align:middle;\" src=\"https://img.shields.io/pub/v/analytics.svg\" alt=\"analytics version\"\u003e\u003c/a\u003e.\u003c/p\u003e\n\n## Migrating from 1.x.x to 2.x.x\n\n1.x.x\n\n```dart\n    final analyticService = DefaultAnalyticService();\n    analyticService.addActionPerformer(\n        MyAnalyticActionPerformer(SomeAnalyticService()),\n    );\n```\n\nStarting 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.\n\n```dart\n    final analyticService = AnalyticService.withStrategies({\n        MyAnalyticStrategy(analytics),\n    });\n```\n\n## Changelog\n\nAll notable changes to this project will be documented in [this file](./CHANGELOG.md).\n\n## Issues\n\nTo report your issues, submit directly in the [Issues](https://github.com/surfstudio/flutter-analytics/issues) section.\n\n## Contribute\n\nIf 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](./CONTRIBUTING.md) first and send us your pull request.\n\nYour PRs are always welcome.\n\n## How to reach us\n\nPlease feel free to ask any questions about this package. Join our community chat on Telegram. We speak English and Russian.\n\n[![Telegram](https://img.shields.io/badge/chat-on%20Telegram-blue.svg)](https://t.me/SurfGear)\n\n## License\n\n[Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurfstudio%2Fflutter-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurfstudio%2Fflutter-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurfstudio%2Fflutter-analytics/lists"}