• It is only compatible with Flutter SDK installed via Git, see installation method Flutter Git Install Method
  • Support Flutter SDK Version v2.0.6v2.2.2、 v2.2.3 、v2.5.1 、v2.5.3 、v2.8.0 、v2.8.1 、v2.10.0、v2.10.3、v3.0.0、v3.0.5、v3.3.0、v3.3.1、v3.3.4、v3.3.5、v3.3.6、v3.3.10、v3.7.0、v3.7.6 、v3.7.10、v3.7.12、v3.10.0、v3.10.5(More versions are being adapted)
  • Do not support hot reload: Flutter full bury does not support hot reload operation, please do not use full bury after hot reload operation. It is recommended to close the full burial point during development and then open it during testing.

1. Integrate Flutter full Tracking SDK

Starting with Flutter 3.3.0, all sites of Flutter will be integrated in a new way. The new integration will significantly reduce the cost of access, please use the latest integration for customers who need to use full buried points on Flutter 3.3.0 and above. Versions of Flutter before 3.3.0 still need to be integrated the same way as before.

1.1. Flutter version >= 3.3.0 integrated method

1.1.1. Integrated Flutter plugin

Please refer to:Integrated Sensors Flutter plugin.

1.1.2. Download the full tracking script

ClickDownload  sa_flutter_script_v2.sh.zip script to your computer, opens the Terminal, and executes the following commands respectively:

$ chmod 777 sa_flutter_script_v2.sh $ ./sa_flutter_script_v2.sh
BASH

1.1.3. Reference fully tracking module

Introduce the following plug-in to the project that needs to add a full tracking:

dependencies: ... sa_aspectd_impl: git: url: https://github.com/sensorsdata/sa_aspectd_impl.git # 模块 github 地址 ref: v2.3.0  # 对应版本 tag,建议使用最新版本
CODE

1.1.4. Reference the AOP Dart file

At the project entry point (typically main.dart) introduce the following file:

... import 'package:sa_aspectd_impl/sensorsdata_aop.dart'; //需要引入全埋点入口 void main() { 	... }
CODE

At this point, the Flutter fully tracking module has been integrated.

1.1.5. Extended element path

Flutter's fully-tracking element path contains only widgets used in the project, similar to the functionality provided by Flutter Inspector. However, in actual development, it is likely that multiple projects use the same set of code, which requires packaging this part into a separate library, when the library is used in the project, the captured element path does not include the Widget used in the library implementation. If the customer wants to add this part of the Widget to the element path as well, it can be created in the project root directorysensorsdata_aop_config.yaml, then configure it as follows:

## 配置入口 entry_points: - package:aaa - package:bbb
CODE

Then Dart import uri of Widgets that start with package:aaa、package:bbb are added to the element path.

1.2. Flutter version < 3.3.0 Integration Mode

1.2.1. Integrate Flutter Plugin

To use the old version of Flutter Full-link Point, please use the version v2.1.1 of the plugin. For more details, please refer to: Integrate Sensors Analytics Flutter Plugin.

The Sensors Analytics Flutter Full-link Point module also depends on the Sensors Analytics Flutter Plugin. For more information, please refer to the end of the article: Plugin Version Description in Full-link Point.

Prompt

The integration of the old version of Flutter Full-link Point is more complex. The subsequent development functions are mainly for Flutter >= 3.3.0. We recommend using the new integration method.

1.2.2. Download Full-link Point Script

Click Download sa_flutter_script_v2.sh.zip, and after downloading, put the script in the same level directory as your project, as shown in the figure:

1.2.3. Run the Script

Open the terminal, switch to the directory where the script file is located, and execute the following commands:

$ chmod 777 sa_flutter_script_v2.sh $ ./sa_flutter_script_v2.sh
BASH

After the execution is successful, three folders will be added to the same-level directory of your project:

.my_flutter_demo_dir 			-> 项目文件夹 ├── sa_aspectd_fronted			-> 资源文件1 ├── sa_aspectd_impl 				-> 资源文件2 ├── sa_flutter_aspectd 	 		-> 资源文件3 └── my_flutter_demo 			 	-> 你的项目
BASH

For Windows environment, please Download and install Git Bash

1.2.4. Configure the Project

Because the folder where your app is located may also have other projects, you need to specify which projects support full-link point. There is a file named multiproject.config in the sa_aspectd_impl folder, as shown in the figure below:

Open this file and add the directory name of your project to it. Note that each project occupies one line, as shown in the figure below:

