Skip to content

Conversation

@aweiss-dev
Copy link
Member

@aweiss-dev aweiss-dev commented Dec 29, 2025

SpikeWPB-22201 [Web] Refine an appropriate way of logging on prod and internal in the future

Pull Request

Files to look at:

  • docs/ADRs/2025-12-29-unified-logging-library.md
  • docs/adding-new-projects.md
  • docs/releasing.md
  • libraries/Logger/README.md
  • libraries/Logger/docs/presidio-integration.md

  • This PR replaced all of the Logging and Datadog usage of Webapp with a new library (libraries/Logger).
  • All Datadog dependencies have been removed from webapp
  • All logdown dependencies have been removed from webapp
  • All console statements have been removed (replaced) in the webapp
  • All logging has been replaced with development only logging. Production-ready logging needs to be added over time.
  • Presidio from Microsoft is utilised for PII-compliant data sanitisation via a custom script, since the library has no JavaScript equivalent.
  • Wire specific rules have been preserved
  • The logging library is extensively tested with unit tests
  • File writing in electron and datadog logging has not been tested yet, but both should work according to unit tests

The most important changes are:

Shared Libraries Support & Logger Library

  • Added a new libraries/ directory, including a Logger library, to the project structure for shared code.
  • Added labeler configuration for the Logger library to help with PR triage. (.github/labeler.yml)

Automated Library Releases

  • Introduced a new GitHub Actions workflow, release-libraries.yml, to automate building, testing, and publishing libraries on merges to main or via manual trigger. (.github/workflows/release-libraries.yml)
  • Updated the README with documentation on library release automation and manual release commands. (README.md)

Dependency Management

  • Configured Dependabot to manage dependencies for the new Logger library, ensuring regular updates and maintenance. (.github/dependabot.yml)

ESLint Configuration Standardization

  • Added project-specific ESLint config files for both apps/server and apps/webapp, leveraging a shared base config for consistency. (apps/server/eslint.config.ts, apps/webapp/eslint.config.ts) [1] [2]
  • Added a lint target to the server's Nx project configuration for easier linting. (apps/server/project.json)
  • Updated tsconfig.json for the server to exclude the new ESLint config file from type-checking. (apps/server/tsconfig.json)

Documentation & Instruction Improvements

  • Updated .github/copilot-instructions.md for improved PR review guidelines, updated glob patterns, and clarified specialized instruction file locations. [1] [2] [3] [4]
  • Added new documentation links in the README for adding projects, ADRs, coding standards, and accessibility practices. (README.md)

Other minor changes include formatting adjustments, updating .prettierignore, and minor CSS formatting in server error templates.


Security Checklist (required)

  • External inputs are validated & sanitized on client and/or server where applicable.
  • API responses are validated; unexpected shapes are handled safely (fallbacks or errors).
  • No unsafe HTML is rendered; if unavoidable, sanitization is applied and documented where it happens.
  • Injection risks (XSS/SQL/command) are prevented via safe APIs and/or escaping.

Accessibility (required)

Standards Acknowledgement (required)


Screenshots or demo (if the user interface changed)

Notes for reviewers

  • Trade-offs:
  • Follow-ups (linked issues):
  • Linked PRs (e.g. web-packages):

@aweiss-dev aweiss-dev requested review from a team and otto-the-bot as code owners December 29, 2025 22:37
@aweiss-dev aweiss-dev changed the title feat(libs/Logging): add logging library, integrate datadog, replace it in webapp feat(libs/Logging): add logging library, integrate datadog, replace it in webapp [WPB-22201] Dec 29, 2025
Base automatically changed from dev_new to dev January 5, 2026 15:42
@aweiss-dev aweiss-dev changed the base branch from dev to snapshot_dev_050116 January 5, 2026 15:45
@aweiss-dev aweiss-dev changed the base branch from snapshot_dev_050116 to dev January 5, 2026 15:46
zskhan and others added 16 commits January 5, 2026 17:02
* fix: add guard on join/call buttons.

