-
Notifications
You must be signed in to change notification settings - Fork 423
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
usage segmentation #3263
usage segmentation #3263
Conversation
# Conflicts: # Core/PixelEvent.swift # DuckDuckGo.xcodeproj/project.pbxproj
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.
Mostly looks good @brindy , left some comments. Thanks for the useful documentation - it really helped in understanding, particularly for UsageSegmentationCalculator
.
Also, tested and validated. One unit test is failing but I believe it’s unrelated.
private extension String { | ||
|
||
func substring(_ range: ClosedRange<Int>) -> String { | ||
let startIndex = self.index(self.startIndex, offsetBy: range.lowerBound) |
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.
Should we account for out-of-bounds here with something like:
guard range.lowerBound >= 0,
range.upperBound < self.count else {
return nil
}
and then return an Optional String.
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.
Probably using min(self.count, range.upperBound) is better and more like you'd expect from a substring function. Annoying swift just doesn't provide these tbh
} | ||
|
||
/// This implementation is based on https://dub.duckduckgo.com/flawrence/felix-jupyter-modules/blob/master/segments_reference.py and has been written to try and | ||
/// resemble the original code as closely as possible. |
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.
👍🏼
@@ -115,7 +115,7 @@ private extension String { | |||
|
|||
func substring(_ range: ClosedRange<Int>) -> String { | |||
let startIndex = self.index(self.startIndex, offsetBy: range.lowerBound) | |||
let endIndex = self.index(self.startIndex, offsetBy: range.upperBound + 1) | |||
let endIndex = self.index(self.startIndex, offsetBy: min(self.count, range.upperBound + 1)) |
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.
👍🏼
LGTM @brindy . Still a unit test failing - |
Task/Issue URL: https://app.asana.com/0/392891325557410/1208213671229670/f Tech Design URL: CC: **Description**: Do not send any default parameters with this pixel. **Steps to test this PR**: 1. Run the app and get the usage segmentation pixel to fire, see #3263 2. Ensure that pixel does not include the atb or app version parameters **Definition of Done (Internal Only)**: * [ ] Does this PR satisfy our [Definition of Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?
# By Christopher Brind (4) and others # Via Alessandro Boron (1) and others * main: (27 commits) Bump C-S-S to 6.14.1 (#3331) DuckPlayer Launch Experiment for iOS (#3328) defer loading the tab switcher button until view did load (#3326) Release 7.136.0-3 (#3324) Release PR: Check for the negative attribution case (#3311) fix tab switcher crashes (speculative fix) (#3319) Onboarding highlights feature flag setup (#3308) Release 7.136.0-2 (#3320) Attempt to fix dissapearing privacy icon (#3317) Fix bookmarks toolbar behaviour with Sync Promo on iOS 15 (#3313) Bump BSK with C-S-S to 6.14.0 (#3314) ensure no atb or app version sent with pixel (#3315) Fix #3298: Add support for Xcode 16 (#3299) Fix Keychain Debug view controller segue (#3310) Release 7.136.0-1 (#3309) Fix an issue that causes the fire dialog to show multiple times for the same website after dismissing it (#3305) [DuckPlayer] 28. Open in Youtube -> Youtube App (#3290) usage segmentation (#3263) Fix wrong URL displayed for auth dialog (#3307) iOS Integration of BSK Onboarding (#3282) ... # Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj # DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Task/Issue URL: https://app.asana.com/0/392891325557410/1206955287217877/f
Tech Design URL: https://app.asana.com/0/392891325557410/1208090005627335/f
CC:
Description:
This PR ads usage segmentation calculations to the app so that we can monitor usage across segments in a private way, without having to send granular usage information to the server.
Deviation from tech design:
Steps to test this PR:
First run, new user:
m_retention_segments
pixel should be firedSubsequent run a few days later
Reset the simulator (so that the keychain is cleared)
Modify StatisticsLoader add the following line at the start of the
load
function:Run the app
An assertion failure should crash the app saying this is not a valid ATB.
Update the above line as follows and reset the simulator again:
Ensure that
m_retention_segments
pixel is fired. There will be various parameters but one should indicate "app_use" activityRe-launch the app
No additional pixel should be fired
Perform a search
The pixel will be fired again and there should be a parameter indicating search activity.
Perform another search
No additional pixel should be fired
Return user test
Repeat the above test bit with the following atb. The pixels sent should include
reinstaller
in the segments parameter.Definition of Done (Internal Only):