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

[Feature] Remove chrome extension dependency for post-purchase #5584

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

carolinesalib
Copy link

@carolinesalib carolinesalib commented Mar 28, 2025

WHY are these changes introduced?

Fixes https://github.com/Shopify/temp-project-mover-syfiawoo-20250403105126/issues/68

The checkout post-purchase extension depends on the Shopify Post-purchase Developer Tools Chrome Extension that is currently unavailable. What the chrome extension does is to inject parameters to the checkout allowing developers to test their post-purchase extension on their development store. With this PR we are removing the dependency of the chrome extension and passing the required parameters via cart permalink when running the dev server.

WHAT is this pull request doing?

  1. Remove the developer dashboard post-purchase row component that refers to the chrome extension
  2. Add cart url to the list of post-purchase feature allowing it to be used as a dev url for testing the extension
  3. Set post-purchase required params to the permalink cart url allowing post-purchase to be tested on a real checkout

As a bonus, this PR also makes the checkout_post_purchase extension more consistent with the checkout checkout_ui_extension patterns.

How to test your changes?

  1. Create a post-purchase app and extension following this guide
    • TLDR; shopify app init and then shopify app generate extension --template post_purchase_ui --name my-post-purchase-ui-extension
  2. On the cli repo, switch to this branch
  3. Run dev based on this branch by running pnpm shopify app dev --path PATH_TO_EXTENSION on cli repo
  4. Click the preview link to install the app
  5. Finally, clicking on the preview link for the post-purchase extension should start a new checkout and after clicking on the "Pay now" button user is redirected to the post-purchase page/extension. No browser required 🙌

Post-release steps

Yes, I do need to update some docs before merging this PR but I will wait on feedback first since this is my first time contributing to this repo.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@carolinesalib carolinesalib force-pushed the post-purchase/remove-chrome-extension-dependency branch 2 times, most recently from 033a281 to d77dccf Compare March 28, 2025 18:23
@Shopify Shopify deleted a comment from github-actions bot Mar 28, 2025
@carolinesalib carolinesalib force-pushed the post-purchase/remove-chrome-extension-dependency branch from d77dccf to 0073d19 Compare March 28, 2025 18:26
@Shopify Shopify deleted a comment from github-actions bot Mar 28, 2025
@carolinesalib carolinesalib force-pushed the post-purchase/remove-chrome-extension-dependency branch from 0073d19 to 1588bd0 Compare March 29, 2025 16:57
@Shopify Shopify deleted a comment from github-actions bot Mar 29, 2025
@carolinesalib carolinesalib force-pushed the post-purchase/remove-chrome-extension-dependency branch from 1588bd0 to 9e0ac78 Compare March 31, 2025 15:07
Copy link
Contributor

github-actions bot commented Mar 31, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
76.72% (+0.03% 🔼)
9488/12367
🟡 Branches
71.83% (+0.05% 🔼)
4655/6481
🟡 Functions 76.45% 2457/3214
🟡 Lines
77.25% (+0.03% 🔼)
8975/11618

Test suite run success

2192 tests passing in 958 suites.

Report generated by 🧪jest coverage report action from 69fee77

@@ -88,6 +88,11 @@ export async function getUIExtensionPayload(
async function getExtensionPoints(extension: ExtensionInstance, url: string) {
const extensionPoints = extension.configuration.extension_points as DevNewExtensionPointSchema[]

if (extension.type === 'checkout_post_purchase') {
// Mock target for post-purchase in order to get the right extension point redirect url
return [{target: 'purchase.post.render'}] as DevNewExtensionPointSchema[]
Copy link
Author

Choose a reason for hiding this comment

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

There is no purchase.post.render target. Post-purchase extension has two extension points however no targets as there is no option to select where the extension will render (aka it is static). However, following an idea introduced by @vividviolet on this PR I decided to re-use the implicit post-purchase mock target to try to reuse most of the logic that was already used by checkout ui extensions. Let me know if you have any thoughts about this approach

Copy link
Member

Choose a reason for hiding this comment

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

@carolinesalib isn't there a new target for post purchase when it's a ui_extension right? Is that what we're using here?

Copy link
Member

Choose a reason for hiding this comment

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

Another idea - couldn't we transform the extension's schema here so that it correctly has the right shape and then we don't need this special conditional?

Copy link
Author

Choose a reason for hiding this comment

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

@vividviolet I don't think there is a target for post-purchase extensions. It doesn't use the same framework as ui_extension 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok, I thought these already have corresponding new targets in the shared ui_extension specification. Will we never migrate post_purchase then?

Choose a reason for hiding this comment

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

It's been in our roadmap for years, but it always ends up getting pushed to the next year 🥲

It seems like we'll finally start working on a post-purchase migration later this year/beginning of next year, but no hard plans just yet - we are discussing when we could start working on it.

@carolinesalib carolinesalib changed the title WIP: remove chrome extension dependency for post-purchase [Feature] Remove chrome extension dependency for post-purchase Mar 31, 2025
@carolinesalib carolinesalib marked this pull request as ready for review March 31, 2025 16:17
@carolinesalib carolinesalib requested a review from a team as a code owner March 31, 2025 16:17
Copy link
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.

Comment on lines +43 to +46
// This can never be null because we always generate it
// whenever there is an extension point targeting Post Purchase
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
rawUrl.pathname = options.checkoutCartUrl!
Copy link
Contributor

Choose a reason for hiding this comment

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

We should try this case:

  • Starting a dev-session (with the new API) for an app without extensions
  • Adding a new post-purchase extension while dev is still running

Copy link
Author

Choose a reason for hiding this comment

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

what is the expectation here? that the dev dashboard reloads with 2 extensions for testing? 🤔

/**
* The URL of the websocket used for hot reload
*/
websocketURL?: string
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 need this here? the caller of devUIExtensions is never including the websocketURL as part of ExtensionDevOptions

Copy link
Contributor

Choose a reason for hiding this comment

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

And ExtensionsPayloadStoreOptions is already a ExtensionDevOptions + websocketURL

Copy link
Author

Choose a reason for hiding this comment

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

I added that because I was getting this error when trying to get websocketURL.

image

Is there a better way to work around this? Typescript can still be challenging for me so if you have an example I would appreciate it 🙏

Copy link
Contributor

Choose a reason for hiding this comment

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

it's beacuse we are using ExtensionDevOptions in many places where we should be using ExtensionsPayloadStoreOptions.

I've pushed a commit fixing this :)

@carolinesalib carolinesalib force-pushed the post-purchase/remove-chrome-extension-dependency branch from c50683c to 5face64 Compare April 9, 2025 00:06
@carolinesalib carolinesalib removed the request for review from kumar303 April 9, 2025 14:44
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.

4 participants