CDP-5981: add v2 batch endpoint to TrackClient#194
Open
jcpsimmons wants to merge 2 commits into
Open
Conversation
added 2 commits
May 26, 2026 15:41
Adds TrackClient.batch(operations) which POSTs an array of operations to the v2 /api/v2/batch endpoint. The v2 root is derived from the existing track root (or custom URL) so region selection continues to work without configuration changes.
Replaces the in-constructor .replace() ceremony with a trackV2Url field on Region, so the canonical v2 URL is the source of truth and a future change to the Region URL shape doesn't silently no-op. Custom URLs keep the .replace() fallback (best-effort for proxies that already include /api/v1). Tests now assert literal expected URLs instead of mirroring the same .replace() expression, and the batch tests assert calledOnce on the post stub.
This was referenced May 26, 2026
mike-engel
approved these changes
May 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
TrackClient.batch(operations)which POSTs an array of operations to the v2 batch endpoint. The v2 URL is derived from the existing track root (or a customdefaults.url) by swapping/api/v1→/api/v2, so region selection and custom URL overrides continue to work without additional configuration.API
The
operationsparameter is required and must be a non-empty array; otherwise aMissingParamErroris thrown. Operation items are passed through as thebatchfield of the request body, so callers are free to shape items per the public API docs without the SDK pinning a schema snapshot.Test plan
npm run build— cleannpm test— 156 tests pass, nyc 100% coverage gate holds (branches/lines/functions/statements)trackV2Rootfield for default region, both regions, and custom URL#batchtests cover the happy path (US), region variant (EU), empty-array rejection, and non-array rejectionOpening as draft pending review of the URL derivation strategy and the permissive
BatchOperationtype.Note
Low Risk
New optional API surface with input validation only; no changes to existing identify/track flows beyond URL metadata on the client.
Overview
Adds
TrackClient.batch(operations)to POST a non-empty array of operations to the Track API/api/v2/batchendpoint, wrapping them as{ batch: operations }with permissiveBatchOperationtyping.Introduces
trackV2Root(andRegion.trackV2Url) by deriving v2 from the existing v1 track URL—/api/v1→/api/v2for built-in US/EU regions and customdefaults.urlwhen that segment is present; a custom URL without/api/v1is used unchanged for both roots.README documents usage; tests cover US/EU batch URLs, v2 root construction, and validation when
operationsis missing, empty, or not an array.Reviewed by Cursor Bugbot for commit 6077cd1. Bugbot is set up for automated code reviews on this repo. Configure here.