Skip to content

Custom event tracking#286

Open
marksmith wants to merge 3 commits into
mainfrom
custom-event-tracking
Open

Custom event tracking#286
marksmith wants to merge 3 commits into
mainfrom
custom-event-tracking

Conversation

@marksmith

@marksmith marksmith commented May 27, 2026

Copy link
Copy Markdown
Collaborator

This change adds support for tracking named user events, sent from application code using Aikido::Zen.track_user_event. User events include the event name, user ID, and IP address.

This change extends and should be reviewed after #285.

Summary by Aikido

Security Issues: 0 🔍 Quality Issues: 8 Resolved Issues: 0

🚀 New Features

  • Added user event tracking with API methods and UserEvent class

⚡ Enhancements

  • Adjusted API client to send events to realtime endpoint and handle 204

More info

@marksmith marksmith requested review from hansott and tomaisthorpe May 27, 2026 15:06
Comment thread lib/aikido/zen/agent.rb Outdated
@marksmith marksmith force-pushed the custom-event-tracking branch from 0018654 to 17f3482 Compare May 28, 2026 08:19
Comment thread lib/aikido/zen/api_client.rb
@marksmith marksmith force-pushed the custom-event-tracking branch from 17f3482 to 23ffc5f Compare May 28, 2026 08:21
@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/aikido/zen/api_client.rb 56.25% 6 Missing and 1 partial ⚠️
lib/aikido/zen/agent.rb 50.00% 1 Missing and 2 partials ⚠️
lib/aikido/zen.rb 71.42% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@marksmith marksmith force-pushed the custom-event-tracking branch from 23ffc5f to 29ebef3 Compare May 29, 2026 11:22
@marksmith marksmith force-pushed the custom-event-tracking branch from 29ebef3 to 381c5a7 Compare June 15, 2026 10:53
Comment thread lib/aikido/zen/agent.rb
Comment thread lib/aikido/zen/api_stream.rb
Comment thread lib/aikido/zen/api_stream.rb
Comment thread lib/aikido/zen/api_stream.rb
@marksmith marksmith force-pushed the custom-event-tracking branch from 381c5a7 to 8ebdcdb Compare June 18, 2026 11:51
Comment thread lib/aikido/zen/api_client.rb
@marksmith marksmith force-pushed the custom-event-tracking branch 2 times, most recently from 925d1bd to 03c8326 Compare June 19, 2026 15:42
Comment thread lib/aikido/zen/api_client.rb
@marksmith marksmith requested a review from timokoessler June 19, 2026 15:57
Comment thread docs/track.md
Comment thread lib/aikido/zen.rb

@config.logger.debug("Reporting #{event_type.upcase} event")

req = Net::HTTP::Post.new("/api/runtime/events", default_headers)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These events can only be sent to zen.aikido.dev, the old runtime API does not support this.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That's quite an important point for the other agents too. If the agent is unable to connect to zen.aikido.dev, we need to make it really clear that the user events aren't going to work. I wonder if we need a log here, @timokoessler?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed, makes sense. Maybe log if user calls the track() API for the first time? cc. @hansott.

def send_user_event(event)
event_type = "user_event"

if @rate_limiter.throttle?(event_type)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As these events are not send to Aikido Core, maybe not re-use the same rate limiter? (I think this is the case)

@marksmith marksmith force-pushed the custom-event-tracking branch from 03c8326 to 2a48e50 Compare June 26, 2026 12:00
Comment thread lib/aikido/zen/agent.rb Outdated
Comment thread lib/aikido/zen/ipc/rpc.rb Outdated
Comment thread lib/aikido/zen/ipc/rpc.rb Outdated
Comment thread lib/aikido/zen/ipc/ipc.rb Outdated
Comment thread lib/aikido/zen.rb Outdated
Comment thread lib/aikido/zen/worker_process/agent/client.rb Outdated
Comment thread lib/aikido/zen/ipc/rpc.rb Outdated
Comment thread lib/aikido/zen/ipc/ipc.rb Outdated
@marksmith marksmith force-pushed the custom-event-tracking branch from 2a48e50 to 03c8326 Compare June 26, 2026 12:15
Comment thread lib/aikido/zen/agent.rb
@marksmith marksmith force-pushed the custom-event-tracking branch from 03c8326 to a13654a Compare June 26, 2026 12:20
Comment thread lib/aikido/zen.rb
@marksmith marksmith force-pushed the custom-event-tracking branch from 34372fc to 8bf6fbd Compare June 26, 2026 15:18
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