Data Collection Custom Rules¶
View¶
Automatic Collection¶
Method 1: Collection via routes¶
Add FTRouteObserver to MaterialApp.navigatorObservers, and set the pages to navigate in MaterialApp.routes. The key in routes is the page name (view_name).
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomeRoute(),
navigatorObservers: [
FTRouteObserver(),
],
routes: <String, WidgetBuilder>{
'logging': (BuildContext context) => Logging(),
'rum': (BuildContext context) => RUM(),
'tracing_custom': (BuildContext context) => CustomTracing(),
'tracing_auto': (BuildContext context) => AutoTracing(),
},
);
}
}
Navigator.pushNamed(context, "logging");
Method 2: Collection via FTMaterialPageRoute¶
Add FTRouteObserver to MaterialApp.navigatorObservers. Use the custom FTMaterialPageRoute to parse the page name from the widget's runtimeType. The widget class name is the page name (view_name).
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomeRoute(),
navigatorObservers: [
FTRouteObserver(),
],
);
}
}
Navigator.of(context).push(
FTMaterialPageRoute(builder: (context) => new NoRouteNamePage()),
);
For examples, please refer to here.
Method 3: Collection via RouteSettings.name¶
Customize RouteSettings.name in Route type pages. FTRouteObserver will prioritize obtaining this value. This method also applies to Dialog type pages, such as showDialog(), showTimePicker(), etc.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomeRoute(),
navigatorObservers: [
FTRouteObserver(),
],
);
}
}
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => new NoRouteNamePage(),
settings: RouteSettings(name: "RouteSettingName"),
),
);
The above three methods can be used together in a single project.
Sleep and Wake Event Collection¶
For versions below 0.5.1-pre.1, if you need to collect application sleep and wake behaviors, add the following code:
class _HomeState extends State<HomeRoute> {
@override
void initState() {
FTLifeRecycleHandler().initObserver();
}
@override
void dispose() {
FTLifeRecycleHandler().removeObserver();
}
}
Automatic Collection Filtering¶
Only supported in version 0.5.0-pre.1 and above.
FTRouteObserver¶
MaterialApp(
navigatorObservers: [
FTRouteObserver(routeFilter: (Route? route, Route? previousRoute) {
if (filterConfig) {
return true;
}
return false;
}),
],
)
| Field | Type | Required | Description |
|---|---|---|---|
| routeFilter | RouteFilter | No | Page method callback. You can make judgments based on the entering and previous route specifics. Returning true means filtering data that meets the condition. |
FTDialogRouteFilterObserver¶
Filters DialogRoute type pages, such as showDialog(), showTimePicker(), etc.
MaterialApp(
navigatorObservers: [
FTDialogRouteFilterObserver(filterOnlyNoSettingName: true),
],
)
showAboutDialog(
context: context,
routeSettings: RouteSettings(name: "About"),
);
| Field | Type | Required | Description |
|---|---|---|---|
| filterOnlyNoSettingName | bool | No | Only filters Route pages where RouteSettings.name is null. |
Resource¶
Automatic Collection Filtering¶
You can filter Resource data that does not need to be collected via the isInTakeUrl callback in FTRUMManager().setConfig(...).