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

Google Ads: Add eligibility check for campaign creation #13192

Merged
merged 10 commits into from
Jul 1, 2024

Conversation

itsmeichigo
Copy link
Contributor

@itsmeichigo itsmeichigo commented Jun 28, 2024

Closes: #13190

Description

This PR adds an eligibility checker to decide whether to display the entry point to Google ads campaign creation on the app. The logic includes:

  • Check the new feature flag googleAdsCampaignCreationOnWebView to ensure that it's enabled.
  • Check the cached system plugin for GLA plugin. If not, fetch from remote the plugin by GLA's slug.
  • If found, the plugin should be active and has version 2.7.5 or above.
  • If the plugin is satisfied, check to ensure that Google ads account is connected for the plugin.

Testing steps

The eligibility check has not been used anywhere, so just unit tests passing is sufficient.

Screenshots

N/A


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

@itsmeichigo itsmeichigo added type: task An internally driven task. feature: google-ads-campaigns Related to Google ads campaigns labels Jun 28, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jun 28, 2024

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr13192-c5b1a0e
Version19.2
Bundle IDcom.automattic.alpha.woocommerce
Commitc5b1a0e
App Center BuildWooCommerce - Prototype Builds #9814
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@itsmeichigo itsmeichigo added this to the 19.4 milestone Jun 28, 2024
@itsmeichigo itsmeichigo changed the base branch from trunk to task/13182-yosemite-fetch-gla-campaigns June 28, 2024 07:51
@itsmeichigo itsmeichigo marked this pull request as ready for review June 28, 2024 07:54
Base automatically changed from task/13182-yosemite-fetch-gla-campaigns to trunk June 28, 2024 07:54
@selanthiraiyan selanthiraiyan self-assigned this Jun 28, 2024
Copy link
Contributor

@selanthiraiyan selanthiraiyan left a comment

Choose a reason for hiding this comment

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

This looks good to me and is ready to ship. 🚢

I left a couple of non-blocking questions.

self.featureFlagService = featureFlagService
}

func isSiteEligible(siteID: Int64) async -> Bool {
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 mark this as MainActor? Also, I think marking the protocol method as MainActor doesn't really check the MainActor conformance 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.

@selanthiraiyan Actually marking the protocol method with @MainActor ensures that all conformance method are on the main actor. I learned this when attempting to do the migration for Swift 6, so I figured it's better to do it correctly now than to fix it later in the migration process.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually marking the protocol method with @mainactor ensures that all conformance method are on the main actor.

That is great. TIL. Thanks.


let isPluginSatisfied: Bool = await {
if let savedPlugin = await fetchPluginFromStorage(siteID: siteID) {
return checkIfGoogleAdsIsSupported(plugin: savedPlugin)
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 fetch the plugin from remote in case the plugin version has been updated recently and it isn't synched to storage yet?
This is an edge case considering that we fetch plugin info upon app launch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@selanthiraiyan do you mean we should always fetch from remote rather than relying on storage?

Copy link
Contributor

Choose a reason for hiding this comment

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

do you mean we should always fetch from remote rather than relying on storage?

We can fetch from remote only when the local plugin version doesn't match the required pluginMinimumVersion. This covers the case in which the user has updated the plugin version recently but we haven't fetched the new version details. This is an edge case and please feel free to ignore it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is safer to always fetch plugins from remote to avoid edge cases. Updated in 5f0f3ea. Thanks Sharma for the suggestion!

@itsmeichigo itsmeichigo merged commit 5ac3e1e into trunk Jul 1, 2024
19 of 22 checks passed
@itsmeichigo itsmeichigo deleted the task/13190-gla-eligibility-check branch July 1, 2024 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: google-ads-campaigns Related to Google ads campaigns type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eligibility check for entry point
3 participants