* fix: return empty cleanup method
- Install Nx dependencies
- Create nx.json with build caching configuration
- Set up default targets and inputs

[skip ci]
Preserves git history by using git mv.
No code changes, pure directory restructure.
- Configure build, serve, and test targets
- Set up TypeScript compilation with @nx/js:tsc
- Define project metadata and tags
- Create shared tsconfig.base.json at root
- Extend base config in server tsconfig
- Maintain existing compiler options
- Add nx commands for server operations
- Update build:prod to use nx run-many
- Maintain backward compatibility with existing scripts
Server successfully migrated to Nx monorepo structure:
- Build target working
- Serve target working
- Tests passing
- Git history preserved
Preserves git history with git mv.
No code changes.
- Move resource/ directory
- Move assets/ directory
- Move test/ directory
Git history preserved.
- Extend from root tsconfig.base.json
- Update outDir to dist/apps/webapp
- Maintain all existing paths and options
- Configure webpack build with existing configs
- Set up dev server with HMR
- Configure Jest for unit tests
- Configure Playwright for E2E tests
- Add linting target
- Update DIST_PATH to point to dist/apps/webapp
- Update ROOT_PATH to point to monorepo root
- Update server config import path
- fix wrong src/ paths
- create webapp package.json with nx scripts
- Add workspace configuration
- Add nx scripts for all operations
- Add affected commands for CI optimization
- Maintain all existing dependencies
- Create shared jest.preset.js
- Update webapp jest config to use preset
- Fix module paths for monorepo structure
- Unify tsconfigs
- Unify eslint configs
- Fix all existing eslint issues
- Run eslint --fix where possible
- update .gitignore to ignore Nx cache and dist
- update nvmrc to node 24
- fix unit test runs
- move all existing scripts to use nx commands
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 5, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
6 Security Hotspots
11.8% Duplication on New Code (required ≤ 5%)
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Contributor

Copilot AI left a comment

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 introduces a comprehensive logging library (@wireapp/logger) to centralize and standardize logging across the Wire webapp, replacing the previous Datadog and logdown implementations. The library provides PII-compliant sanitization using Microsoft's Presidio patterns, separates development and production logging concerns, and establishes a foundation for consistent observability practices.

Key Changes:

  • Created a new shared logging library with extensive sanitization rules and transport management
  • Replaced all webapp logging with the new library (Datadog and logdown dependencies removed)
  • Implemented automated library release workflows via GitHub Actions
  • Added ESLint project-specific configurations for better code quality enforcement

Reviewed changes

Copilot reviewed 158 out of 164 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tsconfig.eslint.json Reformatted include/exclude arrays for consistency
tsconfig.base.json Added TypeScript path mapping for @wireapp/logger
test/e2e_tests/specs/Folders/folders.spec.ts New E2E test suite for folder management functionality
src/script/components/Modals/FileHistoryModal/* New file history/versioning modal components and hooks
package.json Major dependency changes: added Logger library workspace, updated versions
nx.json Added library release configuration and updated lint input paths
libraries/Logger/* Complete new logging library implementation with sanitization, transports, and utilities

Comment on lines +215 to +216
// Log performance for awareness
console.log(`Large message sanitization: ${duration.toFixed(2)}ms for 100 x 20KB messages`);
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

Console.log statements should be removed from test files or wrapped in a conditional check. These statements will pollute test output and should use a test reporter or be removed entirely.

Suggested change
// Log performance for awareness
console.log(`Large message sanitization: ${duration.toFixed(2)}ms for 100 x 20KB messages`);
// Log performance for awareness when explicitly enabled to avoid polluting test output
if (process.env.LOG_STRESS_TEST_METRICS === 'true') {
console.log(`Large message sanitization: ${duration.toFixed(2)}ms for 100 x 20KB messages`);
}

Copilot uses AI. Check for mistakes.
Comment on lines +459 to +465

// Log performance metrics (for manual inspection during development)
console.log('Performance metrics (ms):');
console.log(` Simple logging: ${operations.simpleLog.toFixed(2)}`);
console.log(` With context: ${operations.logWithContext.toFixed(2)}`);
console.log(` With error: ${operations.logWithError.toFixed(2)}`);
console.log(` Sanitization: ${operations.sanitization.toFixed(2)}`);
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

Multiple console.log statements in test files create noisy test output. Consider using Jest's performance reporters or remove these debug statements.

Suggested change
// Log performance metrics (for manual inspection during development)
console.log('Performance metrics (ms):');
console.log(` Simple logging: ${operations.simpleLog.toFixed(2)}`);
console.log(` With context: ${operations.logWithContext.toFixed(2)}`);
console.log(` With error: ${operations.logWithError.toFixed(2)}`);
console.log(` Sanitization: ${operations.sanitization.toFixed(2)}`);

Copilot uses AI. Check for mistakes.
Comment on lines +949 to +954

console.log(`\n=== Production Stress Test ===`);
console.log(`Total duration: ${duration.toFixed(2)}ms`);
console.log(`Logs processed: 1000`);
console.log(`Average time per log: ${avgTimePerLog.toFixed(3)}ms`);
console.log(`Throughput: ${((1000 / duration) * 1000).toFixed(0)} logs/second`);
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

Console.log statements in tests should be removed or replaced with proper test reporting mechanisms. These add noise to test output.

Suggested change
console.log(`\n=== Production Stress Test ===`);
console.log(`Total duration: ${duration.toFixed(2)}ms`);
console.log(`Logs processed: 1000`);
console.log(`Average time per log: ${avgTimePerLog.toFixed(3)}ms`);
console.log(`Throughput: ${((1000 / duration) * 1000).toFixed(0)} logs/second`);

Copilot uses AI. Check for mistakes.
Comment on lines +135 to +144

/* eslint-disable-next-line no-console */
console.log(`
🔧 Wire Logging Helpers Available:
• wireLogging.exportLogs() - Export all logs as JSON
• wireLogging.copyLogsToClipboard() - Copy logs to clipboard
• wireLogging.getDatadogInfo() - Get Datadog session info
• wireLogging.clearLogs() - Clear log buffer
• wireLogging.getLogStats() - Get log statistics
`);
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

Using console.log in library code that will be consumed by applications can pollute application console output. Consider using a conditional debug flag or removing this installation message, as developers can discover these methods through documentation or TypeScript autocomplete.

Suggested change
/* eslint-disable-next-line no-console */
console.log(`
🔧 Wire Logging Helpers Available:
wireLogging.exportLogs() - Export all logs as JSON
wireLogging.copyLogsToClipboard() - Copy logs to clipboard
wireLogging.getDatadogInfo() - Get Datadog session info
wireLogging.clearLogs() - Clear log buffer
wireLogging.getLogStats() - Get log statistics
`);

Copilot uses AI. Check for mistakes.
} {
return {
active: isOverrideActive,
environment: 'unknown', // Environment info should come from GlobalConfig
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The environment field always returns 'unknown'. According to the comment on line 152, "Environment info should come from GlobalConfig". Consider implementing proper environment detection or document why this is intentionally returning 'unknown'.

Copilot uses AI. Check for mistakes.
Comment on lines +47 to +51
timestamp: new Date(),
level: LogLevel.INFO,
message: 'Test message',
loggerName: 'test-logger',
metadata: {
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The testEntry object has a timestamp field of type Date, but LogEntry type expects metadata.timestamp to be a string (ISO format). This mismatch could cause type errors. Ensure test data matches the actual types.

Suggested change
timestamp: new Date(),
level: LogLevel.INFO,
message: 'Test message',
loggerName: 'test-logger',
metadata: {
level: LogLevel.INFO,
message: 'Test message',
loggerName: 'test-logger',
metadata: {
timestamp: new Date().toISOString(),

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

🔗 Download Full Report Artifact

❌ No Playwright report.json found - test execution may have failed or no tests were run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants