Skip to content

Commit

Permalink
Android Jetpack Compose doc (#350)
Browse files Browse the repository at this point in the history
* jetpack compose doc

* android sdk v4.4.0
  • Loading branch information
cpacm authored Jan 15, 2025
1 parent 0944704 commit 5a0ed6a
Show file tree
Hide file tree
Showing 22 changed files with 212 additions and 55 deletions.
2 changes: 1 addition & 1 deletion docs/android/AGP7.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ plugins {
···
// 添加GrowingIO 无埋点 SDK 插件
id 'com.growingio.android.autotracker' version '4.3.0' apply false
id 'com.growingio.android.autotracker' version '4.4.0' apply false
}
```

Expand Down
10 changes: 5 additions & 5 deletions docs/android/Introduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ apply plugin: 'com.android.application'
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
//GrowingIO 无埋点 SDK
implementation 'com.growingio.android:autotracker'
Expand All @@ -112,7 +112,7 @@ dependencies {
apply plugin: 'com.android.application'
dependencies {
implementation 'com.growingio.android:autotracker:4.3.2'
implementation 'com.growingio.android:autotracker:4.4.0'
}
```

Expand Down Expand Up @@ -146,7 +146,7 @@ plugins {
···
// 添加GrowingIO 无埋点 SDK 插件
id 'com.growingio.android.autotracker' version '4.3.0' apply false
id 'com.growingio.android.autotracker' version '4.4.0' apply false
}
```

Expand Down Expand Up @@ -178,7 +178,7 @@ buildscript {
}
dependencies {
//GrowingIO 无埋点 SDK plugin
classpath 'com.growingio.android:autotracker-gradle-plugin:4.3.0'
classpath 'com.growingio.android:autotracker-gradle-plugin:4.4.0'
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ class MyApplication : Application() {

```shell
!!! Thank you very much for using GrowingIO. We will do our best to provide you with the best service. !!!
!!! GrowingIO Tracker version: 4.3.0 !!!
!!! GrowingIO Tracker version: 4.4.0 !!!
```

则说明SDK已经集成成功。
Expand Down
8 changes: 4 additions & 4 deletions docs/android/PlatformBom.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ title: 依赖清单BoM
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:tracker'
implementation 'com.growingio.android:autotracker'
Expand All @@ -34,9 +34,9 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:autotracker:4.3.2'
implementation 'com.growingio.android:autotracker:4.4.0'
}
```
</details>
Expand Down Expand Up @@ -73,7 +73,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation 'com.growingio.android:autotracker-bom:4.3.2'
implementation 'com.growingio.android:autotracker-bom:4.4.0'
implementation 'com.growingio.android:autotracker'
}
Expand Down
4 changes: 2 additions & 2 deletions docs/android/modules/abtest module.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import TabItem from '@theme/TabItem';

```groovy
dependencies {
implementation 'com.growingio.android:abtest:4.3.2'
implementation 'com.growingio.android:abtest:4.4.0'
}
```
</TabItem>
Expand All @@ -41,7 +41,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:abtest'
}
Expand Down
2 changes: 1 addition & 1 deletion docs/android/modules/adapter module.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:analytics-fa'
implementation 'com.growingio.android:analytics-ga'
Expand Down
4 changes: 2 additions & 2 deletions docs/android/modules/advert module.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ keytool -list -v -keystore release.keystore

```groovy
dependencies {
implementation 'com.growingio.android:ads:4.3.2'
implementation 'com.growingio.android:ads:4.4.0'
}
```
</TabItem>
Expand All @@ -145,7 +145,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:ads'
}
Expand Down
4 changes: 2 additions & 2 deletions docs/android/modules/circler module.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import TabItem from '@theme/TabItem';

