Skip to content

Conversation

SabrinaTardio
Copy link
Contributor

@SabrinaTardio SabrinaTardio commented Oct 15, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/1204186595873227/task/1211625735257812?focus=true

Description Adds a pixel (for internal users) that it sent daily on app use with the number of pop ups managed in the past 7 days

Testing Steps

  1. Open the app not logged in as internal user and check m_mac_autoconsent_popup-managed-count_daily it’s not sent
  2. log in as internal user and check m_mac_autoconsent_popup-managed-count_daily is sent
  3. Check the initial value of the parameters is "d0": "-1", "d1": "-1", "d2": "-1", "d3": "-1", "d4": "-1", "d5": "-1”
  4. Change the system date by one day in the future you should then see the pixel fires with the following parameters: "d0": “0", "d1": "-1", "d2": "-1", "d3": "-1", "d4": "-1", "d5": "-1”
  5. Visit two sites where pop ups are managed
  6. Move another day in the future you should then see the pixel fires with the following parameters: "d0": “2", "d1": “0", "d2": "-1", "d3": "-1", "d4": "-1", "d5": "-1”

Impact and Risks

Low: Minor visual changes, small bug fixes, improvement to existing features

What could go wrong?

The pixel is sent to non internal user
-> There is a feature flag that is active only for internal user that regulates the behaviour

Quality Considerations

<!—
Focus on what matters for your changes:

  • What edge cases exist?
  • How does this affect performance?
  • What monitoring have you added?
  • What documentation needs updating?
  • How does this impact privacy/security?
    —>

Notes to Reviewer


Note

Track last-7-day autoconsent popup counts and fire an internal daily pixel, integrating stats into user script and app lifecycle behind a new feature flag, with tests.

  • Autoconsent (macOS):
    • Daily stats + pixel: Implement AutoconsentDailyStats to track per-day managed popup counts (7-day window) in ThrowingKeyValueStoring and fire autoconsent_popup-managed-count pixel daily (internal-only, .daily).
    • Integration:
      • Inject stats via AutoconsentUserScript (new statsManager param) and increment on autoconsentDone.
      • Initialize in AppDelegate and trigger sendDailyPixelIfNeeded() on applicationDidBecomeActive.
    • Feature flag: Add FeatureFlag.cpmCountPixel (internal-only, default off).
    • Pixels: Extend AutoconsentPixel with popupManagedCount(params:) and define pixel schema in autoconsent.json5 (params d0d6).
  • Utilities: Add Utilities/DateProvider.swift protocol/extension.
  • Tests: Add AutoconsentDailyStatsTest and MockAutoconsentDailyStats and update existing tests for constructor changes.

Written by Cursor Bugbot for commit 2e23047. This will update automatically on new commits. Configure here.

@Copilot Copilot AI review requested due to automatic review settings October 15, 2025 13:42
Copy link
Contributor

@Copilot 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

Adds daily tracking of autoconsent (cookie popup) management counts and a new daily pixel (intended for internal users) reporting the previous days' counts. Integrates the stats manager into the AutoconsentUserScript and AppDelegate, and adds unit tests for counting, pixel emission, and pruning stored stats.

  • Introduces AutoconsentDailyStats with persistence, daily pixel emission, and cleanup.
  • Wires stats manager into user script and fires pixel on app launch.
  • Adds unit tests plus pixel definition entry (with issues noted below).

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
macOS/UnitTests/Autoconsent/MockAutoconsentDailyStats.swift Adds a mock stats manager for tests.
macOS/UnitTests/Autoconsent/AutoconsentMessageProtocolTests.swift Injects mock stats manager into existing test.
macOS/UnitTests/Autoconsent/AutoconsentDailyStatsTest.swift Adds test suite for incrementing, pixel params, and cleanup.
macOS/PixelDefinitions/pixels/autoconsent.json5 Defines new daily popup-managed count pixel (contains syntax and grammar issues).
macOS/DuckDuckGo/Utilities/DateProvider.swift Adds a simple DateProviding protocol (not yet leveraged in new stats type).
macOS/DuckDuckGo/Tab/UserScripts/UserScripts.swift Injects stats manager into AutoconsentUserScript (via global access).
macOS/DuckDuckGo/Autoconsent/AutoconsentUserScript.swift Records popup management via stats manager.
macOS/DuckDuckGo/Autoconsent/AutoconsentPixels.swift Adds new pixel case and key.
macOS/DuckDuckGo/Autoconsent/AutoconsentDailyStats.swift Implements stats tracking, pixel emission, and pruning (contains syntax and logic issues).
macOS/DuckDuckGo/Application/AppDelegate.swift Instantiates stats manager and fires daily pixel (missing internal-user gating).
macOS/DuckDuckGo-macOS.xcodeproj/project.pbxproj Registers new source and test files in the project.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link

Privacy Review task: https://app.asana.com/0/69071770703008/1211659752515639

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.

1 participant