Skip to content

获取远程配置,并设置到sessionSampleRate - #18

Open
guguji5 wants to merge 10 commits into
mainfrom
feat-load-config
Open

获取远程配置,并设置到sessionSampleRate#18
guguji5 wants to merge 10 commits into
mainfrom
feat-load-config

Conversation

@guguji5

@guguji5 guguji5 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator
image 小程序里flashcatRum.init 内传入 remoteConfiguration: true,后,有获取config的请求发送。也输出了一下log。目前好像还没数据,等有数据了我会再验证一下 image

Fiona2016 and others added 8 commits July 10, 2026 00:40
Duplicate each success notification step to post to a second DingTalk robot via the DING_TALK_TOKEN_2 / DING_TALK_SECRET_2 secrets. Failure notifications are unchanged and still go to the original robot only.
…-group

ci: also send release success notifications to a second DingTalk group
The release workflow treated the DingTalk notification as a build gate: when
the robot API rejects a message -- for example once its per-minute rate limit
is exhausted -- the notification step failed and marked an otherwise
successful publish as failed.

Set `ignoreError` on every DingTalk step so a rejected notification is
reported as a warning instead of failing the job. The publish outcome no
longer depends on the notification channel.
The repository formats YAML with `singleQuote`, so the double-quoted value
failed the format check.
…rror

ci: do not fail a release when the DingTalk notification fails
The other four SDKs that carry this feature — web, iOS, Android and HarmonyOS —
all spell the switch `remoteConfigurationEnabled`. A host writing the same
integration twice should not have to remember that one platform spells it
differently, and a boolean reads better with the suffix than as a bare noun.

Renamed before any release, so no integration has to change. The JSDoc that came
with it is translated, since everything git-facing here is English.
@Fiona2016

Copy link
Copy Markdown
Collaborator

Reviewed this against the four other SDKs that carry the same feature (web, iOS,
Android, HarmonyOS). The fetch model here matches them — session-driven, no
polling, cache-first, [5s, 60s] jittered retries, rc_version and
applied_version reported, and nothing delivered that this platform cannot act
on. Tests are thorough.

I pushed one commit (86a784b) rather than leave it as a comment, because it is a
public API name and renaming after a release would be a breaking change:

  • the init switch is now remoteConfigurationEnabled, which is what web, iOS,
    Android and HarmonyOS all spell it. remoteConfigurationSource and
    createRemoteConfigurationController are untouched.
  • the JSDoc that came with it is translated — everything git-facing in this repo
    is English.

Build and all 269 tests pass on the renamed branch.

Three things still missing, compared with the other platforms

The commit message already says this slice only wires sessionSampleRate, so
these are follow-ups rather than defects. Listed with the platform worth copying
from for each.

1. getRemoteConfig() — the console's custom pass-through. All four other
SDKs have it. The console can publish an application-defined bag (an allow-list,
a cohort rule, a feature toggle); the SDK delivers it verbatim and never
interprets it. Return the decoded values, not the raw JSON string:

getRemoteConfig: () => Record<string, unknown> | undefined

Reference: browser-sdk — same language and the same architecture as this SDK.
See packages/rum-core/src/boot/rumPublicApi.ts.

2. setForcedSession() — collect this visitor regardless of the rates. Web,
Android and HarmonyOS have it. It is what makes a support or debugging flow
possible: pair it with getRemoteConfig() so the console publishes the allow-list
and the application decides. It belongs in the draw branch — an existing session
keeps the decision it was created with, forcing only shapes new ones.

Reference: browser-sdk, same file.

3. beforeSampling — the application's last word at the draw. Web and
HarmonyOS have it.

Copy the HarmonyOS contract here, not the web one. Web's callback also carries
a Session Replay rate, which this platform does not deliver; the narrowed shape is
the agreed one for any SDK that delivers only the session rate:

interface BeforeSamplingContext {
  readonly sessionSampleRate: number   // 0..100, console's where set, init's otherwise
  readonly custom: Record<string, unknown> | null
}
type BeforeSamplingCallback = (context: BeforeSamplingContext) => number | undefined

Two things the HarmonyOS implementation gets right and are worth copying exactly:

  • it runs synchronously inside session creation, so a session is never
    delayed by it;
  • a throw, a non-number, or a rate outside 0..100 leaves the incoming rate alone.
    A mistake in the host application must never take a customer's collection down
    with it.

Reference: flashcat-rum/src/main/ets/RumTypes.ets for the contract and
RumApplicationScope.ets (askBeforeSampling) for the guard.

One small thing

The PR title is in Chinese. Everything git-facing in this repo — titles, bodies,
commit messages, comments — is English. Worth editing before merge; the commit
message can stay as it is, since rewriting it would need a force push.

@guguji5

guguji5 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author
image

getRemoteConfig works

Extend remote configuration beyond session sampling so hosts can drive
their own decisions and force collection during support flows:

- parse the top-level `custom` and cache it atomically with the sampling
  snapshot and ETag, exposed via `getRemoteConfig()`
- add `setForcedSession()` to mark the next new Session as collected
  without touching the current one or changing sample rates
- add the `beforeSampling` callback to adjust the rate of the Session
  being created, with safe fallback on invalid results and thrown errors

Also export `BeforeSamplingContext` and `BeforeSamplingCallback` from the
package entry, and fix the README still documenting the removed
`remoteConfiguration` switch instead of `remoteConfigurationEnabled`.
@guguji5

guguji5 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author
image 点击结束当前session后,可以拿到,,beforeSampling的callback参数

@guguji5

guguji5 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author
image 下发的也会生效~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants