SCIX-891 feat(api): add X-Ui-Tag header to all outbound API calls#894
SCIX-891 feat(api): add X-Ui-Tag header to all outbound API calls#894thostetler wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #894 +/- ##
========================================
- Coverage 66.1% 66.0% -0.0%
========================================
Files 342 341 -1
Lines 40282 40305 +23
Branches 2037 2039 +2
========================================
- Hits 26612 26598 -14
- Misses 13626 13663 +37
Partials 44 44
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Risk summary: Low-to-medium regression risk. The change is largely additive (new header for outbound requests), but consistency of the tagging taxonomy and a misleading test assertion could reduce the value of the feature and confuse future maintenance.
Purpose: Add a consistent X-Ui-Tag header to outbound API requests so backend logs/analytics can attribute requests to UI call types across src/api/*, including React Query-driven flows and select SSR call sites.
Changes:
- Extended
ApiRequestConfigwith optionalui_tagand added an Axios request interceptor to map it to theX-Ui-Tagheader. - Annotated most API request builders across
src/api/with aui_tagtaxonomy (and threaded tags via React Querymetafor shared query functions). - Added a unit test verifying the interceptor sets
X-Ui-Tagfromui_tag.
Findings (priority order)
-
medium: Inconsistent
ui_tagtaxonomy for delete-notification (delvsadd/edit)- Impact: Fragments backend log filtering/aggregation for notification operations.
- Location:
src/api/vault/vault.ts(delete notification request config) - Fix: Use a consistent verb, e.g.
vault/delete-notification. - Confidence: high
-
medium: Inconsistent casing in
ui_tag(metrics/timeSeriescamelCase vs the rest lower/kebab)- Impact: Fragments backend log filtering/aggregation for metrics time series calls.
- Location:
src/api/metrics/metrics.ts(time series querymeta.ui_tag) - Fix: Normalize to lowercase/kebab, e.g.
metrics/time-series. - Confidence: high
-
medium: New interceptor test claims to validate “stripping ui_tag”, but the assertion doesn’t actually test that behavior
- Impact: Misleading test name/assertion may cause false confidence and confusion; the URL query-string check is not a meaningful proxy for “config stripping”.
- Location:
src/api/__tests__/api.test.ts(new interceptor test) - Fix: Rename the test and remove the ineffective query-string assertion (or replace with a mechanism that truly inspects the final Axios config).
- Confidence: high
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/api/api.ts | Adds request interceptor to translate ui_tag into X-Ui-Tag header. |
| src/api/types.ts | Extends ApiRequestConfig to include optional ui_tag. |
| src/api/tests/api.test.ts | Adds coverage for X-Ui-Tag header injection via interceptor. |
| src/api/search/search.ts | Threads ui_tag through React Query meta and SSR header usage for search requests. |
| src/api/vault/vault.ts | Adds ui_tag to vault queries/mutations and threads tag via meta for shared query fn. |
| src/api/vis/vis.ts | Adds ui_tag values to visualization-related API calls. |
| src/api/resolver/resolver.ts | Adds ui_tag to resolver fetch. |
| src/api/reference/reference.ts | Fixes TS key parameter typing and adds ui_tag for reference fetch. |
| src/api/orcid/orcid.ts | Adds ui_tag to Orcid API calls. |
| src/api/objects/objects.ts | Adds ui_tag to objects API calls and sets SSR header. |
| src/api/metrics/metrics.ts | Adds ui_tag to metrics calls and threads via meta. |
| src/api/journals/journals.ts | Adds ui_tag to journal endpoints. |
| src/api/graphics/graphics.ts | Adds ui_tag to graphics fetch. |
| src/api/feedback/feedback.ts | Adds ui_tag to feedback submission. |
| src/api/export/export.ts | Adds ui_tag to export endpoints. |
| src/api/citation_helper/citation_helper.ts | Adds ui_tag to citation helper endpoint. |
| src/api/biblib/libraries.ts | Adds ui_tag across library CRUD/notes/permission endpoints. |
| src/api/author-affiliation/author-affiliation.ts | Fixes TS key parameter typing and adds ui_tag to author affiliation endpoints. |
9ee05a6 to
3e73756
Compare
Add the X-Ui-Tag header, which identifies API call types (e.g. search/primary, search/facet/author).