```groovy
dependencies {
implementation 'com.growingio.android:circler:4.3.2'
implementation 'com.growingio.android:circler:4.4.0'
}
```
</TabItem>
Expand All @@ -46,7 +46,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:circler'
}
Expand Down
115 changes: 115 additions & 0 deletions docs/android/modules/compose module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
sidebar_position: 13
title: Compose 模块
---

Growingio 无埋点 SDK 支持 Jetpack Compose 框架,包括页面事件,无埋点点击事件和圈选功能。

--------
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

### SDK说明
| 关键词 | 是否集成| 输入数据类 | 输出数据类 | 最低SDK版本 |
| :------- | :------: | --:| ---:| :---|
| compose | 需要手动集成 | `ComposeData` | `ComposeJson` | 4.4.0 |

### 依赖方式
<Tabs
groupId="code-language"
defaultValue="common"
values={[
{label: '依赖', value: 'common'},
{label: 'BoM', value: 'bom'},
]
}>

<TabItem value="common">

```groovy
dependencies {
implementation 'com.growingio.android:compose:4.4.0'
}
```
</TabItem>

<TabItem value="bom">

```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:compose'
}
```

</TabItem>
</Tabs>

### 使用方式

1. 初始化时添加 ComposeLibraryGioModule 模块

```kotlin
GrowingAutotracker.startWithConfiguration(this,
AutotrackConfiguration("accountId", "urlScheme")
//...
.addPreloadComponent(ComposeLibraryGioModule()))
```

2. 引入 Kotlin Compiler Plugin 插件

在引入无埋点插件的前提下,添加新的KCP插件.

```toml
[plugins]
growingio-compose-plugin = {id = "com.growingio.compose.plugin",version = "4.4.0"}
```

```groovy
plugins {
//id 'com.growingio.compose.plugin'
alias(libs.plugins.growingio.compose.plugin)
}
```

> 该KCP插件主要为无埋点事件控件的路径`xpath`赋予可读性更高的名称。理论上不集成该插件也能正常发送无埋点事件。
最后不要忘记在项目下的`build.gradle`中声明该插件
```groovy
plugins {
alias libs.plugins.growingio.compose.plugin apply false
}
```

3. 设置无埋点页面

`@composable` 组件下将要声明的页面组件使用 `GrowingComposePage` 包裹。各个参数分别为:`alias`为页面唯一识别名称,`modifier`为需要的组件修饰符,`attributes`为页面属性,`content`则为作为Page的 composable 组件内容。

```kotlin
GrowingComposePage(
alias = "PageName",
modifier: Modifier = Modifier,
attributes: Map<String, String> = hashMapOf(),
content = {
PageScreen(
modifier = modifier,
//...
)
}
)
```
至此,compose 无埋点框架配置完成。

:::warning Dialog
直接包裹AlertDialog将只会发送Page事件,无埋点事件的path无法与page事件绑定。原因为Compose的AlertDialog是一个新的window渲染而来,无法直接穿透获取,所以无埋点事件无法向上遍历得到page节点的alias值。这边建议将page页面包裹AlertDialog的下一级组件。
:::

### 无埋点的配置接口

1. `Modifier.growingTag(tag: String)` 为设置的组件设置别名,反映在无埋点事件的`xpath`路径中;
2. `Modifier.interruptClick()` 在GrowingIO Compose SDK 中获取点击组件是由上而下遍历的且取最后一个可点击组件的过程,所以当多个可点击组件重叠时会优先取到最后面的组件。使用该方法可以控制无埋点事件优先取到 `interruptClick` 装饰的组件;

24 changes: 12 additions & 12 deletions docs/android/modules/core module.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ title: 核心模块

| 名称 | 说明 | 依赖 |
| :------------- | :---------------------------------------------------------------------------------: | :--------------------------------------------- |
| 埋点 Library | 埋点核心库,包含最基本的埋点逻辑 | `com.growingio.android:tracker-core:4.3.2` |
| 无埋点 Library | 无埋点核心库,依赖于埋点核心库,包含无埋点的注入逻辑 | `com.growingio.android:autotracker-core:4.3.2` |
| 模块注解库 | 注解声明,通过注解可以自动生成 SDK 的初始化类来注册所有的模块和聚合模块内的配置类。 | `com.growingio.android:annotation:4.3.2` |
| 注解解析器 | 与上面注解配合使用 | `com.growingio.android:compiler:4.3.2` |
| 埋点 Library | 埋点核心库,包含最基本的埋点逻辑 | `com.growingio.android:tracker-core:4.4.0` |
| 无埋点 Library | 无埋点核心库,依赖于埋点核心库,包含无埋点的注入逻辑 | `com.growingio.android:autotracker-core:4.4.0` |
| 模块注解库 | 注解声明,通过注解可以自动生成 SDK 的初始化类来注册所有的模块和聚合模块内的配置类。 | `com.growingio.android:annotation:4.4.0` |
| 注解解析器 | 与上面注解配合使用 | `com.growingio.android:compiler:4.4.0` |

--------
import Tabs from '@theme/Tabs';
Expand All @@ -37,7 +37,7 @@ SDK 事件通过 `EventDatabase` 来传递到数据库并进行增删改查的

```groovy
dependencies {
implementation 'com.growingio.android:database:4.3.2'
implementation 'com.growingio.android:database:4.4.0'
}
```
</TabItem>
Expand All @@ -47,7 +47,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:database'
}
Expand Down Expand Up @@ -77,9 +77,9 @@ SDK 事件通过 `EventUrl` 指定请求方式、服务器请求地址,再通
```groovy
dependencies {
// 网络模块-okhttp3
implementation 'com.growingio.android:okhttp3:4.3.2'
implementation 'com.growingio.android:okhttp3:4.4.0'
// 可选网络模块-urlconnnection
implementation 'com.growingio.android:urlconnnection:4.3.2'
implementation 'com.growingio.android:urlconnnection:4.4.0'
}
```
</TabItem>
Expand All @@ -89,7 +89,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
// 网络模块-okhttp3
implementation 'com.growingio.android:okhttp3'
Expand All @@ -102,7 +102,7 @@ dependencies {
</Tabs>

## 数据格式库
默认使用 `protobuf` 来做数据传输的格式。通过数据格式转换可以将输入 `EventFormatData` 转为字节数组数据 `EventByteArray` 方便网络数据上传。
默认使用 `protobuf` 来做数据传输的格式。通过数据格式转换可以将输入 `EventFormatData` 转为字节数组数据 `EventByteArray` 方便网络数据上传。若发生pb版本冲突,可参考 [Android-常见问题-14](/docs/question/android) 解决

### 依赖方式
<Tabs
Expand All @@ -118,7 +118,7 @@ dependencies {

```groovy
dependencies {
implementation 'com.growingio.android:protobuf:4.3.2'
implementation 'com.growingio.android:protobuf:4.4.0'
}
```
</TabItem>
Expand All @@ -128,7 +128,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:protobuf'
}
Expand Down
4 changes: 2 additions & 2 deletions docs/android/modules/debugger module.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import TabItem from '@theme/TabItem';

```groovy
dependencies {
implementation 'com.growingio.android:debugger:4.3.2'
implementation 'com.growingio.android:debugger:4.4.0'
}
```
</TabItem>
Expand All @@ -46,7 +46,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:debugger'
}
Expand Down
4 changes: 2 additions & 2 deletions docs/android/modules/encoder module.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import TabItem from '@theme/TabItem';

```groovy
dependencies {
implementation 'com.growingio.android:encoder:4.3.2'
implementation 'com.growingio.android:encoder:4.4.0'
}
```
</TabItem>
Expand All @@ -44,7 +44,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.3.2')
implementation platform('com.growingio.android:autotracker-bom:4.4.0')
implementation 'com.growingio.android:encoder'
}
Expand Down
Loading

0 comments on commit 5a0ed6a

Please sign in to comment.