Skip to content

fix(telemetry): read the instance type's wire name by encoding it - #1060

Merged
swolfand merged 1 commit into
mainfrom
sam/fix-telemetry-instance-type
Oct 6, 2026
Merged

swolfand merged 1 commit into
mainfrom
sam/fix-telemetry-instance-type

Conversation

@swolfand

@swolfand swolfand commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Why

ClerkTelemetryEnvironment() (the default the prebuilt UI uses) reads the instance type's wire name with InstanceEnvironmentType.serializer().descriptor.getElementName(ordinal). Since #1027 merged, that serializer is UnknownFallbackEnumSerializer, whose descriptor is a primitive string descriptor with no elements, so the call throws IllegalStateException: Primitive descriptor … does not have elements every 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

  • Bug Fixes
    • Improved the accuracy of instance-type information recorded in telemetry.

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.
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: clerk/clerk-android/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 4347c863-6f7c-4562-a972-f0dd9d200d18
📥 Commits

Reviewing files that changed from the base of the PR and between 0f05cc5 and 70e390f.

📒 Files selected for processing (1)
  • source/telemetry/src/main/kotlin/com/clerk/telemetry/ClerkTelemetryEnvironment.kt

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.


📝 Walkthrough

Walkthrough

ClerkTelemetryEnvironment now serializes Clerk.instanceEnvironmentType to JSON and reads the primitive content for the instance-type string.

Changes

Telemetry environment type

Layer / File(s) Summary
Serialize instance environment type
source/telemetry/src/main/kotlin/com/clerk/telemetry/ClerkTelemetryEnvironment.kt
The constructor uses JSON serialization to derive the instance-type string instead of looking up the enum descriptor element name by ordinal.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 70e39

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)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the telemetry fix and the method used to read the instance type’s wire name.
Description check ✅ Passed The description explains why the change is needed, what it changes, and how it was tested. It does not include a separate “What to focus on” section or screenshots, but those are not essential for thi…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@swolfand
swolfand merged commit b872a38 into main Oct 6, 2026
9 checks passed
@swolfand
swolfand deleted the sam/fix-telemetry-instance-type branch October 6, 2026 23:57
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.

1 participant