Skip to content

Save AI usage events to PG table too

What does this MR do and why?

Save AI usage events to PG table too. This table stores 3 months of data at the most.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Ensure you have ClickHouse enabled. And code_suggestions_usage_events_in_pg feature flag enabled.
  2. curl http://localhost:3000/api/v4/usage_data/track_event -X POST -H "Authorization: Bearer glpat-YOURPAT" -H 'Content-Type: application/json' -d '{"event": "code_suggestion_shown_in_ide", "additional_properties": {"language": "javascript", "suggestion_size": 12, "timestamp": "2024-09-05 14:51:00 UTC"}}'
  3. Ai::CodeSuggestionEvent.last to check that your event is saved to PG.
  4. ClickHouse::Client.select("SELECT * FROM code_suggestion_usages WHERE suggestion_size > 0 ORDER BY timestamp DESC limit 30", :main) to check that your event is saved to CH.

Numbered steps to set up and validate the change are strongly suggested.

Related to #477229 (closed)

Edited by Pavel Shutsin

Merge request reports

Loading