Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# HyperDX browser RUM (self-hosted). Leave empty locally to skip init.
NEXT_PUBLIC_HYPERDX_API_KEY=
NEXT_PUBLIC_HYPERDX_URL=https://hyperdx.devrecated.com
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/
out/
.env
.env.*
!.env.example
!box/env.example
*.token
.token
Expand All @@ -17,3 +18,5 @@ npm-debug.log*
dist/
__pycache__/
*.pyc
.env.local
.env*.local
2 changes: 2 additions & 0 deletions app/layout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { HyperDXInit } from "@/components/hyperdx-init";
import "./globals.css";
import { REPO_URL } from "@/lib/links";
import { DEMO } from "@/lib/db";
export const metadata={title:"GrugBot Console"};
export default function L({children}){return <html lang="en"><head>{DEMO&&<script src="/demo-shim.js"/>}</head><body>
<HyperDXInit service="grokbot-management-console" disableReplay={true} />
{DEMO&&<div className="demo-bar">Demo with made-up data. Click around: changes are faked in your browser and vanish when you close the tab. <a href={REPO_URL}>Get your own</a></div>}
{children}</body></html>}
35 changes: 35 additions & 0 deletions components/hyperdx-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use client";

import { useEffect } from "react";
import HyperDX from "@hyperdx/browser";

let initialized = false;

/** Browser RUM for HyperDX (self-hosted). Init only when NEXT_PUBLIC_HYPERDX_API_KEY is set. */
export function HyperDXInit({ service, disableReplay = false }) {
useEffect(() => {
if (initialized || typeof window === "undefined") return;
const key = (process.env.NEXT_PUBLIC_HYPERDX_API_KEY || "").trim();
if (!key) {
if (process.env.NODE_ENV === "production") {
console.warn(
"NEXT_PUBLIC_HYPERDX_API_KEY is not set; skipping HyperDX init",
);
}
return;
}
initialized = true;
HyperDX.init({
apiKey: key,
service,
url:
process.env.NEXT_PUBLIC_HYPERDX_URL ||
"https://hyperdx.devrecated.com",
consoleCapture: true,
advancedNetworkCapture: false,
disableReplay,
});
}, [service, disableReplay]);

return null;
}
Loading
Loading