You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: install.mdx
+137Lines changed: 137 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -637,6 +637,143 @@ Make sure you use the same `<SDK_WRITE_KEY>` for both your website and your app.
637
637
```
638
638
639
639
</Tab>
640
+
<Tabicon="angular"title="Angular">
641
+
642
+
<Note>
643
+
Working example: [with-angular](https://github.com/getformo/examples/tree/main/with-angular). Also see the [Angular section](/sdks/web#angular) of the Web SDK page.
644
+
</Note>
645
+
646
+
Angular has no first-class Formo binding — `FormoAnalyticsProvider` and `useFormo()` are React-only. Angular apps install Formo on the **non-wagmi, non-React path**: the framework-agnostic `FormoAnalytics.init()` core wrapped in an injectable service, with wallets connected over the bare EIP-1193 provider (`window.ethereum`).
647
+
648
+
#### 1. Install the Formo SDK
649
+
650
+
Install the SDK along with the `buffer` polyfill (Angular's esbuild build doesn't auto-polyfill Node globals, but the SDK uses `Buffer` to decode signed-message payloads) and viem:
Replace `NG_APP_FORMO_WRITE_KEY` with your write key in `.env`. The `NG_APP_*` prefix is exposed to the client by [`@ngx-env/builder`](https://github.com/chihab/ngx-env).
710
+
711
+
#### 3. Initialize before bootstrap
712
+
713
+
Use `provideAppInitializer` so the SDK's autocapture wraps `window.ethereum`**before** any wallet interaction can happen:
Don't initialize from `ngOnInit` — it runs after first render, leaving a race window where early wallet interactions are not captured.
734
+
</Warning>
735
+
736
+
#### 4. Identify users
737
+
738
+
Call `identify()` once a wallet address is known. Angular Router's `pushState` is already wrapped by the SDK, so `page` events are autocaptured on every route change — do not add a `NavigationEnd` subscription that calls `formo.page()` or you'll double-count.
739
+
740
+
```ts
741
+
import { Injectable, inject, signal } from'@angular/core';
-[Angular](#angular) for Angular apps using the bare EIP-1193 provider
24
25
25
26
We recommend installing Formo on **both your website (example.com) and your app (app.example.com)** on the same project with the same SDK write key.
26
27
@@ -143,6 +144,83 @@ const HomePage = () => {
143
144
exportdefaultHomePage;
144
145
```
145
146
147
+
### Angular
148
+
149
+
<Note>
150
+
`FormoAnalyticsProvider` and `useFormo()` are React-only. Angular apps use the framework-agnostic `FormoAnalytics.init()` core, wrapped in an injectable service, with wallets connected over the bare EIP-1193 provider (`window.ethereum`). Full working example: [with-angular](https://github.com/getformo/examples/tree/main/with-angular).
151
+
</Note>
152
+
153
+
Install the Web SDK along with the `buffer` polyfill. Angular's esbuild build doesn't auto-polyfill Node globals, but the SDK uses `Buffer` to decode signed-message payloads — without it, signing throws `ReferenceError: Buffer is not defined`.
Angular Router navigates with `history.pushState`, which the SDK hooks on init — page changes are autocaptured. Don't add a `NavigationEnd` subscription that calls `formo.page()` or you'll double-count.
222
+
</Note>
223
+
146
224
## Identify users
147
225
148
226
Call [`identify()`](/data/events/identify) after a user connects their wallet or signs in on your website or app:
@@ -223,6 +301,29 @@ If no parameters are specified, the Formo SDK will attempt to auto-identify the
223
301
></script>
224
302
```
225
303
</Tab>
304
+
<Tabtitle="Angular">
305
+
Inject the analytics service and call `identify()` from the same place you discover the wallet address (for example, a `WalletService` that drives `eth_requestAccounts`):
306
+
307
+
```ts
308
+
import { Injectable, inject, signal } from'@angular/core';
See the [with-angular example](https://github.com/getformo/examples/tree/main/with-angular) for the full wallet service, including the hydrate-on-load and `wallet_revokePermissions` patterns.
326
+
</Tab>
226
327
</Tabs>
227
328
228
329
## Track events
@@ -335,6 +436,27 @@ You can [track volume, revenue, and points](/data/events/track#tracking-volume,-
0 commit comments