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

Add support for skipping sending usage pixels for remote messages #902

Merged
merged 4 commits into from
Jul 19, 2024

Conversation

ayoy
Copy link
Contributor

@ayoy ayoy commented Jul 18, 2024

Please review the release process for BrowserServicesKit here.

Required:

Task/Issue URL: https://app.asana.com/0/1201621708115095/1207841204698435/f
iOS PR: duckduckgo/iOS#3106
macOS PR: duckduckgo/macos-browser#2994
What kind of version bump will this require?: Major

Description:
This change allows to skip sending usage pixels for a given remote message if that's stated in the RMF config.

Steps to test this PR:
For both iOS and macOS apps:

  1. Replace config URL in RemoteMessagingClient.swift with https://www.jsonblob.com/api/1263462242434539520. This config contains 4 messages: 1, 2, and 4 send pixels, and 3 has pixels disabled.
  2. Run the app from Xcode. If on macOS, set internal user state and restart the app before proceeding.
  3. Launch the app again and observe the logs (Pixel logs are enabled by default on both apps).
  4. Verify that shown and shown unique pixel is fired for message 1
  5. Dismiss message 1
  6. Verify that message dismissed pixel was sent for message 1
  7. Restart the app.
  8. Verify steps 4-6 for message 2
  9. Restart the app
  10. Verify that no pixels are sent for message 3
  11. Restart the app
  12. Verify steps 4-6 for message 4
  13. You can reset remote messages (to restart config parsing) on macOS via Main Menu -> Debug -> Reset Data -> Reset Remote Messages, or on iOS via Debug Menu -> Remote Messages -> Delete All.

OS Testing:

  • iOS 14
  • iOS 15
  • iOS 16
  • macOS 10.15
  • macOS 11
  • macOS 12

Internal references:

Software Engineering Expectations
Technical Design Template

@ayoy ayoy self-assigned this Jul 18, 2024
self.content = try container.decodeIfPresent(RemoteMessageModelType.self, forKey: .content)
self.matchingRules = try container.decode([Int].self, forKey: .matchingRules)
self.exclusionRules = try container.decode([Int].self, forKey: .exclusionRules)
self.isMetricsEnabled = try container.decodeIfPresent(Bool.self, forKey: .isMetricsEnabled) ?? 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.

The ?? true part is why we require custom init function

Comment on lines +39 to +51

var isMetricsEnabled: Bool {
metrics?.state.flatMap(JsonMetrics.MetricsState.init) != .disabled
}
}

struct JsonMetrics: Decodable {
let state: String?

enum MetricsState: String, Decodable {
case disabled
case enabled
}
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 the actual change – parse metrics object within the message definition if it exists and decode state property. If "disabled", disable metrics.

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 file contains all supported cases for metrics object, including no metrics object at all.

@ayoy ayoy marked this pull request as ready for review July 18, 2024 16:48
Comment on lines +416 to +429
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CxxCrashHandler"
BuildableName = "CxxCrashHandler"
BlueprintName = "CxxCrashHandler"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Copy link
Member

Choose a reason for hiding this comment

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

Is this part of the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My Xcode keeps bugging me about adding this. It's an update to the otherwise auto-generated scheme, so I reckon it doesn't hurt to include it.

Copy link
Member

@quanganhdo quanganhdo left a comment

Choose a reason for hiding this comment

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

Nice work, thanks for the detailed instructions.

@ayoy ayoy merged commit f8e3817 into main Jul 19, 2024
8 checks passed
@ayoy ayoy deleted the dominik/rmf-skip-pixels branch July 19, 2024 06:27
samsymons added a commit that referenced this pull request Jul 19, 2024
* main:
  Resetting all state for the VPN will cancel the tunnel and stop the monitors (#900)
  Add support for skipping sending usage pixels for remote messages (#902)
  Bump Tests/BrowserServicesKitTests/Resources/privacy-reference-tests (#896)
  Removes the listen port from the wireguard client (#901)
samsymons added a commit that referenced this pull request Jul 19, 2024
* main:
  Resetting all state for the VPN will cancel the tunnel and stop the monitors (#900)
  Add support for skipping sending usage pixels for remote messages (#902)
samsymons added a commit that referenced this pull request Jul 19, 2024
* main:
  Remove unused VPN session utilities (#898)
  Add new deprecated Mac remote message attribute. (#903)
  Resetting all state for the VPN will cancel the tunnel and stop the monitors (#900)
  Add support for skipping sending usage pixels for remote messages (#902)
  Bump Tests/BrowserServicesKitTests/Resources/privacy-reference-tests (#896)
  Removes the listen port from the wireguard client (#901)
  Be explicit when performing developer redirects (#884)
  C-S-S cross origin fixes
  Update C-S-S version (#892)
  Add a debug menu action to reset Remote Messages on macOS (#891)
  Add desktop specific RMF attributes (#883)
  Upload exception message to Sentry (#856)
  Add locale to broken site report (#889)
  Add new subfeature for duckplayer (#885)
  Swiftlint refactoring (#882)
  Remote Messaging Framework for macOS (#876)
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