├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── themes.xml │ │ │ │ └── strings.xml │ │ │ ├── values-land │ │ │ │ └── dimens.xml │ │ │ ├── values-w1240dp │ │ │ │ └── dimens.xml │ │ │ ├── values-w600dp │ │ │ │ └── dimens.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── values-v29 │ │ │ │ └── themes.xml │ │ │ ├── xml │ │ │ │ ├── backup_rules.xml │ │ │ │ └── data_extraction_rules.xml │ │ │ ├── layout │ │ │ │ ├── content_main.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── fragment_first.xml │ │ │ │ ├── fragment_second.xml │ │ │ │ ├── main_fragment.xml │ │ │ │ └── trace_list_fragment.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── navigation │ │ │ │ └── nav_graph.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── cn │ │ │ │ └── alvince │ │ │ │ └── droidprism │ │ │ │ └── sample │ │ │ │ ├── trace │ │ │ │ ├── SampleTrace.kt │ │ │ │ └── SampleInvisibleTrace.kt │ │ │ │ ├── log │ │ │ │ └── CustomPrismLogcatSink.kt │ │ │ │ ├── FirstFragment.kt │ │ │ │ ├── SecondFragment.kt │ │ │ │ ├── MainFragment.kt │ │ │ │ ├── MainActivity.kt │ │ │ │ └── list │ │ │ │ └── TraceListFragment.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── cn │ │ │ └── alvince │ │ │ └── droidprism │ │ │ └── sample │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── cn │ │ └── alvince │ │ └── droidprism │ │ └── sample │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── lib-prism-core ├── .gitignore ├── consumer-rules.pro ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ └── values │ │ │ │ └── ids.xml │ │ └── java │ │ │ └── cn │ │ │ └── alvince │ │ │ └── droidprism │ │ │ ├── internal │ │ │ ├── Log.kt │ │ │ ├── TraceEmitter.kt │ │ │ ├── TraceShooter.kt │ │ │ ├── lifecycle │ │ │ │ └── Lifecycle.kt │ │ │ ├── Utils.kt │ │ │ └── Instrumentation.kt │ │ │ ├── IPrismSink.kt │ │ │ ├── log │ │ │ ├── page │ │ │ │ ├── ILogPage.kt │ │ │ │ ├── ILogPageEntry.kt │ │ │ │ ├── IPageName.kt │ │ │ │ ├── IPageDurationCalc.kt │ │ │ │ └── LogPageManager.kt │ │ │ ├── ActionType.kt │ │ │ ├── impl │ │ │ │ ├── LogPageEntryDelegate.kt │ │ │ │ └── LogPageDelegate.kt │ │ │ ├── TraceSpot.kt │ │ │ ├── ITraceable.kt │ │ │ └── ExposureStateHelper.kt │ │ │ ├── util │ │ │ └── Functions.kt │ │ │ ├── EZPrism.kt │ │ │ ├── app │ │ │ ├── Fragment.kt │ │ │ └── Activity.kt │ │ │ └── operator │ │ │ ├── ViewExposureController.kt │ │ │ └── ViewTraceHelper.kt │ └── test │ │ └── java │ │ └── cn │ │ └── alvince │ │ └── droidprism │ │ └── ExampleUnitTest.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── pub │ └── publish_config.gradle ├── .gitignore ├── .editorconfig ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /lib-prism-core/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /lib-prism-core/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "EZPrism" 2 | include ':app' 3 | include ':lib-prism-core' 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16dp 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 48dp 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/values-w1240dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 200dp 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values-w600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 48dp 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alvince/EZPrism/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/ 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | local.properties 11 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu May 19 16:42:39 CST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/java/cn/alvince/droidprism/internal/Log.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.internal 2 | 3 | import cn.alvince.droidprism.log.page.PageNameOf 4 | 5 | internal val PAGE_BACKGROUND = PageNameOf("Background") 6 | 7 | internal val PAGE_UNDEFINED = PageNameOf("Undefined") 8 | 9 | internal val PAGE_EMPTY = PageNameOf("None") 10 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/java/cn/alvince/droidprism/IPrismSink.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism 2 | 3 | import androidx.annotation.MainThread 4 | import cn.alvince.droidprism.log.ActionType 5 | import org.json.JSONObject 6 | 7 | interface IPrismSink { 8 | 9 | /** 10 | * Called on main thread, sink trace event 11 | */ 12 | @MainThread 13 | fun sink(type: ActionType, logData: JSONObject) 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 4 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.kt] 13 | max_line_length = 160 14 | wildcard_import_limit = 99 15 | 16 | [*.gradle] 17 | max_line_length = 160 18 | 19 | [*.json] 20 | indent_size = 2 21 | 22 | [*.md] 23 | trim_trailing_whitespace = false 24 | -------------------------------------------------------------------------------- /app/src/test/java/cn/alvince/droidprism/sample/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.sample 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /lib-prism-core/src/test/java/cn/alvince/droidprism/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/values-v29/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/java/cn/alvince/droidprism/internal/TraceEmitter.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.internal 2 | 3 | import androidx.annotation.MainThread 4 | import cn.alvince.droidprism.log.ActionType 5 | import cn.alvince.droidprism.log.ITraceable 6 | 7 | class TraceEmitter { 8 | 9 | @MainThread 10 | fun emitAction(actionType: ActionType, trace: ITraceable) { 11 | logDIfDebug { "emit trace: [${actionType.logType()}] $trace" } 12 | TraceShooter.sendWithCommonFields(actionType, actionType.traceToJson(trace)) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/java/cn/alvince/droidprism/log/page/ILogPage.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.log.page 2 | 3 | import cn.alvince.droidprism.log.ExposureStateHelper 4 | 5 | interface ILogPage { 6 | 7 | fun interface OnPageShowStatusChangeListener { 8 | fun onPageShowStatusChanged(show: Boolean) 9 | } 10 | 11 | val exposureStateHelper: ExposureStateHelper 12 | 13 | fun onPageShowingChanged(show: Boolean) 14 | 15 | fun pageName(): IPageName 16 | 17 | fun addOnPageShowStatusChangedListener(listener: OnPageShowStatusChangeListener) 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/java/cn/alvince/droidprism/log/page/ILogPageEntry.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.log.page 2 | 3 | import cn.alvince.zanpakuto.core.serialization.JSONCreator 4 | import org.json.JSONObject 5 | 6 | /** 7 | * [ILogPage] entry that traceable powered by [LogPageManager] 8 | * 9 | * Create by bytedance on 2022/9/24 10 | * 11 | * @author zhangyang.alvince@bytedance.com 12 | */ 13 | interface ILogPageEntry : ILogPage { 14 | 15 | val content: JSONObject 16 | 17 | var className: String 18 | 19 | fun setPageName(pageName: IPageName) 20 | 21 | fun setPageContent(content: JSONObject) 22 | 23 | fun setPageContent(content: JSONCreator.() -> Unit) 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/cn/alvince/droidprism/sample/trace/SampleTrace.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.sample.trace 2 | 3 | import cn.alvince.droidprism.log.ActionType 4 | import cn.alvince.droidprism.log.ITraceable 5 | import cn.alvince.zanpakuto.core.serialization.json 6 | import org.json.JSONObject 7 | 8 | /** 9 | * Sample custom trace model 10 | * 11 | * Create by bytedance on 2022/9/11 12 | * 13 | * @author zhangyang.alvince@bytedance.com 14 | */ 15 | open class SampleTrace(val name: String) : ITraceable { 16 | 17 | override fun toActionJson(actionType: ActionType): JSONObject = json { 18 | "event_id" to name 19 | } 20 | 21 | override fun toString(): String { 22 | return "SampleTrace(name='$name')" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/java/cn/alvince/droidprism/internal/TraceShooter.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.internal 2 | 3 | import cn.alvince.droidprism.log.ActionType 4 | import cn.alvince.droidprism.log.page.ILogPageEntry 5 | import org.json.JSONObject 6 | 7 | internal object TraceShooter { 8 | 9 | fun pageEntry(pageEntry: ILogPageEntry) { 10 | // Instrumentation.traverseSink { it.sink(ActionType.PAGE_ENTER, ) } 11 | } 12 | 13 | fun pageExit(pageEntry: ILogPageEntry) { 14 | Instrumentation.traverseSink { it.sink(ActionType.PAGE_EXIT, pageEntry.content) } 15 | } 16 | 17 | fun sendWithCommonFields(type: ActionType, logData: JSONObject) { 18 | Instrumentation.traverseSink { it.sink(type, logData) } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/java/cn/alvince/droidprism/log/page/IPageName.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.log.page 2 | 3 | import cn.alvince.zanpakuto.core.text.orDefault 4 | 5 | /** 6 | * Log page name indicator 7 | */ 8 | interface IPageName { 9 | val id: String 10 | 11 | val displayName: String get() = id 12 | } 13 | 14 | /** 15 | * Simple [IPageName] impl 16 | */ 17 | class SimplePageName(pageId: String, display: String? = null) : IPageName { 18 | override val id: String = pageId 19 | 20 | override val displayName: String = display.orDefault(pageId) 21 | } 22 | 23 | @Suppress("FunctionName") // Create IPageName via function 24 | fun PageNameOf(pageId: String, displayName: String? = null): IPageName = SimplePageName(pageId, displayName) 25 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/cn/alvince/droidprism/sample/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.sample 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("cn.alvince.droidprism.sample", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /lib-prism-core/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/java/cn/alvince/droidprism/sample/log/CustomPrismLogcatSink.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.sample.log 2 | 3 | import android.util.Log 4 | import cn.alvince.droidprism.EZPrism 5 | import cn.alvince.droidprism.IPrismSink 6 | import cn.alvince.droidprism.log.ActionType 7 | import org.json.JSONObject 8 | 9 | class CustomPrismLogcatSink : IPrismSink { 10 | 11 | override fun sink(type: ActionType, logData: JSONObject) { 12 | Log.d("EZPrism", "——> [custom sink] ${type.typeName} - $logData") 13 | } 14 | 15 | companion object { 16 | private var prepared = false 17 | 18 | fun prepare() { 19 | if (prepared) { 20 | return 21 | } 22 | EZPrism.devMode(true) 23 | .useRawPage() 24 | .addPrinter(CustomPrismLogcatSink()) 25 | prepared = true 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib-prism-core/src/main/java/cn/alvince/droidprism/util/Functions.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.util 2 | 3 | import android.view.View 4 | import cn.alvince.droidprism.log.ExposureStateHelper 5 | import cn.alvince.droidprism.log.page.ILogPage 6 | import cn.alvince.droidprism.log.ITraceable 7 | import cn.alvince.droidprism.operator.ViewTraceHelper 8 | 9 | fun View.traceExpose(page: ILogPage, trace: ITraceable?) { 10 | getTraceHelper().apply { 11 | this.trace = trace 12 | this.exposureStateHelper = page.exposureStateHelper 13 | } 14 | } 15 | 16 | fun View.exposeWith(exposureStateHelper: ExposureStateHelper, trace: ITraceable?) { 17 | getTraceHelper().apply { 18 | this.trace = trace 19 | this.exposureStateHelper = exposureStateHelper 20 | } 21 | } 22 | 23 | fun View.getTraceHelper(): ViewTraceHelper { 24 | return ViewTraceHelper.from(this) ?: ViewTraceHelper.create().also { it.attachToView(this) } 25 | } 26 | -------------------------------------------------------------------------------- /gradle/pub/publish_config.gradle: -------------------------------------------------------------------------------- 1 | project.extensions.create('mvn', MvnConfig) 2 | 3 | class MvnConfig { 4 | String artifact = '' 5 | String group = 'cn.alvince.droidprism' 6 | String version = '' 7 | String name = '' 8 | String description = '' 9 | String packaging = 'aar' 10 | 11 | void setArtifact(String artifact) { 12 | this.artifact = artifact 13 | } 14 | 15 | void setGroup(String group) { 16 | this.group = group 17 | } 18 | 19 | void setVersion(String version) { 20 | this.version = version 21 | } 22 | 23 | void setName(String name) { 24 | this.name = name 25 | } 26 | 27 | void setDescription(String description) { 28 | this.description = description 29 | } 30 | 31 | void setPackaging(String packaging) { 32 | this.packaging = packaging 33 | } 34 | 35 | String getName() { 36 | return name.isEmpty() ? artifact : name 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/cn/alvince/droidprism/sample/trace/SampleInvisibleTrace.kt: -------------------------------------------------------------------------------- 1 | package cn.alvince.droidprism.sample.trace 2 | 3 | import cn.alvince.droidprism.log.ActionType 4 | import cn.alvince.droidprism.log.ITraceWhenInvisibleWithDuration 5 | import cn.alvince.droidprism.log.SimpleDuration 6 | import cn.alvince.zanpakuto.core.serialization.json 7 | import org.json.JSONObject 8 | 9 | /** 10 | * Sample custom trace model that track when invisible only, with exposure duration report 11 | * 12 | * Create by bytedance on 2022/9/11 13 | * 14 | * @author zhangyang.alvince@bytedance.com 15 | */ 16 | class SampleInvisibleTrace(name: String) : SampleTrace(name), ITraceWhenInvisibleWithDuration by SimpleDuration() { 17 | 18 | override fun toActionJson(actionType: ActionType): JSONObject = json { 19 | "event_id" to name 20 | if (actionType == ActionType.EXPOSE) { 21 | "duration" to duration.inSeconds 22 | } 23 | } 24 | 25 | override fun toString(): String { 26 | return "SampleInvisibleTrace(name='$name', duration='$duration')" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 |