-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...es/DataBrokerProtection/Sources/DataBrokerProtection/Pixels/DataBrokerProtectionPixels.swift
Outdated
Show resolved
Hide resolved
...okerProtection/Sources/DataBrokerProtection/Pixels/DataBrokerProtectionPixelsUtilities.swift
Outdated
Show resolved
Hide resolved
|
||
static func shouldWeFirePixel(startDate: Date, endDate: Date, daysDifference: Frequency) -> Bool { | ||
if let differenceBetweenDates = differenceBetweenDates(startDate: startDate, endDate: endDate) { | ||
return differenceBetweenDates >= daysDifference.rawValue |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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
...taBrokerProtection/Sources/DataBrokerProtection/Pixels/DataBrokerProtectionStatsPixels.swift
Outdated
Show resolved
Hide resolved
This PR has been inactive for more than 7 days and will be automatically closed 7 days from now. |
189df3c
to
d2bba51
Compare
56c366b
to
c55c7d9
Compare
# 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
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:
DataBrokerProtectionStatsPixels
class and remove the two statements to check if we should fire the pixels (lines 149 and 154)