2. Upgrade Flutter Full-link Point SDK

Perform the integration steps to integrate Flutter's full embedded SDK again.

3. Uninstall Flutter Full Tracking SDK

$ ./sa_flutter_script_v2.sh -r
BASH

4. Verify if the full-point integration is successful

4.1. Clean project

Flutter full-point integration is now complete. Before verification, you need to clean your project by executing the following command in your project:

$ flutter clean $ flutter pub get
BASH

4.2. Turn on the Android / iOS log switch

Make sure the log switch is turned on.

4.3. Run verification

Run the Android / iOS project and click on interactive buttons. If the console outputs $AppViewScreen and $AppClick events, it means the full-point integration is successful:

5. Full-point support range

Flutter full-point functionality automatically collects page view events ($AppViewScreen) and click events ($AppClick) within the supported range.

5.1. Page view events

The following scenarios support automatic collection of page view events:

  • Navigate pages through routes
  • Click on BottomNavigationBar to navigate pages
  • Click on TabBar to navigate pages
  • Swipe left or right on TabBar

Starting from version v2.2.0 of full-point, the following switch is added to control the page view when the app enters the foreground from the background:

SensorsAnalyticsAutoTrackConfig.getInstance().enableForegroundAndBackgroundViewScreen();
CODE

In addition, the full-point's page view collection capability for complex scenarios such as nested or combined TabBar and BottomNavigationBar is limited. Developers can use the following methods to enable or disable full-point page view collection for these two components:

SensorsAnalyticsAutoTrackConfig.getInstance().isBottomAndTabBarPageViewEnabled = true/false
CODE

5.1.1. Set custom information for the page

Flutter full-point supports adding custom attribute information to page view events. Here is an example:

// 示例是给 PageA 页面浏览事件添加自定义属性 class PageA extends StatelessWidget implements ISensorsDataViewScreen { @override Widget build(BuildContext context) { return Scaffold( appBar: YZSimpleShellNavbar(), body: Center( child: Column( children: [ TextButton( onPressed: () { Navigator.of(context).pushNamed("page_b"); }, child: Text("Goto PageB")) ], ), ), ); }   // 实现该接口可添加自定义属性信息 @override Map<String, dynamic>? get trackProperties => {"aa":"这是自定义属性示例"}; // 实现该接口可以自定义页面名称 @override String? get viewScreenName => "自定义页面名称"; // 实现该接口可以自定义页面标题 @override String? get viewScreenTitle => "自定义页面标题"; // 实现该接口可以自定义页面 URL @override String? get viewScreenUrl => "自定义页面 URL";
CODE
  • Please ensure that you are using v2.0.2 and above version of the plugin.
  • This interface only supports page redirection through route management.
  • Currently, Flutter full tracking has limitations in supporting complex usage scenarios nested with TabBar and BottomNavigationBar. Customers can disable page browsing collection for this part and solve it through self-tracking in the following ways:
  • SensorsAnalyticsAutoTrackHelper.getInstance().autoTrackConfig.isTabBarPageViewEnabled = false;
    CODE

5.2. Element click event

The following scenarios support automatic collection of click events:

  • Use a Widget that provides a click callback configuration
  • Use GestureDetector to handle click events

6. Precautions

6.1. Plugin version description in the full tracking

Sensors Flutter full tracking requires that the version number of the Sensors plugin used in the customer's project is consistent with the version of the plugin dependent on the full tracking sa_aspectd_impl/pubspec.yaml. Generally, the Sensors plugin dependent in full tracking sa_aspectd_impl/pubspec.yaml should be older than the online version of the plugin. If customers are using the latest plugin version, please modify the dependency in sa_aspectd_impl/pubspec.yaml to match the plugin version in the project.


In addition, Flutter full tracking relies on the basic functionality provided by the Flutter plugin. The following lists the Flutter plugin version that each Flutter full tracking version depends on starting from Flutter 3.3.0. Readers should select the same plugin version as the full tracking dependency according to the table below:

Full Tracking VersionPlugin Version Dependent on Full TrackingRange of Plugin Supported by Full Tracking
v2.2.1v2.4.0>= v2.4.0
v2.2.0v2.4.0>= v2.4.0
v2.1.1v2.3.0>= v2.3.0
v2.1.0v2.3.0>= v2.3.0

Note that when the version of the dependent plugin in the project changes, please synchronize and modify the version of the dependent plugin in sa_aspectd_impl/pubspec.yaml.

6.2. Git is required to manage Flutter SDK