Commit 9b455ed
authored
[OPIK-5692] [BE][FE] feat: add agent config & runner analytics events (#6338)
* [OPIK-5692] [BE][FE] feat: add agent config & runner analytics events
Add PostHog instrumentation for agent configs and sandbox runner to
track Opik 2.0 launch metrics defined in OPIK-5245.
Backend (3 events via AnalyticsService):
- opik_agent_config_saved: fired in createAgentConfig() and
updateAgentConfig() to capture both UI and SDK config creation.
- opik_agent_config_deployed: fired in createOrUpdateEnvs() and
setEnvByBlueprintName() to capture all deployment paths.
- opik_sandbox_job_created: fired in createJob() to capture runner
adoption across UI and API.
Frontend (1 event via trackEvent):
- opik_agent_config_ui_deployed: fired from DeployToPopover with
UI-specific context (is_new_prod) not available at the BE endpoint.
All BE calls wrapped in try/catch to avoid disrupting primary
operations. User identity resolved automatically via the updated
AnalyticsService.resolveIdentity().
* fix(analytics): address Baz review — dedup deploy helpers and fix blueprint_id
- Consolidated trackAgentConfigDeployed and trackAgentConfigDeployedByName
into a shared trackAgentConfigDeployedEvent helper (dedup)
- Changed blueprint_id to collect all distinct IDs instead of findFirst(),
avoiding mis-attribution when envs reference different blueprints
* fix(analytics): add opik_ prefix to event names and fix blueprint_id type inconsistency
Address PR review comments: prefix all analytics events with opik_ per
instrumentation guidelines, and separate blueprint_id (UUID) from
blueprint_name (display name) to prevent type mixing in deployed events.
Also update the analytics skill to document property naming conventions.
* fix(analytics): address Boris's PR review comments
- Remove try/catch wrappers around analytics calls (fire-and-forget)
- Add workspace_id to all analytics events
- Emit one event per env instead of comma-separated aggregation
- Track implicit prod deployment on first config creation
- Soften SKILL.md _id naming rule (thread_id is human-readable)
* chore: revert unrelated package-lock.json changes
* fix(analytics): move tracking to service layer for consistent event properties
Move analytics tracking from AgentConfigsResource to AgentConfigServiceImpl
so both deploy paths (by-ID and by-name) emit consistent event properties
(always blueprint_id + blueprint_name).
* fix(analytics): coerce deployed_to_prod to string in frontend
Aligns frontend event type with backend String.valueOf() serialization
so deployed_to_prod is consistently a string across all emitters.
* fix(analytics): move sandbox_job_created tracking to service layer
Move opik_sandbox_job_created event from LocalRunnersResource to
EndpointJobServiceImpl for consistency with agent config tracking.
* fix: add missing AnalyticsService param to test constructors
* fix: use resolved projectId in analytics callbacks to avoid NPE
Move doOnNext callbacks inside flatMap scope so they use the resolved
projectId variable instead of blueprint.projectId() which is null.
Verified with 66 passing AgentConfigsResourceTest tests.1 parent 7e3d4ec commit 9b455ed
9 files changed
Lines changed: 75 additions & 14 deletions
File tree
- .agents/skills/analytics-instrumentation
- apps
- opik-backend/src
- main/java/com/comet/opik
- api/resources/v1/priv
- domain
- test/java/com/comet/opik/domain
- opik-frontend/src
- lib/analytics
- v2/pages/AgentConfigurationPage/AgentConfigurationTab
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | | - | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
| |||
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
58 | | - | |
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| |||
Lines changed: 43 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
130 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
131 | 138 | | |
132 | 139 | | |
133 | 140 | | |
| |||
155 | 162 | | |
156 | 163 | | |
157 | 164 | | |
158 | | - | |
| 165 | + | |
| 166 | + | |
159 | 167 | | |
160 | 168 | | |
161 | 169 | | |
| |||
494 | 502 | | |
495 | 503 | | |
496 | 504 | | |
497 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
498 | 512 | | |
499 | 513 | | |
500 | 514 | | |
| |||
506 | 520 | | |
507 | 521 | | |
508 | 522 | | |
509 | | - | |
| 523 | + | |
510 | 524 | | |
511 | | - | |
| 525 | + | |
512 | 526 | | |
513 | 527 | | |
514 | 528 | | |
| |||
519 | 533 | | |
520 | 534 | | |
521 | 535 | | |
522 | | - | |
523 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
524 | 541 | | |
525 | 542 | | |
526 | 543 | | |
| |||
676 | 693 | | |
677 | 694 | | |
678 | 695 | | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
679 | 715 | | |
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| 134 | + | |
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
137 | | - | |
| 139 | + | |
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| 145 | + | |
143 | 146 | | |
144 | 147 | | |
145 | 148 | | |
| |||
239 | 242 | | |
240 | 243 | | |
241 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
242 | 251 | | |
243 | 252 | | |
244 | 253 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
96 | 105 | | |
97 | 106 | | |
98 | 107 | | |
| |||
0 commit comments