Repository navigation
fix(telemetry): read the instance type's wire name by encoding it - #1060
Conversation
ClerkTelemetryEnvironment looked the wire name up with InstanceEnvironmentType.serializer().descriptor.getElementName(ordinal). Since #1027 that serializer is the unknown-fallback serializer, whose descriptor is a primitive string with no elements, so the lookup threw IllegalStateException whenever telemetry read the instance type. Encode the value through the serializer instead, which works for any serializer shape.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. 📝 WalkthroughWalkthrough
ChangesTelemetry environment type
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The change derives the telemetry instance-type string through JSON serialization. No merge-blocking risk is identified from the supplied evidence. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Why
ClerkTelemetryEnvironment()(the default the prebuilt UI uses) reads the instance type's wire name withInstanceEnvironmentType.serializer().descriptor.getElementName(ordinal). Since #1027 merged, that serializer isUnknownFallbackEnumSerializer, whose descriptor is a primitive string descriptor with no elements, so the call throwsIllegalStateException: Primitive descriptor … does not have elementsevery time telemetry reads the instance type.TelemetryCollectorTest(clerkEnvironmentSendsTestKeyEventsAsDevelopment,clerkEnvironmentSkipsLiveKeyEvents) fails on main for this reason. CI on main doesn't run the telemetry tests yet (#1021 adds them), which is how it slipped through.Change
Encode the value with
Json.encodeToJsonElement(InstanceEnvironmentType.serializer(), …)and read the string, which gives the wire name for any serializer shape.Testing
./gradlew :source:telemetry:testDebugUnitTest: passes with the fix; the two tests above fail without it.:source:telemetry:detekt,spotlessApply: clean.🤖 Generated with Claude Code
Summary by CodeRabbit