Skip to content

Commit 0577149

Browse files
authored
Add Amplitude integration (#312)
1 parent e17d011 commit 0577149

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed

package-lock.json

Lines changed: 153 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"postinstall": "graz generate -g"
1212
},
1313
"dependencies": {
14+
"@amplitude/analytics-browser": "^2.8.1",
1415
"@codesandbox/sandpack-react": "^2.6.1",
1516
"@cosmjs/cosmwasm-stargate": "^0.31.0",
1617
"@headlessui/react": "^1.7.14",

pages/_app.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import "nextra-theme-docs/style.css";
66
import { ReactNode, useEffect, useState } from "react";
77
import { WagmiConfig, createConfig } from "wagmi";
88
import { arbitrum, avalanche, mainnet, sepolia } from "wagmi/chains";
9+
import * as amplitude from "@amplitude/analytics-browser";
910
import { CosmosChains, GlobalContextProvider } from "../contexts/GlobalContext";
1011
import "../styles/styles.css";
1112
import TagManager from "react-gtm-module";
1213

1314
const tagManagerArgs = {
1415
gtmId: "GTM-MN3TWRGJ",
1516
};
17+
const AMPLITUDE_API_KEY = process.env.NEXT_PUBLIC_AMPLITUDE_API_KEY;
1618

1719
const chains = [arbitrum, mainnet, avalanche, sepolia];
1820

@@ -39,6 +41,11 @@ export default function Nextra({ Component, pageProps }: NextraAppProps) {
3941
useEffect(() => {
4042
TagManager.initialize(tagManagerArgs);
4143
}, []);
44+
useEffect(() => {
45+
if (AMPLITUDE_API_KEY) {
46+
amplitude.init(AMPLITUDE_API_KEY);
47+
}
48+
});
4249

4350
// Make the global context available to every page.
4451
return (

0 commit comments

Comments
 (0)