feat: add WithProjectID for project-scoped telemetry - #5
Merged
Conversation
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.
rsd-raindrop
approved these changes
Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
WithProjectIDoption that scopes all telemetry to a named Raindrop project. When set to a valid slug, the SDK attaches anX-Raindrop-Project-Idheader 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 theprojectId/project_idsupport already in the JS and Python SDKs.Changes
WithProjectID(string)option.Testing
go build ./...,go vet ./...,gofmt -l .(clean)go test -race ./...passes;project_id_test.gocovers every endpoint, the unset case, invalid input with a warning, whitespace trimming, and the local mirror.