Skip to content

feat: Events - Support for Test, Delivery, Redelivery and Stats #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

duedares-rvj
Copy link
Member

🔧 Changes

This PR adds full support for advanced event stream management, including test event generation, delivery tracking, redelivery handling, and delivery statistics.

1. Trigger a Test Event

testEvent := &TestEvent{EventType: auth0.String("user.created")}
err := api.EventStream.Test(ctx, streamID, testEvent)
if err != nil {
	log.Fatalf("test event failed: %v", err)
}

2. List Deliveries by Event Types

deliveries, err := api.EventStream.ListDeliveries(
	ctx,
	streamID,
	WithEventTypes("user.created", "user.updated"),
)
if err != nil {
	log.Fatalf("failed to fetch deliveries: %v", err)
}

3. Fetch Event Stream Stats Within a Date Range

from := time.Now().Add(-1 * time.Hour)
to := time.Now()
opts := WithDateRange(from, to)

stats, err := api.EventStream.Stats(ctx, streamID, opts...)
if err != nil {
	log.Fatalf("failed to fetch stats: %v", err)
}

4. Redeliver All Failed Deliveries

req := &BulkRedeliverRequest{}
err := api.EventStream.RedeliverMany(ctx, streamID, req)
if err != nil {
	log.Fatalf("bulk redelivery failed: %v", err)
}

5. Redeliver a Single Failed Event

err := api.EventStream.Redeliver(ctx, streamID, deliveryID)
if err != nil {
	log.Fatalf("single redelivery failed: %v", err)
}

6. Inspect a Single Delivery

delivery, err := api.EventStream.ReadDelivery(ctx, streamID, deliveryID)
if err != nil {
	log.Fatalf("failed to read delivery: %v", err)
}

📚 References

https://auth0.com/docs/customize/events

🔬 Testing

All relevant test cases has been added to the testsuite

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@duedares-rvj duedares-rvj requested a review from a team as a code owner July 26, 2025 17:43
Comment on lines +210 to +218
| Endpoint | Operation | Preconditions | Validations |
| ------------------------ | ------------------- | ------------------------------- | -------------------------------------------- |
| `/test` | Trigger fake events | Webhook stream w/ subscriptions | Validate event created, status=pending |
| `/deliveries` | List failures | Trigger test events | Check count, type filter, status |
| `/deliveries/{event_id}` | View event details | Event ID from above | Check attempt history, error, timestamps |
| `/redeliver` | Bulk redelivery | Failed events exist | Triggered again, stats window total += N |
| `/redeliver/{event_id}` | Single redelivery | Specific failed event ID | +1 attempt shown in `/deliveries/{event_id}` |
| `/stats` | Metrics | Events delivered | Buckets, window range, failed delivery count |
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Great 👍 this is nice

Copy link
Contributor

@kushalshit27 kushalshit27 left a comment

Choose a reason for hiding this comment

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

Examples added 👍

@duedares-rvj duedares-rvj self-assigned this Aug 1, 2025
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 98.06950% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.05%. Comparing base (4ab7a97) to head (67bc1f3).

Files with missing lines Patch % Lines
management/event_stream.go 77.27% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #580      +/-   ##
==========================================
+ Coverage   96.01%   96.05%   +0.03%     
==========================================
  Files          60       60              
  Lines       12236    12484     +248     
==========================================
+ Hits        11749    11992     +243     
- Misses        367      372       +5     
  Partials      120      120              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kushalshit27 kushalshit27 requested a review from Copilot August 1, 2025 10:35
Copilot

This comment was marked as resolved.

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.

3 participants