Skip to content

Commit f0b810a

Browse files
authored
Merge pull request #240 from flashcatcloud/docs/harmony-tracking-consent
docs(harmony): expand tracking-consent section to match the Android page
2 parents 2f47305 + c2a7b7a commit f0b810a

2 files changed

Lines changed: 47 additions & 17 deletions

File tree

en/rum/sdk/harmony/advanced-config.mdx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,35 @@ const config = new ConfigurationBuilder('<CLIENT_TOKEN>', 'production')
4040

4141
## Tracking consent
4242

43-
Pass `TrackingConsent` during initialization. You can also update it at runtime with `Flashcat.setTrackingConsent()`.
43+
To comply with privacy regulations such as GDPR and CCPA, the SDK requires a tracking consent state at initialization (the third argument of `Flashcat.initialize()`), and lets you change it at any time afterwards.
44+
45+
### Consent states
46+
47+
| State | Behavior | When to use |
48+
|-------|----------|-------------|
49+
| `TrackingConsent.GRANTED` | Collects data and sends it to Flashduty | The user has agreed to data collection |
50+
| `TrackingConsent.NOT_GRANTED` | Collects nothing | The user has declined data collection |
51+
| `TrackingConsent.PENDING` | Collects data but does not send it | Waiting for the user's decision |
52+
53+
<Info>
54+
When initialized with `TrackingConsent.PENDING`, the SDK writes events to a separate local buffer and sends nothing until consent changes to `GRANTED` — at which point the buffered data is migrated and uploaded automatically. Changing to `NOT_GRANTED` clears the buffer instead.
55+
</Info>
56+
57+
### Setting and changing consent
58+
59+
At initialization:
4460

4561
```ts
4662
import { Flashcat, TrackingConsent } from '@flashcatcloud/core';
4763

48-
Flashcat.setTrackingConsent(TrackingConsent.PENDING);
49-
Flashcat.setTrackingConsent(TrackingConsent.GRANTED);
64+
Flashcat.initialize(this.context, coreConfig, TrackingConsent.PENDING);
5065
```
5166

52-
| State | Behavior |
53-
|-------|----------|
54-
| `GRANTED` | Writes to the main upload directory and starts batch uploads |
55-
| `PENDING` | Writes events to a separate pending buffer; when consent changes to `GRANTED`, the SDK migrates and uploads them |
56-
| `NOT_GRANTED` | Drops new events, clears the pending buffer, and stops uploads |
67+
After initialization, via the `setTrackingConsent` API (for example once the user responds to your privacy dialog):
68+
69+
```ts
70+
Flashcat.setTrackingConsent(TrackingConsent.GRANTED);
71+
```
5772

5873
<Warning>
5974
Trace headers also honor tracking consent. The SDK injects correlatable `traceparent` and `tracestate` headers only when consent is `GRANTED`.

zh/rum/sdk/harmony/advanced-config.mdx

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,37 @@ const config = new ConfigurationBuilder('<CLIENT_TOKEN>', 'production')
3838
`Flashcat.initialize()` 同一个实例名只会初始化一次。重复初始化会返回已存在实例,不会重新注册功能模块。
3939
</Note>
4040

41-
## 隐私同意状态
41+
## 用户跟踪同意
4242

43-
初始化时需要传入 `TrackingConsent`。你也可以在运行时通过 `Flashcat.setTrackingConsent()` 修改。
43+
为遵守 GDPR、CCPA 等隐私法规,SDK 要求在初始化时设置用户跟踪同意状态(`Flashcat.initialize()` 的第三个参数),并可在初始化后随时变更。
44+
45+
### 同意状态说明
46+
47+
| 状态 | 行为 | 使用场景 |
48+
|------|------|----------|
49+
| `TrackingConsent.GRANTED` | 开始收集数据并发送到 Flashduty | 用户已同意数据收集 |
50+
| `TrackingConsent.NOT_GRANTED` | 不收集任何数据 | 用户拒绝数据收集 |
51+
| `TrackingConsent.PENDING` | 收集数据但不发送 | 等待用户确认 |
52+
53+
<Info>
54+
如果初始化时使用 `TrackingConsent.PENDING`,SDK 会将事件写入单独的本地缓冲区,但在同意状态更改为 `GRANTED` 之前不会发送;变更为 `GRANTED` 后缓冲数据自动迁移并上传,变更为 `NOT_GRANTED` 则清空缓冲。
55+
</Info>
56+
57+
### 设置与更改同意状态
58+
59+
初始化时设置:
4460

4561
```ts
4662
import { Flashcat, TrackingConsent } from '@flashcatcloud/core';
4763

48-
Flashcat.setTrackingConsent(TrackingConsent.PENDING);
49-
Flashcat.setTrackingConsent(TrackingConsent.GRANTED);
64+
Flashcat.initialize(this.context, coreConfig, TrackingConsent.PENDING);
5065
```
5166

52-
| 状态 | 行为 |
53-
|------|------|
54-
| `GRANTED` | 写入主上传目录并启动批量上传 |
55-
| `PENDING` | 事件写入单独的 pending 缓冲区,不上传;变更为 `GRANTED` 后迁移并上传 |
56-
| `NOT_GRANTED` | 丢弃新事件,清空 pending 缓冲区并停止上传 |
67+
初始化后通过 `setTrackingConsent` API 更改(例如用户在隐私弹窗中做出选择后):
68+
69+
```ts
70+
Flashcat.setTrackingConsent(TrackingConsent.GRANTED);
71+
```
5772

5873
<Warning>
5974
Trace header 也受同意状态控制。只有状态为 `GRANTED` 时,SDK 才会向请求注入可关联的 `traceparent``tracestate`

0 commit comments

Comments
 (0)