magpie_log 1.0.1

Pub使用 #

1. Depend on it #

Add this to your package's pubspec.yaml

dependencies:
 magpie_log: ^1.0.0

2. Install it #

You can install packages from the command line:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it #

Now in your Dart code, you can use:

import 'package:magpie_log/magpie_log.dart';

Dart使用方式 #

在自己工程首页调用MagpieLog.instance.init初始化方法

Widget build(BuildContext context) {
    MagpieLog.instance.init(context, 
        ReportMethod.timing, 
        ReportChannel.natives,
        callback: _receiverMagpieData, 
        time: 1 * 60 * 1000,     
        count: 3);
    return Container();
}

redux圈选使用方式 #

redux圈选 你的工程需要使用flutter-redux做状态管理 需要注入一个中间件CircleMiddleWare

final store = Store<AppState>(reducer,
      middleware: [CircleMiddleWare()], initialState: AppState.initState());

其中的AppState也就是store存储的数据集必须继承LogState 因为我们需要toJson方法才能更好的获取参数

class AppState extends LogState {
  Map<String, dynamic> toJson() => _$AppStateToJson(this);
}

随后就可以使用我们的redux圈选

页面圈选使用 #

需要注册navigator监听LogObserver,当然我们需要你显示的设置页面settings这样我们才能获取页面的唯一标识

MaterialApp(
    routes: {
      '/': (BuildContext context) => TopScreen(),
      '/UnderScreen': (BuildContext context) => UnderScreen(),
    },
    navigatorObservers: [
      LogObserver<AppState>(),
    ],
    title: 'Flutter Demo',
    theme: ThemeData(primarySwatch: Colors.deepOrange),
  ),

setState()圈选使用 #

继承WidgetLogState即可实现对应方法

class AddTextState extends WidgetLogState<AddTextWidget> {
  @override
  Map<String, dynamic> toJson() {
    Map map = Map<String, dynamic>();
    map["count"] = count.toString();
    return map;
  }

  @override
  String getActionName() {
    return "AddText";
  }

  @override
  int getIndex() {
    return 0;
  }
}

详细文档参见 #

magpie圈选埋点实现

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:magpie_log/interceptor/intercepter_screen_log.dart';
import 'package:magpie_log/interceptor/interceptor_circle_log.dart';
import 'package:redux/redux.dart';

import 'states/app_state.dart';
import 'top_screen.dart';
import 'under_screen.dart';

void main() {
  final store = Store<AppState>(reducer,
      middleware: [CircleMiddleWare()], initialState: AppState.initState());
  runApp(MyApp(store));
}

class MyApp extends StatelessWidget {
  final Store<AppState> store;

  MyApp(this.store);

  @override
  Widget build(BuildContext context) {
    return StoreProvider<AppState>(
      store: store,
      child: MaterialApp(
        routes: {
          '/': (BuildContext context) => TopScreen(),
          '/UnderScreen': (BuildContext context) => UnderScreen(),
        },
        navigatorObservers: [
          LogObserver<AppState>(),
        ],
        title: 'Flutter Demo',
        theme: ThemeData(primarySwatch: Colors.deepOrange),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  magpie_log: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:magpie_log/magpie_log.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
27
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
10
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/handler/statistics_handler.dart. (-1.49 points)

Analysis of lib/handler/statistics_handler.dart reported 3 hints:

line 4 col 8: Unused import: 'package:magpie_log/file/data_analysis.dart'.

line 6 col 8: Unused import: 'package:magpie_log/file/file_utils.dart'.

line 55 col 3: Prefer using /// for doc comments.

Fix lib/ui/log_select_report.dart. (-1 points)

Analysis of lib/ui/log_select_report.dart reported 2 hints:

line 223 col 10: The declaration '_buildTimeWidget' isn't referenced.

line 276 col 10: The declaration '_buildTotalWidget' isn't referenced.

Format lib/model/analysis_model.dart.

Run flutter format to format lib/model/analysis_model.dart.

Format lib/ui/log_screen.dart.

Run flutter format to format lib/ui/log_screen.dart.

Maintenance issues and suggestions

Support latest dependencies. (-30 points)

The version constraint in pubspec.yaml does not support the latest published versions for 3 dependencies (flutter_redux, fluttertoast, redux).

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://m.58.com was unreachable.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
cupertino_icons ^0.1.2 0.1.3
device_info ^0.4.1+3 0.4.2+1
flutter 0.0.0
flutter_redux ^0.5.2 0.5.4 0.6.0
fluttertoast ^3.1.3 3.1.3 4.0.1
json_annotation ^3.0.0 3.0.1
path_provider ^1.5.0 1.6.5
redux ^3.0.0 3.0.0 4.0.0
rubber ^0.4.0 0.4.0
Transitive dependencies
after_layout 1.0.7+2
collection 1.14.11 1.14.12
meta 1.1.8
path_provider_macos 0.0.4
path_provider_platform_interface 1.0.1
platform 2.2.1
plugin_platform_interface 1.0.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner ^1.7.0
flutter_test
json_serializable ^3.2.3