Skip to content

Commit 189bbed

Browse files
committed
Release 2.0.2
1 parent a3d9e26 commit 189bbed

File tree

7 files changed

+42
-7
lines changed

7 files changed

+42
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.2
2+
3+
* 新增采集插件版本号功能
4+
15
## 2.0.1
26

37
* 修复 track 接口时传入 const map 报错

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
```yml
1818
dependencies:
1919
# 添加神策 flutter plugin
20-
sensors_analytics_flutter_plugin: ^2.0.1
20+
sensors_analytics_flutter_plugin: ^2.0.2
2121
```
2222
2323
执行 flutter packages get 命令安装插件

example/lib/main.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ class _MyAppState extends State<MyApp> {
9090
// "a_time": DateTime.now(),
9191
// "product_name": "Apple 12 max pro"
9292
// });
93-
var map = const {};
94-
map = {};
95-
SensorsAnalyticsFlutterPlugin.track(
96-
"hello", const <String, dynamic>{"address": "xxx road"});
93+
var map = {/*r"$lib_plugin_version":["flutter:234"],*/"address":"000000000000"};
94+
SensorsAnalyticsFlutterPlugin.track("hello", map);
9795
},
9896
),
9997
ListTile(

ios/sensors_analytics_flutter_plugin.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
Pod::Spec.new do |s|
55
s.name = 'sensors_analytics_flutter_plugin'
6-
s.version = '2.0.1'
6+
s.version = '2.0.2'
77
s.summary = 'A new flutter plugin project.'
88
s.description = <<-DESC
99
A new flutter plugin project.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
///页面浏览接口
4+
///配合全埋点功能使用,全埋点会判断页面浏览发生的页面是否实现了此接口,如果实现了此接口就使用此实现中的数据替换原始埋点数据
5+
abstract class ISensorsDataViewScreen {
6+
///页面名称,其格式为:package::xxx/yyy.dart/ZzzPage,表示 ZzzPage 在 yyy.dart 中使用,
7+
///其中 package::xxx/yyy.dart 为 dart 的 importUri,ZzzPage 为页面 Widget。
8+
String? get viewScreenName;
9+
///页面标题
10+
String? get viewScreenTitle;
11+
///页面 url,如果为 null 就使用 viewScreenName 替换
12+
String? get viewScreenUrl => viewScreenName;
13+
///其他的页面属性
14+
Map<String, dynamic>? get trackProperties;
15+
}

lib/sensors_analytics_flutter_plugin.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import 'package:flutter/services.dart';
55

66
// This is the official Flutter Plugin for Sensors Analytics.
77
class SensorsAnalyticsFlutterPlugin {
8+
static const String FLUTTER_PLUGIN_VERSION = "2.0.2";
9+
static bool hasAddedFlutterPluginVersion = false;
10+
811
static const MethodChannel _channel =
912
const MethodChannel('sensors_analytics_flutter_plugin');
1013

@@ -25,6 +28,7 @@ class SensorsAnalyticsFlutterPlugin {
2528
static void track(String eventName, Map<String, dynamic>? properties) {
2629
properties = properties == null ? null : {...properties};
2730
_convertDateTime(properties);
31+
_setupLibPluginVersion(properties);
2832
List<dynamic> params = [eventName, properties];
2933
_channel.invokeMethod('track', params);
3034
}
@@ -519,6 +523,20 @@ class SensorsAnalyticsFlutterPlugin {
519523
}
520524
return true;
521525
}
526+
527+
///添加 Flutter 插件版本号
528+
static void _setupLibPluginVersion(Map<String, dynamic>? properties) {
529+
if (!hasAddedFlutterPluginVersion) {
530+
if (properties == null) {
531+
properties = {};
532+
}
533+
List<String>? values = properties[r"$lib_plugin_version"];
534+
values = values == null ? [] : [...values];
535+
values.add("flutter_plugin:$FLUTTER_PLUGIN_VERSION");
536+
properties[r"$lib_plugin_version"] = values;
537+
hasAddedFlutterPluginVersion = true;
538+
}
539+
}
522540
}
523541

524542
enum SANetworkType {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: sensors_analytics_flutter_plugin
22
description: This is the official flutter plugin for Sensors Analytics,with this plugin you can easily collect your app data on Android and iOS.
3-
version: 2.0.1
3+
version: 2.0.2
44
homepage: "https://github.com/sensorsdata/sensors_analytics_flutter_plugin"
55

66
environment:

0 commit comments

Comments
 (0)