add telemetry header - #130
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe client now emits anonymous SDK telemetry by default. It records completed request data, builds bounded structured-field headers for later requests, supports disabling telemetry, preserves adapter behavior, and exposes related types and constants. ChangesSDK telemetry
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CreateChargebee
participant RequestWrapper
participant HTTPClient
participant SdkTelemetryState
CreateChargebee->>SdkTelemetryState: initialize telemetry state
RequestWrapper->>SdkTelemetryState: read previous completed snapshot
RequestWrapper->>HTTPClient: send request with telemetry header
HTTPClient-->>RequestWrapper: return response or error
RequestWrapper->>SdkTelemetryState: record success or failure snapshot
🚥 Pre-merge checks | ❌ 1❌ Failed checks (1 warning)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/telemetry/sdkTelemetryHeaderBuilder.ts`:
- Around line 78-87: Update escapeSfString to detect CR, LF, or NUL characters
before constructing the structured-field value, and omit the invalid parameter
or entire telemetry header according to the existing builder flow. Ensure
invalid api_error_code values never reach Headers.append and valid values retain
the current escaping behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 0851d4ae-0b64-4c83-8917-b060651111f8
📒 Files selected for processing (12)
README.mdsrc/RequestWrapper.tssrc/createChargebee.tssrc/telemetry/index.tssrc/telemetry/sdkTelemetryEmitter.tssrc/telemetry/sdkTelemetryHeader.tssrc/telemetry/sdkTelemetryHeaderBuilder.tssrc/telemetry/sdkTelemetrySnapshot.tssrc/telemetry/sdkTelemetryState.tssrc/types.d.tstest/requestWrapper.test.tstypes/index.d.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/telemetry/sdkTelemetryHeaderBuilder.ts (1)
72-75: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winValidate feature tokens before adding them to the header.
featureTokensbypass all Structured Field and invalid-character validation. A token containing CR, LF, or NUL reaches the outgoing header and can makeHeaders.appendthrow, which prevents the subsequent API request. Skip invalid feature tokens, or omit the telemetry header. Add a regression test for an invalid feature token.As per path instructions, restrict feedback to functionality-breaking problems.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/telemetry/sdkTelemetryHeaderBuilder.ts` around lines 72 - 75, Validate each featureToken in the snapshot feature-token loop using the existing Structured Field and invalid-character validation before pushing it into items; skip tokens that fail validation so they cannot reach Headers.append. Add a regression test covering CR, LF, or NUL in a feature token and verify the API request still proceeds.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/telemetry/sdkTelemetryHeaderBuilder.ts`:
- Around line 72-75: Validate each featureToken in the snapshot feature-token
loop using the existing Structured Field and invalid-character validation before
pushing it into items; skip tokens that fail validation so they cannot reach
Headers.append. Add a regression test covering CR, LF, or NUL in a feature token
and verify the API request still proceeds.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 0acadf37-8768-4b01-8eb8-3f2cbb9dd1f3
📒 Files selected for processing (2)
src/telemetry/sdkTelemetryHeaderBuilder.tstest/sdkTelemetryHeaderBuilder.test.ts
TBA
Adds anonymous SDK telemetry to the Chargebee Node SDK. The SDK sends telemetry headers by default, records request outcomes, supports feature flags, and limits header size. Users can disable telemetry with
sdkTelemetryEnabled: false. Documentation, exports, types, and tests are included.