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

Adds pixels to VPN tips #3629

Merged
merged 2 commits into from
Nov 28, 2024
Merged

Adds pixels to VPN tips #3629

merged 2 commits into from
Nov 28, 2024

Conversation

diegoreymendez
Copy link
Contributor

@diegoreymendez diegoreymendez commented Nov 27, 2024

Task/Issue URL: https://app.asana.com/0/1206580121312550/1208856370909429/f

Description

Add pixels for VPN tips in iOS.

Testing

  1. Open Console.app and filter by "Pixel fired".
  2. To start clean go into Settings > All Debug Options > Reset TipKit, and relaunch the app.
  3. Enable the VPN.
  4. First tip shown will be geoswitching. This tip can be dismissed by clicking X or actioning it (open locations). Ignoring a tip means you close the status view without doing anything with it.

Based on the previous description you should get different pixels depending on how you interact with the tip:

11:40:50.374186+0100    2746: 0x10c044  debug   General DuckDuckGo      Pixel fired m.vpn.tip.geoswitching.shown
11:41:25.337882+0100    2746: 0x10c044  debug   General DuckDuckGo      Pixel fired m.vpn.tip.geoswitching.actioned
11:44:35.587539+0100    2761: 0x10d604  debug   General DuckDuckGo      Pixel fired m.vpn.tip.geoswitching.ignored
11:44:44.401814+0100    2761: 0x10d604  debug   General DuckDuckGo      Pixel fired m.vpn.tip.geoswitching.dismissed
  1. Second tip is "Add Widget" when the VPN is off. Can be dismissed by clicking x or actioning it (tap "learn More").

The pixels you can get with this tip are:

11:41:44.250283+0100    2746: 0x10c044  debug   General DuckDuckGo      Pixel fired m.vpn.tip.widget.shown
11:41:55.950480+0100    2746: 0x10c044  debug   General DuckDuckGo      Pixel fired m.vpn.tip.widget.actioned
11:45:22.136784+0100    2761: 0x10d604  debug   General DuckDuckGo      Pixel fired m.vpn.tip.widget.ignored
11:45:51.363188+0100    2761: 0x10d604  debug   General DuckDuckGo      Pixel fired m.vpn.tip.widget.dismissed
  1. Last tip is snooze, when the VPN is back on. This can be dismissed by clicking x or snoozing the VPN.

The pixels you can get with this tip are:

11:46:08.038970+0100    2761: 0x10d604  debug   General DuckDuckGo      Pixel fired m.vpn.tip.snooze.shown
11:46:45.431303+0100    2761: 0x10d604  debug   General DuckDuckGo      Pixel fired m.vpn.tip.snooze.actioned
11:46:30.707391+0100    2761: 0x10d604  debug   General DuckDuckGo      Pixel fired m.vpn.tip.snooze.ignored
11:43:05.883666+0100    2746: 0x10c044  debug   General DuckDuckGo      Pixel fired m.vpn.tip.snooze.dismissed

Definition of Done (Internal Only):


Internal references:

Software Engineering Expectations
Technical Design Template

@diegoreymendez diegoreymendez requested review from a team and amddg44 and removed request for a team November 27, 2024 11:14
@diegoreymendez diegoreymendez marked this pull request as ready for review November 27, 2024 11:14
case networkProtectionWidgetTipShown
case networkProtectionWidgetTipActioned
case networkProtectionWidgetTipDismissed
case networkProtectionWidgetTipIgnored
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New pixels

