Skip to content

[OPIK-6769] [BE] feat: exclude demo data from prompt version creation BI event#6948

Merged
BorisTkachenko merged 1 commit into
mainfrom
boryst/OPIK-6769-be-exclude-demo-data-from-prompt-version-creation-bi-event
Jun 2, 2026
Merged

[OPIK-6769] [BE] feat: exclude demo data from prompt version creation BI event#6948
BorisTkachenko merged 1 commit into
mainfrom
boryst/OPIK-6769-be-exclude-demo-data-from-prompt-version-creation-bi-event

Conversation

@BorisTkachenko
Copy link
Copy Markdown
Contributor

Details

Prompt version creation emits a prompt_version_created BI event used for product analytics. Versions created for built-in demo prompts were inflating these metrics. This change skips the event when the prompt name matches a known demo prompt, so analytics reflect only real user activity.

  • Threads the prompt name through savePromptVersion into trackPromptVersionCreated, which now returns early when the name is in DemoData.PROMPTS.
  • Adds support-agent-system to the demo prompt list.

Change checklist

  • User facing
  • Documentation update

Issues

  • Resolves #
  • OPIK-6769

AI-WATERMARK

AI-WATERMARK: yes

  • Tools: Claude Code
  • Model(s): Claude Opus 4.8
  • Scope: Implementation and tests
  • Human verification: Author reviewed diff and test coverage

Testing

  • Added parameterized test shouldCreatePromptVersion__whenDemoPrompt__thenDoesNotEmitEvent (one case per demo prompt name) in PromptResourceTest, verifying no prompt_version_created event is emitted for demo prompts. A sentinel real prompt is created afterward through the same async pipeline; once its event arrives, the absence of the demo event is conclusive.
  • Run: mvn test -Dtest=PromptResourceTest

Documentation

N/A

@BorisTkachenko BorisTkachenko self-assigned this Jun 2, 2026
@BorisTkachenko BorisTkachenko requested a review from a team as a code owner June 2, 2026 11:01
@github-actions github-actions Bot added java Pull requests that update Java code Backend tests Including test files, or tests related like configuration. labels Jun 2, 2026
Comment on lines +559 to +560
if (DemoData.PROMPTS.contains(promptName)) {
return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we normalize promptName here or use a case-insensitive check, otherwise DemoData.PROMPTS.contains(promptName) misses migrated casing and emits prompt_version_created for demo data.

Severity

Want Baz to fix this for you? Activate Fixer

Other fix methods

Fix in Cursor

Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
apps/opik-backend/src/main/java/com/comet/opik/domain/PromptService.java around lines
557-561, the `trackPromptVersionCreated(...)` method uses
`DemoData.PROMPTS.contains(promptName)` which is case-sensitive. Refactor the guard to
compare in a case-insensitive way by normalizing `promptName` (and/or precomputing a
normalized set from `DemoData.PROMPTS`) before the `contains` check. Also ensure the
normalization handles null/blank safely so demo prompts with different casing never leak
`prompt_version_created` events.

Copy link
Copy Markdown
Contributor

@LifeXplorer LifeXplorer left a comment

Choose a reason for hiding this comment

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

Looks good!

@BorisTkachenko BorisTkachenko merged commit 73c1d15 into main Jun 2, 2026
64 checks passed
@BorisTkachenko BorisTkachenko deleted the boryst/OPIK-6769-be-exclude-demo-data-from-prompt-version-creation-bi-event branch June 2, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend java Pull requests that update Java code tests Including test files, or tests related like configuration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants