Skip to content

Commit 5b4680c

Browse files
committed
Add GA events
1 parent 5d636a2 commit 5b4680c

File tree

7 files changed

+50
-5
lines changed

7 files changed

+50
-5
lines changed

llmstack/client/src/App.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ export default function App({ children }) {
5252
const location = useLocation();
5353

5454
useEffect(() => {
55-
ReactGA.initialize("G-WV60HC9CHD");
55+
ReactGA.initialize(
56+
process.env.REACT_APP_GA_MEASUREMENT_ID || "G-WV60HC9CHD",
57+
);
5658
ReactGA.send({
5759
hitType: "pageview",
5860
page: location.pathname + location.search,

llmstack/client/src/components/Connections.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState } from "react";
2+
import ReactGA from "react-ga4";
23
import { Button, Stack, Typography } from "@mui/material";
34
import { AddOutlined } from "@mui/icons-material";
45
import AddConnectionModal from "./connections/AddConnectionModal";
@@ -74,6 +75,13 @@ function Connections() {
7475
});
7576
reject(err);
7677
});
78+
79+
ReactGA.event({
80+
category: "Connections",
81+
action: "Create Connection",
82+
label: conn.connection_type_slug,
83+
transport: "beacon",
84+
});
7785
}
7886
});
7987
};

llmstack/client/src/components/apps/AgentRenderer.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useEffect, useRef, useState } from "react";
2+
import ReactGA from "react-ga4";
23
import { Avatar, Box, Chip, Fab, Grid, Stack, Typography } from "@mui/material";
34
import { ThemeProvider, createTheme } from "@mui/material/styles";
45
import { Liquid } from "liquidjs";
@@ -511,6 +512,13 @@ export function AgentRenderer({ app, isMobile, embed = false, ws }) {
511512
session_id: appSessionId,
512513
}),
513514
);
515+
516+
ReactGA.event({
517+
category: "App",
518+
action: "Run Agent",
519+
label: app?.name,
520+
transport: "beacon",
521+
});
514522
};
515523

516524
useEffect(() => {

llmstack/client/src/components/apps/AppTemplatesList.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useCallback, useEffect, useState } from "react";
2+
import ReactGA from "react-ga4";
23
import { Card, CardContent, Chip, Stack, Typography } from "@mui/material";
34
import { useNavigate, useParams } from "react-router-dom";
45
import { axios } from "../../data/axios";
@@ -98,6 +99,13 @@ export function AppTemplatesList() {
9899
key={index}
99100
style={{ maxWidth: "300px", cursor: "pointer" }}
100101
onClick={() => {
102+
ReactGA.event({
103+
category: "App Template",
104+
action: "Select",
105+
label: template.slug,
106+
transport: "beacon",
107+
});
108+
101109
navigate(`/apps/templates/${template.slug}`);
102110
}}
103111
>

llmstack/client/src/components/apps/WebAppRenderer.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState, useRef, useEffect } from "react";
2+
import ReactGA from "react-ga4";
23
import { Button } from "@mui/material";
34
import { ThemeProvider, createTheme } from "@mui/material/styles";
45
import { CircularProgress, Grid } from "@mui/material";
@@ -164,6 +165,13 @@ export function WebAppRenderer({ app, ws }) {
164165
}),
165166
);
166167
setIsRunning(true);
168+
169+
ReactGA.event({
170+
category: "App",
171+
action: "Run Web App",
172+
label: app?.name,
173+
transport: "beacon",
174+
});
167175
};
168176

169177
return (

llmstack/client/src/components/apps/WebChatRender.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useEffect, useRef, useState } from "react";
2+
import ReactGA from "react-ga4";
23
import { Avatar, Chip, Fab, Grid, Stack, Typography } from "@mui/material";
34
import { ThemeProvider, createTheme } from "@mui/material/styles";
45
import { Liquid } from "liquidjs";
@@ -324,6 +325,13 @@ export function WebChatRender({ app, isMobile, embed = false, ws }) {
324325
session_id: appSessionId,
325326
}),
326327
);
328+
329+
ReactGA.event({
330+
category: "App",
331+
action: "Run Chat App",
332+
label: app?.name,
333+
transport: "beacon",
334+
});
327335
};
328336

329337
useEffect(() => {

llmstack/client/src/pages/AppRender.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ function AppRenderPage({ headless = false }) {
3535
}/ws`;
3636

3737
useEffect(() => {
38-
ReactGA.initialize("G-WV60HC9CHD", {
39-
gaOptions: {
40-
cookieFlags: "SameSite=None;Secure",
38+
ReactGA.initialize(
39+
process.env.REACT_APP_GA_MEASUREMENT_ID || "G-WV60HC9CHD",
40+
{
41+
gaOptions: {
42+
cookieFlags: "SameSite=None;Secure",
43+
},
4144
},
42-
});
45+
);
4346
}, []);
4447

4548
const isMobile = useRecoilValue(isMobileState);

0 commit comments

Comments
 (0)