Skip to content

Conversation

@chrisgacsal
Copy link
Collaborator

@chrisgacsal chrisgacsal commented Aug 28, 2025

Overview

Extend payload of events with entitlements.balance.threshold and entitlements.reset types with optional Customer information. If a Subject is linked to a Customer via usage attribution, the event payload will include the Customer object as well.

Summary by CodeRabbit

  • New Features
    • Entitlement notification payloads (balance-threshold and reset) can now include an optional Customer object for richer context.
    • API schemas and OpenAPI definitions expose a read-only customer field in relevant components.
    • JavaScript client types updated to include optional customer in payload shapes.
    • Backward compatible: field is optional and omitted when not present.

@chrisgacsal chrisgacsal self-assigned this Aug 28, 2025
@chrisgacsal chrisgacsal requested a review from a team as a code owner August 28, 2025 19:34
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 28, 2025

📝 Walkthrough

Walkthrough

Adds an optional read-only customer field to entitlement event payloads and schemas, updates TSP model and JS client types, and propagates a mapped Customer through notification creation and HTTP driver mappings. No other runtime behavior changes.

Changes

Cohort / File(s) Summary of changes
OpenAPI specs
api/openapi.yaml, api/openapi.cloud.yaml
Added a readOnly customer property (via allOf -> #/components/schemas/Customer, title "Customer") to two component schemas adjacent to existing value/threshold properties.
Client schema types
api/client/javascript/src/client/schemas.ts
Added optional customer?: components['schemas']['Customer'] (with JSDoc /** Customer */) in two exported interface blocks.
TSP notification model
api/spec/src/notification/entitlements.tsp
Added optional customer?: OpenMeter.Customer.Customer to NotificationEventEntitlementValuePayloadBase with @visibility(Lifecycle.Read) and @summary("Customer").
Notification payload structs
openmeter/notification/entitlements.go
Added Customer *api.Customer with json:"customer,omitempty" to EntitlementValuePayloadBase.
Notification consumers & mappings
openmeter/notification/consumer/entitlementbalancethreshold.go, openmeter/notification/consumer/entitlementreset.go, openmeter/notification/httpdriver/mapping.go
Map optional snapshot Customer via customerhttpdriver.CustomerToAPI, guard nil and errors, include Customer: lo.EmptyableToPtr(...) in created payloads; replaced an inline anonymous Data struct with public api.NotificationEventBalanceThresholdPayloadData and populate new Customer fields.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dcc0dc9 and 11c8582.

📒 Files selected for processing (4)
  • openmeter/notification/consumer/entitlementbalancethreshold.go (3 hunks)
  • openmeter/notification/consumer/entitlementreset.go (3 hunks)
  • openmeter/notification/entitlements.go (1 hunks)
  • openmeter/notification/httpdriver/mapping.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • openmeter/notification/consumer/entitlementreset.go
  • openmeter/notification/entitlements.go
  • openmeter/notification/consumer/entitlementbalancethreshold.go
🧰 Additional context used
🧬 Code graph analysis (1)
openmeter/notification/httpdriver/mapping.go (1)
api/api.gen.go (5)
  • NotificationEventBalanceThresholdPayloadData (5113-5120)
  • Entitlement (2571-2573)
  • Feature (3273-3302)
  • Subject (6598-6623)
  • Customer (2188-2238)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Artifacts / Container image
  • GitHub Check: Test
  • GitHub Check: Artifacts / Benthos Collector Container image
  • GitHub Check: Migration Checks
  • GitHub Check: Lint
  • GitHub Check: Code Generators
  • GitHub Check: Build
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
openmeter/notification/httpdriver/mapping.go (1)

529-541: BalanceThreshold payload now includes optional Customer — good change.

Switching to api.NotificationEventBalanceThresholdPayloadData and wiring Customer from e.Payload.BalanceThreshold.Customer aligns with the new schema and preserves omitempty behavior via pointer.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/entitlement-events

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@chrisgacsal chrisgacsal added release-note/breaking-change Release note: Breaking Changes release-note/misc Miscellaneous changes labels Aug 28, 2025
@chrisgacsal chrisgacsal force-pushed the feat/entitlement-events branch from dcc0dc9 to 11c8582 Compare August 28, 2025 19:42
@chrisgacsal chrisgacsal merged commit bf0dff2 into main Aug 29, 2025
21 checks passed
@chrisgacsal chrisgacsal deleted the feat/entitlement-events branch August 29, 2025 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/breaking-change Release note: Breaking Changes release-note/misc Miscellaneous changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants