Closed billdizl closed 2 years ago
麻烦你这边提供一个问题复现 demo
能否添加下您的私Q吗 然后你看下具体是什么问题导致的 之前我们只是开启了activity的全埋点,没有任何问题
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年7月11日(星期一) 晚上6:31 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [sensorsdata/sa-sdk-android] fragment无法自动采集埋点 (Issue #105)
麻烦你这边提供一个问题复现 demo
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
实在搞不懂了,我写了个demo能抓到,原模原样的复制到项目就不能不能收集到fragment的埋点
终于找到问题了,不是我集成错了 是因为神策没有高版本适配
@billdizl 你说的高版本是什么?能具体说一下吗?或者提供个 demo,我们测试一下。如果有问题我们尽快适配
`apply plugin: 'com.android.application' //添加 com.sensorsdata.analytics.android 插件 apply plugin: 'com.sensorsdata.analytics.android'
android { compileSdkVersion rootProject.ext.buildConfig.compileSdkVersion
defaultConfig {
applicationId "com.sensorsdata.sdk.demo"
minSdkVersion rootProject.ext.buildConfig.minSdkVersion
targetSdkVersion rootProject.ext.buildConfig.targetSdkVersion
versionCode rootProject.ext.buildConfig.versionCode
versionName rootProject.ext.buildConfig.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled true
}
// sensorsAnalytics { // debug = true // }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies { implementation fileTree(include: ['.jar', '.so'], dir: 'libs') implementation rootProject.ext.androidx.appcompat implementation rootProject.ext.androidx.google_material implementation rootProject.ext.androidx.constraintlayout implementation project(':SensorsAnalyticsSDK') implementation 'com.google.dagger:dagger:2.42' annotationProcessor 'com.google.dagger:dagger-compiler:2.42' } `
package com.sensorsdata.sdk.demo;
import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
/**
*/ public class BlankFragment extends Fragment {
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { /* 参数:
}
package com.sensorsdata.sdk.demo;
import android.os.Bundle;
import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentTransaction;
public class FragmentTestActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_empty); final FragmentTransaction fragmentTransaction = this.getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(R.id.fragmentContainer, new BlankFragment()); fragmentTransaction.commit(); } }
/*
import android.app.Application;
import com.sensorsdata.analytics.android.sdk.SAConfigOptions; import com.sensorsdata.analytics.android.sdk.SensorsAnalyticsAutoTrackEventType; import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
public class MyApplication extends Application { /**
Sensors Analytics 采集数据的地址 */ private final static String SA_SERVER_URL = "https://sdkdebugtest.datasink.sensorsdata.cn/sa?project=default&token=cfb8b60e42e0ae9b";
@Override public void onCreate() { super.onCreate(); initSensorsDataAPI(); }
/**
package com.sensorsdata.sdk.demo;
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction;
public class TestActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initLambdaButton();
initButton();
}
public void onViewClick(View view) {
}
private void initLambdaButton() {
Button button = (Button) findViewById(R.id.lambdaButton);
button.setOnClickListener(v -> {
// //获得FragmentManager对象 // FragmentManager fragmentManager = getSupportFragmentManager(); // // 通过FragmentManager对象获得FragmentTransaction对象(开启事务) // FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); // // fragmentTransaction.add(R.id.fl_layout, new BlankFragment());//动态添加 // fragmentTransaction.commit();//提交 提交 提交(很重要) startActivity(new Intent(TestActivity.this,FragmentTestActivity.class)); }); }
private void initButton() {
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
} // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { apply from: "script_config/config.gradle" repositories { jcenter() mavenCentral() google() maven { url 'https://maven.google.com' } maven { url '../repo' } } dependencies { classpath 'com.android.tools.build:gradle:7.2.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' //添加 Sensors Analytics android-gradle-plugin 依赖 classpath 'com.sensorsdata.analytics.android:android-gradle-plugin2:3.4.9' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$rootProject.ext.kotlins.kotlin_version" } }
allprojects { repositories { jcenter() mavenCentral() google() maven { url 'https://maven.google.com' } maven { url '../repo' } } }
你这使用的我们的 demo 吧,配置有什么问题吗
你把你们的demo替换下我发的代码,然后运行下试试 fragment就不会自动采集了
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年7月12日(星期二) 中午11:40 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [sensorsdata/sa-sdk-android] fragment无法自动采集埋点 (Issue #105)
你这使用的我们的 demo 吧,配置有什么问题吗
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
@billdizl 你这边方便,把你的 demo clean 一下,发给我吗?我担心改的配置容易出现问题,没办法复现
我怎么celean一下发给你呢?
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年7月12日(星期二) 中午11:58 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [sensorsdata/sa-sdk-android] fragment无法自动采集埋点 (Issue #105)
@billdizl 你这边方便,把你的 demo clean 一下,发给我吗?我担心改的配置容易出现问题,没办法复现
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
./gradlew clean
经测试 我的项目中不能使用classpath 'com.android.tools.build:gradle:7.2.1' 使用classpath 'com.android.tools.build:gradle:4.1.3'可以获取到fragment数据,7.2.1 在我的代码中不行~~~~我写了个demo 发现在demo中是可行的
SA_SERVER_URL = BuildConfig.SA_SERVER_URL; SAConfigOptions saConfigOptions = new SAConfigOptions(SA_SERVER_URL); saConfigOptions.setAutoTrackEventType(SensorsAnalyticsAutoTrackEventType.APP_CLICK | SensorsAnalyticsAutoTrackEventType.APP_START | SensorsAnalyticsAutoTrackEventType.APP_END | SensorsAnalyticsAutoTrackEventType.APP_VIEW_SCREEN) .enableLog(true) .enableVisualizedAutoTrack(true); //开 SensorsDataAPI.startWithConfigOptions(this, saConfigOptions); // 初始化 SDK 之后,开启自动采集 Fragment 页面浏览事件 SensorsDataAPI.sharedInstance().trackFragmentAppViewScreen();
同时我也配置了插件 classpath 'com.sensorsdata.analytics.android:android-gradle-plugin2:3.4.9' sdk版本: implementation 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.4.2'
//神策 apply plugin: 'com.sensorsdata.analytics.android' 但是就是获取不到fragment自动采集埋点