Skip to content

feat(tooling): add TOOL_USAGE_COLLECTION_DB_PATH env var to override SQLite DB path#28926

Merged
NicolasMassart merged 2 commits into
mainfrom
MCWP-539-po-c-phase-1-b-env-var-override-for-sq-lite-db-path
Apr 21, 2026
Merged

feat(tooling): add TOOL_USAGE_COLLECTION_DB_PATH env var to override SQLite DB path#28926
NicolasMassart merged 2 commits into
mainfrom
MCWP-539-po-c-phase-1-b-env-var-override-for-sq-lite-db-path

Conversation

@NicolasMassart
Copy link
Copy Markdown
Contributor

@NicolasMassart NicolasMassart commented Apr 16, 2026

Description

The SQLite database path in scripts/tooling/db.ts was hardcoded to ~/.tool-usage-collection/events.db, making it impossible to redirect the database without modifying source code.

This PR introduces the TOOL_USAGE_COLLECTION_DB_PATH environment variable as an optional override. When set, openDb() uses that path; when absent, it falls back to the existing default.

A scripts/tooling/README.md is also added documenting the database location, the env var, the CLI, and the three collection paths.

Part of MCWP-448 — sub-task MCWP-539.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-539

Manual testing steps

Feature: TOOL_USAGE_COLLECTION_DB_PATH env var overrides the SQLite database path

  Background:
    Given I have the metamask-mobile repository checked out
    And I have run yarn setup

  Scenario: default database path is used when env var is not set
    Given TOOL_USAGE_COLLECTION_DB_PATH is not set in my shell environment

    When I run a yarn script that triggers tool-usage collection
    Then the events database is created at ~/.tool-usage-collection/events.db

  Scenario: custom database path is used when env var is set to a valid path
    Given I export TOOL_USAGE_COLLECTION_DB_PATH="/tmp/test-tooling/mydb.db"

    When I run a yarn script that triggers tool-usage collection
    Then the events database is created at /tmp/test-tooling/mydb.db
    And the directory /tmp/test-tooling is created automatically if it does not exist
    And no file is written to ~/.tool-usage-collection/events.db

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@NicolasMassart NicolasMassart self-assigned this Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbotv2 metamaskbotv2 Bot added the team-mobile-platform Mobile Platform team label Apr 16, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue Apr 16, 2026
@NicolasMassart NicolasMassart added area-devex Issues and PRs focused on developer experience skip-e2e skip E2E test jobs labels Apr 16, 2026
@NicolasMassart NicolasMassart marked this pull request as ready for review April 16, 2026 16:05
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1de2c1b. Configure here.

Comment thread scripts/tooling/db.ts
@github-actions github-actions Bot added the risk-low Low testing needed · Low bug introduction risk label Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 99%
click to see 🤖 AI reasoning details

E2E Test Selection:
All three changed files are in scripts/tooling/ and relate exclusively to a local developer tool usage tracking system using SQLite. The changes include: (1) README.md documentation updates, (2) db.ts - a utility that opens/creates a local SQLite database for storing developer tool events, and (3) db.test.ts - unit tests for that database utility. These files have no connection to the app codebase, E2E test infrastructure, or any user-facing features. No app code imports from scripts/tooling/db.ts (confirmed via grep). The tooling system is a local-only developer utility that never affects the mobile app build, runtime behavior, or test execution. No E2E tests are needed.

Performance Test Selection:
The changes are limited to developer tooling scripts (local SQLite database for tool usage tracking). There is no impact on app performance, UI rendering, data loading, or any user-facing flows. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Lgtm

@NicolasMassart NicolasMassart added this pull request to the merge queue Apr 21, 2026
@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Apr 21, 2026
Merged via the queue into main with commit e365a65 Apr 21, 2026
73 checks passed
@NicolasMassart NicolasMassart deleted the MCWP-539-po-c-phase-1-b-env-var-override-for-sq-lite-db-path branch April 21, 2026 10:46
@github-project-automation github-project-automation Bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue Apr 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 21, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.75.0 Issue or pull request that will be included in release 7.75.0 label Apr 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-devex Issues and PRs focused on developer experience release-7.75.0 Issue or pull request that will be included in release 7.75.0 risk-low Low testing needed · Low bug introduction risk size-M skip-e2e skip E2E test jobs team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants