Skip to content

Conversation

@Ecarrion
Copy link
Contributor

@Ecarrion Ecarrion commented May 31, 2023

closes #9845

Why

We found a public WPCom API to get the user's IP country code: https://public-api.wordpress.com/geo/. This PR updates the feature to rely solely on this API for WPCom and non-WPCom users.

How

  • Adds a new IPLocationRemote type to fetch and parse from the new endpoint.

  • Update the PrivacyBannerPresentationUseCase to:

    • Use the new API as the only source for the ip country code.
    • Not fetch the new API if privacy choices have been saved.
    • Do not rely on the locale at all.
  • Removes the now unused ipCountryCode property from the Account type. (I'm glad I didn't save this on core data!)

Demo

WPCom - EU

wpcom-eu.mov

WPCom - NO EU

wpcom-no-eu.mov

Non WPCom - EU

non-wpcom-eu.mov

Non WPCom - NO EU

non-epcom-no-eu.mov

Testing Steps

Prerequisite before each scenario

  • Navigate to settings
  • Tap 4 times in the heart at the bottom of the screen
  • Reset privacy choices

WPCom - EU

  • Login with a WPCom account in the EU (use a VPN and turn off the proxy)
  • Launch the app
  • See that the privacy banner is presented

WPCom - NO EU

  • Login with a WPCom account outside of the EU (use a VPN and turn off the proxy)
  • Launch the app
  • See that the privacy banner is not presented

Non-WPCom - EU

  • Login with a Non-WPCom account in the EU (use a VPN and turn off the proxy)
  • Launch the app
  • See that the privacy banner is presented

Non-WPCom - NO EU

  • Login with a Non-WPCom account outside of the EU (use a VPN and turn off the proxy)
  • Launch the app
  • See that the privacy banner is not presented

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 31, 2023

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr9851-37cbe5f on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@Ecarrion Ecarrion force-pushed the issue/9845-ip-location branch from b9f84b9 to 24b9505 Compare June 1, 2023 03:31
@Ecarrion Ecarrion changed the title [Privacy Choices] Use 3rd Party API for Non-WPCom accounts [Privacy Choices] Use a consolidated API to fetch the user ip country code Jun 1, 2023
@Ecarrion Ecarrion requested review from ThomazFB and rachelmcr June 1, 2023 03:34
@Ecarrion Ecarrion added the feature: privacy Related to the privacy choices project label Jun 1, 2023
@Ecarrion Ecarrion added this to the 13.9 milestone Jun 1, 2023
@Ecarrion Ecarrion marked this pull request as ready for review June 1, 2023 11:23
@rachelmcr rachelmcr self-assigned this Jun 2, 2023
return onCompletion(.failure(IPLocationError.malformedURL)) // Should not happen.
}

let request = UnauthenticatedRequest(request: .init(url: url))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be adding the custom user-agent header with .asURLRequest() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I totally missed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: privacy Related to the privacy choices project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Privacy Choices] [iOS] Improve country code for non-JP sites

4 participants