Skip to content

UoE/Remove debug console output and avoidable failed requests#12

Merged
milanmajchrak merged 2 commits into
datashare-UoEMainLibrary-dspace-8_xfrom
uoe/remove-console-noise-and-failed-requests
Jun 30, 2026
Merged

UoE/Remove debug console output and avoidable failed requests#12
milanmajchrak merged 2 commits into
datashare-UoEMainLibrary-dspace-8_xfrom
uoe/remove-console-noise-and-failed-requests

Conversation

@milanmajchrak

Copy link
Copy Markdown
Collaborator

What & why

While running DataShare, the browser console showed a lot of development logging and the Network tab showed several failed requests, which makes the app look unpolished. This PR removes that noise and eliminates the avoidable failed requests without changing user-facing behaviour.

Every issue below was reproduced against the live dev (dev-6.pc:8853) and production (datashare.ed.ac.uk) instances with a headless browser, then traced back to its source in the code.

Console output removed

Debug console.logs that fired during normal use:

  • Bitstream: <object> — logged once per file on every item page (10× on a typical production item) — file-section.component.ts
  • Environment extended with app configevery page loadconfig.util.ts
  • ~12 further debug logs across the submission, upload, access-control and datashare services, the submission footer and the section container

Left untouched on purpose: genuine error/diagnostic logging in core services, debug logging already guarded by appConfig.debug / environment.debug, and server-side (Node/SSR) logging that never reaches the browser console.

Failed requests eliminated

A browser always logs a network 404/401 for a failed XHR (JS cannot suppress it), so each fix avoids making the request when it isn't needed rather than just swallowing the error:

Request When it fired Fix
404 …/config/properties/google.analytics.key every page (the analytics service and the cookie-consent dialog both probe it) new info.enableGoogleAnalytics flag (default false) — DataShare does not use GA
404 …/config/properties/bulkedit.export.max.items /search, for every user only fetched once the admin CSV-export button is actually shown
401 …/integration/qualityassurancesources/search/byTarget item page, anonymous users gated on the CanSeeQA authorization inside the QA component
404 /favicon.ico production the DataShare favicon is now served at the web root

Behaviour change to note (Google Analytics)

info.enableGoogleAnalytics defaults to false. DataShare configures no backend google.analytics.key, so for us this is a no-op that simply removes the per-page 404. Any installation that does use Google Analytics must set info.enableGoogleAnalytics: true to keep tracking — documented in config.example.yml and default-app-config.ts. When enabled, behaviour is identical to before (tracking snippet + the Klaro GA consent option).

Deliberately NOT changed (to avoid regressions)

  • The HAL self-link mismatch console.warn in core data parsing — touching it risks the object/request cache
  • The correctiontypes request in ds-item-alerts — that component also renders the withdrawn / private-item alerts that anonymous users must keep seeing
  • COAR-notify 401 and the base-DSpace DspaceRestService error log — base behaviour, not part of the observed production noise
  • The dev-only 500 thumbnail responses — a backend/data issue, absent on production (not a frontend bug)

Verification

  • tsc --noEmit passes for both the app and spec projects; ESLint is clean on every changed file (no new warnings)
  • Updated the google-analytics and browser-klaro specs for the new flag and added CanSeeQA gate coverage (plus the previously-missing test provider) to the QA component spec
  • Reviewed for correctness, regressions, performance and completeness

🤖 Generated with Claude Code

Make the running app look professional by removing development console
logging and eliminating avoidable failed network requests. Each issue was
reproduced against the live dev and production instances and traced to its
source.

Console noise removed (fired during normal browser use):
- "Bitstream: <object>" logged once per file on every item page
- "Environment extended with app config" on every page load
- debug logs across the submission, upload, access-control and datashare
  services, the submission footer and the section container

Avoidable failed requests eliminated (the request is now avoided, since a
browser always logs a network 404/401 that JS cannot suppress):
- 404 google.analytics.key on every page -> gated behind a new
  info.enableGoogleAnalytics flag (default false; DataShare does not use GA)
- 404 bulkedit.export.max.items on /search -> only requested once the admin
  export button is shown
- 401 qualityassurancesources on item pages for anonymous users -> gated on
  the CanSeeQA authorization inside the QA component
- 404 /favicon.ico -> the DataShare favicon is served from the web root

Specs updated for the new GA flag and CanSeeQA gate (with added coverage).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9e3c1cce-4881-4583-b704-339e9701bca5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces browser console noise and eliminates several avoidable failed HTTP requests (404/401) by removing debug logging and gating backend probes behind explicit config/authorization checks, while aiming to preserve user-visible behavior.

Changes:

  • Removed unguarded console.log debug output across submission/upload/access-control and item file listing.
  • Introduced info.enableGoogleAnalytics (default false) and used it to prevent probing google.analytics.key (and GA/Klaro setup) when GA isn’t intended.
  • Avoided unnecessary backend requests by gating: CSV export limit lookup behind “export button is actually shown”, and QA sources lookup behind FeatureID.CanSeeQA; also served the theme favicon at /favicon.ico.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/environments/environment.test.ts Adds info.enableGoogleAnalytics to the test environment config.
src/config/info-config.interface.ts Extends InfoConfig with enableGoogleAnalytics and documents its intent.
src/config/default-app-config.ts Defaults enableGoogleAnalytics to false with rationale.
src/config/config.util.ts Removes an unconditional console log during config merge.
src/app/submission/sections/upload/section-upload.component.ts Removes debug logging during duplicate/size validation.
src/app/submission/sections/container/section-container.component.ts Removes debug logging related to open panel state.
src/app/submission/form/footer/submission-form-footer.component.ts Removes debug logs tied to signal lifecycle/changes.
src/app/statistics/google-analytics.service.ts Skips GA setup entirely unless enableGoogleAnalytics is true.
src/app/statistics/google-analytics.service.spec.ts Updates tests to cover GA-disabled behavior via the new flag.
src/app/shared/search/search-export-csv/search-export-csv.component.ts Defers bulkedit.export.max.items probe until the export button is actually showable.
src/app/shared/cookies/browser-klaro.service.ts Avoids probing GA key when GA is disabled; hides GA consent option without the request.
src/app/shared/cookies/browser-klaro.service.spec.ts Updates/extends tests for GA key probing and GA-disabled behavior.
src/app/shared/access-control-form-container/bulk-access-control.service.ts Removes debug logging when executing the bulk access-control script.
src/app/shared/access-control-form-container/access-control-form-container.component.ts Removes debug logging and unused subscribe callback.
src/app/item-page/simple/qa-event-notification/qa-event-notification.component.ts Gates QA sources request on CanSeeQA authorization to avoid anonymous 401s.
src/app/item-page/simple/qa-event-notification/qa-event-notification.component.spec.ts Adds test coverage for the new CanSeeQA gate and fixes provider shadowing.
src/app/item-page/simple/field-components/file-section/file-section.component.ts Removes per-bitstream debug logging when loading file/license pages.
src/app/datashare/datashare-submission.service.ts Removes debug logs from service creation and signal updates.
src/app/datashare/datashare-submission-form-section-container.service.ts Removes debug log from open-panel ID setter.
config/config.example.yml Documents and defaults info.enableGoogleAnalytics.
angular.json Copies theme favicon to the web root to satisfy /favicon.ico.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…bed when the export button is shown

Locks in the fix from this PR so a regression that reintroduces the per-page
404 (probing the config property for non-admin/anonymous users) is caught.
Addresses Copilot review feedback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@milanmajchrak milanmajchrak merged commit a4a18e9 into datashare-UoEMainLibrary-dspace-8_x Jun 30, 2026
10 checks passed
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