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

[WEB-1007] FetchUserEmailQuery #1800

Merged
merged 16 commits into from
Mar 15, 2023
Merged

[WEB-1007] FetchUserEmailQuery #1800

merged 16 commits into from
Mar 15, 2023

Conversation

scottkicks
Copy link
Contributor

@scottkicks scottkicks commented Mar 8, 2023

📲 What

In order to reduce the amount/size of network calls to get the currently logged in user's email for our CAPI events, we can add a simpler query that just gets the email and store it globally instead of asking for the entire user object every time.

🤔 Why

reduces the amount of network calls needed and makes accessing the user's email simpler.

🛠 How

Add a small one field query in AppDelegate that will grab the email and make it accessible app-wide in AppEnvironment.currency.loggedInUserEmail

@scottkicks scottkicks added the WIP label Mar 8, 2023
@scottkicks scottkicks added this to the release-5.7.0 milestone Mar 8, 2023
@scottkicks scottkicks self-assigned this Mar 8, 2023
Copy link
Contributor

@msadoon msadoon left a comment

Choose a reason for hiding this comment

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

Mostly there, just fix these issues.

KsApi/ServiceType.swift Outdated Show resolved Hide resolved
KsApi/models/UserEnvelope.swift Show resolved Hide resolved
KsApi/models/graphql/GraphUserEmailTests.swift Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #1800 (71e8382) into main (3e59797) will decrease coverage by 0.04%.
The diff coverage is 73.61%.

@@            Coverage Diff             @@
##             main    #1800      +/-   ##
==========================================
- Coverage   85.40%   85.36%   -0.04%     
==========================================
  Files        1284     1286       +2     
  Lines      117604   117624      +20     
  Branches    31121    31142      +21     
==========================================
- Hits       100437   100413      -24     
- Misses      16083    16127      +44     
  Partials     1084     1084              
Impacted Files Coverage Δ
...ontroller/PledgePaymentMethodsViewController.swift 45.20% <ø> (-0.80%) ⬇️
.../PledgeView/Controllers/PledgeViewController.swift 72.93% <ø> (-0.12%) ⬇️
KsApi/Service.swift 9.48% <0.00%> (-0.10%) ⬇️
KsApi/ServiceType.swift 76.06% <ø> (ø)
KsApi/models/UserEnvelope.swift 0.00% <0.00%> (ø)
KsApi/models/graphql/GraphUserEmail.swift 0.00% <0.00%> (ø)
Library/SharedFunctions.swift 85.16% <ø> (-0.05%) ⬇️
Library/Tracking/AppTrackingTransparency.swift 0.00% <0.00%> (-5.00%) ⬇️
...ary/ViewModels/PledgePaymentMethodsViewModel.swift 93.12% <0.00%> (+0.11%) ⬆️
...iewModels/PledgePaymentMethodsViewModelTests.swift 98.07% <ø> (-0.03%) ⬇️
... and 20 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kickstarter kickstarter deleted a comment from nativeksr Mar 13, 2023
@scottkicks scottkicks marked this pull request as ready for review March 13, 2023 16:18
@scottkicks scottkicks requested a review from msadoon March 13, 2023 16:18
Copy link
Contributor

@msadoon msadoon left a comment

Choose a reason for hiding this comment

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

Some minor things here to update, but overall pretty good.
Mostly just get that signal firing from userSessionStarted.

Comment on lines +235 to +236
self.applicationWillEnterForegroundProperty.signal,
self.applicationLaunchOptionsProperty.signal.ignoreValues(),
Copy link
Contributor

@msadoon msadoon Mar 14, 2023

Choose a reason for hiding this comment

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

Can you get this signal firing without these signals because they don't exactly correlate to the user logging in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@msadoon I wanted to account for the case where users are already logged in when the feature is turned on. This way the next time they open the app we make sure to set their email. As opposed to waiting until they've logged out and then back in.

Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, good call, didn't think about that.

@@ -165,6 +165,10 @@ public protocol ServiceType {
func fetchGraphUser(withStoredCards: Bool)
-> SignalProducer<UserEnvelope<GraphUser>, ErrorEnvelope>

/// Fetches the email of the currently logged in User using graphQL.
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to specify that it is GraphQL.

@@ -48,6 +48,9 @@ public struct Environment {
/// The currently logged in user.
public let currentUser: User?

/// The currently logged in user's email. Fetched from GraphQL
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to say you get it from GQL

@@ -64,7 +64,7 @@ public protocol PledgeViewModelInputs {
func riskMessagingViewControllerDismissed(isApplePay: Bool)
func scaFlowCompleted(with result: StripePaymentHandlerActionStatusType, error: Error?)
func shippingRuleSelected(_ shippingRule: ShippingRule)
func storeFacebookCAPIUserEmail(_ email: String?)

Copy link
Contributor

Choose a reason for hiding this comment

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

can probably remove this newline, format might do it, if not don't worry about it.

@nativeksr
Copy link
Collaborator

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

Copy link
Contributor

@msadoon msadoon left a comment

Choose a reason for hiding this comment

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

Good to go, just make that comment fix and tests pass.

@scottkicks scottkicks merged commit f78b71c into main Mar 15, 2023
@scottkicks scottkicks deleted the web-1007 branch March 15, 2023 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants