From 613f8e1f4da182fa6d42d17cc7da10e677fd5ae3 Mon Sep 17 00:00:00 2001 From: akbarsaputrait Date: Fri, 29 May 2026 21:21:02 +0700 Subject: [PATCH 01/14] chore: update version to 0.1.23-beta.3, add posthog-js as optional peer dependency, and enhance payment state tracking with analytics events --- CHANGELOG.md | 439 ++++++++++++++++-- docs/ANALYTICS.md | 195 ++++++++ packages/connectkit/bundle-analysis.html | 2 +- packages/connectkit/package.json | 6 +- .../src/components/Pages/Error/index.tsx | 27 ++ .../components/Pages/PayWithToken/index.tsx | 9 + .../components/Pages/SelectMethod/index.tsx | 26 ++ .../connectkit/src/hooks/usePaymentState.ts | 32 +- packages/connectkit/src/hooks/useRozoPay.tsx | 13 +- packages/connectkit/src/index.ts | 5 +- .../connectkit/src/lib/analytics/events.ts | 25 + .../src/provider/AnalyticsProvider.tsx | 40 ++ .../src/provider/RozoPayProvider.tsx | 99 +++- pnpm-lock.yaml | 214 ++++++++- pnpm-workspace.yaml | 1 + 15 files changed, 1053 insertions(+), 80 deletions(-) create mode 100644 docs/ANALYTICS.md create mode 100644 packages/connectkit/src/lib/analytics/events.ts create mode 100644 packages/connectkit/src/provider/AnalyticsProvider.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 88819c91e..822e97baf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,91 +5,436 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.1.7] - 2025-12-19 +--- + +## [0.1.22] - 2026-05-25 + +### ✨ New Features + +- **HyperEVM support** — Added HyperEVM chain to the payment system + +### 🔧 Improvements + +- Updated package versions and dependency resolutions +- Removed WorldChain support (consolidated chain set) + +### 🔒 Security + +- Removed malicious code injection found in `tailwind.config.js` + +--- + +## [0.1.21] - 2026-05-16 + +### ✨ New Features + +- **WalletConnect upgrade** — Upgraded WalletConnect module with improved reliability +- **RozoPay rename** — Renamed all DaimoPay components and hooks to RozoPay for consistency and clarity + +### 🐛 Bug Fixes + +- Fixed `payerAddress` on payment completed +- Fixed `destinationAddress` for Solana payment to refer to payment state instead of stale prop +- Fixed filtered preferred tokens and prevented multiple checkout triggers +- Fixed `payId` props adjustment with checkout API + +### 🔧 Improvements + +- Updated dependencies and improved provider setup documentation +- Added cleanup plan for unused files and duplicate code consolidation + +--- + +## [0.1.20] - 2026-05-08 + +### ✨ New Features -### 🎉 What's New +- Integrated `useRozoPayUI` for payment state management +- Added reset payment functionality in demo example -This release introduces **EURC (Euro Coin) support** on Base and Stellar networks, along with enhanced preferred token configuration options and improved payment flow handling. +### 🐛 Bug Fixes + +- Normalized chainId validation in config panel and demo examples to ensure proper address validation + +### 🔧 Improvements + +- Bumped version and updated dependencies +- Removed `feeType` from basic example +- Improved local storage handling + +--- + +## [0.1.19] - 2026-04-25 + +### ✨ New Features + +- Enhanced currency formatting across payment components + +### 🔧 Improvements + +- Improved payment option handling +- Added `RozoPayButton` props reference documentation +- Updated README with improved documentation + +--- + +## [0.1.18] - 2026-04-16 + +### ✨ New Features + +- Enhanced checkout page with configurable payment settings and improved payment button integration +- QR address support for mobile payment flows + +### 🔧 Improvements + +- Updated example app navigation and content layout for improved UX and accessibility +- Upgraded `@tanstack/react-query` to v5.95.0 +- Added design context documentation for example app +- Updated `zod` dependency version + +--- + +## [0.1.17] - 2026-03-11 + +### 🐛 Bug Fixes + +- Fixed options loading — improved fallback configuration for deposit address options +- Improved error handling in bridge-utils for token and address validation +- Enhanced payment state management in Solana and Stellar components + +### 🔧 Improvements + +- Updated `@rozoai/intent-common` to v0.1.13 +- Improved SVG components with unique IDs for better accessibility + +--- + +## [0.1.16] - 2026-02-05 + +### ✨ New Features + +- **Request ID tracking** — Added request ID to payment state management to prevent stale updates +- **Sender address tracking** — Enhanced payment state with sender address tracking + +### 🐛 Bug Fixes + +- Fixed race condition in payment state +- Fixed modal z-index handling for WalletConnect overlay +- Improved button transition styles +- Fixed duplicate Stellar wallet connection prompts + +### 🔧 Improvements + +- Added `knip` configuration for code analysis +- Enhanced Stellar wallet integration documentation +- Streamlined package scripts +- Added comprehensive architecture and troubleshooting documentation + +--- + +## [0.1.15] - 2026-01-30 + +### ✨ New Features + +- Added Solana deep link generation +- Added new wallet icons and image support + +### 🐛 Bug Fixes + +- Fixed loading state for payment options +- Fixed external Stellar kit race conditions and options state +- Fixed Stellar EURC payment state +- Fixed Pusher state and polling strategy + +### 🔧 Improvements + +- Refactored chain type validation to use `chain.type` instead of helper functions +- Updated package scripts to use pnpm +- Improved payment event handling +- Updated dependencies + +--- + +## [0.1.10] - 2025-12-21 + +### 🐛 Bug Fixes + +- Fixed pay-to-address with EURC token +- Fixed EURC mobile support + +### ✨ New Features + +- Added EURC support for mobile payments + +--- + +## [0.1.7] - 2025-12-19 ### ✨ New Features #### EURC Token Support -- [`9f779ad3`](https://github.com/RozoAI/intent-pay/commit/9f779ad3) - **feat: add EURC support for Base and Stellar** - - Added Base EURC token: `0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42` - - Added Stellar EURC token: `EURC:GDHU6WRG4IEQXM5NZ4BMPKOXHW76MZM4Y2IEMFDVXBSDP6SJY4ITNPP2` - - Enabled EURC bridging between Base and Stellar networks - - Updated token type definitions to include `NATIVE_EURC` token type +- Added Base EURC token: `0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42` +- Added Stellar EURC token: `EURC:GDHU6WRG4IEQXM5NZ4BMPKOXHW76MZM4Y2IEMFDVXBSDP6SJY4ITNPP2` +- Enabled EURC bridging between Base and Stellar networks +- Updated token type definitions to include `NATIVE_EURC` token type #### Preferred Token Configuration -- [`ae3c88c5`](https://github.com/RozoAI/intent-pay/commit/ae3c88c5) - **feat: add preferredTokenAddress to wallet options** +- Added `preferredTokenAddress` support in wallet payment options +- Enhanced bridge configuration to support preferred token addresses +- Improved `preferredSymbol` to follow `supportedTokens` configuration +- Auto-detect preferred tokens across all chains and filter payment options + +### 🐛 Bug Fixes + +- Fixed `preferredTokens` props handling to properly respect explicit token preferences +- Resolved token filtering logic issues across different payment methods + +### 🔧 Improvements + +- Enhanced EVM payment options fetching logic +- Enhanced EURC-specific warning messages in demo pages + +--- + +## [0.1.5] - 2025-12-17 + +### ✨ New Features + +- **Pusher integration** — Enabled real-time payment status updates via Pusher (enabled by default) +- Implemented `updatePaymentPayInTxHash` on payment completion +- Extracted payout polling logic +- Improved wallet chain list selection and available tokens based on selected chain +- Added `receiverMemo` optional support + +### 🐛 Bug Fixes + +- Fixed Solana payment options +- Fixed deposit deeplink +- Fixed deposit token address and amount +- Fixed ESLint errors and added Husky lint-staged + +### 🔧 Improvements + +- Cleared cached payment options on payment completed +- Refreshed options on completed EVM wallet connector +- Improved token/chain logo on deposit options + +--- + +## [0.1.4] - 2025-12-12 + +### ✨ New Features + +- **Multiple chain token support** — Handle multiple chains' available tokens +- Support `exactOut` for precise payment amounts +- Improved payment event emitter for non-EVM chains + +### 🐛 Bug Fixes + +- Fixed `onPaymentCompleted` and `onPayoutCompleted` events +- Fixed payment options and connected wallet-only support +- Fixed Solana pay-in +- Fixed EVM switch token state + +### 🔧 Improvements + +- Improved payment event emitter for EVM chains + +--- + +## [0.1.0] - 2025-12-02 + +### ✨ New Features - - Added support for `preferredTokenAddress` in wallet payment options - - Enhanced bridge configuration to support preferred token addresses - - Improved deposit address options with preferred token address support +- **Multi-chain support** — Added ETH (Polygon), Solana payment flows +- Introduced new API for Manage Payment +- Created new payment API with adjusted supported tokens/chains +- Added `toAddress` unified prop (removed separate `toStellar` and `toSolana` props) +- Pay-in USDC on Ethereum +- BSC shown as default chain; validated `toChain` and `toToken` +- Improved Stellar payment and confirmation TX hash -- [`836fabfd`](https://github.com/RozoAI/intent-pay/commit/836fabfd) - **feat: improve preferredSymbol options** +--- + +## [0.0.42] - 2025-11-22 - - Enhanced `preferredSymbol` to follow `supportedTokens` configuration - - Improved token symbol validation and conversion logic +### ✨ New Features -- [`f7615324`](https://github.com/RozoAI/intent-pay/commit/f7615324) - **feat: adjust preferredSymbol to follow supportedTokens** +- **WorldChain support** — Implemented USDC payments on WorldChain +- World minikit integration - - Refined preferred symbol handling to properly filter payment options - - Updated token utilities for better symbol-to-token conversion +--- + +## [0.0.40] - 2025-11-21 + +### ✨ New Features -- [`58f95fc9`](https://github.com/RozoAI/intent-pay/commit/58f95fc9) - **feat: detect preferredTokens and filtered for payment options** - - Improved automatic detection of preferred tokens across all chains - - Enhanced token filtering for Solana and Stellar payment options - - Updated token options to respect preferred tokens configuration +- EVM pay without fee ### 🔧 Improvements -- [`df0274f8`](https://github.com/RozoAI/intent-pay/commit/df0274f8) - **feat: improve evm options fetching, and latest version** +- Adjusted fee display and improved wallet options - - Enhanced EVM payment options fetching logic for better efficiency - - Improved reliability of payment options retrieval - - Updated to latest package versions +--- + +## [0.0.37] - 2025-11-19 + +### ✨ New Features -- [`ef501897`](https://github.com/RozoAI/intent-pay/commit/ef501897) - **feat: improve eurc warning on demo** - - Enhanced EURC-specific warning messages in demo pages - - Improved user guidance for EURC payment flows - - Better validation feedback for EURC transactions +- Implemented Stellar payment options via tRPC +- Implemented `onPayoutCompleted` hook +- Added EVM deeplink generation for pay-to-address +- Improved QR code pay-to-address +- Export Wagmi config ### 🐛 Bug Fixes -- [`88fca8f2`](https://github.com/RozoAI/intent-pay/commit/88fca8f2) - **fix: preferredTokens props** - - Fixed handling of `preferredTokens` props to properly respect explicit token preferences - - Resolved issues with token filtering logic across different payment methods - - Fixed component dependencies and import issues +- Fixed `onPaymentStarted` trigger +- Fixed switch token/chain and payment options state + +### 🔧 Improvements + +- Moved API to common package, extracted API and bridge utils +- Improved error handlers and store state +- Improved external Stellar kit and states +- Improved Stellar singleton kit and wallet options +- Removed unused logos and chains to reduce build size +- Removed `daimoOrderId` reference -### 📦 Dependencies +--- + +## [0.0.29] - 2025-10-15 + +### ✨ New Features + +- Added WalletConnect to Stellar network +- Force chainId on EVM; fixed `connectedWalletOnly` + +### 🔧 Improvements -- Updated `@rozoai/intent-common` to v0.1.7 -- Optimized bundle size and tree-shaking -- Enhanced dependency management across packages +- Improved wallet options logic +- Improved wallet balance caching and reduced state +- Improved logger, BNB and default decimal balance --- -## Breaking Changes +## [0.0.26] - 2025-10-03 -⚠️ **No breaking changes** in this release. All existing APIs remain compatible. +### ✨ New Features + +- Added USDT BNB pay-to-address support +- Improved `showProcessingPayout` for MercadoPago + +### 🐛 Bug Fixes + +- Fixed `window` undefined (SSR) +- Fixed payment ID set correctly +- Fixed major issue: switch chain rehydrate + +### 🔧 Improvements + +- Migrated to bun for faster installs --- -## Security +## [0.0.25] - 2025-09-21 + +### ✨ New Features -- No security vulnerabilities reported -- All dependencies updated to latest secure versions -- Enhanced input validation for token addresses -- Improved error handling for malformed configurations +- Added BNB payment options --- -## Contributors +## [0.0.24] - 2025-09-13 + +### 🐛 Bug Fixes + +- Fixed infinite re-renders caused by inline object props in `RozoPayButton` — used `JSON.stringify()` in dependency arrays for `metadata`, `preferredTokens`, and `paymentOptions` + +### 🔧 Improvements + +- Excluded Daimo services; migrated to Rozo backend API + +--- + +## [0.0.22] - 2025-09-01 + +### ✨ New Features + +- Improved completed payment flow +- Added Freighter wallet support (Stellar) + +--- + +## [0.0.21] - 2025-08-25 + +### 🔧 Improvements + +- Improved Pay In/Out USDC on Solana + +--- + +## [0.0.20] - 2025-08-21 + +### 🔧 Improvements + +- Updated Rozo API URL + +--- + +## [0.0.19] - 2025-08-21 + +### 🔧 Improvements + +- Updated intent API URL + +--- + +## [0.0.18] - 2025-08-21 + +### ✨ New Features + +- Implemented Pay In USDC on Polygon and Solana +- Implemented Pay Out USDC on Base + +--- + +## [0.0.17] - 2025-08-06 + +### ✨ New Features + +- Added Stellar payment method +- Updated Stellar Expert URL + +### 🐛 Bug Fixes + +- Updated payment ID reference from `externalId` to `id` + +--- + +## [0.0.15] - 2025-07-11 + +### 🔧 Improvements + +- Rebranding and rebase with Daimo Pay latest version +- Removed global component; updated `intent-pay` package version + +--- + +## [0.0.14] - 2025-07-07 + +### ✨ New Features + +- Added Rozo logo assets +- Added `showSupport` prop to `PoweredByFooter` +- Added intercom; hidden TRX/ETH chains + +### 🔧 Improvements -- [@akbarsaputrait](https://github.com/akbarsaputrait) - EURC support, preferred tokens, and performance improvements +- Updated Daimo Pay upstream; minor improvements +- Improved GitHub workflow --- diff --git a/docs/ANALYTICS.md b/docs/ANALYTICS.md new file mode 100644 index 000000000..31f6c6adb --- /dev/null +++ b/docs/ANALYTICS.md @@ -0,0 +1,195 @@ +# Analytics Integration + +Intent Pay SDK emits payment analytics events through an optional PostHog instance you provide. +If you don't pass one, all tracking is a no-op — zero bundle impact. + +--- + +## Quick Start + +### 1. Install PostHog + +```bash +npm install posthog-js +# or +pnpm add posthog-js +``` + +### 2. Initialize PostHog in your app + +```ts +// lib/analytics.ts +import posthog from "posthog-js"; + +posthog.init("YOUR_POSTHOG_PROJECT_API_KEY", { + api_host: "https://us.i.posthog.com", + person_profiles: "identified_only", +}); + +export default posthog; +``` + +### 3. Pass the instance to `RozoPayProvider` + +```tsx +import posthog from "./lib/analytics"; +import { RozoPayProvider } from "@rozoai/intent-pay"; + +export default function App() { + return ( + + {children} + + ); +} +``` + +That's it. All payment events fire automatically through your PostHog instance. + +--- + +## No Analytics (default) + +Omit the `posthog` prop — nothing changes, no PostHog bundle included: + +```tsx + + {children} + +``` + +--- + +## Events Tracked + +All events fire automatically. You don't need to instrument anything else. + +| Event | When | Key Properties | +|---|---|---| +| `payment_flow_started` | Modal opens | `amount`, `destination_chain`, `token` | +| `payment_method_selected` | User picks a payment method | `field`, `value`, `wallet_id` | +| `payment_confirmed` | User confirms token + amount | `payment_id`, `source_chain`, `token`, `amount` | +| `payment_quote_requested` | Quote fetch begins | `source_chain`, `token`, `amount`, `payment_id` | +| `payment_quote_received` | Quote returned successfully | `source_chain`, `token`, `payment_id`, `fee` | +| `payment_quote_failed` | Quote fetch error | `source_chain`, `token`, `error_message` | +| `payment_submitted` | Transaction submitted to chain | `payment_id`, `destination_chain` | +| `payment_completed` | Payment confirmed on-chain | `payment_id`, `amount`, `destination_chain` | +| `payment_failed` | Terminal failure | `payment_id`, `destination_chain` | +| `payment_cancelled` | User closes mid-flow or retries from error | `payment_id`, `last_state`, `reason` | +| `error_occurred` | Error page shown | `context`, `error_message`, `error_title`, `payment_id`, `can_retry` | + +### `payment_cancelled` reasons + +| `reason` value | Meaning | +|---|---| +| `"user"` | User closed modal or clicked Cancel on error page | +| `"retry"` | User clicked "Try Another Method" on error page | + +--- + +## Identifying Users + +Intent Pay does **not** call `posthog.identify()` automatically. Identity is your app's responsibility. + +**Why:** A single user can connect EVM, Solana, and Stellar wallets simultaneously — three different +addresses. The SDK has no way to know which address represents the canonical user identity, and +calling `identify()` with the wrong address would fragment your user profiles in PostHog. + +Call `identify()` yourself at the point where your app has a canonical user identity +(after auth, after wallet connect, after Privy session, etc.): + +```ts +import posthog from "./lib/analytics"; + +// After your app resolves user identity +posthog.identify(userId, { + wallet_address: evmAddress ?? solanaAddress ?? stellarAddress, +}); +``` + +All subsequent `payment_*` events will be attributed to that user in PostHog. + +--- + +## Using `useAnalytics` for Custom Events + +If you need to fire additional events from within components that are children of `RozoPayProvider`, +use the exported `useAnalytics` hook: + +```tsx +import { useAnalytics } from "@rozoai/intent-pay"; + +function MyComponent() { + const { capture } = useAnalytics(); + + const handleCustomAction = () => { + capture("my_custom_event", { + some_property: "value", + }); + }; + + return ; +} +``` + +`useAnalytics` returns a no-op `capture` if no `posthog` was passed to `RozoPayProvider` — +safe to call unconditionally. + +--- + +## PostHog Setup Tips + +### Same project as your app + +Pass the same PostHog instance your app already uses. Payment events will appear alongside +your other product events, linked to the same user session. + +### Separate project + +If you want payment analytics isolated, initialize a second PostHog instance with a different +project key and pass only that to `RozoPayProvider`. + +### App name property + +Set an `app_name` property on your PostHog instance so you can filter payment events by app +in dashboards (useful if multiple apps use the same PostHog project): + +```ts +posthog.init("YOUR_KEY", { + api_host: "https://us.i.posthog.com", + bootstrap: { + // or use posthog.register() after init: + }, +}); + +posthog.register({ app_name: "your-app-name" }); +``` + +--- + +## Suggested PostHog Insights + +Once events are flowing, these insights answer the key product questions: + +**Funnel — payment completion rate** +``` +payment_flow_started → payment_confirmed → payment_submitted → payment_completed +``` + +**Most common failure reason** +> Breakdown `error_occurred` by `error_title` + +**Quote reliability** +> `payment_quote_failed` / `payment_quote_requested` ratio, breakdown by `source_chain` + +**Time to complete** +> Duration between `payment_submitted` and `payment_completed`, breakdown by `destination_chain` + +**Abandonment vs retry** +> `payment_cancelled` breakdown by `reason` (`"user"` vs `"retry"`) + +**Method preference** +> `payment_method_selected` breakdown by `value` (`evm`, `solana`, `stellar`, `unconnected_wallet`) diff --git a/packages/connectkit/bundle-analysis.html b/packages/connectkit/bundle-analysis.html index 8bee354fc..1644c53ce 100644 --- a/packages/connectkit/bundle-analysis.html +++ b/packages/connectkit/bundle-analysis.html @@ -4929,7 +4929,7 @@