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

upgrade doc #286

Merged
merged 7 commits into from
Jan 26, 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ yarn-error.log*

pnpm-lock.yaml
.pnpm-debug.log
package-lock.json
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

clone 本站点后,若想在本地运行,请确保本地有以下环境:

1. Node.js >= 16.14.0 或更高版本(可以通过运行 node -v 命令检查版本)。你可以使用 nvm 在一个计算机上管理多个版本的 Node
2. Yarn >= 1.5 版本(可以通过运行 yarn --version 命令检查版本)。Yarn 是 JavaScript 生态中的高性能软件包管理工具,可取代 npm。虽然这不是严格必须的,但强烈推荐。
1. Node.js >= 18.0.0 或更高版本(可以通过运行 node -v 命令检查版本)。你可以使用 nvm 在一个计算机上管理多个版本的 Node.

进入到站点目录,运行

Expand Down
61 changes: 32 additions & 29 deletions blog/2022-10-09-custom android sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ tags: [sdk, android, custom]

<!--truncate-->

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

## 自定义SDK

在 GrowingIO 的 SDK 中,已经有多个模块功能已经从代码中分离出来后续将会独立出更多的模块。具体可以到[模块功能](/docs/android/modules)查看已有的功能模块。
Expand All @@ -45,7 +48,7 @@ buildscript {
}
dependencies {
//无埋点注入插件
classpath "com.growingio.android:autotracker-gradle-plugin:3.4.2"
classpath "com.growingio.android:autotracker-gradle-plugin:4.0.0"
}
}
```
Expand All @@ -62,7 +65,7 @@ plugins {

dependencies {
//无埋点基础库
implementation 'com.growingio.android:autotracker-core:3.4.2'
implementation 'com.growingio.android:autotracker-core:4.0.0'
}

```
Expand All @@ -74,12 +77,12 @@ dependencies {
```groovy
dependencies {
//无埋点基础库
implementation 'com.growingio.android:autotracker-core:3.4.2'
implementation 'com.growingio.android:autotracker-core:4.0.0'

//所需的模块
implementation 'com.growingio.android:okhttp3:3.4.2'
implementation 'com.growingio.android:database:3.4.2'
implementation 'com.growingio.android:json:3.4.2'
implementation 'com.growingio.android:okhttp3:4.0.0'
implementation 'com.growingio.android:database:4.0.0'
implementation 'com.growingio.android:protobuf:4.0.0'
}
```

Expand All @@ -90,23 +93,23 @@ dependencies {
```groovy
dependencies {
//无埋点基础库
implementation 'com.growingio.android:autotracker-core:3.4.2'
implementation 'com.growingio.android:autotracker-core:4.0.0'

//所需的模块
implementation 'com.growingio.android:okhttp3:3.4.2'
implementation 'com.growingio.android:database:3.4.2'
implementation 'com.growingio.android:json:3.4.2'
implementation 'com.growingio.android:okhttp3:4.0.0'
implementation 'com.growingio.android:database:4.0.0'
implementation 'com.growingio.android:json:4.0.0'

//注解解析
implementation 'com.growingio.android:annotation:3.4.2'
annotationProcessor 'com.growingio.android:compiler:3.4.2'
implementation 'com.growingio.android:annotation:4.0.0'
annotationProcessor 'com.growingio.android:compiler:4.0.0'
}
```

:::tip kapt
若使用kotlin,可以通过 kapt 来依赖注解器

`kapt 'com.growingio.android:compiler:3.4.2'`
`kapt 'com.growingio.android:compiler:4.0.0'`
:::

### 4. 使用注解自定义SDK的属性
Expand Down Expand Up @@ -151,7 +154,7 @@ class GrowingIODemoAppModule : AppGioModule(){

2. DemoAutotracker 类
该类名称由 `@GIOAppModule#name` 决定。
该类主要用来提供SDK初始化接口,总共提供了两个初始化方法, 一个为 `startWithConfiguration(Application,DemoTackerConfiguration)`,该方法要求传入用户已经配置完成的config对象;另一为 `start(Application)`,该方法需要配合 `@GIOTracker` 注解使用,会在下面介绍,可以直接获取config进行代码配置;两者方法效果一样,都是整个 SDK 初始化的入口。
该类主要用来提供SDK初始化接口,总共提供了两个初始化方法, 一个为 `startWithConfiguration(Coontext,DemoTackerConfiguration)`,该方法要求传入用户已经配置完成的config对象;另一为 `start(Context)`,该方法需要配合 `@GIOTracker` 注解使用,会在下面介绍,可以直接获取config进行代码配置;两者方法效果一样,都是整个 SDK 初始化的入口。

同时,还可以通过调用 `DemoAutotracker.get()` 来获取整个 SDK 对外的开放接口。

Expand All @@ -161,7 +164,7 @@ class GrowingIODemoAppModule : AppGioModule(){

| 名称 | 参数 | 作用 |
| --------- | -------- | -------------------- |
| path | Class<?> | Tracker接口类路径 |
| path | Class{'<'}?{'>'} | Tracker接口类路径 |
| accountId | String | SDK初始化的项目id |
| urlScheme | String | SDK初始化的urlScheme |

Expand Down Expand Up @@ -232,7 +235,7 @@ DemoAutotracker.start(this)

```txt
!!! Thank you very much for using GrowingIO. We will do our best to provide you with the best service. !!!
!!! GrowingIO Tracker version: 3.4.2 !!!
!!! GrowingIO Tracker version: 4.0.0 !!!
```
和点击后出现 click 事件日志

Expand All @@ -242,10 +245,11 @@ DemoAutotracker.start(this)
║ "eventType": "VIEW_CLICK",
║ "timestamp": 1626847839398,
║ ...
║ "sdkVersion": "3.4.2",
║ "sdkVersion": "4.0.0",
║ "path": "/MainActivity",
║ "pageShowTimestamp": 1626839380613,
║ "xpath": "/Page/LinearLayout[0]/FrameLayout[0]/ActionBarOverlayLayout[0]#decor_content_parent/ContentFrameLayout[0]/CoordinatorLayout[0]/FloatingActionButton[0]#fab",
║ "xpath": "/MainActivity/LinearLayout/FrameLayout/ActionBarOverlayLayout/ContentFrameLayout/CoordinatorLayout/FloatingActionButton",
║ "xcontent": "/0/0/0/decor_content_parent/0/0/fab",
║ "index": -1
║ }
╚═══════════════════════════════════════════════════════════════════════════════════════
Expand Down Expand Up @@ -279,11 +283,11 @@ DemoAutotracker.start(this)
```groovy
dependencies {
//埋点基础库
implementation 'com.growingio.android:tracker-core:3.4.2'
implementation 'com.growingio.android:tracker-core:4.0.0'

//注解解析
implementation 'com.growingio.android:annotation:3.4.2'
annotationProcessor 'com.growingio.android:compiler:3.4.2'
implementation 'com.growingio.android:annotation:4.0.0'
annotationProcessor 'com.growingio.android:compiler:4.0.0'
}
```

Expand Down Expand Up @@ -500,7 +504,7 @@ public class OkhttpConfig implements Configurable {
后续需要将该配置类配置到模块注解中,自动注册完成后生成的 `<Custom>TackerConfiguration` 类中会自动包含 `OkhttpConfig` 中的配置方法以便 SDK 初始化时同时配置。

### 添加模块注解
最后一步是将模块的 `Factory` 与输入输出数据绑定一起,提供给 `TrackerRegistry` 注册。这时候有两种情况:通过注解注册和通过代码调用
最后一步是将模块的 `Factory` 与输入输出数据绑定一起,提供给 `TrackerRegistry` 注册。这时候有两种情况:通过注解注册或者通过代码调用

#### 在Library模块中
使用 `@GIOLibraryModule` 注解和 `LibraryGioModule` 配合,如下所示:
Expand All @@ -509,16 +513,16 @@ public class OkhttpConfig implements Configurable {
@GIOLibraryModule(config = OkhttpConfig.class)
public class OkhttpLibraryGioModule extends LibraryGioModule {
@Override
public void registerComponents(Context context, TrackerRegistry registry) {
registry.register(EventUrl.class, EventResponse.class, new OkHttpDataLoader.Factory());
public void registerComponents(TrackerContext context) {
context.getRegistry().register(EventUrl.class, EventResponse.class, new OkHttpDataLoader.Factory());
}
}

```
> `@GIOLibraryModule` 在项目中的 Project Module 中使用,经过 APT 编译后每一个 Project Module 中都会生成一个有着 `@Index` 注解的类,该类会记录其 Module 下的所有`@GIOLibraryModule`信息。

#### 在App主模块中
需要将模块放入到主模块的注解中,如下所示:
或者手动将模块放入到主模块的注解中,如下所示:

```java
@GIOAppModule(name = "DemoAutotracker", configName = "DemoTackerConfiguration",config = OkhttpConfig.class)
Expand All @@ -532,8 +536,8 @@ public class GrowingIODemoAppModule extends AppGioModule {
}

@Override
public void registerComponents(Context context, TrackerRegistry registry) {
registry.register(EventUrl.class, EventResponse.class, new OkHttpDataLoader.Factory());
public void registerComponents(TrackerContext context) {
context.getRegistry().register(EventUrl.class, EventResponse.class, new OkHttpDataLoader.Factory());
}
}
```
Expand All @@ -554,8 +558,7 @@ GrowingTracker.startWithConfiguration(this,
```java
DemoAutotracker.start(this);
//手动注册模块和配置类
ConfigurationProvider.get().addConfiguration(new OkhttpConfig());
DemoAutotracker.get().registerComponent(new OkhttpLibraryGioModule());
DemoAutotracker.get().registerComponent(new OkhttpLibraryGioModule(), new OkhttpConfig());
```

## 结束语
Expand Down
8 changes: 4 additions & 4 deletions docs/android/AGP7.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ plugins {
| :------------------------- | :------ | :----: |:------ |:------| -------------------------- |
| logEnabled | _Boolean_ | 否 | `false` | 编译时是否输出log日志 | |
| skipDependencyCheck | _Boolean_ | 否 | `false` | 编译时检测当前project是否配置SDK依赖(模块中依赖时配置为true) | |
| includePackages | _Array<String\>_ | 否 | `null` | 需要额外包含编译的包名 | |
| excludePackages | _Array<String\>_ | 否 | `null` | 需要跳过编译的包名 | |
| includePackages | _Array\<String\>_ | 否 | `null` | 需要额外包含编译的包名 | |
| excludePackages | _Array\<String\>_ | 否 | `null` | 需要跳过编译的包名 | |
| giokit | _GiokitExtension_ | 否 | `null` | 可以用来配置是否引入 Giokit | |

配置代码示例
Expand Down Expand Up @@ -114,8 +114,8 @@ dependencies {
| :------------------------- | :------ | :----: |:------ |:------|
| enabled | _Boolean_ | 否 | `false` | 是否添加 Giokit |
| trackerFinderEnabled | _Boolean_ | 否 | `true` | 查找App下调用App埋点接口的信息 |
| trackerFinderDomain | _Array<String\>_ | 否 | 默认为应用 ApplicationId | 查找的范围 |
| trackerCalledMethod | _Array<String\>_ | 否 | 默认为SDK相应接口 | 要查找的类和方法,类名与方法名使用#连接 |
| trackerFinderDomain | _Array\<String\>_ | 否 | 默认为应用 ApplicationId | 查找的范围 |
| trackerCalledMethod | _Array\<String\>_ | 否 | 默认为SDK相应接口 | 要查找的类和方法,类名与方法名使用#连接 |
| autoAttachEnabled | _Boolean_ | 否 | `true` | GioKit 是否自动依附在Activity上,若设为false,需要自行调用api打开GioKit |
| releaseEnabled | _Boolean_ | 否 | `false` | **请不要打开**,否则会在 Release 打包中包含 GioKit 代码 |
| autoInstallVersion | _String_ | 否 | `2.0.0` | 自动依赖的GioKit版本号 |
Expand Down
5 changes: 5 additions & 0 deletions docs/android/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import TabItem from '@theme/TabItem';
| setImpressionScale [#](#1-setimpressionscale) | _float_ | 否 | `0` | 元素曝光事件中的比例因子,范围 [0-1] | |
| setWebViewBridgeEnabled [#](#2-setwebviewbridgeenabled)| _boolean_| 否 | `true` | 是否全量采集 hybrid 数据 | |
| downgrade [#](#3-downgrade) | _void_ | 否 | 无 | 恢复旧版本无埋点上报逻辑 | |
| enableFragmentTag [#](#4-enableFragmentTag) | _boolean_ | 否 | `false` | 是否将Fragment的tag作为无埋点路径的记号 | |


## 通用配置说明
Expand Down Expand Up @@ -202,3 +203,7 @@ GrowingAutotracker.startWithConfiguration(this,

### 3. downgrade
调用该方法后,所有的无埋点将以旧版本的无埋点逻辑上报数据,请谨慎使用。

### 4. enableFragmentTag
在使用一些库时会导致Fragment的Tag不可预计,比如在高版本 Navigation 库,Navigation库会对所有的导航 Fragment 赋予一个 UUID 生成的随机TAG。为了保证无埋点路径的准确,取消无埋点路径xcontent中对tag的支持,现在默认取 Fragment 的id为xcontent路径。
若客户需要tag支持,可打开 enableFragmentTag(true)。
10 changes: 5 additions & 5 deletions docs/android/Introduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ buildscript {
}
dependencies {
//GrowingIO 无埋点 SDK plugin
classpath 'com.growingio.android:autotracker-gradle-plugin:4.0.0'
classpath 'com.growingio.android:autotracker-gradle-plugin:4.1.0'
}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ apply plugin: 'com.android.application'

dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.0.0')
implementation platform('com.growingio.android:autotracker-bom:4.1.0')

//GrowingIO 无埋点 SDK
implementation 'com.growingio.android:autotracker'
Expand All @@ -193,7 +193,7 @@ dependencies {
apply plugin: 'com.android.application'

dependencies {
implementation 'com.growingio.android:autotracker:4.0.0'
implementation 'com.growingio.android:autotracker:4.1.0'
}
```

Expand Down Expand Up @@ -349,7 +349,7 @@ apply plugin: 'com.android.application'

dependencies {
// Import the BoM for the GrowingIO platform
implementation platform('com.growingio.android:autotracker-bom:4.0.0')
implementation platform('com.growingio.android:autotracker-bom:4.1.0')

//GrowingIO 埋点 SDK
implementation 'com.growingio.android:tracker'
Expand All @@ -365,7 +365,7 @@ apply plugin: 'com.android.application'

dependencies {
//GrowingIO 埋点 SDK
implementation 'com.growingio.android:tracker:4.0.0'
implementation 'com.growingio.android:tracker:4.1.0'
}
```

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.0.0')
implementation platform('com.growingio.android:autotracker-bom:4.1.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.0.0')
implementation platform('com.growingio.android:autotracker-bom:4.1.0')

implementation 'com.growingio.android:autotracker:4.0.0'
implementation 'com.growingio.android:autotracker:4.1.0'
}
```
</details>
Expand Down Expand Up @@ -72,7 +72,7 @@ dependencies {
```groovy
dependencies {
// Import the BoM for the GrowingIO platform
implementation 'com.growingio.android:autotracker-bom:4.0.0'
implementation 'com.growingio.android:autotracker-bom:4.1.0'

implementation 'com.growingio.android:autotracker'
}
Expand Down
14 changes: 7 additions & 7 deletions docs/android/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ GrowingTracker.get().cleanLocation()
| 参数 | 参数类型 | 说明 |
| :----------- | :-------------------- | :-------------------------------------------------------------------------------- |
| `eventName` | _String_ | 事件名,事件标识符 |
| `attributes` | _Map<String, String>_ | 事件发生时所伴随的属性信息;当事件属性关联有维度表时,属性值为对应的维度表模型ID(记录ID)(可选) |
| `attributes` | _Map{'<'}String, String{'>'}_ | 事件发生时所伴随的属性信息;当事件属性关联有维度表时,属性值为对应的维度表模型ID(记录ID)(可选) |
#### 示例

**无埋点SDK示例代码:**
Expand Down Expand Up @@ -281,7 +281,7 @@ GrowingTracker.get().trackCustomEvent("registerSuccess", map)
#### 参数说明
| 参数 | 参数类型 | 说明 |
| :----------- | :-------------------- | :----------- |
| `attributes` | _Map<String, String>_ | 用户属性信息 |
| `attributes` | _Map{'<'}String, String{'>'}_ | 用户属性信息 |
#### 示例

**无埋点SDK示例代码:**
Expand Down Expand Up @@ -420,7 +420,7 @@ GrowingTracker.get().bridgeWebView(webview)
| 参数 | 参数类型 | 说明 |
| :---------- | :------- | :------------------- |
| `eventName` | _String_ | 事件名称,事件标识符 |
| `attributes` | _Map<String, String>_ | 事件发生时所伴随的属性信息 |
| `attributes` | _Map{'<'}String, String{'>'}_ | 事件发生时所伴随的属性信息 |

#### 返回值说明
| 参数 | 参数类型 | 说明 |
Expand Down Expand Up @@ -516,7 +516,7 @@ GrowingTracker.get().registerComponent(module,<config>)
#### 参数说明
| 参数 | 参数类型 | 说明 |
| :---------- | :------- | :------------------- |
| `variables` | _Map<String, String>_ | 设置通用属性信息 |
| `variables` | _Map{'<'}String, String{'>'}_ | 设置通用属性信息 |
| `keys` | _String..._ | 删除指定通用属性|

#### 示例
Expand Down Expand Up @@ -624,7 +624,7 @@ GrowingTracker.get().trackCustomEvent("registerSuccess", builder.build());
| :------ | :---------------------- | :---: | :---------------|
| `page` | _Activity_ / _Fragment_ | 是 | 需要采集的页面对象 |
| `alias` | _String_ | 是 | 采集的页面名称 |
| `attributes` | _Map<String, String>_ | 否 | 页面的属性信息,可选|
| `attributes` | _Map{'<'}String, String{'>'}_ | 否 | 页面的属性信息,可选|

在Android系统中,可以采集的页面主要为 `Activity`,`Fragment`(包括support,app的和androidx包下)。同时需要开发者为每一个页面指定一个名称,用于分析云平台页面数据处理。<br/>
为了保证页面信息的准确性,推荐在页面的 `onCreate` 中调用采集页面事件接口。
Expand Down Expand Up @@ -681,7 +681,7 @@ override fun onCreate(savedInstanceState: Bundle?) {
| 参数 | 参数类型 | 说明 |
| :------ | :-------------------- | :----------------------|
| `page` | _Activity_ / _Fragment_ | 需要设置属性的页面对象 |
| `attributes` | _Map<String, String>_ | 属性信息 |
| `attributes` | _Map{'<'}String, String{'>'}_ | 属性信息 |
#### 示例

**无埋点SDK示例代码:**
Expand Down Expand Up @@ -733,7 +733,7 @@ override fun onCreate(savedInstanceState: Bundle?) {
| :-------------------- | :-------------------- | :------------------------- |
| `view` | _View_ | 需要采集曝光事件的View对象 |
| `impressionEventName` | _String_ | 曝光的事件名 |
| `attributes` | _Map<String, String>_ | 曝光的事件属性 |
| `attributes` | _Map{'<'}String, String{'>'}_ | 曝光的事件属性 |
#### 示例

**无埋点SDK示例代码:**
Expand Down
Loading
Loading