Skip to content

Dogfood preload observability in React Native sample - #656

Merged
markmur merged 2 commits into
mainfrom
rn-sample-preload-observability
Aug 18, 2026
Merged

Dogfood preload observability in React Native sample#656
markmur merged 2 commits into
mainfrom
rn-sample-preload-observability

Conversation

@markmur

@markmur markmur commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What changes

  • Observe each cart preload in the React Native sample app and render its current lifecycle state.
  • Start a fresh request-scoped observation when the cart screen gains focus or the cart URL/quantity changes.
  • Remove the previous observer during effect cleanup without invalidating the cached checkout.
  • Surface failure reasons and HTTP status codes when a preload fails.

Sample pattern

The sample demonstrates that the callback can be stable while the options object remains local to the effect; merchants do not need to memoize the options object.

const [preloadState, setPreloadState] = useState<PreloadState>({
  type: 'idle',
});
const {preload} = useShopifyCheckout();

useEffect(() => {
  if (
    !isFocused ||
    !checkoutPreloadingEnabled ||
    !checkoutUrl ||
    totalQuantity === 0
  ) {
    setPreloadState({type: 'idle'});
    return;
  }

  const subscription = preload(checkoutUrl, {
    onStateChange: setPreloadState,
  });

  return () => subscription.remove();
}, [
  checkoutPreloadingEnabled,
  checkoutUrl,
  isFocused,
  preload,
  totalQuantity,
]);

The cart UI then makes the observed state visible while dogfooding:

<Text>Checkout preload: {formatPreloadState(preloadState)}</Text>

@markmur
markmur requested a review from a team as a code owner August 17, 2026 10:36
@github-actions github-actions Bot added the #gsd:50662 Rebase Checkout Kit on UCP label Aug 17, 2026

markmur commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown

React Native — Coverage Report

Lines Statements Branches Functions
Coverage: 91%
90.97% (363/399) 87.29% (213/244) 100% (92/92)

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown

Package Size

Platform Artifact Base Head Delta
React Native npm tarball 107.3 KiB 107.3 KiB 0 B
React Native file breakdown
File Base Head Delta
node_modules/@shopify/checkout-kit-protocol/src/generated/Models.ts 85.4 KiB 85.4 KiB 0 B
node_modules/@shopify/checkout-kit-protocol/src/generated/Models.d.ts 53.0 KiB 53.0 KiB 0 B
android/src/main/java/com/shopify/reactnative/checkoutkit/ShopifyCheckoutKitModule.java 16.0 KiB 16.0 KiB 0 B
ios/ShopifyCheckoutKit.swift 15.9 KiB 15.9 KiB 0 B
ios/AcceleratedCheckoutButtons.swift 14.1 KiB 14.1 KiB 0 B
src/components/AcceleratedCheckoutButtons.tsx 13.0 KiB 13.0 KiB 0 B
src/index.ts 12.7 KiB 12.7 KiB 0 B
lib/commonjs/index.js 12.4 KiB 12.4 KiB 0 B
lib/commonjs/components/AcceleratedCheckoutButtons.js 11.4 KiB 11.4 KiB 0 B
src/index.d.ts 11.1 KiB 11.1 KiB 0 B
lib/commonjs/components/AcceleratedCheckoutButtons.js.map 10.4 KiB 10.4 KiB 0 B
lib/module/index.js 10.4 KiB 10.4 KiB 0 B
lib/module/components/AcceleratedCheckoutButtons.js 10.2 KiB 10.2 KiB 0 B
node_modules/@shopify/checkout-kit-protocol/src/generated/ProtocolNotifications.ts 9.5 KiB 9.5 KiB 0 B
lib/module/components/AcceleratedCheckoutButtons.js.map 9.1 KiB 9.1 KiB 0 B
lib/module/index.js.map 8.1 KiB 8.1 KiB 0 B
src/present-dispatcher.ts 8.0 KiB 8.0 KiB 0 B
lib/commonjs/index.js.map 7.9 KiB 7.9 KiB 0 B
node_modules/@shopify/checkout-kit-protocol/src/generated/ProtocolNotifications.d.ts 7.6 KiB 7.6 KiB 0 B
node_modules/@shopify/checkout-kit-protocol/src/generated/ProtocolRenameMap.ts 7.2 KiB 7.2 KiB 0 B
…and 117 smaller files

Measured from the PR base SHA and PR head SHA. The file breakdown shows uncompressed sizes within each package artifact, so individual files do not sum to the compressed artifact total. This comment reports package artifact sizes only; it is not a final app binary-size report.

@markmur markmur self-assigned this Aug 17, 2026
@bitrise

bitrise Bot commented Aug 17, 2026

Copy link
Copy Markdown

Install this build

Open Tophat, select your target device, then click Install. Links open on the Mac running Tophat.

SDK Install
React Native Install with Tophat

Checkout Kit E2E results

Status Suite Target Platform OS version tag Device
react-native-ios react-native ios latest iPhone 15
iOS 27 Beta
react-native-android react-native android latest Google Pixel 10
Android 16.0

@markmur
markmur force-pushed the rn-sample-preload-observability branch from b6946b2 to 7350bfc Compare August 17, 2026 10:54
@markmur
markmur force-pushed the rn-current-activity-api branch from 784fb2e to 162a2ce Compare August 17, 2026 10:54
@markmur
markmur force-pushed the rn-sample-preload-observability branch from 7350bfc to fdbdb7f Compare August 17, 2026 11:25
@markmur
markmur force-pushed the rn-current-activity-api branch from 162a2ce to f8a4ce2 Compare August 17, 2026 11:25
@markmur markmur mentioned this pull request Aug 17, 2026
4 tasks
@markmur
markmur force-pushed the rn-current-activity-api branch from f8a4ce2 to ca62c99 Compare August 17, 2026 11:50
@markmur
markmur force-pushed the rn-sample-preload-observability branch 2 times, most recently from 61d653a to 260e77b Compare August 17, 2026 13:30
@markmur
markmur force-pushed the rn-current-activity-api branch from ca62c99 to 3de53fe Compare August 17, 2026 13:30
@markmur
markmur force-pushed the rn-sample-preload-observability branch from 260e77b to 68f1602 Compare August 17, 2026 13:34
@markmur
markmur force-pushed the rn-sample-preload-observability branch from 68f1602 to e291e83 Compare August 18, 2026 09:34
@markmur
markmur force-pushed the rn-current-activity-api branch from 3de53fe to d5de149 Compare August 18, 2026 09:34
Base automatically changed from rn-current-activity-api to main August 18, 2026 10:28
@markmur
markmur merged commit e7c02f3 into main Aug 18, 2026
43 of 49 checks passed
@markmur
markmur deleted the rn-sample-preload-observability branch August 18, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants