Skip to content

🚀 Feature Request: 支持 auto_route 页面跳转的自动埋点识别 #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
youdianfan opened this issue May 6, 2025 · 1 comment

Comments

@youdianfan
Copy link


🚀 Feature Request: 支持 auto_route 页面跳转的自动埋点识别

背景说明

当前在 Flutter 项目中集成了神策官方插件,并启用了自动埋点配置 SAAutoTrackConfig,通过如下方式初始化页面配置:

SAAutoTrackPageConfig<CouponListPage>(
  title: '优惠券列表',
  screenName: 'CouponList',
  properties: {'page': 'coupon_list'},
),

在使用原生 Navigator 进行页面跳转时,可以正常识别页面信息并上报 $AppViewScreen 事件:

Navigator.of(context).push(MaterialPageRoute(builder: (context) => const CouponListPage()));

正常上报示例(Navigator 跳转):

"event": "$AppViewScreen",
"lib": {
  "$lib_detail": "CouponList######"
},
"properties": {
  "$title": "优惠券列表",
  "$screen_name": "CouponList",
  "page": "coupon_list"
}

问题说明

项目中实际采用 [auto_route](https://pub.dev/packages/auto_route)(版本:`^9.2.2`) 进行路由管理。在使用 auto_route 进行页面跳转时,神策未能正确读取到 SAAutoTrackPageConfig 中的配置信息。

当前行为(auto_route 跳转):

"event": "$AppViewScreen",
"lib": {
  "$lib_detail": "RouteDataScope######"
},
"properties": {
  "$title": "My Coupons",
  "$screen_name": "RouteDataScope"
}

可以看到页面识别为 RouteDataScope,未读取 SAAutoTrackPageConfig 的配置。


对比参考

使用 firebase_analytics 插件时,可以正确识别 auto_route 的页面类,并上报对应路径。

示例 Firebase Analytics 页面日志截图如下:
Firebase Analytics


期望行为

希望官方插件在自动埋点中:

  • 支持 auto_route 管理的页面跳转
  • 自动读取并匹配 SAAutoTrackPageConfig 中配置的信息;
  • 使页面浏览事件 $AppViewScreen 上报时包含开发者预设的 titlescreenNameproperties 等字段;

环境信息

  • Flutter
  • 插件版本:sensors_analytics_flutter_plugin
  • auto_route: ^9.2.2
  • firebase_analytics: ^11.4.5

如需我协助提供 Demo 项目或更多测试数据,也欢迎联系!


@youdianfan
Copy link
Author

页面未定义 AppBar 时无法记录 title

在实际开发中,部分页面(如全屏弹窗、Dialog、滑动面板等)不使用 AppBar,因此 $title 无法自动填充,导致 $AppViewScreen 事件中缺失 title 字段。

这类页面即使配置了 SAAutoTrackPageConfig,title 仍然不会出现在最终上报数据中。


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant