Skip to content

Commit 5d740c0

Browse files
author
weiqiangliu
committed
Release 2.2.2
1 parent ec02967 commit 5d740c0

File tree

27 files changed

+285
-184
lines changed

27 files changed

+285
-184
lines changed

.idea/workspace.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2.2
2+
3+
* 新增接口 bind、unbind、loginWithKey
4+
15
## 2.2.1
26

37
* Swift 项目中,使用 modular 头文件导入报错的缺陷

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.2.1
20+
sensors_analytics_flutter_plugin: ^2.2.2
2121
```
2222
2323
执行 flutter packages get 命令安装插件

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ android {
3333
}
3434

3535
dependencies {
36-
api 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.5.1'
36+
api 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.5.4'
3737
//implementation 'org.json:json:20220320'
3838
}

android/src/main/java/com/sensorsdata/analytics/sensorsanalyticsflutterplugin/SensorsAnalyticsFlutterPlugin.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import androidx.annotation.NonNull;
77

8-
import com.sensorsdata.analytics.android.sdk.PropertyBuilder;
98
import com.sensorsdata.analytics.android.sdk.SAConfigOptions;
109
import com.sensorsdata.analytics.android.sdk.SALog;
1110
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
@@ -181,6 +180,15 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
181180
case "init":
182181
startWithConfig(list, result);
183182
break;
183+
case "bind":
184+
bind(list, result);
185+
break;
186+
case "unbind":
187+
unbind(list, result);
188+
break;
189+
case "loginWithKey":
190+
loginWithKey(list, result);
191+
break;
184192
default:
185193
result.notImplemented();
186194
break;
@@ -608,6 +616,40 @@ public void properties(SAPropertiesFetcher fetcher) {
608616
result.success(null);
609617
}
610618

619+
private void bind(List list, Result result) {
620+
try {
621+
String key = (String) list.get(0);
622+
String value = (String) list.get(1);
623+
SensorsDataAPI.sharedInstance().bind(key, value);
624+
result.success(null);
625+
} catch (Exception e) {
626+
SALog.printStackTrace(e);
627+
}
628+
}
629+
630+
private void unbind(List list, Result result) {
631+
try {
632+
String key = (String) list.get(0);
633+
String value = (String) list.get(1);
634+
SensorsDataAPI.sharedInstance().unbind(key, value);
635+
result.success(null);
636+
} catch (Exception e) {
637+
SALog.printStackTrace(e);
638+
}
639+
}
640+
641+
private void loginWithKey(List list, Result result) {
642+
try {
643+
String key = (String) list.get(0);
644+
String value = (String) list.get(1);
645+
JSONObject properties = assertProperties2(list.get(2));
646+
SensorsDataAPI.sharedInstance().loginWithKey(key, value, properties);
647+
result.success(null);
648+
} catch (Exception e) {
649+
SALog.printStackTrace(e);
650+
}
651+
}
652+
611653
private JSONObject assertProperties(Map map) {
612654
if (map != null) {
613655
return new JSONObject(map);

example/.metadata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled and should not be manually edited.
4+
# This file should be version controlled.
55

66
version:
7-
revision: f7a6a7906be96d2288f5d63a5a54c515a6e987fe
7+
revision: eb6d86ee27deecba4a83536aa20f366a6044895c
88
channel: stable
99

1010
project_type: app

example/analysis_options.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options

example/android/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ gradle-wrapper.jar
55
/gradlew.bat
66
/local.properties
77
GeneratedPluginRegistrant.java
8+
9+
# Remember to never publicly share your keystore.
10+
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11+
key.properties
12+
**/*.keystore
13+
**/*.jks

example/android/app/build.gradle

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,33 @@ if (flutterVersionName == null) {
2222
}
2323

2424
apply plugin: 'com.android.application'
25+
apply plugin: 'kotlin-android'
2526
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2627

2728
android {
28-
compileSdkVersion 28
29+
compileSdkVersion flutter.compileSdkVersion
30+
ndkVersion flutter.ndkVersion
2931

30-
lintOptions {
31-
disable 'InvalidPackage'
32+
compileOptions {
33+
sourceCompatibility JavaVersion.VERSION_1_8
34+
targetCompatibility JavaVersion.VERSION_1_8
35+
}
36+
37+
kotlinOptions {
38+
jvmTarget = '1.8'
39+
}
40+
41+
sourceSets {
42+
main.java.srcDirs += 'src/main/kotlin'
3243
}
3344

3445
defaultConfig {
3546
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
36-
applicationId "com.sensorsdata.analytics.sensorsanalyticsflutterplugin_example"
37-
minSdkVersion 16
38-
targetSdkVersion 28
47+
applicationId "cn.sensorsdata.example"
48+
// You can update the following values to match your application needs.
49+
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
50+
minSdkVersion flutter.minSdkVersion
51+
targetSdkVersion flutter.targetSdkVersion
3952
versionCode flutterVersionCode.toInteger()
4053
versionName flutterVersionName
4154
}
@@ -45,11 +58,14 @@ android {
4558
// TODO: Add your own signing config for the release build.
4659
// Signing with the debug keys for now, so `flutter run --release` works.
4760
signingConfig signingConfigs.debug
48-
4961
}
5062
}
5163
}
5264

5365
flutter {
5466
source '../..'
5567
}
68+
69+
dependencies {
70+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
71+
}

example/android/app/src/debug/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.sensorsdata.analytics.sensorsanalyticsflutterplugin_example">
3-
<!-- Flutter needs it to communicate with the running application
2+
package="cn.sensorsdata.example">
3+
<!-- The INTERNET permission is required for development. Specifically,
4+
the Flutter tool needs it to communicate with the running application
45
to allow setting breakpoints, to provide hot reload, etc.
56
-->
67
<uses-permission android:name="android.permission.INTERNET"/>

0 commit comments

Comments
 (0)