Skip to content

feat(audience): MessageBuilder — wire-format message construction (SDK-129)#688

Merged
ImmutableJeffrey merged 2 commits into
mainfrom
feat/sdk-129-message-builder
Apr 17, 2026
Merged

feat(audience): MessageBuilder — wire-format message construction (SDK-129)#688
ImmutableJeffrey merged 2 commits into
mainfrom
feat/sdk-129-message-builder

Conversation

@nattb8
Copy link
Copy Markdown
Collaborator

@nattb8 nattb8 commented Apr 15, 2026

Summary

  • Adds MessageBuilder.cs to Runtime/Events/ — builds wire-format Dictionary<string, object> payloads matching backend OAS schema
  • Supports track, identify, and alias message types
  • Auto-sets required fields on every message: messageId, eventTimestamp, context, surface
  • Field truncation enforced per backend constraints (256 char limits)

Test plan

  • Track: required fields present, truncation applied
  • Identify: identity fields set correctly
  • Alias: from/to fields set correctly
  • All messages: context.library, context.libraryVersion, surface present

Linear: SDK-129

🤖 Generated with Claude Code


Note

Low Risk
Adds new isolated message-construction utility and tests without modifying existing runtime behavior; risk is mainly schema/field-mapping correctness.

Overview
Adds a new internal MessageBuilder that constructs wire-format Dictionary<string, object> payloads for track, identify, and alias events, including shared metadata (messageId, eventTimestamp, context.library/libraryVersion, and surface).

Applies 256-character truncation to key string fields and omits optional identifiers/traits/properties when null or empty. Adds NUnit coverage to verify required fields, truncation behavior, and consistent context/surface across message types.

Reviewed by Cursor Bugbot for commit 415a800. Bugbot is set up for automated code reviews on this repo. Configure here.

@nattb8 nattb8 requested review from a team as code owners April 15, 2026 00:23
@nattb8 nattb8 force-pushed the feat/sdk-129-message-builder branch from ca28579 to 6deae7a Compare April 16, 2026 05:38
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e88c9cb. Configure here.

Comment thread src/Packages/Audience/Runtime/Events/MessageBuilder.cs Outdated
@nattb8 nattb8 requested a review from ImmutableJeffrey April 17, 2026 00:59
Addresses cursor[bot] review comment: every other user-supplied string
field in MessageBuilder (eventName, anonymousId, userId, fromId, toId,
libraryVersion) is truncated to 256 chars per the backend schema. The
three identity-type fields were unintentionally exempt.

While the plan's IdentityType values are fixed strings that fit within
256 chars, applying Truncate consistently matches the stated behavior
and prevents future surprise if callers pass arbitrary type strings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ImmutableJeffrey ImmutableJeffrey merged commit 81f3e5e into main Apr 17, 2026
19 checks passed
@ImmutableJeffrey ImmutableJeffrey deleted the feat/sdk-129-message-builder branch April 17, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants