Skip to content

Conversation

amovar18
Copy link
Collaborator

@amovar18 amovar18 commented Sep 3, 2025

Description

This pull request introduces a major overhaul of the IP Protection and Script Blocking features within the extension. It introduces comprehensive statistics, integrates the Masked Domain List (MDL) for richer context, and completely revamps the UI for better observability and user experience.

Key enhancements include:

  • Statistics Tracking: The extension now tracks and displays statistics for Probabilistic Reveal Tokens (PRTs) and script blocking, offering both a session-specific (Site) and a persistent (Global) view.
  • Masked Domain List (MDL) Integration: The extension dynamically fetches and parses the official MDL to provide details on domain owners and the script-blocking impact for each domain.
  • Revamped UI: A new, unified UI panel (MdlCommonPanel) has been created to present this data, featuring statistical dashboards, advanced filtering, and a consistent user experience across the IP Protection and Script Blocking tabs.
  • Performance and Refactoring: The build process has been streamlined, the heavy P5.js component is now lazy-loaded for faster initial rendering, and the Tabs component has been refactored for more robust state management.

Relevant Technical Choices

  • MDL Integration: To provide the most current information, the PRTStore now fetches the Masked Domain List directly from the official repository upon initialization. This data is parsed and stored in memory to enrich the UI with domain owner and script blocking scope details.
  • Statistics Engine: A new statistics module has been implemented. For PRTs, it tracks total tokens and tokens with non-zero signals. For Script Blocking, it counts partially and completely blocked domains. This data is persisted in chrome.storage.sync for the "Global" view and updated in the service worker as new domains or tokens are observed.
  • UI Abstraction (MdlCommonPanel): To avoid code duplication and ensure a consistent UX, a new reusable MdlCommonPanel component was created. This component abstracts the common layout of a stats header, a resizable table, and a JSON/detail viewer, and is now used by both the PRT and Script Blocking tables.
  • State Management Refactor: The logic for processing domains and tokens has been centralized within the PRTStore, moving it from the more generic DataStore. This improves separation of concerns and co-locates state with the logic that manages it.
  • Tabs Component Refactor: The internal state management of the Tabs component was refactored. Instead of using a local useState for the expanded group, it now uses a centralized activeGroup state managed by the TabsProvider context. This simplifies event handling, especially for keyboard navigation, and makes the component's state more predictable.
  • Performance Optimization: The ReactP5Wrapper, a dependency for the explorable explanations, is a heavy component. It is now loaded asynchronously using React.lazy and Suspense to improve the initial load time and responsiveness of the DevTools panel.
  • Build Process Refactoring: The vite.extension.config.mts file was significantly refactored. The previous implementation used multiple functions and conditional blocks. The new approach uses a more declarative, loop-based system to build all scripts and UI targets, making the process cleaner, more readable, and easier to maintain.

Testing Instructions

  1. Navigate to the Privacy Sandbox panel in Chrome DevTools.
  2. Select the IP Protection tab from the sidebar. You should see a new tabbed interface.
  3. Clicking on the heading of any tab group should open the first tab in the tab group.

IP Proxying (PRT) Tab

  1. Click on the "IP Proxying" tab.
  2. At the top, you should see a statistics header with "Site" and "Global" views for "PRTs with Signal" and "PRTs without Signal".
  3. Browse websites that may use Private State Tokens. As tokens are detected, verify the following:
    • The "Site" statistics update in real-time.
    • The table populates with entries showing the Domain, Owner, Decrypted status (✓), Signal status (✓), and PRT Prefix.
    • The filters work correctly. Test filtering by Owner, by Signal (PRT with signal vs. PRT with no Signal), and by Decrypted status (True vs. False).
    • Clicking a row displays the full JSON details for the token in the panel below.

Masked Domain List Tab

  1. Click on the "Masked Domain List" tab.
  2. At the top, observe the statistics header showing counts for "Completely Blocked" and "Partially Blocked" domains relevant to the current page.
  3. The table should display the full Masked Domain List.
  4. Enable the "Show only domains on this page" checkbox. The table should filter to show only domains that made requests on the current page.
  5. Verify that domains are correctly highlighted and that the filtering by "Owner" and "Impacted by Script Blocking" works as expected.

General Verification

  1. Navigate to Private Advertising -> Protected Audience.
  2. Open the Explorable Explanation.
  3. Confirm that the animation canvas loads and functions correctly, verifying that the lazy-loading implementation is working.
  4. Navigate through various tabs in the extension to ensure the UI remains stable and that the Tabs component refactor has not introduced any regressions.

Additional Information:

This PR represents a significant functional and visual upgrade for the IP Protection feature suite. The introduction of statistics and MDL integration provides developers with much deeper insights into how these privacy technologies are operating on their sites.

Screenshot/Screencast

Screen.Recording.2025-09-16.at.14.47.25.mov

Checklist

  • I have thoroughly tested this code to the best of my abilities.
  • I have reviewed the code myself before requesting a review.
    - [ ] This code is covered by unit tests to verify that it works as intended. NA
  • The QA of this PR is done by a member of the QA team (to be checked by QA).

@amovar18 amovar18 self-assigned this Sep 3, 2025
amovar18 and others added 24 commits September 4, 2025 13:16
… ProbabilisticRevealTokens component for improved domain visibility
…mproved highlighting and script blocking integration
…ens' to 'Masked Domain List' for consistency
…okens

- Introduced a new Script Blocking context and provider to manage unique response domains.
- Created a new Script Blocking page with a table displaying blocked domains and their statuses.
- Refactored the Probabilistic Reveal Tokens context and provider to remove unused properties and improve state management.
- Updated the devtools sidebar to include a new Script Blocking tab.
- Removed deprecated IP Proxy context and related files.
- Enhanced the overall structure and organization of state providers for better maintainability.
…eLabs/ps-analysis-tool into feat/merge-script-protection
…eLabs/ps-analysis-tool into feat/merge-script-protection
@amovar18 amovar18 requested a review from mayan-000 September 29, 2025 05:51
amovar18 and others added 14 commits September 29, 2025 11:51
… item titles in Glossary, update StatItem type for optional fields, integrate Glossary and Panel in MDLTable with tabs, and simplify Legend styling.
…ent with DraggableTray and manage collapse state
…class assignment and update colors for mdl table highlight
…cy and update SessionInsights to use memoized stats and matrixData
… use 'count' instead of 'centerCount', integrate useMemo for performance optimization, and replace CirclePieChart with CookiesLandingWrapper for improved layout.
…eLabs/ps-analysis-tool into feat/merge-script-protection
Copy link
Collaborator

@mohdsayed mohdsayed left a comment

Choose a reason for hiding this comment

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

Looks good, just a few questions.

@mohdsayed mohdsayed merged commit f82d147 into develop Oct 1, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from Under Review to Done in PS Analysis Tool Oct 1, 2025
@mohdsayed mohdsayed deleted the feat/merge-script-protection branch October 1, 2025 04:23
@mohdsayed mohdsayed mentioned this pull request Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants