Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:cdp autotrcker upgrade #209

Merged
merged 6 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gio-sdk/autotracker-cdp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
53 changes: 53 additions & 0 deletions gio-sdk/autotracker-cdp/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apply plugin: 'com.android.library'

android {
namespace 'com.growingio.android.sdk.autotracker.cdp'
compileSdkVersion buildConfiguration.compileVersion
defaultConfig {
minSdkVersion buildConfiguration.minSdkVersion
targetSdkVersion buildConfiguration.targetSdkVersion
versionName libs.versions.growingio.get()
versionCode libs.versions.growingioCode.get().toInteger()
}

buildTypes {
debug {
testCoverageEnabled = true
}

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'consumer-proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility buildConfiguration.sourceCompatibility
targetCompatibility buildConfiguration.targetCompatibility
}
lintOptions {
abortOnError false
}
}

dependencies {
debugApi project(':growingio-tracker-core')
debugApi project(':growingio-autotracker-core')
debugApi project(':growingio-network:okhttp3')
debugApi project(':growingio-data:database')
debugApi project(':growingio-data:protobuf')
debugApi project(':growingio-webservice:circler')
debugApi project(':growingio-webservice:debugger')
debugApi project(':growingio-hybrid')

releaseApi libs.bundles.growingio.autotracker.sdk

compileOnly libs.androidx.appcompat
compileOnly libs.support.appcompat

releaseImplementation libs.growingio.annotation
debugImplementation project(":growingio-annotation")
annotationProcessor project(":growingio-annotation:compiler")
}

apply from: "${rootProject.projectDir}/gradle/publishMaven.gradle"
Empty file.
20 changes: 20 additions & 0 deletions gio-sdk/autotracker-cdp/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# 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.
#

POM_NAME=autotracker-cdp
POM_ARTIFACT_ID=autotracker-cdp
POM_PACKAGING=aar
POM_DESCRIPTION=GrowingIO Android SDK AutoTracker CDP.
21 changes: 21 additions & 0 deletions gio-sdk/autotracker-cdp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright (C) 2023 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.app.Activity;
import android.content.Context;

import com.growingio.android.sdk.autotrack.page.PageProvider;
import com.growingio.android.sdk.autotrack.page.SuperFragment;
import com.growingio.android.sdk.track.TrackMainThread;
import com.growingio.android.sdk.track.log.Logger;
import com.growingio.android.sdk.track.providers.TrackerLifecycleProvider;

import java.util.Map;

public class CdpAutotracker extends Autotracker {
private static final String TAG = "GrowingAutotracker";

public CdpAutotracker(Context context) {
super(context);
}

public void ignorePage(Activity activity) {
if (!isInited || activity == null) {
Logger.e(TAG, "sdk not init or activity is NULL");
return;
}
TrackMainThread.trackMain().runOnUiThread(() -> {
Logger.d(TAG, "ignorePage: " + activity.getClass().getSimpleName());
PageProvider.get().ignoreActivity(activity, true);
});
}


/**
* android.app.Fragment is deprecated
*/
@Deprecated
public void ignoreSystemPage(final android.app.Fragment fragment) {
if (!isInited || fragment == null) {
Logger.e(TAG, "sdk not init or fragment is NULL");
return;
}
Logger.d(TAG, "ignorePage: " + fragment.getClass().getSimpleName());
TrackMainThread.trackMain().runOnUiThread(() -> PageProvider.get().ignoreFragment(SuperFragment.make(fragment), true));
}

/**
* android.support.v4.app.Fragment is deprecated
*/
@Deprecated
public void ignoreSupportPage(final android.support.v4.app.Fragment fragment) {
if (!isInited || fragment == null) {
Logger.e(TAG, "sdk not init or fragment is NULL");
return;
}
Logger.d(TAG, "ignorePage: " + fragment.getClass().getSimpleName());
TrackMainThread.trackMain().runOnUiThread(() -> PageProvider.get().ignoreFragment(SuperFragment.makeSupport(fragment), true));
}

public void ignorePage(final androidx.fragment.app.Fragment fragment) {
if (!isInited || fragment == null) {
Logger.e(TAG, "sdk not init or fragment is NULL");
return;
}
Logger.d(TAG, "ignorePage: " + fragment.getClass().getSimpleName());
TrackMainThread.trackMain().runOnUiThread(() -> PageProvider.get().ignoreFragment(SuperFragment.makeX(fragment), true));
}

@Override
protected Map<Class<? extends TrackerLifecycleProvider>, TrackerLifecycleProvider> extraProviders() {
Map<Class<? extends TrackerLifecycleProvider>, TrackerLifecycleProvider> providerMap = super.extraProviders();
providerMap.put(CdpDowngradeProvider.class, new CdpDowngradeProvider());
return providerMap;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2023 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 com.growingio.android.sdk.TrackerContext;
import com.growingio.android.sdk.track.middleware.CdpConfig;
import com.growingio.android.sdk.track.providers.ConfigurationProvider;
import com.growingio.android.sdk.track.providers.TrackerLifecycleProvider;

public class CdpDowngradeProvider implements TrackerLifecycleProvider {
private static final String TAG = "CdpDowngradeProvider";
private ConfigurationProvider configurationProvider;

@Override
public void setup(TrackerContext context) {
configurationProvider = context.getConfigurationProvider();
CdpConfig config = configurationProvider.getConfiguration(CdpConfig.class);
if (config.isDowngrade()) {
downgrade();
}
}

/**
* Downgrade the autotrack config to the version before 4.0.0.
*/
private void downgrade() {
AutotrackConfig config = configurationProvider.getConfiguration(AutotrackConfig.class);
config.getAutotrackOptions().setFragmentPageEnabled(true);
config.getAutotrackOptions().setActivityPageEnabled(true);
}

@Override
public void shutdown() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2023 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 com.growingio.android.sdk.AppGioModule;
import com.growingio.android.sdk.track.middleware.CdpConfig;
import com.growingio.sdk.annotation.GIOAppModule;
import com.growingio.sdk.annotation.GIOTracker;

@GIOAppModule(name = "GrowingAutotracker", configName = "CdpAutotrackConfiguration", config = CdpConfig.class)
public class GrowingAutoAppModule extends AppGioModule {

@GIOTracker(path = CdpAutotracker.class)
public void config(CdpAutotrackConfiguration configuration) {
if (TextUtils.isEmpty(configuration.getDataSourceId())) {
throw new IllegalStateException("DataSourceId is NULL");
}
}
}
1 change: 1 addition & 0 deletions gio-sdk/tracker-cdp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
49 changes: 49 additions & 0 deletions gio-sdk/tracker-cdp/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apply plugin: 'com.android.library'

android {
namespace 'com.growingio.android.sdk.tracker.cdp'
compileSdkVersion buildConfiguration.compileVersion
defaultConfig {
minSdkVersion buildConfiguration.minSdkVersion
targetSdkVersion buildConfiguration.targetSdkVersion
versionName libs.versions.growingio.get()
versionCode libs.versions.growingioCode.get().toInteger()
}

buildTypes {
debug {
testCoverageEnabled = true
}

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'consumer-proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility buildConfiguration.sourceCompatibility
targetCompatibility buildConfiguration.targetCompatibility
}
lintOptions {
abortOnError false
}
}

dependencies {
debugApi project(':growingio-tracker-core')
debugApi project(':growingio-network:okhttp3')
debugApi project(':growingio-data:database')
debugApi project(':growingio-data:protobuf')
debugApi project(':growingio-webservice:debugger')

releaseApi libs.bundles.growingio.tracker.sdk

compileOnly libs.support.appcompat

releaseImplementation libs.growingio.annotation
debugImplementation project(":growingio-annotation")
annotationProcessor project(":growingio-annotation:compiler")
}

apply from: "${rootProject.projectDir}/gradle/publishMaven.gradle"
Empty file.
20 changes: 20 additions & 0 deletions gio-sdk/tracker-cdp/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# 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.
#

POM_NAME=tracker-cdp
POM_ARTIFACT_ID=tracker-cdp
POM_PACKAGING=aar
POM_DESCRIPTION=GrowingIO Android Tracker SDK CDP.
21 changes: 21 additions & 0 deletions gio-sdk/tracker-cdp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Loading
Loading