tracesSampleRate is random per-transaction — the same device may be sampled for one session and not the next. This makes before/after regression comparison unreliable. A deterministic per-installation sampler that hashes a stable device identifier would ensure the same device is always in/out of sample across launches and releases.
Implementation
Native side (minor): Add a synchronous getInstallationId() method to the native bridge on both platforms. The value already exists:
- iOS:
PrivateSentrySDKOnly.installationID (already computed and stored)
- Android: Installation ID from
InternalSentrySdk.serializeScope() (already available)
Currently only accessible via the async fetchNativeDeviceContexts() call, which is unsuitable for the synchronous tracesSampler callback.
JS side:
- Implement a pure-JS hash (e.g. FNV-1a) that maps
hash(installationId) / MAX_HASH_VALUE to a float in [0, 1).
- Export a helper:
installationBasedSampler(rate: number) that returns a tracesSampler-compatible function.
- Usage:
tracesSampler: installationBasedSampler(0.1) — 10% of installations, consistent across launches.
Notes
- The installation ID persists across app launches but resets on reinstall — acceptable for this use case.
- No third-party device info libraries needed.
- The
tracesSampler callback interface is unchanged — the helper just returns a function compatible with the existing API.
Scope
JS + thin native. Sync getInstallationId() bridge method on iOS and Android + JS hash utility + exported helper.
tracesSampleRateis random per-transaction — the same device may be sampled for one session and not the next. This makes before/after regression comparison unreliable. A deterministic per-installation sampler that hashes a stable device identifier would ensure the same device is always in/out of sample across launches and releases.Implementation
Native side (minor): Add a synchronous
getInstallationId()method to the native bridge on both platforms. The value already exists:PrivateSentrySDKOnly.installationID(already computed and stored)InternalSentrySdk.serializeScope()(already available)Currently only accessible via the async
fetchNativeDeviceContexts()call, which is unsuitable for the synchronoustracesSamplercallback.JS side:
hash(installationId) / MAX_HASH_VALUEto a float in[0, 1).installationBasedSampler(rate: number)that returns atracesSampler-compatible function.tracesSampler: installationBasedSampler(0.1)— 10% of installations, consistent across launches.Notes
tracesSamplercallback interface is unchanged — the helper just returns a function compatible with the existing API.Scope
JS + thin native. Sync
getInstallationId()bridge method on iOS and Android + JS hash utility + exported helper.