Skip to content

Commit

Permalink
Feat/database (#133)
Browse files Browse the repository at this point in the history
* 拆分数据库模块;
1. 完成数据库迁移逻辑;
2. 添加pb数据;
3. 调整event类位置;
4. 完善数据库单元测试。

* feat/protobuf
1. add protobuf module;
2. sdk user json store data default;
3. optimize modelloader;
4. complete data unit test;
5. set baseevent serialVersionUID
  • Loading branch information
cpacm authored Dec 1, 2021
1 parent 743c107 commit 31849fe
Show file tree
Hide file tree
Showing 133 changed files with 3,024 additions and 1,289 deletions.
5 changes: 1 addition & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@
<!-- 在下方描述你的PR实现了什么功能,或者修复了什么问题 -->



## 测试步骤

<!-- 请描述怎样操作才证明已经处理了问题. -->


## 影响范围

<!-- 请描述你的PR能造成的影响范围. -->


## 是否属于重要变动?

- [ ]
- [x]


## 其他信息


1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
run: |
bash ./gradle/publishAllToMavenLocal.sh
bash ./config/checkstyle/checkstyle.sh
./gradlew lint
./gradlew assembleDebug
- name: Run tests
Expand Down
15 changes: 12 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ buildscript {
]

releaseConfiguration = [
releaseVersion : "3.3.2",
releaseVersionCode: 30302,
releaseVersion : "3.3.3-SNAPSHOT",
releaseVersionCode: 30303,
]

versions = [
'gradleTool': '3.5.0',
'gradleTool': '4.2.2',
]
libraries = [
android : [
Expand Down Expand Up @@ -53,11 +53,13 @@ buildscript {

'hybrid' : "com.growingio.android:hybrid:$releaseConfiguration.releaseVersion",
'okhttp3' : "com.growingio.android:okhttp3:$releaseConfiguration.releaseVersion",
'database' : "com.growingio.android:database:$releaseConfiguration.releaseVersion",
'volley' : "com.growingio.android:volley:$releaseConfiguration.releaseVersion",
'urlconnection' : "com.growingio.android:urlconnection:$releaseConfiguration.releaseVersion",
'debugger' : "com.growingio.android:debugger:$releaseConfiguration.releaseVersion",
'circler' : "com.growingio.android:circler:$releaseConfiguration.releaseVersion",
'json' : "com.growingio.android:json:$releaseConfiguration.releaseVersion",
'protobuf' : "com.growingio.android:protobuf:$releaseConfiguration.releaseVersion",
'encoder' : "com.growingio.android:encoder:$releaseConfiguration.releaseVersion",
'crash' : "com.growingio.android:crash:$releaseConfiguration.releaseVersion",
'oaid' : "com.growingio.android:oaid:$releaseConfiguration.releaseVersion",
Expand All @@ -67,6 +69,12 @@ buildscript {
'google' : [
'auto_service' : 'com.google.auto.service:auto-service:1.0-rc7',
'auto_service_annotations': 'com.google.auto.service:auto-service-annotations:1.0-rc7',

'protobuf_gradle_plugin' : 'com.google.protobuf:protobuf-gradle-plugin:0.8.17',
'protobuf_java' : 'com.google.protobuf:protobuf-java:3.19.1',
'protobuf_javalite' : 'com.google.protobuf:protobuf-javalite:3.19.1',
'protobufc' : 'com.google.protobuf:protoc:3.9.1',
'protobuf_java_util' : 'com.google.protobuf:protobuf-java-util:3.19.1',
],

'squareup' : [
Expand Down Expand Up @@ -128,6 +136,7 @@ buildscript {
classpath "com.android.tools.build:gradle:${versions.gradleTool}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
classpath libraries.google.protobuf_gradle_plugin
classpath libraries.sonar.sonar
}
}
Expand Down
2 changes: 2 additions & 0 deletions config/checkstyle/checkstyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
&& ./gradlew :growingio-tracker-core:checkstyle \
&& ./gradlew :growingio-autotracker-core:checkstyle \
&& ./gradlew :growingio-data:json:checkstyle \
&& ./gradlew :growingio-data:protobuf:checkstyle \
&& ./gradlew :growingio-data:encoder:checkstyle \
&& ./gradlew :growingio-data:database:checkstyle \
&& ./gradlew :growingio-hybrid:checkstyle \
&& ./gradlew :growingio-network:okhttp3:checkstyle \
&& ./gradlew :growingio-network:urlconnection:checkstyle \
Expand Down
1 change: 1 addition & 0 deletions demos/demo-autotrack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {

debugApi project(':gio-sdk:autotracker-cdp')
releaseApi libraries.growingio.autotracker_cdp
//api "com.growingio.android:autotracker-cdp:3.3.1"

implementation project(':demo-core')

Expand Down
3 changes: 3 additions & 0 deletions demos/demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ buildscript {
}
dependencies {
classpath "com.growingio.android:autotracker-gradle-plugin:${releaseConfiguration.releaseVersion}"
//classpath "com.growingio.android:autotracker-gradle-plugin:3.3.1"
}
}

Expand Down Expand Up @@ -47,6 +48,7 @@ android {
lintOptions {
abortOnError false
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -103,6 +105,7 @@ dependencies {
implementation project(":demo-autotrack")
debugImplementation project(":growingio-tools:oaid")
releaseImplementation libraries.growingio.oaid
//implementation libraries.growingio.oaid

compileOnly libraries.androidx.appcompat

Expand Down
6 changes: 3 additions & 3 deletions demos/demo/multidex-config.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
com/growingio/android/sdk/track/middleware/EventsContentProvider.class
com/growingio/android/sdk/track/middleware/EventsInfoTable.class
com/growingio/android/sdk/track/middleware/EventsSQLiteOpenHelper.class
com/growingio/database/EventDataContentProvider.class
com/growingio/database/EventDataTable.class
com/growingio/database/EventDataSQLiteOpenHelper.class
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,16 @@ public void alertDialogClickEventTest() {

@Test
public void noTitleAlertDialogClickEventTest() {
String xpath = "/AlertDialog/这是一个没有标题的AlertDialog/BUTTON_NEGATIVE";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
xpath = "/AlertDialog/BUTTON_NEGATIVE";
}
final AtomicBoolean receivedEvent = new AtomicBoolean(false);
getEventsApiServer().setOnReceivedEventListener(new OnReceivedViewClickEventsListener(
receivedEvent,
new ViewElementEvent.Builder()
.setPath("/DialogTestActivity")
.setXpath("/AlertDialog/这是一个没有标题的AlertDialog/BUTTON_NEGATIVE")
.setXpath(xpath)
.setTextValue("Cancel")
.setIndex(-1)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import com.growingio.android.hybrid.SuperWebView;
import com.growingio.android.sdk.track.SDKConfig;
import com.growingio.android.sdk.track.async.Callback;
import com.growingio.android.sdk.track.data.PersistentDataProvider;
import com.growingio.android.sdk.track.ipc.PersistentDataProvider;
import com.growingio.android.sdk.track.utils.JsonUtil;
import com.growingio.autotest.EventsTest;
import com.growingio.autotest.TestTrackConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void deleteAllData() {
}

public static void deleteEventsDatabase() {
ApplicationProvider.getApplicationContext().deleteDatabase("growing3.db");
ApplicationProvider.getApplicationContext().deleteDatabase("growingio.db");
}

public static void deletePersistentSharedData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import com.google.common.truth.Truth;
import com.growingio.android.sdk.track.events.AutotrackEventType;
import com.growingio.android.hybrid.event.HybridEventType;
import com.growingio.android.sdk.track.events.TrackEventType;
import com.growingio.android.sdk.track.providers.ConfigurationProvider;

Expand Down Expand Up @@ -197,7 +196,7 @@ private void dispatchReceivedEvents(String json) {
mOnReceivedEventListener.onReceivedPageAttributesEvents(jsonArray);
}
break;
case HybridEventType.FORM_SUBMIT:
case TrackEventType.FORM_SUBMIT:
if (mOnReceivedEventListener != null) {
mOnReceivedEventListener.onReceivedHybridFormSubmitEvents(jsonArray);
}
Expand Down
6 changes: 6 additions & 0 deletions gio-sdk/autotracker-cdp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ dependencies {
debugApi project(':growingio-webservice:debugger')
releaseApi libraries.growingio.debugger

debugApi project(':growingio-data:database')
releaseApi libraries.growingio.database

debugApi project(':growingio-data:json')
releaseApi libraries.growingio.json

debugApi project(':growingio-webservice:circler')
releaseApi libraries.growingio.circler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import android.text.TextUtils;

import com.growingio.android.sdk.track.TrackMainThread;
import com.growingio.android.sdk.track.cdp.CdpEventBuildInterceptor;
import com.growingio.android.sdk.track.cdp.ResourceItem;
import com.growingio.android.sdk.track.cdp.ResourceItemCustomEvent;
import com.growingio.android.sdk.track.events.cdp.ResourceItem;
import com.growingio.android.sdk.track.events.cdp.ResourceItemCustomEvent;
import com.growingio.android.sdk.track.log.Logger;
import com.growingio.android.sdk.track.providers.ConfigurationProvider;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2020 Beijing Yishu Technology Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.growingio.android.sdk.autotrack;

import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.growingio.android.sdk.track.ipc.PersistentDataProvider;
import com.growingio.android.sdk.track.events.EventBuildInterceptor;
import com.growingio.android.sdk.track.events.base.BaseEvent;
import com.growingio.android.sdk.track.listener.OnUserIdChangedListener;
import com.growingio.android.sdk.track.log.Logger;
import com.growingio.android.sdk.track.middleware.GEvent;
import com.growingio.android.sdk.track.providers.UserInfoProvider;

public class CdpEventBuildInterceptor implements EventBuildInterceptor, OnUserIdChangedListener {
private static final String TAG = "CdpEventBuildInterceptor";

private static final String KEY_GIO_ID = "GIO_ID";

private final String mDataSourceId;

public CdpEventBuildInterceptor(String dataSourceId) {
mDataSourceId = dataSourceId;
UserInfoProvider.get().registerUserIdChangedListener(this);
}

@Override
public void eventWillBuild(BaseEvent.BaseBuilder<?> eventBuilder) {
eventBuilder.addExtraParam("dataSourceId", mDataSourceId);
String mLatestGioId = getGioId();
if (!TextUtils.isEmpty(mLatestGioId)) {
eventBuilder.addExtraParam("gioId", mLatestGioId);
}
}

@Override
public void eventDidBuild(GEvent event) {

}

private String getGioId() {
return PersistentDataProvider.get().getString(KEY_GIO_ID, null);
}

private void setGioId(String gioId) {
PersistentDataProvider.get().putString(KEY_GIO_ID, gioId);
}

@Override
public void onUserIdChanged(@Nullable String newUserId) {
String mLatestGioId = getGioId();
Logger.d(TAG, "onUserIdChanged: newUserId = " + newUserId + ", mLatestGioId = " + mLatestGioId);
if (!TextUtils.isEmpty(newUserId) && !newUserId.equals(mLatestGioId)) {
setGioId(newUserId);
}
}
}
6 changes: 6 additions & 0 deletions gio-sdk/autotracker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ dependencies {
debugApi project(':growingio-network:okhttp3')
releaseApi libraries.growingio.okhttp3

debugApi project(':growingio-data:database')
releaseApi libraries.growingio.database

debugApi project(':growingio-data:json')
releaseApi libraries.growingio.json

debugApi project(':growingio-webservice:circler')
releaseApi libraries.growingio.circler

Expand Down
6 changes: 6 additions & 0 deletions gio-sdk/tracker-cdp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ dependencies {
debugApi project(':growingio-network:okhttp3')
releaseApi libraries.growingio.okhttp3

debugApi project(':growingio-data:database')
releaseApi libraries.growingio.database

debugApi project(':growingio-data:json')
releaseApi libraries.growingio.json

debugApi project(':growingio-webservice:debugger')
releaseApi libraries.growingio.debugger

Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
/*
* Copyright (C) 2020 Beijing Yishu Technology Co., Ltd.
* Copyright (C) 2020 Beijing Yishu Technology Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.growingio.android.sdk.track.cdp;
package com.growingio.android.sdk.track;

import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.growingio.android.sdk.track.data.PersistentDataProvider;
import com.growingio.android.sdk.track.events.EventBuildInterceptor;
import com.growingio.android.sdk.track.events.base.BaseEvent;
import com.growingio.android.sdk.track.ipc.PersistentDataProvider;
import com.growingio.android.sdk.track.listener.OnUserIdChangedListener;
import com.growingio.android.sdk.track.log.Logger;
import com.growingio.android.sdk.track.middleware.GEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
import androidx.annotation.CallSuper;

import com.growingio.android.sdk.Tracker;
import com.growingio.android.sdk.track.cdp.CdpEventBuildInterceptor;
import com.growingio.android.sdk.track.cdp.ResourceItem;
import com.growingio.android.sdk.track.cdp.ResourceItemCustomEvent;
import com.growingio.android.sdk.track.events.cdp.ResourceItem;
import com.growingio.android.sdk.track.events.cdp.ResourceItemCustomEvent;
import com.growingio.android.sdk.track.log.Logger;
import com.growingio.android.sdk.track.providers.ConfigurationProvider;

Expand Down
6 changes: 6 additions & 0 deletions gio-sdk/tracker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ dependencies {
debugApi project(':growingio-network:okhttp3')
releaseApi libraries.growingio.okhttp3

debugApi project(':growingio-data:database')
releaseApi libraries.growingio.database

debugApi project(':growingio-data:json')
releaseApi libraries.growingio.json

debugApi project(':growingio-webservice:debugger')
releaseApi libraries.growingio.debugger

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ systemProp.org.gradle.internal.http.connectionTimeout=100000
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.injected.testOnly=false
android.useAndroidX=false
android.useAndroidX=true
android.enableJetifier=false
GROUP_ID=com.growingio.android
BINTRAY_USER_ORG=growingio-android
Expand Down
Loading

0 comments on commit 31849fe

Please sign in to comment.