@paywithglide/glide-react 0.0.46 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { GlideWidgetTheme } from './theme.ts';
2
2
  import { CAIP2, Session } from '@paywithglide/glide-js';
3
+ import { GlideAnalyticsCallback } from './analytics.ts';
3
4
  export type Hex = `0x${string}`;
4
5
  export type EVMTransaction = {
5
6
  chainId: number;
@@ -76,17 +77,27 @@ export type GlideDepositWalletProvider = {
76
77
  sendTransactionAsync: (tx: EVMTransaction) => Promise<Hex>;
77
78
  signTypedDataAsync?: (args: PermitTypedData<bigint>) => Promise<Hex>;
78
79
  };
80
+ export type GlideSolanaWalletProvider = {
81
+ address: string | undefined;
82
+ currentChainId: "solana:101" | "solana:103";
83
+ signMessageAsync: (message: Uint8Array) => Promise<Uint8Array>;
84
+ sendTransactionAsync: (transaction: Uint8Array) => Promise<Uint8Array>;
85
+ };
79
86
  export type GlideLocalStorageProvider = {
80
87
  getItem: (key: string) => Promise<string | null>;
81
88
  setItem: (key: string, value: string) => Promise<void>;
82
89
  removeItem: (key: string) => Promise<void>;
83
90
  getKeys: () => Promise<string[]>;
84
91
  };
85
- export type FundingSource = "transfer" | "coinbase" | "coinbase_app" | "interac" | "fiat" | "wallet" | "debit_card_alias";
92
+ export type FundingSource = "transfer" | "coinbase" | "coinbase_app" | "interac" | "fiat" | "wallet" | "debit_card_alias" | "onramp";
86
93
  export type ShowAppLogo = "default" | "always" | "never";
87
94
  export type DebitCardAlias = "fiat" | "coinbase";
88
95
  export type GlideDepositOptions = {
89
96
  app: string;
97
+ /**
98
+ * Optional project ID for analytics segmentation
99
+ */
100
+ projectId?: string;
90
101
  recipient?: string;
91
102
  mode?: "deposit" | "withdraw" | "pay" | "call" | "buy";
92
103
  amount?: string;
@@ -120,6 +131,7 @@ export type GlideDepositOptions = {
120
131
  enableRefundEmails?: boolean;
121
132
  payerEmail?: string;
122
133
  walletProvider?: GlideDepositWalletProvider;
134
+ solanaWalletProvider?: GlideSolanaWalletProvider;
123
135
  localStorageProvider?: GlideLocalStorageProvider;
124
136
  onOpen?: () => void;
125
137
  onSuccess?: (fulfillmentTxHash: Hex, session: Session) => void;
@@ -138,10 +150,24 @@ export type GlideDepositOptions = {
138
150
  popupsBlocked?: boolean;
139
151
  baseUrl?: string;
140
152
  debug?: boolean;
153
+ /**
154
+ * Analytics callback for tracking user events and behavior
155
+ * Called with various events throughout the deposit/payment flow
156
+ * Use this to integrate with your own analytics platform (e.g., Amplitude, Mixpanel)
157
+ */
158
+ onAnalyticsEvent?: GlideAnalyticsCallback;
141
159
  };
142
160
  export declare class GlideDeposit {
143
161
  opts: GlideDepositOptions;
144
162
  constructor(opts: GlideDepositOptions);
163
+ /**
164
+ * Get analytics context for events tracked directly in SDK
165
+ */
166
+ private getAnalyticsContext;
167
+ /**
168
+ * Track an analytics event with context
169
+ */
170
+ private trackEvent;
145
171
  open: () => void;
146
172
  get externalUrl(): string;
147
173
  private initialize;
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Analytics Event Types for GLIDE SDK
3
+ *
4
+ * These events allow clients to track user behavior and conversions
5
+ * through their own analytics platforms (e.g., Amplitude, Mixpanel, etc.)
6
+ */
7
+ /**
8
+ * Base context included with every analytics event
9
+ * This allows segmentation by client/project and user identification
10
+ */
11
+ export type GlideAnalyticsContext = {
12
+ projectId?: string;
13
+ appSlug: string;
14
+ sdkVersion: string;
15
+ referrerDomain?: string;
16
+ walletAddress?: string;
17
+ device: {
18
+ isMobile: boolean;
19
+ platform: "ios" | "android" | "windows" | "macos" | "linux" | "unknown";
20
+ browser: string;
21
+ };
22
+ };
23
+ /**
24
+ * Raw event types (without context - used internally in the widget)
25
+ */
26
+ export type GlideAnalyticsEventType = {
27
+ type: "modal_opened";
28
+ timestamp: number;
29
+ } | {
30
+ type: "modal_closed";
31
+ timestamp: number;
32
+ completedTransaction: boolean;
33
+ } | {
34
+ type: "mode_selected";
35
+ mode: "deposit" | "withdraw" | "pay" | "call" | "buy";
36
+ timestamp: number;
37
+ } | {
38
+ type: "step_viewed";
39
+ step: string;
40
+ timestamp: number;
41
+ } | {
42
+ type: "step_exited";
43
+ step: string;
44
+ timestamp: number;
45
+ direction: "forward" | "back";
46
+ } | {
47
+ type: "payment_method_selected";
48
+ paymentMethod: "wallet" | "transfer" | "coinbase" | "coinbase_app" | "fiat" | "interac" | "debit_card_alias";
49
+ timestamp: number;
50
+ } | {
51
+ type: "funding_source_viewed";
52
+ availableOptions: string[];
53
+ timestamp: number;
54
+ } | {
55
+ type: "funding_source_selected";
56
+ fundingSource: "wallet" | "crypto" | "fiat";
57
+ timestamp: number;
58
+ } | {
59
+ type: "wallet_connect_started";
60
+ timestamp: number;
61
+ } | {
62
+ type: "wallet_connected";
63
+ address: string;
64
+ chainId: number;
65
+ timestamp: number;
66
+ } | {
67
+ type: "wallet_connection_failed";
68
+ error: string;
69
+ timestamp: number;
70
+ } | {
71
+ type: "wallet_disconnected";
72
+ timestamp: number;
73
+ } | {
74
+ type: "chain_selected";
75
+ chainId: string;
76
+ chainName: string;
77
+ timestamp: number;
78
+ } | {
79
+ type: "currency_selected";
80
+ currencyId: string;
81
+ currencySymbol: string;
82
+ chainId: string;
83
+ timestamp: number;
84
+ } | {
85
+ type: "amount_entered";
86
+ amount: string;
87
+ currencySymbol: string;
88
+ amountUSD?: number;
89
+ timestamp: number;
90
+ } | {
91
+ type: "session_creation_started";
92
+ timestamp: number;
93
+ } | {
94
+ type: "session_created";
95
+ sessionId: string;
96
+ paymentMethod: string;
97
+ estimatedAmountUSD?: number;
98
+ timestamp: number;
99
+ } | {
100
+ type: "session_creation_failed";
101
+ error: string;
102
+ timestamp: number;
103
+ } | {
104
+ type: "transaction_started";
105
+ sessionId: string;
106
+ paymentMethod: string;
107
+ fromToken: string;
108
+ toToken: string;
109
+ amount: string;
110
+ estimatedAmountUSD?: number;
111
+ timestamp: number;
112
+ } | {
113
+ type: "transaction_signature_requested";
114
+ sessionId: string;
115
+ timestamp: number;
116
+ } | {
117
+ type: "transaction_signed";
118
+ sessionId: string;
119
+ txHash: string;
120
+ timestamp: number;
121
+ } | {
122
+ type: "transaction_signature_rejected";
123
+ sessionId: string;
124
+ timestamp: number;
125
+ } | {
126
+ type: "transaction_completed";
127
+ sessionId: string;
128
+ txHash: string;
129
+ paymentMethod: string;
130
+ success: boolean;
131
+ amountUSD?: number;
132
+ timestamp: number;
133
+ } | {
134
+ type: "transaction_failed";
135
+ sessionId: string;
136
+ error: string;
137
+ paymentMethod: string;
138
+ timestamp: number;
139
+ } | {
140
+ type: "onramp_window_opened";
141
+ provider: "coinbase" | "moonpay";
142
+ timestamp: number;
143
+ } | {
144
+ type: "onramp_window_closed";
145
+ provider: "coinbase" | "moonpay";
146
+ completed: boolean;
147
+ timestamp: number;
148
+ } | {
149
+ type: "deposit_address_generated";
150
+ sessionId: string;
151
+ chainId: string;
152
+ currencySymbol: string;
153
+ timestamp: number;
154
+ } | {
155
+ type: "deposit_address_copied";
156
+ sessionId: string;
157
+ timestamp: number;
158
+ } | {
159
+ type: "waiting_for_deposit";
160
+ sessionId: string;
161
+ chainId: string;
162
+ currencySymbol: string;
163
+ timestamp: number;
164
+ } | {
165
+ type: "deposit_detected";
166
+ sessionId: string;
167
+ amount: string;
168
+ currencySymbol: string;
169
+ timestamp: number;
170
+ } | {
171
+ type: "transfer_completed";
172
+ sessionId: string;
173
+ txHash: string;
174
+ chainId: string;
175
+ currencySymbol: string;
176
+ amount: string;
177
+ amountUSD?: number;
178
+ timestamp: number;
179
+ } | {
180
+ type: "error_occurred";
181
+ errorType: string;
182
+ errorMessage: string;
183
+ step?: string;
184
+ timestamp: number;
185
+ } | {
186
+ type: "conversion_completed";
187
+ sessionId: string;
188
+ paymentMethod: string;
189
+ amountUSD?: number;
190
+ duration: number;
191
+ timestamp: number;
192
+ };
193
+ /**
194
+ * Full analytics event with context
195
+ * This is what clients receive in their callback
196
+ */
197
+ export type GlideAnalyticsEvent = GlideAnalyticsEventType & GlideAnalyticsContext;
198
+ /**
199
+ * Callback function type for analytics events
200
+ */
201
+ export type GlideAnalyticsCallback = (event: GlideAnalyticsEvent) => void;
202
+ /**
203
+ * Helper class for emitting analytics events
204
+ */
205
+ export declare class GlideAnalytics {
206
+ private callback?;
207
+ private startTime?;
208
+ private currentStep?;
209
+ constructor(callback?: GlideAnalyticsCallback);
210
+ setCallback(callback: GlideAnalyticsCallback | undefined): void;
211
+ track(event: GlideAnalyticsEvent): void;
212
+ modalOpened(): void;
213
+ modalClosed(completedTransaction: boolean): void;
214
+ stepViewed(step: string): void;
215
+ stepExited(step: string, direction: "forward" | "back"): void;
216
+ paymentMethodSelected(paymentMethod: "wallet" | "transfer" | "coinbase" | "coinbase_app" | "fiat" | "interac" | "debit_card_alias"): void;
217
+ transactionCompleted(sessionId: string, txHash: string, paymentMethod: string, amountUSD?: number): void;
218
+ errorOccurred(errorType: string, errorMessage: string, step?: string): void;
219
+ }
220
+ export declare const glideAnalytics: GlideAnalytics;
@@ -0,0 +1,5 @@
1
+ export * from './GlideDeposit.ts';
2
+ export * from './theme.ts';
3
+ export * from './browserLocalStorageProvider.ts';
4
+ export * from './walletProviderBridge.ts';
5
+ export * from './analytics.ts';
@@ -6,3 +6,4 @@ export * from './useGlideBuy.ts';
6
6
  export * from './theme.ts';
7
7
  export * from './browserLocalStorageProvider.ts';
8
8
  export * from './walletProviderBridge.ts';
9
+ export * from './analytics.ts';
@@ -1,4 +1,4 @@
1
- import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider, Hex, ShowAppLogo, DebitCardAlias } from './GlideDeposit.ts';
1
+ import { FundingSource, GlideDepositWalletProvider, GlideSolanaWalletProvider, GlideLocalStorageProvider, Hex, ShowAppLogo, DebitCardAlias } from './GlideDeposit.ts';
2
2
  import { GlideWidgetTheme } from './theme.ts';
3
3
  import { CAIP2, Session } from '@paywithglide/glide-js';
4
4
  interface UseGlideBuyProps {
@@ -18,6 +18,7 @@ interface UseGlideBuyProps {
18
18
  copyOverrides?: Record<string, string>;
19
19
  theme?: GlideWidgetTheme;
20
20
  walletProvider?: GlideDepositWalletProvider;
21
+ solanaWalletProvider?: GlideSolanaWalletProvider;
21
22
  localStorageProvider?: GlideLocalStorageProvider;
22
23
  onOpen?: () => void;
23
24
  onSuccess?: (hash: Hex, session: Session) => void;
@@ -25,7 +26,7 @@ interface UseGlideBuyProps {
25
26
  autoCloseOnSuccess?: boolean;
26
27
  baseUrl?: string;
27
28
  }
28
- export declare const useGlideBuy: ({ app, recipient, chainId, currencyId, preferGaslessPayment, chainIds, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, sessionMetadata, showAppLogo, showOnrampFirst, debitCardAlias, copyOverrides, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, baseUrl, }: UseGlideBuyProps) => {
29
+ export declare const useGlideBuy: ({ app, recipient, chainId, currencyId, preferGaslessPayment, chainIds, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, sessionMetadata, showAppLogo, showOnrampFirst, debitCardAlias, copyOverrides, theme, walletProvider, solanaWalletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, baseUrl, }: UseGlideBuyProps) => {
29
30
  openGlideBuy: () => void;
30
31
  externalUrl: string;
31
32
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
@@ -1,4 +1,4 @@
1
- import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider, Hex, ShowAppLogo, DebitCardAlias } from './GlideDeposit.ts';
1
+ import { FundingSource, GlideDepositWalletProvider, GlideSolanaWalletProvider, GlideLocalStorageProvider, Hex, ShowAppLogo, DebitCardAlias } from './GlideDeposit.ts';
2
2
  import { GlideWidgetTheme } from './theme.ts';
3
3
  import { CAIP2, Session } from '@paywithglide/glide-js';
4
4
  interface UseGlideCallProps {
@@ -25,6 +25,7 @@ interface UseGlideCallProps {
25
25
  copyOverrides?: Record<string, string>;
26
26
  theme?: GlideWidgetTheme;
27
27
  walletProvider?: GlideDepositWalletProvider;
28
+ solanaWalletProvider?: GlideSolanaWalletProvider;
28
29
  localStorageProvider?: GlideLocalStorageProvider;
29
30
  onOpen?: () => void;
30
31
  onSuccess?: (hash: Hex, session: Session) => void;
@@ -34,7 +35,7 @@ interface UseGlideCallProps {
34
35
  baseUrl?: string;
35
36
  debug?: boolean;
36
37
  }
37
- export declare const useGlideCall: ({ app, evm, approval, preferGaslessPayment, chainIds, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, sessionMetadata, showAppLogo, showOnrampFirst, debitCardAlias, copyOverrides, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideCallProps) => {
38
+ export declare const useGlideCall: ({ app, evm, approval, preferGaslessPayment, chainIds, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, sessionMetadata, showAppLogo, showOnrampFirst, debitCardAlias, copyOverrides, theme, walletProvider, solanaWalletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideCallProps) => {
38
39
  openGlideCall: () => void;
39
40
  externalUrl: string;
40
41
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
@@ -1,4 +1,4 @@
1
- import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider, ShowAppLogo, DebitCardAlias } from './GlideDeposit.ts';
1
+ import { FundingSource, GlideDepositWalletProvider, GlideSolanaWalletProvider, GlideLocalStorageProvider, ShowAppLogo, DebitCardAlias } from './GlideDeposit.ts';
2
2
  import { GlideWidgetTheme } from './theme.ts';
3
3
  import { CAIP2, Hex, Session } from '@paywithglide/glide-js';
4
4
  interface UseGlideDepositProps {
@@ -34,6 +34,7 @@ interface UseGlideDepositProps {
34
34
  disableWithdrawToSelfSuggestion?: boolean;
35
35
  theme?: GlideWidgetTheme;
36
36
  walletProvider?: GlideDepositWalletProvider;
37
+ solanaWalletProvider?: GlideSolanaWalletProvider;
37
38
  localStorageProvider?: GlideLocalStorageProvider;
38
39
  onOpen?: () => void;
39
40
  onSuccess?: (hash: Hex, session: Session) => void;
@@ -43,7 +44,7 @@ interface UseGlideDepositProps {
43
44
  baseUrl?: string;
44
45
  debug?: boolean;
45
46
  }
46
- export declare const useGlideDeposit: ({ app, recipient, chainId, currencyId, amount, gasRefuelAmountPerChain, preferGaslessPayment, chainIds, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, fundingSources, appMetadata, enableRefundEmails, payerEmail, mode, hideSettlementCopy, showAppLogo, showOnrampFirst, debitCardAlias, copyOverrides, stableDepositAddressKey, sessionId, sessionMetadata, disableWithdrawToSelfSuggestion, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
47
+ export declare const useGlideDeposit: ({ app, recipient, chainId, currencyId, amount, gasRefuelAmountPerChain, preferGaslessPayment, chainIds, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, fundingSources, appMetadata, enableRefundEmails, payerEmail, mode, hideSettlementCopy, showAppLogo, showOnrampFirst, debitCardAlias, copyOverrides, stableDepositAddressKey, sessionId, sessionMetadata, disableWithdrawToSelfSuggestion, theme, walletProvider, solanaWalletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlideDepositProps) => {
47
48
  openGlideDeposit: () => void;
48
49
  externalUrl: string;
49
50
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
@@ -1,4 +1,4 @@
1
- import { FundingSource, GlideDepositWalletProvider, GlideLocalStorageProvider, ShowAppLogo, DebitCardAlias } from './GlideDeposit.ts';
1
+ import { FundingSource, GlideDepositWalletProvider, GlideSolanaWalletProvider, GlideLocalStorageProvider, ShowAppLogo, DebitCardAlias } from './GlideDeposit.ts';
2
2
  import { GlideWidgetTheme } from './theme.ts';
3
3
  import { CAIP2, Hex, Session } from '@paywithglide/glide-js';
4
4
  type UseGlidePayProps = {
@@ -27,6 +27,7 @@ type UseGlidePayProps = {
27
27
  sessionMetadata?: string;
28
28
  theme?: GlideWidgetTheme;
29
29
  walletProvider?: GlideDepositWalletProvider;
30
+ solanaWalletProvider?: GlideSolanaWalletProvider;
30
31
  localStorageProvider?: GlideLocalStorageProvider;
31
32
  onOpen?: () => void;
32
33
  onSuccess?: (hash: Hex, session: Session) => void;
@@ -36,7 +37,7 @@ type UseGlidePayProps = {
36
37
  baseUrl?: string;
37
38
  debug?: boolean;
38
39
  };
39
- export declare const useGlidePay: ({ app, preferGaslessPayment, chainIds, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, fundingSources, allowedPaymentCurrencies, appMetadata, enableRefundEmails, payerEmail, hideSettlementCopy, showAppLogo, showOnrampFirst, debitCardAlias, copyOverrides, amount, sessionId, sessionMetadata, theme, walletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlidePayProps) => {
40
+ export declare const useGlidePay: ({ app, preferGaslessPayment, chainIds, excludeChainIds, excludeCurrencyTiers, excludeFundingSources, fundingSources, allowedPaymentCurrencies, appMetadata, enableRefundEmails, payerEmail, hideSettlementCopy, showAppLogo, showOnrampFirst, debitCardAlias, copyOverrides, amount, sessionId, sessionMetadata, theme, walletProvider, solanaWalletProvider, localStorageProvider, onOpen, onSuccess, onClose, autoCloseOnSuccess, popupsBlocked, baseUrl, debug, }: UseGlidePayProps) => {
40
41
  openGlidePay: () => void;
41
42
  externalUrl: string;
42
43
  opts: import('./GlideDeposit.ts').GlideDepositOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paywithglide/glide-react",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -12,6 +12,10 @@
12
12
  "types": "./dist/index.d.ts",
13
13
  "default": "./dist/glide.js"
14
14
  },
15
+ "./core": {
16
+ "types": "./dist/core.d.ts",
17
+ "default": "./dist/core.js"
18
+ },
15
19
  "./package.json": "./package.json"
16
20
  },
17
21
  "sideEffects": false,
@@ -25,11 +29,16 @@
25
29
  "prepublishOnly": "bun run build"
26
30
  },
27
31
  "dependencies": {
28
- "@paywithglide/glide-js": "0.13.10"
32
+ "@paywithglide/glide-js": "0.13.32"
29
33
  },
30
34
  "devDependencies": {
31
35
  "@antiwork/shortest": "^0.2.1",
32
36
  "@eslint/js": "^9.15.0",
37
+ "@privy-io/react-auth": "^3.10.1",
38
+ "@solana-program/memo": "^0.10.0",
39
+ "@solana-program/system": "^0.10.0",
40
+ "@solana-program/token": "^0.9.0",
41
+ "@solana/kit": "^5.1.0",
33
42
  "@tanstack/react-query": "^5.61.5",
34
43
  "@types/chrome": "^0.0.299",
35
44
  "@types/react": "^18.3.12",
File without changes