{"id":28135631,"url":"https://github.com/mobiletelesystems/mts-analytics-flutter-sdk","last_synced_at":"2025-05-14T15:19:42.322Z","repository":{"id":280436056,"uuid":"898369054","full_name":"MobileTeleSystems/mts-analytics-flutter-sdk","owner":"MobileTeleSystems","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-03T12:19:11.000Z","size":157,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-03T12:34:43.698Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MobileTeleSystems.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2024-12-04T09:18:10.000Z","updated_at":"2025-03-03T11:43:45.000Z","dependencies_parsed_at":"2025-03-03T12:45:03.094Z","dependency_job_id":null,"html_url":"https://github.com/MobileTeleSystems/mts-analytics-flutter-sdk","commit_stats":null,"previous_names":["mobiletelesystems/mts-analytics-flutter-sdk"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileTeleSystems%2Fmts-analytics-flutter-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileTeleSystems%2Fmts-analytics-flutter-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileTeleSystems%2Fmts-analytics-flutter-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileTeleSystems%2Fmts-analytics-flutter-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MobileTeleSystems","download_url":"https://codeload.github.com/MobileTeleSystems/mts-analytics-flutter-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254170134,"owners_count":22026223,"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":"2025-05-14T15:19:14.957Z","updated_at":"2025-05-14T15:19:42.316Z","avatar_url":"https://github.com/MobileTeleSystems.png","language":"Dart","readme":"# mts_analytics_plugin\n\nПлагин от МТС Аналитики для Flutter\n\n## Установка\n\nВ pubspec.yaml добавить зависимость:\n\n```yaml\n  mts_analytics_plugin:\n    git:\n      url: git@github.com:MobileTeleSystems/mts-analytics-flutter-sdk.git\n      ref: 1.8.0\n```\n\nПример подключения: \u003chttps://github.com/MobileTeleSystems/mts-analytics-flutter-sdk/tree/master/example\u003e\n\n### Android\n\n#### Требования\n\n* Kotlin 1.7.10+\n* AGP 7.3.0+\n* Android SDK 21+\n* Target SDK 34\n\n#### Интеграция\n\nНеобходимо добавить в .gradle вашего проекта зависимости на maven репозитории:\n\n```groovy\nallprojects {\n    repositories {\n        maven {\n            name \"mts_analytics_sdk_external\"\n            url \"https://packages.a.mts.ru/repository/maven-releases/\"\n        }\n    }\n}\n```\n\n### iOS\n\n#### Требования\n\niOS 13.0+\ntvOS 13.0+\n\n#### Интеграция\n\nДобавить в podfile проекта\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nsource 'https://github.com/MobileTeleSystems/mts-analytics-podspecs'\n\npod 'MTMetrics', '~\u003e 3.2.0'\n```\n\n## Использование\n\n### Инициализация\n\nПри инициализации вы должны передать Config с обязательным параметром **androidFlowId/iosFlowId**, который будет выдаваться при регистрации вашего приложения в нашей системе. Остальные параметры опциональны.\n\n```dart\nMtsAnalyticsConfig config = MtsAnalyticsConfig()\n      ..logLevel = LogLevel.DEBUG\n      ..crashReportingEnabled = true\n      ..backgroundTimeout = 120\n      ..activeTimeout = 90\n      ..eventStorageLimit = 3000\n      ..networkTrafficEnabled = false\n      ..androidFlowId = \"\"\n      ..iosFlowId = \"\";\n    MtsAnalyticsPlugin().init(config);\n```\n\n### Обновление конфигурации\n\n```dart\nMtsAnalyticsConfig config = MtsAnalyticsConfig()\n      ..logLevel = LogLevel.OFF\n      ..crashReportingEnabled = false\n      ..backgroundTimeout = 20\n      ..activeTimeout = 45\n      ..eventStorageLimit = 1500\n      ..networkTrafficEnabled = true\n      ..androidFlowId = \"\"\n      ..iosFlowId = \"\";\n    MtsAnalyticsPlugin().updateConfig(config);\n```\n\n### Отправка событий\n\n```dart\n  MtsAnalyticsPlugin().trackEvent\n  MtsAnalyticsPlugin().trackEventName(eventName)\n  MtsAnalyticsPlugin().trackEventWithParameter(eventName, key);\n  MtsAnalyticsPlugin().trackEventWithKeyValue(eventName, key, value);\n  MtsAnalyticsPlugin().trackEventWithMap(eventName, map);\n```\n\n### Пример отправки события mtsEvent (использовать именно MtsEvent для всех команд MTS)\n\n```dart\n  MtsEvent mtsEvent = MtsEvent(\n    eventCategory: \"eventCategoryTest\",\n    eventLabel: \"eventLabelTest\",\n    eventContent: \"eventContentTest\",\n    eventContext: \"eventContextTest\",\n    eventValue: 124,\n    interactionType: const interaction_type.NonInteractions(),\n    touchPoint: const touch_point.App(),\n    buttonLocation: const button_location.TopBar(),\n    target: const tg.Banner(),\n    action: const act.Play(),\n    clientId: \"ebtQL47cHrk\",\n    mClientId: \"93270144851671100000\",\n    sessionId: \"93270144851671100000_1680427772409\",\n    hitId: \"93270144851671100000_1680439999409\",\n    timestamp: DateTime.now().millisecondsSinceEpoch.toString(),\n    userId: \"userTestId\",\n    grClientId: \"1a2b3c4grClient\",\n    grId: \"fCj6fvgxypE_20080610152447302\",\n    aId: \"br7ac10b-55cc-4372-a534-0e02b2c3d479\",\n    dId: \"d24b5a970278d1d8\",\n    userAuth: const auth_type.Auth(),\n    projectName: \"2memory\",\n    filterName: \"time|single|high|low\",\n    productName: \"2memoryAndroid\",\n    productId: \"productId\",\n    funnelName: \"fnl_sales\",\n    funnelStep: \"fnl_sales_st1\",\n    formId: \"form1\",\n    formOrderId: \"formOrderId\",\n    multiAccountType: const multi_account_type.Parent(),\n    accountType: const account_type.Fix(),\n    bannerName: \"DCM_nabber_cashback\",\n    bannerId: \"4534534\",\n    region: \"Ufa\",\n    abName: \"a/b test\",\n    abVariant: \"a/b test variant\",\n    currentTariff: const current_tariff.Trial(),\n    paymentType: const payment_type.InstallmentPaymentOnline(),\n    deliveryType: const delivery_type.Pickup(),\n    eventPosition: \"23\",\n    eventProductPromoLabel: const eppl.NotSet(),\n    eventProductAvailable: const ep_availability.PreOffer(),\n    eventProductDeliveryTerms: const epdt.Pickup(),\n    appTheme: const app_theme.Dark(),\n    eco: const m_eco.Payments(),\n    profileType: \"employee\",\n    productCategory: const product_category.BankCard(),\n    appsflyerId: \"1661431768043-2213402944332562490\",\n    screenName: \"MainActivity\",\n    eventName: e_name.Custom(value: \"test\"),\n    customDimensions: {\n      \"customParameter\": \"1\",\n      \"customParameter2\": 1,\n      \"customParameter3\": 1.123123124,\n      \"customParameter4\": true,\n      \"customParameter5\": null,\n      \"customParameter6\": [1, \"1\", null, true, 1.1],\n      \"customParameter7\": {\n        \"customParameter\": \"1\",\n        \"customParameter2\": 1,\n        \"customParameter3\": 1.123123124,\n        \"customParameter4\": true,\n        \"customParameter5\": null,\n      }\n    }\n);\n\n  MtsAnalyticsPlugin().trackEvent(mtsEvent);\n```\n\n### Пример отправки события screenEvent\n\n```dart\n    ScreenEvent event = ScreenEvent(\n        screenName: \"MainActivityScreen\",\n        customDimensions: {\n          \"customParameter\": \"1\",\n          \"customParameter2\": 1,\n          \"customParameter3\": 1.123123124,\n          \"customParameter4\": true,\n          \"customParameter5\": null,\n          \"customParameter6\": [1, \"1\", null, true, 1.1],\n          \"customParameter7\": {\n            \"customParameter\": \"1\",\n            \"customParameter2\": 1,\n            \"customParameter3\": 1.123123124,\n            \"customParameter4\": true,\n            \"customParameter5\": null,\n          }\n        }\n    );\n\n    MtsAnalyticsPlugin().trackEvent(event);\n```\n\n### Пример отправки события customEvent (если предыдущие вам не подошли)\n\n```dart\n    CustomEvent event = CustomEvent(\n        screenName: \"MainActivityScreen\",\n        eventName: const e_name.Screen(),\n        customDimensions: {\n          \"customParameter\": \"1\",\n          \"customParameter2\": 1,\n          \"customParameter3\": 1.123123124,\n          \"customParameter4\": true,\n          \"customParameter5\": null,\n          \"customParameter6\": [1, \"1\", null, true, 1.1],\n          \"customParameter7\": {\n            \"customParameter\": \"1\",\n            \"customParameter2\": 1,\n            \"customParameter3\": 1.123123124,\n            \"customParameter4\": true,\n            \"customParameter5\": null,\n          }\n        }\n    );\n    MtsAnalyticsPlugin().trackEvent(event);\n```\n\n### Отслеживание кроссплатформы\n\n```dart\n    MtsAnalyticsPlugin().getWebSessionQuery(\"https://mts.ru\");\n```\n\n### Отправка события аутентификации\n\n```dart\n  String ssoState = \"234234111\";\n  String redirectUrl = \"https://client-analytics.mts.ru/api/mts-sso/callback\";\n  MtsAnalyticsPlugin().sendAuthenticationEvent(ssoState, redirectUrl);\n```\n\n### Отправка геолокации\n\n```dart\n    double latitude = 55.75;\n    double longitude = 37.6167;\n    mtsAnalyticsPlugin.setLocation(latitude, longitude);\n```\n\n### Link manager\n\n#### Отправка событий Uri\n\nВ плагине имеется возможность отправки события перехода по Deeplink. Deeplink можно получить используя пакет [go_router](https://pub.dev/documentation/go_router/latest/topics/Deep%20linking-topic.html)\n\n```dart\nGoRoute(\n    path: '/',\n    builder: (_, __) =\u003e HomePage(\n      title: 'SDK Demo Home Page',\n      mtsAnalyticsPlugin: mtsAnalyticsPlugin,\n    ),\n    routes: [\n        GoRoute(\n            name: LinkmanagerPage.route,\n            path: LinkmanagerPage.path,\n            builder: (_, goRouterState) {\n                mtsAnalyticsPlugin.trackUri(uri: goRouterState.uri);\n                return LinkmanagerPage(\n                    uri: goRouterState.uri,\n                    mtsAnalyticsPlugin: mtsAnalyticsPlugin,\n                )\n            },\n        )\n    ]\n);\n/// Можно отправить событие с произвольной ссылкой\nfinal url = 'http:\\\\shop.mts.ru'\nmtsAnalyticsPlugin.trackUri(uri: Uri.parse(url));\n```\n\n#### Получение параметров ссылки сформированной в Link manager\n\nНачиная с версии плагина МТС Аналитики `1.6.0`, добавлена возможность получения данных из короткой ссылки,\nкоторая была заранее сгенерирована в `LinkManager`. Короткая ссылка также может являться `deeplink` в приложении.\nДля работы с `deeplink` сгенерируйте ссылку согласно инструкции в 'LinkManager' и поддержите их в своем  [приложении](https://docs.flutter.dev/ui/navigation/deep-linking) используя пакет [go_router](https://pub.dev/documentation/go_router/latest/topics/Deep%20linking-topic.html)\n\nЕсли продукт перехватил `deeplink`, содержащий такую ссылку или в приложении уже есть короткая ссылка,\nто можно получить параметры из неё:\n\n```dart\n`resolveLink(uri: Uri): DeeplinkResult`\n```\n\nнапример:\n\n```dart\nfinal MtsAnalyticsConfig config = MtsAnalyticsConfig()\n    ..logLevel = LogLevel.verbose\n    ..crashReportingEnabled = false\n    ..backgroundTimeout = 120\n    ..activeTimeout = 90\n    ..eventStorageLimit = 3000\n    ..networkTrafficEnabled = true\n    ..androidFlowId = androidFlowId\n    ..iosFlowId = iosFlowId;\nfinal mtsAnalyticsPlugin = MtsAnalyticsPlugin();\nmtsAnalyticsPlugin.init(config);\n\n\nfinal uri = Uri.parse(\"https://url.mts.ru/short_link\")\n\nfinal DeepLinkResult result = await mtsAnalyticsPlugin.resolveLink(uri: uri)\n\n```\n\n`DeepLinkResultSuccess` содержит: `location`(url редиректа) и `params`(набор параметров полученных из Link Manager)\nВложенность `params` может быть не более 3 уровней.\n`DeepLinkResultError` содержит: `error` (сообщение об ошибке)\n\n```dart\nsealed class DeepLinkResult {\n  const DeepLinkResult();\n}\n\n@JsonSerializable()\nclass DeepLinkResultSuccess extends DeepLinkResult {\n  const DeepLinkResultSuccess({\n    required this.params,\n    required this.location,\n  });\n\n  final String location;\n  final Map\u003cString, dynamic\u003e params;\n}\n\nclass DeepLinkResultError extends DeepLinkResult {\n  const DeepLinkResultError(this.error);\n\n  final Exception error;\n}\n```\n\n### ECommerce\n\n#### Отправка событий ECommerce UA\n\n```dart\nfinal event = ECommerceUAEvent(\n    eventName: eventName,\n    customDimensions: {'customParameter5': 23.8},\n    ecommerceParameters:{'customecommerceParameters':'value1'},\n    ecommerce: ECommerceUAEventName.checkoutOption,\n    currencyCode: 'RUB',\n  );\nmtsAnalyticsPlugin.trackEvent(event);\n```\n\n#### Отправка событий ECommerce GA4\n\n```dart\nfinal ecommerceGA4EventItem = ECommerceGA4EventItem(\n  itemId: 'id123',\n  itemName: 'Watermelon',\n  itemListName: 'Fruits',\n  itemListId: '123145',\n  index: '1',\n  itemBrand: 'MyFarmerMarket',\n  itemCategory: 'Food',\n  itemCategory2: 'Fruits',\n  itemCategory3: 'Green',\n  itemCategory4: 'Round',\n  itemCategory5: '10kg',\n  itemVariant: 'Medium',\n  affiliation: 'online store',\n  discount: '15%',\n  coupon: 'SUMMER24',\n  price: '230',\n  currency: 'RUB',\n  quantity: '1',\n  creativeName: 'fruit adv',\n  creativeSlot: 'top',\n  promotionId: '098e',\n  promotionName: 'Summer Season',\n  customDimensions: {'customParameter1': '1'},\n);\n\nfinal ga4EventItemNullProp = ECommerceGA4EventItem(\n  itemId: 'id123',\n  itemName: 'Watermelon',\n  itemListName: null,\n  itemListId: null,\n  index: null,\n  itemBrand: null,\n  itemCategory: null,\n  itemCategory2: null,\n  itemCategory3: null,\n  itemCategory4: null,\n  itemCategory5: null,\n  itemVariant: null,\n  affiliation: null,\n  discount: null,\n  coupon: null,\n  price: null,\n  currency: null,\n  quantity: null,\n  creativeName: null,\n  creativeSlot: null,\n  promotionId: null,\n  promotionName: null,\n  customDimensions: {'customParameter1': null},\n);\n\nfinal event = ECommerceGA4Event(\n    eventName: eventName,\n    transactionId: '1234',\n    affiliation: 'online store',\n    value: '230',\n    currency: 'RUB',\n    tax: '10',\n    shipping: 'ground',\n    shippingTier: '1',\n    paymentType: 'credit card',\n    coupon: 'SUMMER24',\n    itemListName: 'Fruits',\n    itemListId: '123145',\n    items: [\n      ecommerceGA4EventItem,\n      ga4EventItemNullProp,\n    ],\n    creativeName: 'fruit adv',\n    creativeSlot: 'top',\n    promotionId: '098e',\n    promotionName: 'Summer Season',\n    customDimensions: {'customParameter2': 2},\n  );\nmtsAnalyticsPlugin.trackEvent(event);\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobiletelesystems%2Fmts-analytics-flutter-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmobiletelesystems%2Fmts-analytics-flutter-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobiletelesystems%2Fmts-analytics-flutter-sdk/lists"}