Skip to content

Commit ec48f14

Browse files
authored
Align docs examples to DeFi flows: swaps, deposits, mints, and quests (#89)
* docs: use crypto event examples consistently * Fix typo in web SDK track docs * Add Vale vocabulary for docs terms * Update Vale ignores for docs lint
1 parent 1aeaf42 commit ec48f14

9 files changed

Lines changed: 148 additions & 47 deletions

File tree

.vale.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
StylesPath = styles
2+
Vocab = Formo
3+
MinAlertLevel = suggestion
4+
5+
[*.{md,mdx}]
6+
BasedOnStyles = Vale
7+
8+
TokenIgnores = \b(Wagmi|Solana|Onchain|Autocapture|Autocaptured|Serverless|formo)\b

data/concepts.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ Wallets are automatically linked to the user when multiple wallets are connected
3636
### 3. Properties
3737

3838
Properties are **additional information about users and events.**
39-
- Event properties are attributes that describe details specific to the particular instance of an event. For example, if you had a Purchase Completed event, you could specify what the user purchased, the total value of the order, and the payment method used.
39+
- Event properties are attributes that describe details specific to the particular instance of an event. For example, if you had a Swap Completed event, you could specify the token pair, input amount, output amount, volume, and protocol fee.
4040
- User properties are traits describing the user and apply across all their future events until the properties are modified. Formo's SDK captures several user properties by default, and you can also set up your own properties to track.
4141

4242
Properties examples:
4343
- A Connect Wallet event has wallet address and chain ID (Ethereum, Base, etc.)
4444
- A Page View event has page URL, referrer URL, and other metadata.
4545
- A User has net worth and first-touch UTM parameter properties.
4646

47-
When you track custom events, you can also set properties to describe the event. For example, if you had a Purchase Completed event, you could specify what the user purchased, the total value of the order, and the payment method used.
47+
When you track custom events, you can also set properties to describe the event. For example, if you had a Swap Completed event, you could specify the token pair, input amount, output amount, volume, and protocol fee.

data/events/track.mdx

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ description: 'Reference for the custom events used to record custom user actions
66
Record any [custom events](/features/product-analytics/custom-events) in your app,
77
along with properties that describe the action.
88

9-
Custom events can capture a broad range of actions, such as clicking a button or completing a purchase.
9+
Custom events can capture a broad range of actions, such as starting a swap or completing a deposit.
1010

11-
Additional information about the event can be included in the properties field. For example, for a `Purchase Completed` event, you may want to include the product ids of the purchased products.
11+
Additional information about the event can be included in the properties field. For example, for a `Swap Completed` event, you may want to include the token pair, input amount, and output amount.
1212

1313
## Naming events
1414

1515
When naming events, Formo recommends establishing a consistent naming convention that uses:
1616

1717
- Consistent formatting: Event names are case sensitive.
18-
- A consistent syntax: Adopt nouns and past tense verbs like `Swap Reviewed` and `Order Submitted`. A standard of `[Noun] + [Past-Tense Verb]` ensures all your events are consistent.
19-
- A consistent actor: Does `Message Sent` mean that the user sent a message or that you sent a message to the user? If all your events are named in a way that reflects the user's perspective, the meaning is clear immediately.
18+
- A consistent syntax: Adopt nouns and past tense verbs like `Swap Completed` and `Deposit Submitted`. A standard of `[Noun] + [Past-Tense Verb]` ensures all your events are consistent.
19+
- A consistent actor: Does `Transaction Submitted` mean that the user submitted a transaction or that your app submitted it on their behalf? If all your events are named in a way that reflects the user's perspective, the meaning is clear immediately.
2020

2121
This allows everyone including you 6 months from now to instantly understand the meaning of an event.
2222

@@ -29,9 +29,11 @@ Every custom event has `type` set to `track` and `event` set to your custom even
2929
```json
3030
{
3131
"type": "track",
32-
"event": "Swap Reviewed",
32+
"event": "Swap Completed",
3333
"properties": {
34-
"rating": 5
34+
"pair": "ETH/USDC",
35+
"token_in": "ETH",
36+
"token_out": "USDC"
3537
}
3638
}
3739
```
@@ -56,20 +58,36 @@ Include these optional properties in a custom event to track values associated w
5658
<img src="/images/revenue.png" alt="Revenue tracking." />
5759
</Frame>
5860

61+
For example, call `.track()` with the reserved properties alongside any other event properties:
62+
63+
```typescript
64+
analytics.track('Swap Completed', {
65+
pair: 'ETH/USDC',
66+
token_in: 'ETH',
67+
token_out: 'USDC',
68+
amount_in: 1.5,
69+
amount_out: 4500,
70+
volume: 4500,
71+
revenue: 13.5,
72+
points: 50
73+
});
74+
```
75+
5976
## Sample Payload
6077

6178
```json
6279
{
6380
"type": "track",
64-
"event": "Product Reviewed",
81+
"event": "Swap Completed",
6582
"properties": {
66-
"volume": -100.5,
67-
"revenue": 20.5,
68-
"currency": "USD",
69-
"points": 100,
70-
"product_id" : "9578257311",
71-
"rating" : 3.0,
72-
"review_body" : "Good value for the price."
83+
"pair": "ETH/USDC",
84+
"token_in": "ETH",
85+
"token_out": "USDC",
86+
"amount_in": 1.5,
87+
"amount_out": 4500,
88+
"volume": 4500,
89+
"revenue": 13.5,
90+
"points": 50
7391
}
7492
}
75-
```
93+
```

data/metrics.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ How many times a page has been viewed across your site or app.
3535

3636
### Sessions
3737

38-
A session (also known as a visit) is a set of actions that a user takes on your site.
38+
A session (also known as a visit) is a set of actions that a user takes on your site.
3939
Formo counts unique session IDs. With the web SDK, each visitor's session is counted once per day, so one visitor can have multiple sessions across days.
4040

4141
### Session Duration
@@ -145,7 +145,7 @@ Users who visit your site or app for the first time within the selected time per
145145

146146
### Returning Users
147147

148-
Users who have visited your site or app in previous time periods and return within the current period.
148+
Users who have visited your site or app in previous time periods and return within the current period.
149149

150150
### Resurrected Users
151151

@@ -163,7 +163,7 @@ Users with no activity within the project's churn window.
163163

164164
Events are user-defined custom events. They have a name and optional metadata key/value pairs. When you expand the activity feed, you can view and filter the metadata.
165165

166-
Metadata can be anything. For example, you can define an event Button clicked and track which button was clicked as the metadata field `button=Header`.
166+
Metadata can be anything. For example, you can define a `Swap Completed` event and track the swap pair as the metadata field `pair=ETH/USDC`.
167167

168168
### Top apps
169169

features/product-analytics/custom-events.mdx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: 'Custom events'
3-
description: 'Define and track custom events like button clicks, form submissions, and purchases with structured properties using the Formo SDK Track API.'
3+
description: 'Define and track custom events like swaps, deposits, and quests with structured properties using the Formo SDK Track API.'
44
---
55

66
## Overview
@@ -22,8 +22,8 @@ Track actions that aren't captured automatically:
2222

2323
| Action | Why track it |
2424
|--------|--------------|
25-
| Button clicks | Measure CTA effectiveness |
26-
| Form submissions | Track lead generation |
25+
| Swap submissions | Measure swap conversion |
26+
| Deposit completions | Track liquidity flows |
2727
| Feature usage | Understand adoption |
2828
| Errors | Debug user issues |
2929
| Key conversions | Measure business outcomes |
@@ -47,7 +47,7 @@ Track actions that aren't captured automatically:
4747

4848
```javascript
4949
// Track an event
50-
window.formo.track('Event Name', { property: 'value' });
50+
window.formo.track('Swap Completed', { pair: 'ETH/USDC' });
5151
```
5252
</Tab>
5353
</Tabs>
@@ -73,9 +73,11 @@ analytics.track('Swap Completed', {
7373
For events with monetary value, use special properties:
7474

7575
```typescript
76-
analytics.track('Trade Executed', {
76+
analytics.track('Swap Completed', {
7777
pair: 'ETH/USDC',
78-
volume: 5000, // USD value of the trade
78+
token_in: 'ETH',
79+
token_out: 'USDC',
80+
volume: 5000, // USD value of the swap
7981
revenue: 25, // Revenue earned (e.g., fees)
8082
points: 100 // Loyalty/reward points
8183
});
@@ -167,21 +169,22 @@ analytics.track('Swap Failed', {
167169
});
168170
```
169171

170-
### Example: Tracking feature adoption
172+
### Example: Tracking DeFi feature adoption
171173

172-
Measure which features users engage with:
174+
Measure which protocol features users engage with:
173175

174176
```typescript
175-
// User opens a feature
176-
analytics.track('Feature Opened', {
177-
feature: 'Portfolio',
177+
// User opens a liquidity pool
178+
analytics.track('Pool Opened', {
179+
pool_id: 'ETH/USDC',
178180
source: 'sidebar'
179181
});
180182

181-
// User completes key action in feature
182-
analytics.track('Portfolio Export', {
183-
format: 'csv',
184-
date_range: '30d'
183+
// User completes a key action in the pool
184+
analytics.track('Liquidity Added', {
185+
pool_id: 'ETH/USDC',
186+
token_0: 'ETH',
187+
token_1: 'USDC'
185188
});
186189
```
187190

sdks/mobile.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ formo.track('Swap Completed', {
230230
});
231231

232232
// With reserved properties for analytics
233-
formo.track('Purchase Completed', {
234-
productId: 'premium-nft-001',
233+
formo.track('NFT Minted', {
234+
collection: 'founders-pass',
235+
tokenId: '001',
235236
revenue: 99.99, // Reserved: revenue tracking
236-
currency: 'USD', // Reserved: currency for revenue
237237
});
238238

239-
formo.track('Achievement Unlocked', {
240-
achievementId: 'first_transaction',
239+
formo.track('Quest Completed', {
240+
questId: 'first_swap',
241241
points: 500, // Reserved: points tracking
242242
});
243243

sdks/server.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,15 @@ To track custom events (actions, conversions, or backend states) use the [`track
5353
await analytics.track({
5454
address: "0x9798d87366bdfc5d70b300abdffc4f9e95369b3d", // optional: wallet address
5555
anonymousId: uuid(), // optional: auto-generated if not provided
56-
event: "Purchase Completed", // required: event name
56+
event: "Swap Completed", // required: event name
5757
properties: {
58-
order_id: "123",
59-
revenue: 99.99,
60-
currency: "USD",
58+
pair: "ETH/USDC",
59+
token_in: "ETH",
60+
token_out: "USDC",
61+
amount_in: 1.5,
62+
amount_out: 4500,
63+
volume: 4500,
64+
revenue: 13.5,
6165
},
6266
});
6367
```

sdks/web.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ If no parameters are specified, the Formo SDK will attempt to auto-identify the
326326

327327
> The Web SDK automatically captures common events such as page views and wallet events (connect, disconnect, signature, transaction, etc) with full attribution (referrer, UTM, referrals.) You do not need to manually track them.
328328
329-
To track custom events (in-app user actions, key conversions) use the [`track`](/data/events/track) function with details of what happenned:
329+
To track custom events (in-app user actions, key conversions) use the [`track`](/data/events/track) function with details of what happened:
330330

331331
```ts
332332
import { useFormo } from '@formo/analytics';
@@ -826,7 +826,7 @@ npm install @formo/analytics @solana/client @solana/react-hooks
826826
const formo = useFormo();
827827

828828
const handleClick = () => {
829-
formo.track('button_click', { page: 'home' });
829+
formo.track('Swap Started', { pair: 'ETH/USDC' });
830830
};
831831
}
832832
```
@@ -894,7 +894,7 @@ For Solana-only apps, set `evm: false` to disable EVM provider detection (EIP-11
894894
The [Wagmi integration](#wagmi) automatically tracks wallet connects, disconnects, chain switches, transactions, and signatures by hooking into Wagmi's wallet adapter. The standard [React integration](#react--nextjs-without-wagmi) tracks wallet events by wrapping the EIP-1193 wallet provider to track signatures and transactions. Use the Wagmi integration if your dApp uses Wagmi and its hooks.
895895
</Accordion>
896896
<Accordion title="How do I track custom events like swaps, deposits, or mints?">
897-
Use [formo.track()](/data/events/track) to send custom events with any properties you need. For example: `formo.track('swap', { tokenIn: 'USDC', tokenOut: 'ETH', amount: 1000 })`. Custom events appear in the [Activity](/features/product-analytics/activity) feed and can be queried in the [Explorer](/features/product-analytics/explore).
897+
Use [formo.track()](/data/events/track) to send custom events with any properties you need. For example: `formo.track('Swap Completed', { pair: 'ETH/USDC', token_in: 'ETH', token_out: 'USDC', amount_in: 1.5 })`. Custom events appear in the [Activity](/features/product-analytics/activity) feed and can be queried in the [Explorer](/features/product-analytics/explore).
898898
</Accordion>
899899
<Accordion title="Does the Formo SDK support consent management for GDPR?">
900900
Yes. The SDK provides built-in [consent management](#consent-management) with `optOutTracking()` and `optInTracking()` methods. Call `optOutTracking()` to stop all tracking for a user, and `optInTracking()` to re-enable it. Formo does not use third-party cookies, IP addresses, or device fingerprinting, so most jurisdictions do not require a cookie consent banner.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Angular's
2+
Autocapture
3+
Autocaptured
4+
Beehiiv
5+
Bing
6+
Cloudfront
7+
Dailymotion
8+
Ethereum
9+
Farcaster
10+
Formo
11+
Formo's
12+
Genspark
13+
Kagi
14+
Kimi
15+
Naver
16+
OAuth
17+
Onchain
18+
Phind
19+
Pinterest
20+
Qwen
21+
SDK's
22+
SDKs
23+
Serverless
24+
Snapchat
25+
Solana
26+
Subresource
27+
Substack
28+
UTMs
29+
Uniswap
30+
Vercel
31+
Wagmi
32+
Wagmi's
33+
Wistia
34+
Yandex
35+
async
36+
autocapture
37+
autocaptured
38+
autocaptures
39+
autodetects
40+
backgrounding
41+
config
42+
crypto
43+
dApp
44+
dApps
45+
denylist
46+
ePrivacy
47+
enqueued
48+
esbuild
49+
formo
50+
globals
51+
hostname
52+
hostnames
53+
injectable
54+
leaderboards
55+
lightbulb
56+
logLevel
57+
middleware
58+
offchain
59+
onchain
60+
pageview
61+
polyfill
62+
serverless
63+
solana
64+
subpath
65+
summer_sale
66+
viem
67+
wagmi
68+
zustand

0 commit comments

Comments
 (0)