cx-rum-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRUM Setup Skill
RUM 配置 Skill
Use this skill to onboard an application to Coralogix Real User Monitoring (RUM): get a RUM API key, install the platform SDK, add the call, and verify events land in the dataset.
initrum.events使用此 skill 将应用接入 Coralogix Real User Monitoring (RUM):获取 RUM API key、安装平台 SDK、添加 调用,并验证事件是否已落入 数据集。
initrum.eventsCLI Commands
CLI 命令
| Command | Purpose |
|---|---|
| List candidate keys and the team ID (no permissions in output) |
| List candidate send-data keys (no permissions in output) |
| Read a key's permissions ( |
| Create the RUM key (write - needs approval + |
| Current SDK install and init docs per platform |
| Verify RUM events arrive |
| Profiles and regions - pick the active one for both key and |
cx iamcx dataprime-p <profile>cx profilescx docs-pcx profiles list -p ...| 命令 | 用途 |
|---|---|
| 列出候选密钥和 team ID(输出中不包含权限信息) |
| 列出候选 send-data 密钥(输出中不包含权限信息) |
| 读取密钥的权限( |
| 创建 RUM 密钥(写入操作——需要审批并添加 |
| 获取各平台当前的 SDK 安装和初始化文档 |
| 验证 RUM 事件已到达 |
| Profiles 和区域——为密钥和 |
cx iamcx dataprime-p <profile>cx profilescx docs-pcx profiles list -p ...Workflow
工作流
1. Detect the platform
1. 检测平台
Inspect the user's repo before anything else. Signals overlap (React Native apps also list ; Flutter and React Native repos contain and folders), so check in this order and stop at the first match:
reactios/android/| # | Signal | Platform |
|---|---|---|
| 1 | | Flutter SDK - ignore its |
| 2 | | React Native SDK - ignore |
| 3 | | Next.js (browser SDK, client-only init) |
| 4 | | Browser SDK ( |
| 5 | | iOS SDK |
| 6 | | Android SDK |
A alone (Node backend, tooling) is not a browser app. If nothing matches, tell the user no supported client app was found instead of guessing.
package.json首先检查用户的代码仓库。各项信号可能相互重叠(React Native 应用也会列出 ;Flutter 和 React Native 仓库都包含 和 目录),因此请按以下顺序检查,并在第一个匹配项处停止:
reactios/android/| # | 信号 | 平台 |
|---|---|---|
| 1 | | Flutter SDK——忽略其中的 |
| 2 | | React Native SDK——忽略 |
| 3 | | Next.js(Browser SDK,仅在客户端初始化) |
| 4 | | Browser SDK( |
| 5 | | iOS SDK |
| 6 | 包含 Android plugin 的 | Android SDK |
仅存在 (Node 后端、工具链)并不代表这是一个 browser 应用。如果没有任何匹配项,请告知用户未找到受支持的客户端应用,不要自行猜测。
package.json2. Pick the profile - before any key operation
2. 选择 profile——在执行任何密钥操作之前
The key and the SDK domain must come from one profile, so settle it before touching keys. The active profile is if given, else if set, else the row of - don't just read the row. If there are several profiles and none was named, ask the user which team the app belongs to now, then pass to every and call that follows.
-p <name>$CX_PROFILEDEFAULTcx profiles listDEFAULT-p <name>cx iamcx dataprimecoralogixDomainREGIONEU1EU2US1US2US3AP1AP2AP3密钥和 SDK domain 必须来自同一个 profile,因此在操作密钥前先确定 profile。如果指定了 ,则使用该 profile;否则,如果设置了 ,则使用该环境变量;否则,使用 输出中的 行——不要直接读取 行。如果存在多个 profile 且未指定任何名称,现在询问用户该应用属于哪个 team,然后在后续每次调用 和 时都传入 。
-p <name>$CX_PROFILEcx profiles listDEFAULTDEFAULTcx iamcx dataprime-p <name>coralogixDomainREGIONEU1EU2US1US2US3AP1AP2AP33. Get a RUM API key
3. 获取 RUM API key
RUM keys are public by design - they ship inside client code. Create it with the preset - the same key the UI's RUM flow creates. That preset grants exactly one permission, , and is standalone: never add other presets or permissions. (Granting directly also works but shows as a key in the UI, so prefer the preset.) In Settings → API Keys a RUM key shows type "Send Your Data" with preset . Do not pick the preset - it grants logs/metrics/spans ingest but not RUM, and makes the key secret, not public.
SendRUMDatarum-ingress:SendDatarum-ingress:SendDataCUSTOMSendRUMDataSendDataReuse first. Check for an existing RUM key:
bash
cx iam api-keys list -p <profile> -o json
cx iam api-keys send-data-keys -p <profile> -o jsonThese listings don't include permissions, so treat every row as a candidate only - never reuse a key based on its name. For each candidate run and reuse it only if it is active () and has as its only preset and no other permissions (or as its only permission). Skip inactive keys - the SDK can't send with them. The value is in (returned for unhashed keys - a hashed key can't be reused, create a new one).
cx iam api-keys get <id> -p <profile> -o jsonkeyInfo.active: truekeyInfo.keyPermissionsSendRUMDatarum-ingress:SendDatakeyInfo.valueCreate one if none exists. This is a write - describe it to the user and get approval before passing (same rules as ).
--yescx-platform-adminbash
cat > rum-key.json <<'EOF'
{
"name": "<app-name> RUM",
"owner": { "teamId": <team-id> },
"keyPermissions": { "presets": ["SendRUMData"], "permissions": [] },
"hashed": false
}
EOF
cx iam api-keys create --from-file rum-key.json -p <profile> --yes -o json-
: read
teamIdfrom the step-2 profile's filecached_team_id(written by~/.cx/profiles/<profile>.toml), or thecx initof any key inowner.teamId, or ask the user.cx iam api-keys list -o json -
: RUM keys are Send-Your-Data (data-ingest) keys, so they need the
Permission deniedpermissions, not the team custom-key ones:DATA-INGEST-API-KEYS- on → the role lacks
send-data-keys(view keys);DATA-INGEST-API-KEYS:READCONFIG - on or
get→ the role lackscreate(DATA-INGEST-API-KEYS:MANAGEneeds it too, since it returns the key value).get
Don't retry with other payloads. Tell the user which permission is missing and ask them to get it, or to create it in Settings → API Keys - key type Send Your Data Key, role presetonly (or have an admin do it), then continue from step 4 with the key value.SendRUMData - on
-
keeps the key value retrievable later - fine for a public RUM key.
hashed: false -
The response contains- that is the
valuefor the SDK.public_key
RUM 密钥按设计就是公开的——它们会随客户端代码一同分发。请使用 preset 创建它——这与 UI 中 RUM 流程创建的密钥相同。该 preset 仅授予一项权限 ,并且是独立预设:不要添加其他 preset 或权限。(也可以直接授予 ,但在 UI 中会显示为 密钥,因此优先使用该 preset。)在 Settings → API Keys 中,RUM 密钥的类型显示为 "Send Your Data",preset 为 。不要选择 preset——它授予 logs、metrics 和 spans 摄取权限,但不包括 RUM,而且会使密钥成为 secret,而不是 public。
SendRUMDatarum-ingress:SendDatarum-ingress:SendDataCUSTOMSendRUMDataSendData**优先复用。**检查是否已有 RUM 密钥:
bash
cx iam api-keys list -p <profile> -o json
cx iam api-keys send-data-keys -p <profile> -o json这些列表不包含权限信息,因此应将每一行仅视为候选项——绝不能仅凭名称复用密钥。对于每个候选项,运行 ,仅当该密钥处于启用状态(),并且 将 作为唯一 preset 且不包含其他权限(或仅包含 权限)时,才可以复用。跳过未启用的密钥——SDK 无法使用它们发送数据。密钥值位于 中(仅未哈希的密钥会返回该值;哈希密钥无法复用,需要创建新密钥)。
cx iam api-keys get <id> -p <profile> -o jsonkeyInfo.active: truekeyInfo.keyPermissionsSendRUMDatarum-ingress:SendDatakeyInfo.value**如果不存在,则创建一个。**这是一项写入操作——请向用户说明,并在传入 之前获得批准(规则与 相同)。
--yescx-platform-adminbash
cat > rum-key.json <<'EOF'
{
"name": "<app-name> RUM",
"owner": { "teamId": <team-id> },
"keyPermissions": { "presets": ["SendRUMData"], "permissions": [] },
"hashed": false
}
EOF
cx iam api-keys create --from-file rum-key.json -p <profile> --yes -o json-
:从步骤 2 中 profile 的文件
teamId(由~/.cx/profiles/<profile>.toml写入)读取cx init,或使用cached_team_id中任意密钥的cx iam api-keys list -o json,也可以询问用户。owner.teamId -
:RUM 密钥是 Send-Your-Data(data-ingest)密钥,因此需要
Permission denied权限,而不是 team custom-key 权限:DATA-INGEST-API-KEYS- 执行 时,表示角色缺少
send-data-keys(查看密钥);DATA-INGEST-API-KEYS:READCONFIG - 执行 或
get时,表示角色缺少create(DATA-INGEST-API-KEYS:MANAGE也需要该权限,因为它会返回密钥值)。get
不要使用其他 payload 重试。告知用户缺少哪项权限,并请其获取相应权限,或在 Settings → API Keys 中创建密钥——密钥类型为 Send Your Data Key,role preset 仅设置为(也可以让管理员创建),然后使用密钥值从步骤 4 继续操作。SendRUMData - 执行
-
会让密钥值以后仍可检索——对于 public RUM 密钥,这是可接受的。
hashed: false -
响应中包含——这就是 SDK 使用的
value。public_key
4. Fetch the current SDK docs
4. 获取当前 SDK 文档
SDK package names, versions, and options change - fetch them instead of guessing (see ):
coralogix-docsbash
cx docs search "RUM SDK installation <platform>" --limit 5
cx docs fetch <suffix-from-search>SDK 包名、版本和选项会发生变化——请获取最新文档,不要凭记忆猜测(参见 ):
coralogix-docsbash
cx docs search "RUM SDK installation <platform>" --limit 5
cx docs fetch <suffix-from-search>5. Install and initialize
5. 安装并初始化
Use the profile and from step 2.
coralogixDomainBrowser example (confirm against the fetched docs):
bash
npm install @coralogix/browserts
import { CoralogixRum } from '@coralogix/browser';
CoralogixRum.init({
application: '<app-name>',
environment: 'production',
public_key: process.env.NEXT_PUBLIC_CX_RUM_KEY!, // or import.meta.env.VITE_CX_RUM_KEY
coralogixDomain: 'EU1',
version: '<app-version>',
});Gotchas:
- Init once, as early as possible - the app entry point (,
main.ts, root layout).index.tsx - Next.js: init only on the client - a component that calls
'use client'ininit, rendered from the root layout. Never in server components.useEffect - Env vars: keep the key in env config (,
NEXT_PUBLIC_*,VITE_*), not hard-coded. It is public, but env config makes rotation easy.REACT_APP_* - should match the release - source maps and release comparison rely on it.
version - Source maps (optional) are uploaded with and need a separate key - in the UI, key type Team Key with role preset
coralogix-rum-cli(SourceMapping+source-mapping:ReadMapping) - never reuse the RUM key, and keep this one secret (CI only, not in client code). SeeUploadMapping(search doesn't surface it).cx docs fetch user-guides/rum/cli/rum-cli.md
使用步骤 2 中确定的 profile 和 。
coralogixDomainBrowser 示例(请根据获取到的文档进行确认):
bash
npm install @coralogix/browserts
import { CoralogixRum } from '@coralogix/browser';
CoralogixRum.init({
application: '<app-name>',
environment: 'production',
public_key: process.env.NEXT_PUBLIC_CX_RUM_KEY!, // or import.meta.env.VITE_CX_RUM_KEY
coralogixDomain: 'EU1',
version: '<app-version>',
});注意事项:
- 仅初始化一次,并尽早执行——应在应用入口处调用(、
main.ts、根布局)。index.tsx - **Next.js:**仅在客户端初始化——使用带有 的组件,在
'use client'中调用useEffect,并从根布局渲染该组件。绝不要在 Server Component 中调用。init - **环境变量:**将密钥保存在环境配置中(、
NEXT_PUBLIC_*、VITE_*),不要硬编码。虽然该密钥是 public,但环境配置便于轮换。REACT_APP_* - 应与发布版本一致——Source maps 和版本对比都依赖它。
version - Source maps(可选)通过 上传,并且需要一个单独的密钥——在 UI 中,密钥类型为 Team Key,role preset 为
coralogix-rum-cli(SourceMapping+source-mapping:ReadMapping)——绝不要复用 RUM 密钥,并且该密钥必须保密(仅用于 CI,不能放入客户端代码)。参见UploadMapping(搜索无法找到此文档)。cx docs fetch user-guides/rum/cli/rum-cli.md
6. Verify data arrives (optional)
6. 验证数据到达(可选)
Setup is done once the key exists and is in place - data only flows after the app runs and users hit it, and the SDK sends in batches. Give the user this query to run later, or run it now if they load the app:
initbash
cx dataprime query --source rum.events \
"filter \$d.version_metadata.app_name == '<app-name>' | limit 10" -p <profile> -o jsonNo rows? Check the browser network tab for requests to the RUM ingress endpoint. Ad blockers, a wrong , or a key with extra permissions are the usual causes.
coralogixDomain密钥存在且 已正确放置后,配置即告完成——只有在应用运行且用户访问后,数据才会开始流动,并且 SDK 会批量发送。可以将以下查询留给用户稍后运行,也可以在用户加载应用时立即运行:
initbash
cx dataprime query --source rum.events \
"filter \$d.version_metadata.app_name == '<app-name>' | limit 10" -p <profile> -o json没有数据行?检查 browser 网络面板中是否有发往 RUM ingress endpoint 的请求。广告拦截器、错误的 ,或包含额外权限的密钥通常会导致此问题。
coralogixDomainKey Principles
关键原则
- RUM key = preset only - nothing else on the key
SendRUMData - Reuse before create, and never pass without user approval
--yes - Fetch SDK docs per platform with - don't hard-code versions or options from memory
cx docs - Client-side init only, once, at the app entry point
- Done = key + init in place - hand over the query for checking data later
rum.events
- RUM 密钥只能使用 preset——不要添加任何其他内容
SendRUMData - 先复用,再创建,未经用户批准绝不传入
--yes - 使用 按平台获取 SDK 文档——不要凭记忆硬编码版本或选项
cx docs - 仅在客户端初始化,只执行一次,并放在应用入口处
- 完成标准 = 密钥已就绪 + 已就位——交付
init查询,供用户稍后检查数据rum.events
Related Skills
相关 Skills
- - general API key management
cx-platform-admin - - fetch platform-specific SDK docs
coralogix-docs - - query RUM data once it flows
cx-telemetry-querying
- ——通用 API key 管理
cx-platform-admin - ——获取特定平台的 SDK 文档
coralogix-docs - ——数据开始流动后查询 RUM 数据
cx-telemetry-querying