Skip to content

SCIX-891 feat(api): add X-Ui-Tag header to all outbound API calls#894

Open
thostetler wants to merge 1 commit into
adsabs:masterfrom
thostetler:feature/scix-891-ui-tag-api-calls
Open

SCIX-891 feat(api): add X-Ui-Tag header to all outbound API calls#894
thostetler wants to merge 1 commit into
adsabs:masterfrom
thostetler:feature/scix-891-ui-tag-api-calls

Conversation

@thostetler

@thostetler thostetler commented Jun 24, 2026

Copy link
Copy Markdown
Member

Add the X-Ui-Tag header, which identifies API call types (e.g. search/primary, search/facet/author).

  • Extended ApiRequestConfig with optional ui_tag field; Axios request interceptor in Api lifts it to X-Ui-Tag before dispatch and strips it from the config object
  • Annotated all fetch functions across src/api/ with taxonomy tags; for shared query functions (fetchSearch, fetchVaultSearch) the tag threads through React Query meta
  • useGetSearchFacetJSON uses a dynamic tag (search/facet/) so the actual field name appears in backend logs
  • SSR paths that bypass the Api singleton set X-Ui-Tag directly on the axios headers config

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.81250% with 86 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.0%. Comparing base (318ddd1) to head (3e73756).

Files with missing lines Patch % Lines
src/api/vault/vault.ts 33.4% 32 Missing ⚠️
src/api/search/search.ts 32.0% 17 Missing ⚠️
src/api/biblib/libraries.ts 12.5% 14 Missing ⚠️
src/api/orcid/orcid.ts 0.0% 9 Missing ⚠️
src/api/vis/vis.ts 0.0% 4 Missing ⚠️
src/api/journals/journals.ts 0.0% 3 Missing ⚠️
src/api/objects/objects.ts 0.0% 3 Missing ⚠️
src/api/metrics/metrics.ts 60.0% 2 Missing ⚠️
src/api/feedback/feedback.ts 0.0% 1 Missing ⚠️
src/api/reference/reference.ts 50.0% 1 Missing ⚠️
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             
Files with missing lines Coverage Δ
src/api/api.ts 84.6% <100.0%> (+0.4%) ⬆️
src/api/export/export.ts 95.7% <100.0%> (+0.2%) ⬆️
src/api/graphics/graphics.ts 77.0% <100.0%> (+0.3%) ⬆️
src/api/resolver/resolver.ts 97.3% <100.0%> (+0.1%) ⬆️
src/api/feedback/feedback.ts 44.9% <0.0%> (-1.6%) ⬇️
src/api/reference/reference.ts 55.0% <50.0%> (-1.4%) ⬇️
src/api/metrics/metrics.ts 62.8% <60.0%> (+0.4%) ⬆️
src/api/journals/journals.ts 53.2% <0.0%> (-1.0%) ⬇️
src/api/objects/objects.ts 35.2% <0.0%> (-0.8%) ⬇️
src/api/vis/vis.ts 29.9% <0.0%> (-0.9%) ⬇️
... and 4 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thostetler thostetler marked this pull request as ready for review June 24, 2026 18:08
@thostetler thostetler requested review from Copilot and shinyichen June 24, 2026 18:08

Copilot AI left a comment

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.

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 ApiRequestConfig with optional ui_tag and added an Axios request interceptor to map it to the X-Ui-Tag header.
  • Annotated most API request builders across src/api/ with a ui_tag taxonomy (and threaded tags via React Query meta for shared query functions).
  • Added a unit test verifying the interceptor sets X-Ui-Tag from ui_tag.

Findings (priority order)

  • medium: Inconsistent ui_tag taxonomy for delete-notification (del vs add/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/timeSeries camelCase vs the rest lower/kebab)

    • Impact: Fragments backend log filtering/aggregation for metrics time series calls.
    • Location: src/api/metrics/metrics.ts (time series query meta.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.

Comment thread src/api/vault/vault.ts
Comment thread src/api/metrics/metrics.ts
Comment thread src/api/__tests__/api.test.ts Outdated
@thostetler thostetler force-pushed the feature/scix-891-ui-tag-api-calls branch from 9ee05a6 to 3e73756 Compare June 24, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants