@formo/analytics-react-native 0.1.0
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.
- package/README.md +302 -0
- package/lib/commonjs/FormoAnalytics.js +526 -0
- package/lib/commonjs/FormoAnalytics.js.map +1 -0
- package/lib/commonjs/FormoAnalyticsProvider.js +265 -0
- package/lib/commonjs/FormoAnalyticsProvider.js.map +1 -0
- package/lib/commonjs/constants/config.js +69 -0
- package/lib/commonjs/constants/config.js.map +1 -0
- package/lib/commonjs/constants/events.js +30 -0
- package/lib/commonjs/constants/events.js.map +1 -0
- package/lib/commonjs/constants/index.js +39 -0
- package/lib/commonjs/constants/index.js.map +1 -0
- package/lib/commonjs/constants/storage.js +23 -0
- package/lib/commonjs/constants/storage.js.map +1 -0
- package/lib/commonjs/index.js +65 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/lib/consent/index.js +56 -0
- package/lib/commonjs/lib/consent/index.js.map +1 -0
- package/lib/commonjs/lib/event/EventFactory.js +493 -0
- package/lib/commonjs/lib/event/EventFactory.js.map +1 -0
- package/lib/commonjs/lib/event/EventManager.js +46 -0
- package/lib/commonjs/lib/event/EventManager.js.map +1 -0
- package/lib/commonjs/lib/event/EventQueue.js +290 -0
- package/lib/commonjs/lib/event/EventQueue.js.map +1 -0
- package/lib/commonjs/lib/event/index.js +50 -0
- package/lib/commonjs/lib/event/index.js.map +1 -0
- package/lib/commonjs/lib/event/types.js +6 -0
- package/lib/commonjs/lib/event/types.js.map +1 -0
- package/lib/commonjs/lib/lifecycle/index.js +196 -0
- package/lib/commonjs/lib/lifecycle/index.js.map +1 -0
- package/lib/commonjs/lib/logger/index.js +48 -0
- package/lib/commonjs/lib/logger/index.js.map +1 -0
- package/lib/commonjs/lib/session/index.js +109 -0
- package/lib/commonjs/lib/session/index.js.map +1 -0
- package/lib/commonjs/lib/storage/AsyncStorageAdapter.js +164 -0
- package/lib/commonjs/lib/storage/AsyncStorageAdapter.js.map +1 -0
- package/lib/commonjs/lib/storage/MemoryStorage.js +41 -0
- package/lib/commonjs/lib/storage/MemoryStorage.js.map +1 -0
- package/lib/commonjs/lib/storage/StorageBlueprint.js +24 -0
- package/lib/commonjs/lib/storage/StorageBlueprint.js.map +1 -0
- package/lib/commonjs/lib/storage/StorageManager.js +126 -0
- package/lib/commonjs/lib/storage/StorageManager.js.map +1 -0
- package/lib/commonjs/lib/storage/index.js +49 -0
- package/lib/commonjs/lib/storage/index.js.map +1 -0
- package/lib/commonjs/lib/storage/types.js +2 -0
- package/lib/commonjs/lib/storage/types.js.map +1 -0
- package/lib/commonjs/lib/wagmi/WagmiEventHandler.js +445 -0
- package/lib/commonjs/lib/wagmi/WagmiEventHandler.js.map +1 -0
- package/lib/commonjs/lib/wagmi/index.js +28 -0
- package/lib/commonjs/lib/wagmi/index.js.map +1 -0
- package/lib/commonjs/lib/wagmi/types.js +2 -0
- package/lib/commonjs/lib/wagmi/types.js.map +1 -0
- package/lib/commonjs/types/base.js +6 -0
- package/lib/commonjs/types/base.js.map +1 -0
- package/lib/commonjs/types/events.js +22 -0
- package/lib/commonjs/types/events.js.map +1 -0
- package/lib/commonjs/types/index.js +28 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/utils/address.js +82 -0
- package/lib/commonjs/utils/address.js.map +1 -0
- package/lib/commonjs/utils/hash.js +30 -0
- package/lib/commonjs/utils/hash.js.map +1 -0
- package/lib/commonjs/utils/helpers.js +116 -0
- package/lib/commonjs/utils/helpers.js.map +1 -0
- package/lib/commonjs/utils/index.js +61 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/commonjs/utils/timestamp.js +34 -0
- package/lib/commonjs/utils/timestamp.js.map +1 -0
- package/lib/commonjs/utils/trafficSource.js +147 -0
- package/lib/commonjs/utils/trafficSource.js.map +1 -0
- package/lib/commonjs/version.js +10 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/FormoAnalytics.js +519 -0
- package/lib/module/FormoAnalytics.js.map +1 -0
- package/lib/module/FormoAnalyticsProvider.js +256 -0
- package/lib/module/FormoAnalyticsProvider.js.map +1 -0
- package/lib/module/constants/config.js +62 -0
- package/lib/module/constants/config.js.map +1 -0
- package/lib/module/constants/events.js +24 -0
- package/lib/module/constants/events.js.map +1 -0
- package/lib/module/constants/index.js +4 -0
- package/lib/module/constants/index.js.map +1 -0
- package/lib/module/constants/storage.js +17 -0
- package/lib/module/constants/storage.js.map +1 -0
- package/lib/module/index.js +51 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/lib/consent/index.js +49 -0
- package/lib/module/lib/consent/index.js.map +1 -0
- package/lib/module/lib/event/EventFactory.js +488 -0
- package/lib/module/lib/event/EventFactory.js.map +1 -0
- package/lib/module/lib/event/EventManager.js +41 -0
- package/lib/module/lib/event/EventManager.js.map +1 -0
- package/lib/module/lib/event/EventQueue.js +283 -0
- package/lib/module/lib/event/EventQueue.js.map +1 -0
- package/lib/module/lib/event/index.js +5 -0
- package/lib/module/lib/event/index.js.map +1 -0
- package/lib/module/lib/event/types.js +2 -0
- package/lib/module/lib/event/types.js.map +1 -0
- package/lib/module/lib/lifecycle/index.js +190 -0
- package/lib/module/lib/lifecycle/index.js.map +1 -0
- package/lib/module/lib/logger/index.js +42 -0
- package/lib/module/lib/logger/index.js.map +1 -0
- package/lib/module/lib/session/index.js +92 -0
- package/lib/module/lib/session/index.js.map +1 -0
- package/lib/module/lib/storage/AsyncStorageAdapter.js +158 -0
- package/lib/module/lib/storage/AsyncStorageAdapter.js.map +1 -0
- package/lib/module/lib/storage/MemoryStorage.js +35 -0
- package/lib/module/lib/storage/MemoryStorage.js.map +1 -0
- package/lib/module/lib/storage/StorageBlueprint.js +18 -0
- package/lib/module/lib/storage/StorageBlueprint.js.map +1 -0
- package/lib/module/lib/storage/StorageManager.js +115 -0
- package/lib/module/lib/storage/StorageManager.js.map +1 -0
- package/lib/module/lib/storage/index.js +5 -0
- package/lib/module/lib/storage/index.js.map +1 -0
- package/lib/module/lib/storage/types.js +2 -0
- package/lib/module/lib/storage/types.js.map +1 -0
- package/lib/module/lib/wagmi/WagmiEventHandler.js +439 -0
- package/lib/module/lib/wagmi/WagmiEventHandler.js.map +1 -0
- package/lib/module/lib/wagmi/index.js +3 -0
- package/lib/module/lib/wagmi/index.js.map +1 -0
- package/lib/module/lib/wagmi/types.js +2 -0
- package/lib/module/lib/wagmi/types.js.map +1 -0
- package/lib/module/types/base.js +2 -0
- package/lib/module/types/base.js.map +1 -0
- package/lib/module/types/events.js +17 -0
- package/lib/module/types/events.js.map +1 -0
- package/lib/module/types/index.js +3 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/utils/address.js +74 -0
- package/lib/module/utils/address.js.map +1 -0
- package/lib/module/utils/hash.js +24 -0
- package/lib/module/utils/hash.js.map +1 -0
- package/lib/module/utils/helpers.js +105 -0
- package/lib/module/utils/helpers.js.map +1 -0
- package/lib/module/utils/index.js +6 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/timestamp.js +26 -0
- package/lib/module/utils/timestamp.js.map +1 -0
- package/lib/module/utils/trafficSource.js +137 -0
- package/lib/module/utils/trafficSource.js.map +1 -0
- package/lib/module/version.js +4 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/FormoAnalytics.d.ts +163 -0
- package/lib/typescript/FormoAnalytics.d.ts.map +1 -0
- package/lib/typescript/FormoAnalyticsProvider.d.ts +29 -0
- package/lib/typescript/FormoAnalyticsProvider.d.ts.map +1 -0
- package/lib/typescript/constants/config.d.ts +8 -0
- package/lib/typescript/constants/config.d.ts.map +1 -0
- package/lib/typescript/constants/events.d.ts +23 -0
- package/lib/typescript/constants/events.d.ts.map +1 -0
- package/lib/typescript/constants/index.d.ts +4 -0
- package/lib/typescript/constants/index.d.ts.map +1 -0
- package/lib/typescript/constants/storage.d.ts +10 -0
- package/lib/typescript/constants/storage.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +44 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/lib/consent/index.d.ts +13 -0
- package/lib/typescript/lib/consent/index.d.ts.map +1 -0
- package/lib/typescript/lib/event/EventFactory.d.ts +61 -0
- package/lib/typescript/lib/event/EventFactory.d.ts.map +1 -0
- package/lib/typescript/lib/event/EventManager.d.ts +17 -0
- package/lib/typescript/lib/event/EventManager.d.ts.map +1 -0
- package/lib/typescript/lib/event/EventQueue.d.ts +74 -0
- package/lib/typescript/lib/event/EventQueue.d.ts.map +1 -0
- package/lib/typescript/lib/event/index.d.ts +5 -0
- package/lib/typescript/lib/event/index.d.ts.map +1 -0
- package/lib/typescript/lib/event/types.d.ts +23 -0
- package/lib/typescript/lib/event/types.d.ts.map +1 -0
- package/lib/typescript/lib/lifecycle/index.d.ts +46 -0
- package/lib/typescript/lib/lifecycle/index.d.ts.map +1 -0
- package/lib/typescript/lib/logger/index.d.ts +19 -0
- package/lib/typescript/lib/logger/index.d.ts.map +1 -0
- package/lib/typescript/lib/session/index.d.ts +41 -0
- package/lib/typescript/lib/session/index.d.ts.map +1 -0
- package/lib/typescript/lib/storage/AsyncStorageAdapter.d.ts +48 -0
- package/lib/typescript/lib/storage/AsyncStorageAdapter.d.ts.map +1 -0
- package/lib/typescript/lib/storage/MemoryStorage.d.ts +18 -0
- package/lib/typescript/lib/storage/MemoryStorage.d.ts.map +1 -0
- package/lib/typescript/lib/storage/StorageBlueprint.d.ts +21 -0
- package/lib/typescript/lib/storage/StorageBlueprint.d.ts.map +1 -0
- package/lib/typescript/lib/storage/StorageManager.d.ts +45 -0
- package/lib/typescript/lib/storage/StorageManager.d.ts.map +1 -0
- package/lib/typescript/lib/storage/index.d.ts +5 -0
- package/lib/typescript/lib/storage/index.d.ts.map +1 -0
- package/lib/typescript/lib/storage/types.d.ts +22 -0
- package/lib/typescript/lib/storage/types.d.ts.map +1 -0
- package/lib/typescript/lib/wagmi/WagmiEventHandler.d.ts +104 -0
- package/lib/typescript/lib/wagmi/WagmiEventHandler.d.ts.map +1 -0
- package/lib/typescript/lib/wagmi/index.d.ts +3 -0
- package/lib/typescript/lib/wagmi/index.d.ts.map +1 -0
- package/lib/typescript/lib/wagmi/types.d.ts +54 -0
- package/lib/typescript/lib/wagmi/types.d.ts.map +1 -0
- package/lib/typescript/types/base.d.ts +219 -0
- package/lib/typescript/types/base.d.ts.map +1 -0
- package/lib/typescript/types/events.d.ts +111 -0
- package/lib/typescript/types/events.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +3 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/utils/address.d.ts +25 -0
- package/lib/typescript/utils/address.d.ts.map +1 -0
- package/lib/typescript/utils/hash.d.ts +10 -0
- package/lib/typescript/utils/hash.d.ts.map +1 -0
- package/lib/typescript/utils/helpers.d.ts +26 -0
- package/lib/typescript/utils/helpers.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +6 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/lib/typescript/utils/timestamp.d.ts +13 -0
- package/lib/typescript/utils/timestamp.d.ts.map +1 -0
- package/lib/typescript/utils/trafficSource.d.ts +30 -0
- package/lib/typescript/utils/trafficSource.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +2 -0
- package/lib/typescript/version.d.ts.map +1 -0
- package/package.json +143 -0
- package/src/FormoAnalytics.ts +685 -0
- package/src/FormoAnalyticsProvider.tsx +296 -0
- package/src/constants/config.ts +62 -0
- package/src/constants/events.ts +26 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/storage.ts +16 -0
- package/src/index.ts +55 -0
- package/src/lib/consent/index.ts +52 -0
- package/src/lib/event/EventFactory.ts +682 -0
- package/src/lib/event/EventManager.ts +50 -0
- package/src/lib/event/EventQueue.ts +371 -0
- package/src/lib/event/index.ts +4 -0
- package/src/lib/event/types.ts +107 -0
- package/src/lib/lifecycle/index.ts +215 -0
- package/src/lib/logger/index.ts +56 -0
- package/src/lib/session/index.ts +103 -0
- package/src/lib/storage/AsyncStorageAdapter.ts +173 -0
- package/src/lib/storage/MemoryStorage.ts +43 -0
- package/src/lib/storage/StorageBlueprint.ts +30 -0
- package/src/lib/storage/StorageManager.ts +121 -0
- package/src/lib/storage/index.ts +4 -0
- package/src/lib/storage/types.ts +23 -0
- package/src/lib/wagmi/WagmiEventHandler.ts +574 -0
- package/src/lib/wagmi/index.ts +2 -0
- package/src/lib/wagmi/types.ts +71 -0
- package/src/types/base.ts +287 -0
- package/src/types/events.ts +140 -0
- package/src/types/index.ts +2 -0
- package/src/utils/address.ts +84 -0
- package/src/utils/hash.ts +23 -0
- package/src/utils/helpers.ts +139 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/timestamp.ts +25 -0
- package/src/utils/trafficSource.ts +153 -0
- package/src/version.ts +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# @formo/analytics-react-native
|
|
2
|
+
|
|
3
|
+
Formo Analytics SDK for React Native - Track wallet events and user analytics in mobile dApps.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @formo/analytics-react-native @react-native-async-storage/async-storage
|
|
9
|
+
|
|
10
|
+
# or with yarn
|
|
11
|
+
yarn add @formo/analytics-react-native @react-native-async-storage/async-storage
|
|
12
|
+
|
|
13
|
+
# or with pnpm
|
|
14
|
+
pnpm add @formo/analytics-react-native @react-native-async-storage/async-storage
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### iOS Setup
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cd ios && pod install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### 1. Wrap your app with the provider
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
29
|
+
import { FormoAnalyticsProvider } from '@formo/analytics-react-native';
|
|
30
|
+
|
|
31
|
+
function App() {
|
|
32
|
+
return (
|
|
33
|
+
<FormoAnalyticsProvider
|
|
34
|
+
writeKey="your-write-key"
|
|
35
|
+
asyncStorage={AsyncStorage}
|
|
36
|
+
options={{
|
|
37
|
+
app: {
|
|
38
|
+
name: 'MyApp',
|
|
39
|
+
version: '1.0.0',
|
|
40
|
+
},
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<YourApp />
|
|
44
|
+
</FormoAnalyticsProvider>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 2. Use the hook in your components
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { useFormo } from '@formo/analytics-react-native';
|
|
53
|
+
import { useEffect } from 'react';
|
|
54
|
+
|
|
55
|
+
function HomeScreen() {
|
|
56
|
+
const formo = useFormo();
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
// Track screen view
|
|
60
|
+
formo.screen('Home');
|
|
61
|
+
}, []);
|
|
62
|
+
|
|
63
|
+
const handleSignUp = () => {
|
|
64
|
+
// Track custom event
|
|
65
|
+
formo.track('Sign Up Button Pressed', {
|
|
66
|
+
screen: 'Home',
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return <Button onPress={handleSignUp}>Sign Up</Button>;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Wagmi Integration
|
|
75
|
+
|
|
76
|
+
For dApps using Wagmi for wallet connections, you can enable automatic wallet event tracking:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
80
|
+
import { createConfig } from 'wagmi';
|
|
81
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
82
|
+
import { FormoAnalyticsProvider } from '@formo/analytics-react-native';
|
|
83
|
+
|
|
84
|
+
const queryClient = new QueryClient();
|
|
85
|
+
const wagmiConfig = createConfig({
|
|
86
|
+
// your wagmi config
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
function App() {
|
|
90
|
+
return (
|
|
91
|
+
<FormoAnalyticsProvider
|
|
92
|
+
writeKey="your-write-key"
|
|
93
|
+
asyncStorage={AsyncStorage}
|
|
94
|
+
options={{
|
|
95
|
+
wagmi: {
|
|
96
|
+
config: wagmiConfig,
|
|
97
|
+
queryClient: queryClient,
|
|
98
|
+
},
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
<YourApp />
|
|
102
|
+
</FormoAnalyticsProvider>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This automatically tracks:
|
|
108
|
+
- Wallet connections and disconnections
|
|
109
|
+
- Chain changes
|
|
110
|
+
- Signature requests (with QueryClient)
|
|
111
|
+
- Transaction events (with QueryClient)
|
|
112
|
+
|
|
113
|
+
## API Reference
|
|
114
|
+
|
|
115
|
+
### FormoAnalyticsProvider Props
|
|
116
|
+
|
|
117
|
+
| Prop | Type | Required | Description |
|
|
118
|
+
|------|------|----------|-------------|
|
|
119
|
+
| `writeKey` | `string` | Yes | Your Formo write key |
|
|
120
|
+
| `asyncStorage` | `AsyncStorageInterface` | Yes | AsyncStorage instance |
|
|
121
|
+
| `options` | `Options` | No | Configuration options |
|
|
122
|
+
| `disabled` | `boolean` | No | Disable analytics |
|
|
123
|
+
|
|
124
|
+
### Options
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
interface Options {
|
|
128
|
+
// Wagmi integration
|
|
129
|
+
wagmi?: {
|
|
130
|
+
config: any; // Wagmi config from createConfig()
|
|
131
|
+
queryClient?: any; // TanStack QueryClient for mutation tracking
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// App information
|
|
135
|
+
app?: {
|
|
136
|
+
name?: string;
|
|
137
|
+
version?: string;
|
|
138
|
+
build?: string;
|
|
139
|
+
bundleId?: string;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Event batching
|
|
143
|
+
flushAt?: number; // Batch size (default: 20)
|
|
144
|
+
flushInterval?: number; // Flush interval in ms (default: 30000)
|
|
145
|
+
retryCount?: number; // Retry count (default: 3)
|
|
146
|
+
maxQueueSize?: number; // Max queue size in bytes (default: 500KB)
|
|
147
|
+
|
|
148
|
+
// Autocapture control
|
|
149
|
+
autocapture?: boolean | {
|
|
150
|
+
connect?: boolean;
|
|
151
|
+
disconnect?: boolean;
|
|
152
|
+
signature?: boolean;
|
|
153
|
+
transaction?: boolean;
|
|
154
|
+
chain?: boolean;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// Tracking control
|
|
158
|
+
tracking?: boolean | {
|
|
159
|
+
excludeChains?: number[];
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// Logging
|
|
163
|
+
logger?: {
|
|
164
|
+
enabled?: boolean;
|
|
165
|
+
levels?: ('debug' | 'info' | 'warn' | 'error' | 'log')[];
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// Custom API host
|
|
169
|
+
apiHost?: string;
|
|
170
|
+
|
|
171
|
+
// Ready callback
|
|
172
|
+
ready?: (formo: IFormoAnalytics) => void;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### useFormo Hook Methods
|
|
177
|
+
|
|
178
|
+
#### `screen(name, properties?, context?, callback?)`
|
|
179
|
+
Track a screen view.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
formo.screen('Profile', { userId: '123' });
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### `track(event, properties?, context?, callback?)`
|
|
186
|
+
Track a custom event.
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
formo.track('Purchase Completed', {
|
|
190
|
+
revenue: 99.99,
|
|
191
|
+
currency: 'USD',
|
|
192
|
+
productId: 'nft-001',
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### `identify(params, properties?, context?, callback?)`
|
|
197
|
+
Identify a user by their wallet address.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
formo.identify({
|
|
201
|
+
address: '0x1234...',
|
|
202
|
+
userId: 'user-123',
|
|
203
|
+
providerName: 'MetaMask',
|
|
204
|
+
rdns: 'io.metamask',
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### `connect(params, properties?, context?, callback?)`
|
|
209
|
+
Track wallet connection.
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
formo.connect({
|
|
213
|
+
chainId: 1,
|
|
214
|
+
address: '0x1234...',
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### `disconnect(params?, properties?, context?, callback?)`
|
|
219
|
+
Track wallet disconnection.
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
formo.disconnect({
|
|
223
|
+
chainId: 1,
|
|
224
|
+
address: '0x1234...',
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### `chain(params, properties?, context?, callback?)`
|
|
229
|
+
Track chain change.
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
formo.chain({
|
|
233
|
+
chainId: 137,
|
|
234
|
+
address: '0x1234...',
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### `signature(params, properties?, context?, callback?)`
|
|
239
|
+
Track signature event.
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { SignatureStatus } from '@formo/analytics-react-native';
|
|
243
|
+
|
|
244
|
+
formo.signature({
|
|
245
|
+
status: SignatureStatus.CONFIRMED,
|
|
246
|
+
chainId: 1,
|
|
247
|
+
address: '0x1234...',
|
|
248
|
+
message: 'Sign this message',
|
|
249
|
+
signatureHash: '0xabcd...',
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### `transaction(params, properties?, context?, callback?)`
|
|
254
|
+
Track transaction event.
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
import { TransactionStatus } from '@formo/analytics-react-native';
|
|
258
|
+
|
|
259
|
+
formo.transaction({
|
|
260
|
+
status: TransactionStatus.BROADCASTED,
|
|
261
|
+
chainId: 1,
|
|
262
|
+
address: '0x1234...',
|
|
263
|
+
to: '0x5678...',
|
|
264
|
+
value: '1000000000000000000',
|
|
265
|
+
transactionHash: '0xdef...',
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### Consent Management
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
// Opt out of tracking (GDPR compliance)
|
|
273
|
+
formo.optOutTracking();
|
|
274
|
+
|
|
275
|
+
// Check opt-out status
|
|
276
|
+
const isOptedOut = formo.hasOptedOutTracking();
|
|
277
|
+
|
|
278
|
+
// Opt back in
|
|
279
|
+
formo.optInTracking();
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Event Types
|
|
283
|
+
|
|
284
|
+
The SDK automatically enriches events with mobile-specific context:
|
|
285
|
+
|
|
286
|
+
- Device information (OS, version, model)
|
|
287
|
+
- Screen dimensions and density
|
|
288
|
+
- Locale and timezone
|
|
289
|
+
- App information (if provided)
|
|
290
|
+
- Anonymous ID (persistent across sessions)
|
|
291
|
+
|
|
292
|
+
## Offline Support
|
|
293
|
+
|
|
294
|
+
Events are queued locally and sent when the device has network connectivity. Events are automatically flushed when:
|
|
295
|
+
|
|
296
|
+
- The batch size is reached (default: 20 events)
|
|
297
|
+
- The flush interval passes (default: 30 seconds)
|
|
298
|
+
- The app goes to background
|
|
299
|
+
|
|
300
|
+
## License
|
|
301
|
+
|
|
302
|
+
MIT
|