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

Integrate RemoteMessaging with NewTabPage #3017

Merged
merged 6 commits into from
Jul 3, 2024
Merged

Conversation

dus7
Copy link
Contributor

@dus7 dus7 commented Jul 1, 2024

Task/Issue URL: https://app.asana.com/0/1206226850447395/1207703703130204/f
Tech Design URL:
CC:

Description:

Adds RemoteMessaging capability to new NewTabPage layout.

PixelFiring protocol got reorganized and extended, allowing to abstract this functionality and make depending logic testable. So far it was used only in AdAttributionPixelReporter.

Steps to test this PR:

  1. Change RemoteMessagingClient.endpoint value to https://www.jsonblob.com/api/1257306235471781888.
  2. Restart app.
  3. Make sure Internal User flag is set and NewTabPage sections are enabled in debug menu.
  4. Test functionality of all 5 messages.
  5. Check if proper pixels are fired on dismiss, appear, close and actions.
  6. Verify if message does not appear twice after it's dismissed.

Definition of Done (Internal Only):

Device Testing:

  • iPhone 14 Pro
  • iPad

Internal references:

Software Engineering Expectations
Technical Design Template

Copy link

github-actions bot commented Jul 1, 2024

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

Generated by 🚫 dangerJS against b03af69

self.homeMessageViewModels = homePageMessagesConfiguration.homeMessages.compactMap(self.homeMessageViewModel(for:))
}

private func homeMessageViewModel(for message: HomeMessage) -> HomeMessageViewModel? {
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 function is copied from HomeMessageViewSectionRenderer.

@@ -19,13 +19,32 @@

import SwiftUI
import DuckUI
import RemoteMessaging
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Required for Preview

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved from AdAttributionPixelReporter.


public protocol PixelFiring {

static func fire(_ pixel: Pixel.Event,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to make first param unnamed to avoid name ambiguity, but I think API still makes sense, only downside is that when using Pixel directly there are both variants available in autocomplete. In the end I believe we should be using protocol exclusively.

Comment on lines +76 to +77
static let messageMaximumWidth: CGFloat = 380
static let messageMaximumWidthPad: CGFloat = 455
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used values from HomeMessageCollectionViewCell.

@dus7 dus7 marked this pull request as ready for review July 1, 2024 15:30
@dus7 dus7 requested a review from brindy July 1, 2024 15:31
Copy link
Contributor

@brindy brindy left a comment

Choose a reason for hiding this comment

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

The pixel thing confused me for a moment. Took me a minute to understand why we need the async one, but I get it. If you think this a pattern we should propagate then please create a diary entry for it. Not sure how compatible it is with the PixelKit work?

Anyway, aside from that, LGTM!

@dus7
Copy link
Contributor Author

dus7 commented Jul 3, 2024

Not sure how compatible it is with the PixelKit work?

@federicocappelli any thoughts on this? Do you think it clashes with PixelKit in any way?

@federicocappelli
Copy link
Member

Not sure how compatible it is with the PixelKit work?

@federicocappelli any thoughts on this? Do you think it clashes with PixelKit in any way?

Hi @dus7, from my understanding you wanted to:

  1. Add swift concurrency to the Pixel.fire(...) to fire a pixel synchronously instead of the usual fire-and-forget
  2. Be able to mock pixel firing for testing purposes
    Correct?

Your implementation seems good BUT I'm a bit worried about the constant diverging of our approaches across platforms, this could have been a good occasion for adopting PixelKit (only for .appleAdAttribution), adding swift concurrency to it and using the tools in PixelKitTestingUtilities for your unit tests.

My point is that I would like to see more collaboration and various teams working on shared tools instead of each of us re-implementing its own thing. This code becomes immediately tech debt, and another blocker, as soon someone tries to adopt PixelKit in iOS.

@dus7
Copy link
Contributor Author

dus7 commented Jul 3, 2024

Thanks @federicocappelli, this makes sense to me. Completely agreed we should not be diverging our approaches and it wasn't my goal at all while writing this. I wasn't aware about the existence of PixelKitTestingUtilities, nor there's any usage of PixelKit yet in iOS app so I just went and solved my own problem which has now escalated to multiple places :).

I'll merge this PR and add a task for myself to add swift concurrency to PixelKit and refactor this code to use PixelKit instead.

@federicocappelli
Copy link
Member

Thanks @federicocappelli, this makes sense to me. Completely agreed we should not be diverging our approaches and it wasn't my goal at all while writing this. I wasn't aware about the existence of PixelKitTestingUtilities, nor there's any usage of PixelKit yet in iOS app so I just went and solved my own problem which has now escalated to multiple places :).

I'll merge this PR and add a task for myself to add swift concurrency to PixelKit and refactor this code to use PixelKit instead.

Perfectly understandable! Thank you for putting in the effort!

@dus7 dus7 merged commit 116d840 into main Jul 3, 2024
30 checks passed
@dus7 dus7 deleted the mariusz/ntp-integrate-rfm branch July 3, 2024 10:09
samsymons added a commit that referenced this pull request Jul 4, 2024
* main: (24 commits)
  Add pixels to measure baseline for New Tab Page sections (#3024)
  backgrounding UI tests (#3021)
  improve bookmarks and favorites UI tests (#3019)
  [DuckPlayer] - 4. Remote Config (#3018)
  Updates BSK
  Fix issue when cancelling a download (#3030)
  Tentative fix for a crash and connectivity issues (#3027)
  autofill UI tests (#3012)
  scripts for running UI tests (#3000)
  Integrate RemoteMessaging with NewTabPage (#3017)
  Update to iOS 15 deployment target (#3001)
  Fire a pixel when removing the VPN configuration (#3014)
  Release 7.127.0-0 (#3020)
  point to BSK branch (#3016)
  [DuckPlayer] - 3. URL management & FE comms (#3007)
  Bump BSK version (#3011)
  New Tab Page layout and base elements (#3008)
  Remove Privacy Pro from device once expired account is deleted (#3009)
  Improvements to subscription settings (#2959)
  Toggle reports limiter (#3005)
  ...
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.

None yet

3 participants