Skip to content

Commit e95604e

Browse files
Small Tweak (#729)
1 parent 0bcb9a0 commit e95604e

File tree

6 files changed

+51
-8
lines changed

6 files changed

+51
-8
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
VITE_API_BASE_URL=
22
VITE_FRONTEND_VERSION=
3-
VITE_FEATURE_OS_KEY=
3+
VITE_FEATURE_OS_KEY=
4+
VITE_REO_KEY=

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
VITE_API_BASE_URL: "/api/v1"
3636
VITE_FRONTEND_VERSION: ${{ steps.get_version.outputs.VERSION }}
3737
VITE_FEATURE_OS_KEY: ${{ secrets.FEATURE_OS_KEY }}
38+
VITE_REO_KEY: ${{ secrets.REO_KEY }}
3839

3940
- name: Generate Changelog
4041
uses: heinrichreimer/[email protected]

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"jwt-decode": "^4.0.0",
3939
"lodash.debounce": "^4.0.8",
4040
"papaparse": "^5.5.2",
41-
"prismjs": "^1.29.0",
41+
"prismjs": "^1.30.0",
4242
"react": "^18.3.1",
4343
"react-countdown": "^2.3.6",
4444
"react-dom": "^18.3.1",
@@ -48,6 +48,7 @@
4848
"react-markdown": "^9.0.3",
4949
"react-router-dom": "^6.27.0",
5050
"reactflow": "^11.11.4",
51+
"reodotdev": "^1.0.0",
5152
"unique-names-generator": "^4.7.1",
5253
"zod": "^3.24.1"
5354
},

pnpm-lock.yaml

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

src/components/Analytics.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
11
import { fetcher } from "@/data/fetch";
22
import { useServerInfo } from "@/data/server/info-query";
33
import { useCurrentUser } from "@/data/users/current-user-query";
4-
4+
import { loadReoScript } from "reodotdev";
55
import { analyticsServerUrl } from "@/lib/analytics";
66
import { routes } from "@/router/routes";
77
import { PageEvent, PageEventContext, PageEventPage, PageEventProperties } from "@/types/analytics";
88
import { useEffect } from "react";
99
import { matchPath, useLocation } from "react-router-dom";
1010

11+
const REO_KEY = import.meta.env.VITE_REO_KEY;
12+
1113
export function Analytics() {
1214
const { data } = useServerInfo();
1315
const { data: userData } = useCurrentUser();
1416
const location = useLocation();
1517

18+
useEffect(() => {
19+
if (REO_KEY && data && data.analytics_enabled && userData) {
20+
const reoPromise = loadReoScript({ clientID: REO_KEY });
21+
reoPromise
22+
.then(async (Reo) => {
23+
Reo.init({ clientID: REO_KEY });
24+
if (userData.metadata?.email) {
25+
// wait 2 seconds to ensure the script is loaded
26+
await new Promise((resolve) => setTimeout(resolve, 2000));
27+
const identity = {
28+
username: userData.metadata.email,
29+
type: "email"
30+
};
31+
Reo.identify(identity);
32+
}
33+
})
34+
.catch((error) => {
35+
console.error("Error loading Reo", error);
36+
});
37+
}
38+
}, [data, userData]);
39+
1640
useEffect(() => {
1741
if (data && data.analytics_enabled && userData) {
1842
performPageEvent(

src/types/reodotdev.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare module "reodotdev" {
2+
interface ReoInstance {
3+
init(options: { clientID: string }): void;
4+
identify(identity: { username: string; type: string }): void;
5+
}
6+
7+
export function loadReoScript(options: { clientID: string }): Promise<ReoInstance>;
8+
}

0 commit comments

Comments
 (0)