This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
客户ID
读取 EAS Observe 在每个指标和事件上记录的 EAS 客户端 ID,并用它将数据与其他服务关联起来。
EAS Observe 发送的每一个指标、事件和日志记录都带有一个 EAS 客户端 ID:这是你应用某个安装的随机标识。仪表板和 EAS CLI 会用它按安装分组数据,而 Observe.clientId 会把相同的值暴露给你的应用。
🌐 Every metric, event, and log record that EAS Observe sends carries an EAS client ID: a random identifier for one installation of your app. The dashboard and the EAS CLI use it to group data by installation, and Observe.clientId exposes the same value to your app.
用它从其他工具查看某个安装的 Observe 数据,比如你的崩溃报告工具、分析服务提供商,或者你自己的后台。
🌐 Use it to look up an installation's Observe data from another tool, such as your crash reporter, your analytics provider, or your own backend.
读取客户端ID
🌐 Read the client ID
Observe.clientId 是 Android 和 iOS 上的字符串,而在网页上是 null:
import { Observe } from 'expo-observe'; console.log(Observe.clientId); // 'f81d4fae-7dec-41d0-a765-00a0c91e6bf6'
只要导入 expo-observe,这个值就可以使用。你不需要先调用 configure()。
🌐 The value is available as soon as expo-observe is imported. You do not need to call configure() first.
与另一个服务相关联
🌐 Correlate with another service
把客户端 ID 附加到你发送到其他地方的数据上。然后,当你在那个服务中发现问题时,你可以在 EAS Observe 中查询同一个安装。
🌐 Attach the client ID to the data you send elsewhere. Then, when you find a problem in that service, you can query the same installation in EAS Observe.
以下示例会将客户端 ID 与报告一起发送到你自己的后端:
🌐 The following example sends the client ID alongside a report to your own backend:
import { Observe } from 'expo-observe'; async function reportFeedback(message: string) { await fetch('https://example.com/feedback', { method: 'POST', body: JSON.stringify({ message, easClientId: Observe.clientId, }), }); }
崩溃报告和分析 SDK 通常会提供一个标签、自定义属性或上下文字段。启动时设置一次,然后使用该值在 EAS Observe 中找到匹配的安装。
🌐 Crash reporting and analytics SDKs usually offer a tag, a custom property, or a context field for this. Set it once at startup, then use the value to find the matching installation in EAS Observe.
要往相反方向走,运行eas observe:metrics或eas observe:events并使用--json。每个示例都包含它的easClientId。
🌐 To go the other direction, run eas observe:metrics or eas observe:events with --json. Each sample includes its easClientId.
客户端ID的表现
🌐 How the client ID behaves
- 这个 ID 会在 EAS 客户端库第一次需要它时在设备上生成,并存储在本地偏好设置中。它不是从任何硬件或账户标识生成的。
- 它在应用启动、应用更新以及 EAS 更新中都很稳定。
- 它会与你应用中的其他 EAS 客户端库共享,比如
expo-updates。同一个安装在它们之间都有一个相同的 ID。 - 当应用的数据被清除或重新安装时,它会改变,不过备份恢复(包括重新安装时的 Android 自动备份)可以保留之前的ID。
因为这个 ID 识别的是一个安装而不是个人,所以把它当作化名数据处理。如果你要把它发送给第三方服务,检查一下你的隐私政策是否包括这种用途。
🌐 Because the ID identifies an installation rather than a person, treat it as pseudonymous data. If you send it to a third-party service, check that your privacy policy covers that use.
采样和客户端ID
🌐 Sampling and the client ID
sampleRate 决策是根据客户端ID得出的,这就是为什么一个安装在不同启动中会保持在样本内或样本外。 Observe.clientId 会返回ID,无论安装是否在样本内,所以即使应用没有发送任何指标,你也可以记录它。
🌐 The sampleRate decision is derived from the client ID, which is why an installation stays in-sample or out-of-sample across launches. Observe.clientId returns the ID whether or not the installation is in-sample, so you can log it even when the app dispatches no metrics.