Skip to content

feat: add WithProjectID for project-scoped telemetry - #5

Merged
pavel-y-ivanov merged 1 commit into
mainfrom
feat/project-id-support
Jun 27, 2026
Merged

feat: add WithProjectID for project-scoped telemetry#5
pavel-y-ivanov merged 1 commit into
mainfrom
feat/project-id-support

Conversation

@pavel-y-ivanov

Copy link
Copy Markdown
Contributor

Summary

Adds a WithProjectID option that scopes all telemetry to a named Raindrop project. When set to a valid slug, the SDK attaches an X-Raindrop-Project-Id header to every outbound request (events, signals, identify, traces, and the local Workshop mirror). When unset, no header is sent and the backend routes to the org's default project, so existing callers are unaffected.

The slug is trimmed and validated once at New() against ^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$. An invalid value is ignored with a logged warning and no header is sent, so a misconfigured project id never breaks ingestion. This mirrors the projectId / project_id support already in the JS and Python SDKs.

Changes

  • New WithProjectID(string) option.
  • Project header attached centrally in the HTTP layer, covering all four endpoints and the local mirror.
  • Fail-safe validation: warn and omit on invalid input.
  • Bump version to 0.1.5.
  • README: new "Routing To A Project" section plus an option reference.

Testing

  • go build ./..., go vet ./..., gofmt -l . (clean)
  • go test -race ./... passes; project_id_test.go covers every endpoint, the unset case, invalid input with a warning, whitespace trimming, and the local mirror.

Add a WithProjectID option that attaches an X-Raindrop-Project-Id header
to every outbound request, routing events, signals, identify calls, and
traces to a named Raindrop project.

The slug is trimmed and validated against
^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$ once at New(). An unset or empty
value omits the header so the backend falls back to the org's default
project; an invalid value is ignored with a logged warning so a
misconfiguration never breaks ingestion.
@pavel-y-ivanov
pavel-y-ivanov merged commit b1731d6 into main Jun 27, 2026
3 checks passed
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