RI-8196 Enrich BE analytics events with isProduction#5930
Draft
KrumTy wants to merge 1 commit into
Draft
Conversation
Enrich CLI, Workbench, Bulk-actions, and Profiler analytics with `isProduction` (resolved from `DatabaseRepository`), plus `dangerous` (derived from `DangerousCommandsProvider` cache, or action type for bulk) for command-style events and `confirmedThrough` for bulk actions. Adds a new `PROFILER_STARTED` event. Lets analytics answer "did users run dangerous commands on prod?" without parallel FE PROD_CONFIRMATION_SHOWN events. Browser write events are deferred to a follow-up — they have no existing BE analytics to enrich. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Contributor
Code Coverage - Backend unit tests
Test suite run success3444 tests passing in 308 suites. Report generated by 🧪jest coverage report action from a1c4135 |
Contributor
Code Coverage - Integration Tests
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Enriches existing backend analytics events with the connection's production status so we can answer the PRD's analytics questions ("did users run dangerous commands on prod?", "did Profiler start on prod?", "did bulk-delete confirm on prod?") without adding parallel FE
PROD_CONFIRMATION_SHOWNevents. Part of epic RI-6594 — Prod vs non-prod modes. Ticket: RI-8196.Builds on RI-8177 (the
isProductionfield,'true' | 'false'string convention fromdatabase.analytics.ts) and RI-8179 (DangerousCommandsProvider, an ACL-CAT-backed dangerous-command cache).Events enriched
CLI_COMMAND_EXECUTED,CLI_COMMAND_ERROR_RECEIVED,CLI_CLUSTER_NODE_COMMAND_EXECUTEDisProduction,dangerousWORKBENCH_COMMAND_EXECUTED,WORKBENCH_COMMAND_ERROR_RECEIVED,SEARCH_*variants,WORKBENCH_INDEX_INFO_SUBMITTEDisProduction,dangerous(index info:isProductiononly)BULK_ACTIONS_STARTED,BULK_ACTIONS_STOPPED,BULK_ACTIONS_SUCCEED,BULK_ACTIONS_FAILEDisProduction,dangerous(true for Delete/Unlink),confirmedThroughPROFILER_LOG_DOWNLOADED,PROFILER_LOG_DELETED, newPROFILER_STARTEDisProductionImplementation notes
DatabaseRepositoryand uses a privateresolveIsProduction(...)helper, wrapped in try/catch (defaults to'false'on lookup failure so analytics never blocks the request path).dangerousis computed in the caller (CLI/Workbench command executors) usingDangerousCommandsProvider.getDangerousCommands(client)— the cache is per-database, so the cost is one ACL CAT round-trip per connection. Caller passes the boolean viaadditionalData; the analytics service stringifies it.dangerousis derived fromBulkActionType(Delete/Unlink →'true', Upload →'false') since there's no command-level granularity.confirmedThrough: 'standard' | 'type-to-confirm'field onCreateBulkActionDto, threaded throughBulkAction→IBulkActionOverview→ analytics. Defaults tonull(for paths that don't go through a confirmation dialog, including all imports).DangerousCommandsProvideris now exported fromDatabaseModule.PROFILER_STARTEDevent fires fromProfilerService.addListenerForInstanceafter the listener attaches.Out of scope (deferred)
Browser write events (key rename / delete / TTL change / value mutations, hash/list/set/zset/stream writes). The ticket's #5 scope item assumes existing BE analytics to enrich, but the codebase has none for those services — they're FE-tracked today. Adding them is a net-new module-wide telemetry effort and exceeds the "enrich existing emits" framing. RI-8184 will need to keep its FE confirmation event or get a follow-up BE ticket.
Testing
cli-analytics,cli-business,workbench.analytics,workbench-commands.executor,bulk-actions.analytics,bulk-import.service,bulk-action, newprofiler-analytics.service.spec.ts). Full API suite (3444 tests) green. New assertions cover:isProduction='true'when the database is production-flaggeddangerouspassthrough for command events and Delete vs Upload for bulkconfirmedThroughround-trips through the bulk-action DTOisProduction='false'fallback when the repository lookup throwssrc/errors (pre-existingtest/failures unchanged).GET fooandFLUSHDBfrom CLI/Workbench and confirm Segment payloads carry the correctisProductionanddangerous; trigger a bulk-delete with the FE confirmation dialog and confirmconfirmedThrough='type-to-confirm'; open Profiler and confirmPROFILER_STARTEDfires once.🤖 Generated with Claude Code