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

DBP: Implement stats pixels #2812

Merged
merged 4 commits into from
Jun 9, 2024
Merged

Conversation

jotaemepereira
Copy link
Collaborator

Task/Issue URL: https://app.asana.com/0/1204006570077678/1206898271745588/f
Tech Design URL:
CC:

Description
Adds the stats pixels defined in the parent task.

Steps to test this PR:

  1. The best way to test this is to run an initial scan that has a lot of results (two common names and two populated cities)
  2. Go to the DataBrokerProtectionStatsPixels class and remove the two statements to check if we should fire the pixels (lines 149 and 154)
  3. Run again, be sure to attach the background manager before running the app.
  4. Check that pixels are being fired correctly.

@@ -139,11 +139,11 @@ struct DataBrokerProfileQueryOperationManager: OperationsManager {
stageCalculator.fireScanSuccess(matchesFound: extractedProfiles.count)
let event = HistoryEvent(brokerId: brokerId, profileQueryId: profileQueryId, type: .matchesFound(count: extractedProfiles.count))
try database.add(event)
let extractedProfilesForBroker = try database.fetchExtractedProfiles(for: brokerId)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ℹ️ I changed this because we were fetching the extracted profiles from the database inside the loop. This improves how many times we go to the database.

Copy link
Contributor

github-actions bot commented May 23, 2024

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

Generated by 🚫 dangerJS against c55c7d9

@jotaemepereira jotaemepereira requested a review from Bunn May 23, 2024 16:29
Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

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

Tested this. I’m unsure exactly what to confirm (i.e what does the pixels ‘firing correctly’ mean), so I’ve attached screenshots.

Left a few suggested changes. Otherwise, LGTM.

Screenshot 2024-05-24 at 11 46 33 Screenshot 2024-05-24 at 11 46 03


static func shouldWeFirePixel(startDate: Date, endDate: Date, daysDifference: Frequency) -> Bool {
if let differenceBetweenDates = differenceBetweenDates(startDate: startDate, endDate: endDate) {
return differenceBetweenDates >= daysDifference.rawValue
Copy link

@q71114 q71114 May 24, 2024

Choose a reason for hiding this comment

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

This seems to be the definition of rolling windows (comparing to last sent pixel), but for these stats we're requested to send them using fixed windows from the beginning: every X days from the beginning - if one is missed then send the next one asap and then calculate the windows from the beginning again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@q71114 We have two things here: the date from when we calculated the stats and the date from when we fired the pixel.

This one is only to calculate when we should fire the pixel; we use the date from the beginning to calculate the stats.

For example, We fire the weekly pixel (calculating the stats since the beginning), save the date when it was fired, and when seven or more days pass, we fire it again, always calculating the stats from the beginning.

/// If an opt-out wasn't submitted yet, we return 0.
///
/// internal for testing purposes
func calculateDurationOfFirstOptOut(_ brokerProfileQueryData: [BrokerProfileQueryData]) -> Int { guard let dateOfFirstScan = dateOfFirstScan(brokerProfileQueryData),
Copy link

@q71114 q71114 May 24, 2024

Choose a reason for hiding this comment

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

Does this metric reset weekly/monthly when reported per broker? I don't see that part implemented here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good find. I’ve added a new from date parameter here, so now we calculate this from a date. If it is nil, we calculate it from the beginning.

Copy link
Collaborator

@Bunn Bunn left a comment

Choose a reason for hiding this comment

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

Haven't looked at the output since this was already done by Pete (thanks).
Looking at the code itself, LGTM, I'll leave to you to answer Pete questions

Copy link
Contributor

github-actions bot commented Jun 6, 2024

This PR has been inactive for more than 7 days and will be automatically closed 7 days from now.

@github-actions github-actions bot added the stale label Jun 6, 2024
@jotaemepereira jotaemepereira force-pushed the juan/dbp/new-weekly-monthly-pixels branch from 189df3c to d2bba51 Compare June 9, 2024 15:18
@jotaemepereira jotaemepereira force-pushed the juan/dbp/new-weekly-monthly-pixels branch from 56c366b to c55c7d9 Compare June 9, 2024 18:51
@jotaemepereira jotaemepereira merged commit d5f19a2 into main Jun 9, 2024
19 checks passed
@jotaemepereira jotaemepereira deleted the juan/dbp/new-weekly-monthly-pixels branch June 9, 2024 20:56
samsymons added a commit that referenced this pull request Jun 12, 2024
# By Sam Symons (8) and others
# Via GitHub
* main: (35 commits)
  Check DBP Prerequisites in App and Disable Login Item If Necessary (#2850)
  Fixes an issue with my last merge
  Implement VPN control through UDS (#2767)
  Add VPN reddit cookie workaround (#2851)
  Bump version to 1.92.0 (202)
  Update Send Feedback icon (#2852)
  Make passwords easier to discover (#2847)
  Bump version to 1.92.0 (201)
  Update BSK for RMF survey changes (#2846)
  DBP: Update people-wizard.com (#2849)
  Remove VPN launch pixels (#2845)
  Prevent showing multiple VPN uninstalled popovers (#2844)
  Bump version to 1.92.0 (200)
  Set marketing version to 1.92.0
  Update embedded files
  DBP: Implement stats pixels (#2812)
  DBP: Add support for noResultsSelector (#2840)
  Fire compilation failed pixel if needed (#1626)
  Update autoconsent to v10.10.0 (#2842)
  Fix running Autofill-related UI tests in CI (#2843)
  ...

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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.

4 participants