Comment on lines +34 to +36
var tipsModel: VPNTipsModel {
statusModel.tipsModel
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Placing the tips in a model to separate view and other logic.

Comment on lines +343 to +345
for await status in tipsModel.geoswitchingTip.statusUpdates {
if case .invalidated(let reason) = status {
if case .available = previousStatus {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bit nasty. I copied this logic from macOS.

Tips don't have a simple action hook for when they're dismissed through the "X" button, unless we reimplement them from scratch.

Since I didn't want to recreate the standard tip UI, I am observing the tip status and when I detect a change from available (should be shown to the user) to invalidated (either closed or actioned) I'm firing a call to handle the event. This is mostly used for pixel-firing within tipsModel.

@@ -138,7 +140,7 @@ final class NetworkProtectionStatusViewModel: ObservableObject {
didSet {
if #available(iOS 17.0, *) {
if isNetPEnabled {
VPNGeoswitchingTip.donateVPNConnectedEvent()
VPNGeoswitchingTip.vpnEnabledOnce = true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a change to keep this as a flag, rather than an ever growing counter. We just need to know this happened once.

Comment on lines +205 to +208
self.tipsModel = VPNTipsModel(
isTipFeatureEnabled: featureFlagger.isFeatureOn(.networkProtectionUserTips),
statusObserver: statusObserver,
vpnSettings: settings)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spawning the tips model.

@@ -577,30 +585,30 @@ final class NetworkProtectionStatusViewModel: ObservableObject {

// MARK: - UI Events handling

@available(iOS 17.0, *)
@available(iOS 18.0, *)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may seem confusing, but the VPN tips feature was initially meant for iOS 17, but due to some unexpected crashes that seem to be on Apple, we've decided to move them to iOS 18.

This just needed to be updated.

/// - The VPN is enabled when previous tip's status is invalidated.
///
@Parameter
static var isDistancedFromPreviousTip: Bool = false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Distance" is a bit of a vague / abstract concept. This flag signals two things:

  • The previous tip has been dismissed.
  • The previous tip hasn't just been hidden.

@diegoreymendez diegoreymendez requested review from Bunn and removed request for amddg44 November 27, 2024 14:40
Copy link
Contributor

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

LGTM, one question:
Shouldn't we only call configure if the feature flag is enabled here?

controller.configureTipKit([

Here's the output of some of my tests:


Testing dismissed
Pixel fired m.vpn.tip.geoswitching.shown
Pixel fired m.vpn.tip.geoswitching.dismissed


Pixel fired m.vpn.tip.widget.shown
Pixel fired m.vpn.tip.widget.dismissed

Pixel fired m.vpn.tip.snooze.shown
Pixel fired m.vpn.tip.snooze.dismissed


-----
Testing actioned

Pixel fired m.vpn.tip.geoswitching.shown
Pixel fired m.vpn.tip.geoswitching.actioned

Pixel fired m.vpn.tip.widget.shown
Pixel fired m.vpn.tip.widget.actioned

Pixel fired m.vpn.tip.snooze.shown
Pixel fired m.vpn.tip.snooze.actioned

----
Testing ignore
Pixel fired m.vpn.tip.geoswitching.shown
Pixel fired m.vpn.tip.geoswitching.ignored
Pixel fired m.vpn.tip.geoswitching.shown
Pixel fired m.vpn.tip.geoswitching.ignored
Pixel fired m.vpn.tip.geoswitching.shown
Pixel fired m.vpn.tip.geoswitching.dismissed
Pixel fired m.vpn.tip.widget.shown
Pixel fired m.vpn.tip.widget.ignored
Pixel fired m.vpn.tip.widget.shown
Pixel fired m.vpn.tip.widget.ignored
Pixel fired m.vpn.tip.widget.shown
Pixel fired m.vpn.tip.widget.dismissed
Pixel fired m.vpn.tip.snooze.shown
Pixel fired m.vpn.tip.snooze.ignored

@diegoreymendez
Copy link
Contributor Author

Shouldn't we only call configure if the feature flag is enabled here?

This was actually fine, although I understand where the question is coming from - I flagged it during our call 😅

The feature flag guard is a few lines above that point.

@diegoreymendez diegoreymendez merged commit 038dd7a into main Nov 28, 2024
13 checks passed
@diegoreymendez diegoreymendez deleted the diego/vpn-tip-pixels branch November 28, 2024 09:03
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