disable deleting metrics that are in use - #3298
Open
bcb37 wants to merge 3 commits into
Open
Conversation
bcb37
requested review from
danoswaltCL and
zackcl
and
a lite review from Copilot
August 26, 2026 21:15
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request aims to prevent deletion of metrics that are referenced by experiment queries by surfacing “in-use” metadata from the backend and disabling the delete action in the metrics UI, while also avoiding unintended HTTP cancellations during navigation-triggered refreshes.
Changes:
- Add
hasQuerymetadata to the metrics catalog payload and use it in the UI to disable metric deletion with an explanatory tooltip. - Refresh the metrics catalog after experiment metric updates and experiment deletion.
- Add an opt-out mechanism for navigation-based HTTP cancellation for app-wide metrics catalog fetches.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/types/src/Experiment/interfaces.ts | Adds optional hasQuery flag to IMetricUnit for in-use signaling. |
| packages/frontend/projects/upgrade/src/assets/i18n/en.json | Adds tooltip copy for disabled metric deletion. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/profile/components/metrics/metrics.model.ts | Adds isTopLevel marker used to constrain delete affordance to row roots. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/profile/components/metrics/metrics.component.ts | Propagates isTopLevel and hard-blocks deletion when hasQuery is true. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/profile/components/metrics/metrics.component.scss | Styles disabled delete icon state. |
| packages/frontend/projects/upgrade/src/app/features/dashboard/profile/components/metrics/metrics.component.html | Disables delete icon + tooltip when hasQuery, and limits delete to top-level nodes. |
| packages/frontend/projects/upgrade/src/app/core/http-interceptors/http-cancel.interceptor.ts | Introduces SKIP_NAVIGATION_CANCEL context token to bypass navigation cancellation. |
| packages/frontend/projects/upgrade/src/app/core/experiments/store/experiments.effects.ts | Dispatches actionFetchMetrics() after experiment metrics update and experiment deletion. |
| packages/frontend/projects/upgrade/src/app/core/experiments/store/experiments.effects.spec.ts | Adds unit coverage for updateExperimentMetrics$ emitting two actions. |
| packages/frontend/projects/upgrade/src/app/core/analysis/store/analysis.effects.ts | Adds defaultIfEmpty guards so canceled requests emit a failure action. |
| packages/frontend/projects/upgrade/src/app/core/analysis/analysis.data.service.ts | Sets SKIP_NAVIGATION_CANCEL on metrics catalog fetch requests. |
| packages/frontend/projects/upgrade/src/app/core/analysis/analysis.data.service.spec.ts | Updates fetchMetrics expectation (but needs stronger assertion of token behavior). |
| packages/backend/src/api/services/MetricService.ts | Fetches query-used metric keys and annotates top-level metrics with hasQuery. |
| packages/backend/src/api/repositories/QueryRepository.ts | Adds query to return distinct metric keys referenced by queries. |
| packages/backend/test/unit/services/MetricService.test.ts | Updates unit tests to validate hasQuery behavior on metric trees. |
| packages/backend/test/unit/repositories/QueryRepository.test.ts | Adds unit tests for getMetricKeysWithQueries(). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+70
to
+81
| public async getMetricKeysWithQueries(): Promise<string[]> { | ||
| const queryResult = await this.createQueryBuilder('query') | ||
| .innerJoin('query.metric', 'metric') | ||
| .select('DISTINCT metric.key', 'metricKey') | ||
| .getRawMany() | ||
| .catch((errorMsg: any) => { | ||
| const errorMsgString = repositoryError('QueryRepository', 'getMetricKeysWithQueries', {}, errorMsg); | ||
| throw errorMsgString; | ||
| }); | ||
|
|
||
| return queryResult.map((row: { metricKey: string }) => row.metricKey); | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
I've confirmed that this would result in the metrics data disappearing from the data tab and from exports, which we probably don't want.
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.
No description provided.