Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pixels for Privacy Stats on HTML NTP #3659

Merged
merged 12 commits into from
Dec 11, 2024
Merged

Conversation

ayoy
Copy link
Collaborator

@ayoy ayoy commented Dec 11, 2024

Task/Issue URL: https://app.asana.com/0/69071770703008/1208936504720914/f

Description:
This change adds 2 new messages to track actions in the Privacy Stats widget
and implements usage and debug pixels for Privacy Stats.

Steps to test this PR:

  1. Run the app from Xcode, set internal user state and set htmlNewTabPage feature flag.
  2. Filter Xcode console by "PixelKit" subsystem.
  3. Visit some websites to have Privacy Stats widget populated.
  4. Click "Show More" and then "Show Less" and verify the following output in the console:
👾[Daily and Count-Fired] m_mac_new-tab-page_blocked-tracking-attempts_show-more_daily ["appVersion": "1.118.0", "pixelSource": "browser-dmg"]
👾[Daily and Count-Fired] m_mac_new-tab-page_blocked-tracking-attempts_show-more_count ["appVersion": "1.118.0", "pixelSource": "browser-dmg"]
👾[Daily and Count-Fired] m_mac_new-tab-page_blocked-tracking-attempts_show-less_daily ["pixelSource": "browser-dmg", "appVersion": "1.118.0"]
👾[Daily and Count-Fired] m_mac_new-tab-page_blocked-tracking-attempts_show-less_count ["pixelSource": "browser-dmg", "appVersion": "1.118.0"]
  1. Repeat previous step and verify the following output in the console:
👾[Daily and Count-Skipped] m_mac_new-tab-page_blocked-tracking-attempts_show-more_daily ["pixelSource": "browser-dmg", "appVersion": "1.118.0"]
👾[Daily and Count-Fired] m_mac_new-tab-page_blocked-tracking-attempts_show-more_count ["pixelSource": "browser-dmg", "appVersion": "1.118.0"]
👾[Daily and Count-Skipped] m_mac_new-tab-page_blocked-tracking-attempts_show-less_daily ["pixelSource": "browser-dmg", "appVersion": "1.118.0"]
👾[Daily and Count-Fired] m_mac_new-tab-page_blocked-tracking-attempts_show-less_count ["pixelSource": "browser-dmg", "appVersion": "1.118.0"]
  1. Without closing the app, call the following in terminal:
sqlite3 ~/Library/Containers/com.duckduckgo.macos.browser.debug/Data/Library/Application\ Support/PrivacyStats.sqlite 'drop table ZDAILYBLOCKEDTRACKERSENTITY'
  1. Visit a website, verify the following output in the console:
👾[Daily and Count-Fired] m_mac_debug_new-tab-page_privacy-stats_database_error_daily ["e": "2", "d": "PrivacyStatsError", "appVersion": "1.118.0", "ud": "NSCocoaErrorDomain", "ue": "256", "pixelSource": "browser-dmg"]
👾[Daily and Count-Fired] m_mac_debug_new-tab-page_privacy-stats_database_error_count ["pixelSource": "browser-dmg", "appVersion": "1.118.0", "d": "PrivacyStatsError", "ud": "NSCocoaErrorDomain", "e": "2", "ue": "256"]
  1. Quit the app and call the following in terminal:
echo "hello" > ~/Library/Containers/com.duckduckgo.macos.browser.debug/Data/Library/Application\ Support/PrivacyStats.sqlite
  1. Launch the app, verify the following output in the console:
👾[Daily and Count-Fired] m_mac_debug_new-tab-page_privacy-stats_could-not-load-database_daily ["pixelSource": "browser-dmg", "appVersion": "1.118.0", "e": "26", "d": "NSSQLiteErrorDomain"]
👾[Daily and Count-Fired] m_mac_debug_new-tab-page_privacy-stats_could-not-load-database_count ["d": "NSSQLiteErrorDomain", "appVersion": "1.118.0", "e": "26", "pixelSource": "browser-dmg"]
  1. Clean up after testing so that your debug build works:
rm -f ~/Library/Containers/com.duckduckgo.macos.browser.debug/Data/Library/Application\ Support/PrivacyStats.sqlite

Definition of Done:


Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

Copy link
Collaborator

@SabrinaTardio SabrinaTardio left a comment

Choose a reason for hiding this comment

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

Works as expected!
Are the pixel permanent? should we add tests for those?

Copy link
Contributor

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against 2a58f70

@ayoy
Copy link
Collaborator Author

ayoy commented Dec 11, 2024

Thanks @SabrinaTardio!

Pixels are permanent. Show more/less events are tested in NewTabPagePrivacyStatsClientTests (to the point of being pushed to the event mapper - the receiver that fires pixels is trivial and doesn't need testing imo).

Database error pixels aren't tested because it's tricky to break the database in unit tests, but the events are pushed from do-catch handlers for database operations so this is again straightforward.

@ayoy ayoy merged commit 2a6eb56 into main Dec 11, 2024
20 checks passed
@ayoy ayoy deleted the dominik/privacy-stats-pixels branch December 11, 2024 17:16
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