Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

fix: Fix PostHog event tracking and add coverage for untracked features (#1094)

Aman Agarwale465c1c35a06
diff --git a/src/client/package-lock.json b/src/client/package-lock.json
index e8a4d713..a0671539 100644
--- a/src/client/package-lock.json
+++ b/src/client/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "openlit",
- "version": "1.17.2",
+ "version": "1.17.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openlit",
- "version": "1.17.2",
+ "version": "1.17.3",
"dependencies": {
"@ai-sdk/anthropic": "^3.0.6",
"@ai-sdk/cohere": "^3.0.3",
@@ -61,7 +61,7 @@
"next-auth": "^4.24.7",
"next-themes": "^0.3.0",
"openai": "^4.50.0",
- "posthog-js": "^1.261.7",
+ "posthog-js": "^1.364.4",
"react": "^18.3.1",
"react-beautiful-dnd": "^13.1.1",
"react-day-picker": "^8.10.1",
@@ -3734,6 +3734,243 @@
"node": ">=8.0.0"
}
},
+ "node_modules/@opentelemetry/api-logs": {
+ "version": "0.208.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.208.0.tgz",
+ "integrity": "sha512-CjruKY9V6NMssL/T1kAFgzosF1v9o6oeN+aX5JB/C/xPNtmgIJqcXHG7fA82Ou1zCpWGl4lROQUKwUNE1pMCyg==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/api": "^1.3.0"
+ },
+ "engines": {
+ "node": ">=8.0.0"
+ }
+ },
+ "node_modules/@opentelemetry/core": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.2.0.tgz",
+ "integrity": "sha512-FuabnnUm8LflnieVxs6eP7Z383hgQU4W1e3KJS6aOG3RxWxcHyBxH8fDMHNgu/gFx/M2jvTOW/4/PHhLz6bjWw==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/semantic-conventions": "^1.29.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.0.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/exporter-logs-otlp-http": {
+ "version": "0.208.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-logs-otlp-http/-/exporter-logs-otlp-http-0.208.0.tgz",
+ "integrity": "sha512-jOv40Bs9jy9bZVLo/i8FwUiuCvbjWDI+ZW13wimJm4LjnlwJxGgB+N/VWOZUTpM+ah/awXeQqKdNlpLf2EjvYg==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/api-logs": "0.208.0",
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/otlp-exporter-base": "0.208.0",
+ "@opentelemetry/otlp-transformer": "0.208.0",
+ "@opentelemetry/sdk-logs": "0.208.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
+ }
+ },
+ "node_modules/@opentelemetry/otlp-exporter-base": {
+ "version": "0.208.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.208.0.tgz",
+ "integrity": "sha512-gMd39gIfVb2OgxldxUtOwGJYSH8P1kVFFlJLuut32L6KgUC4gl1dMhn+YC2mGn0bDOiQYSk/uHOdSjuKp58vvA==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/otlp-transformer": "0.208.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
+ }
+ },
+ "node_modules/@opentelemetry/otlp-transformer": {
+ "version": "0.208.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.208.0.tgz",
+ "integrity": "sha512-DCFPY8C6lAQHUNkzcNT9R+qYExvsk6C5Bto2pbNxgicpcSWbe2WHShLxkOxIdNcBiYPdVHv/e7vH7K6TI+C+fQ==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/api-logs": "0.208.0",
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/resources": "2.2.0",
+ "@opentelemetry/sdk-logs": "0.208.0",
+ "@opentelemetry/sdk-metrics": "2.2.0",
+ "@opentelemetry/sdk-trace-base": "2.2.0",
+ "protobufjs": "^7.3.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.3.0"
+ }
+ },
+ "node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/resources": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.2.0.tgz",
+ "integrity": "sha512-1pNQf/JazQTMA0BiO5NINUzH0cbLbbl7mntLa4aJNmCCXSj0q03T5ZXXL0zw4G55TjdL9Tz32cznGClf+8zr5A==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/resources": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.6.1.tgz",
+ "integrity": "sha512-lID/vxSuKWXM55XhAKNoYXu9Cutoq5hFdkbTdI/zDKQktXzcWBVhNsOkiZFTMU9UtEWuGRNe0HUgmsFldIdxVA==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/core": "2.6.1",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/resources/node_modules/@opentelemetry/core": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.6.1.tgz",
+ "integrity": "sha512-8xHSGWpJP9wBxgBpnqGL0R3PbdWQndL1Qp50qrg71+B28zK5OQmUgcDKLJgzyAAV38t4tOyLMGDD60LneR5W8g==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/semantic-conventions": "^1.29.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.0.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/sdk-logs": {
+ "version": "0.208.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.208.0.tgz",
+ "integrity": "sha512-QlAyL1jRpOeaqx7/leG1vJMp84g0xKP6gJmfELBpnI4O/9xPX+Hu5m1POk9Kl+veNkyth5t19hRlN6tNY1sjbA==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/api-logs": "0.208.0",
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/resources": "2.2.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.4.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/resources": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.2.0.tgz",
+ "integrity": "sha512-1pNQf/JazQTMA0BiO5NINUzH0cbLbbl7mntLa4aJNmCCXSj0q03T5ZXXL0zw4G55TjdL9Tz32cznGClf+8zr5A==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/sdk-metrics": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.2.0.tgz",
+ "integrity": "sha512-G5KYP6+VJMZzpGipQw7Giif48h6SGQ2PFKEYCybeXJsOCB4fp8azqMAAzE5lnnHK3ZVwYQrgmFbsUJO/zOnwGw==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/resources": "2.2.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.9.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/sdk-metrics/node_modules/@opentelemetry/resources": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.2.0.tgz",
+ "integrity": "sha512-1pNQf/JazQTMA0BiO5NINUzH0cbLbbl7mntLa4aJNmCCXSj0q03T5ZXXL0zw4G55TjdL9Tz32cznGClf+8zr5A==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/sdk-trace-base": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.2.0.tgz",
+ "integrity": "sha512-xWQgL0Bmctsalg6PaXExmzdedSp3gyKV8mQBwK/j9VGdCDu2fmXIb2gAehBKbkXCpJ4HPkgv3QfoJWRT4dHWbw==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/resources": "2.2.0",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/sdk-trace-base/node_modules/@opentelemetry/resources": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.2.0.tgz",
+ "integrity": "sha512-1pNQf/JazQTMA0BiO5NINUzH0cbLbbl7mntLa4aJNmCCXSj0q03T5ZXXL0zw4G55TjdL9Tz32cznGClf+8zr5A==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@opentelemetry/core": "2.2.0",
+ "@opentelemetry/semantic-conventions": "^1.29.0"
+ },
+ "engines": {
+ "node": "^18.19.0 || >=20.6.0"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": ">=1.3.0 <1.10.0"
+ }
+ },
+ "node_modules/@opentelemetry/semantic-conventions": {
+ "version": "1.40.0",
+ "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.40.0.tgz",
+ "integrity": "sha512-cifvXDhcqMwwTlTK04GBNeIe7yyo28Mfby85QXFe1Yk8nmi36Ab/5UQwptOx84SsoGNRg+EVSjwzfSZMy6pmlw==",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=14"
+ }
+ },
"node_modules/@panva/hkdf": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@panva/hkdf/-/hkdf-1.1.1.tgz",
@@ -3775,9 +4012,19 @@
}
},
"node_modules/@posthog/core": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/@posthog/core/-/core-1.0.2.tgz",
- "integrity": "sha512-hWk3rUtJl2crQK0WNmwg13n82hnTwB99BT99/XI5gZSvIlYZ1TPmMZE8H2dhJJ98J/rm9vYJ/UXNzw3RV5HTpQ=="
+ "version": "1.24.4",
+ "resolved": "https://registry.npmjs.org/@posthog/core/-/core-1.24.4.tgz",
+ "integrity": "sha512-S+TolwBHSSJz7WWtgaELQWQqXviSm3uf1e+qorWUts0bZcgPwWzhnmhCUZAhvn0NVpTQHDJ3epv+hHbPLl5dHg==",
+ "license": "MIT",
+ "dependencies": {
+ "cross-spawn": "^7.0.6"
+ }
+ },
+ "node_modules/@posthog/types": {
+ "version": "1.364.4",
+ "resolved": "https://registry.npmjs.org/@posthog/types/-/types-1.364.4.tgz",
+ "integrity": "sha512-U7NpIy9XWrzz1q/66xyDu8Wm12a7avNRKRn5ISPT5kuCJQRaeAaHuf+dpgrFnuqjCCgxg+oIY/ReJdlZ+8/z4Q==",
+ "license": "MIT"
},
"node_modules/@prisma/client": {
"version": "5.15.0",
@@ -3841,6 +4088,70 @@
"@prisma/debug": "5.15.0"
}
},
+ "node_modules/@protobufjs/aspromise": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
+ "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/base64": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz",
+ "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/codegen": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz",
+ "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/eventemitter": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz",
+ "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/fetch": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz",
+ "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@protobufjs/aspromise": "^1.1.1",
+ "@protobufjs/inquire": "^1.1.0"
+ }
+ },
+ "node_modules/@protobufjs/float": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz",
+ "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/inquire": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz",
+ "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/path": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz",
+ "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/pool": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz",
+ "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==",
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@protobufjs/utf8": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz",
+ "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==",
+ "license": "BSD-3-Clause"
+ },
"node_modules/@radix-ui/number": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.0.1.tgz",
@@ -7446,6 +7757,13 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@types/trusted-types": {
+ "version": "2.0.7",
+ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
+ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
+ "license": "MIT",
+ "optional": true
+ },
"node_modules/@types/unist": {
"version": "2.0.10",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz",
@@ -9580,6 +9898,15 @@
"csstype": "^3.0.2"
}
},
+ "node_modules/dompurify": {
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.3.tgz",
+ "integrity": "sha512-Oj6pzI2+RqBfFG+qOaOLbFXLQ90ARpcGG6UePL82bJLtdsa6CYJD7nmiU8MW9nQNOtCHV3lZ/Bzq1X0QYbBZCA==",
+ "license": "(MPL-2.0 OR Apache-2.0)",
+ "optionalDependencies": {
+ "@types/trusted-types": "^2.0.7"
+ }
+ },
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
@@ -13097,6 +13424,12 @@
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"dev": true
},
+ "node_modules/long": {
+ "version": "5.3.2",
+ "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
+ "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
+ "license": "Apache-2.0"
+ },
"node_modules/longest-streak": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz",
@@ -14917,33 +15250,31 @@
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="
},
"node_modules/posthog-js": {
- "version": "1.261.7",
- "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.261.7.tgz",
- "integrity": "sha512-Fjpbz6VfIMsEbKIN/UyTWhU1DGgVIngqoRjPGRolemIMOVzTfI77OZq8WwiBhMug+rU+wNhGCQhC41qRlR5CxA==",
- "dependencies": {
- "@posthog/core": "1.0.2",
+ "version": "1.364.4",
+ "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.364.4.tgz",
+ "integrity": "sha512-T71zr06gH5YcrjS7c+sdzqfZKMxqqXC/a0w++zMQIPbL1ejvF9PdfUi0Kyd6Sy78Ocbb2smobdzBh8vXLwC+lQ==",
+ "license": "SEE LICENSE IN LICENSE",
+ "dependencies": {
+ "@opentelemetry/api": "^1.9.0",
+ "@opentelemetry/api-logs": "^0.208.0",
+ "@opentelemetry/exporter-logs-otlp-http": "^0.208.0",
+ "@opentelemetry/resources": "^2.2.0",
+ "@opentelemetry/sdk-logs": "^0.208.0",
+ "@posthog/core": "1.24.4",
+ "@posthog/types": "1.364.4",
"core-js": "^3.38.1",
+ "dompurify": "^3.3.2",
"fflate": "^0.4.8",
- "preact": "^10.19.3",
- "web-vitals": "^4.2.4"
- },
- "peerDependencies": {
- "@rrweb/types": "2.0.0-alpha.17",
- "rrweb-snapshot": "2.0.0-alpha.17"
- },
- "peerDependenciesMeta": {
- "@rrweb/types": {
- "optional": true
- },
- "rrweb-snapshot": {
- "optional": true
- }
+ "preact": "^10.28.2",
+ "query-selector-shadow-dom": "^1.0.1",
+ "web-vitals": "^5.1.0"
}
},
"node_modules/preact": {
- "version": "10.22.0",
- "resolved": "https://registry.npmjs.org/preact/-/preact-10.22.0.tgz",
- "integrity": "sha512-RRurnSjJPj4rp5K6XoP45Ui33ncb7e4H7WiOHVpjbkvqvA3U+N8Z6Qbo0AE6leGYBV66n8EhEaFixvIu3SkxFw==",
+ "version": "10.29.0",
+ "resolved": "https://registry.npmjs.org/preact/-/preact-10.29.0.tgz",
+ "integrity": "sha512-wSAGyk2bYR1c7t3SZ3jHcM6xy0lcBcDel6lODcs9ME6Th++Dx2KU+6D3HD8wMMKGA8Wpw7OMd3/4RGzYRpzwRg==",
+ "license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/preact"
@@ -15033,6 +15364,30 @@
"url": "https://github.com/sponsors/wooorm"
}
},
+ "node_modules/protobufjs": {
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.5.4.tgz",
+ "integrity": "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg==",
+ "hasInstallScript": true,
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "@protobufjs/aspromise": "^1.1.2",
+ "@protobufjs/base64": "^1.1.2",
+ "@protobufjs/codegen": "^2.0.4",
+ "@protobufjs/eventemitter": "^1.1.0",
+ "@protobufjs/fetch": "^1.1.0",
+ "@protobufjs/float": "^1.0.2",
+ "@protobufjs/inquire": "^1.1.0",
+ "@protobufjs/path": "^1.1.2",
+ "@protobufjs/pool": "^1.1.0",
+ "@protobufjs/utf8": "^1.1.0",
+ "@types/node": ">=13.7.0",
+ "long": "^5.0.0"
+ },
+ "engines": {
+ "node": ">=12.0.0"
+ }
+ },
"node_modules/punycode": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
@@ -15073,6 +15428,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/query-selector-shadow-dom": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/query-selector-shadow-dom/-/query-selector-shadow-dom-1.0.1.tgz",
+ "integrity": "sha512-lT5yCqEBgfoMYpf3F2xQRK7zEr1rhIIZuceDK6+xRkJQ4NMbHTwXqk4NkwDwQMNqXgG9r9fyHnzwNVs6zV5KRw==",
+ "license": "MIT"
+ },
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@@ -17196,9 +17557,10 @@
}
},
"node_modules/web-vitals": {
- "version": "4.2.4",
- "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.4.tgz",
- "integrity": "sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw=="
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-5.2.0.tgz",
+ "integrity": "sha512-i2z98bEmaCqSDiHEDu+gHl/dmR4Q+TxFmG3/13KkMO+o8UxQzCqWaDRCiLgEa41nlO4VpXSI0ASa1xWmO9sBlA==",
+ "license": "Apache-2.0"
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
diff --git a/src/client/package.json b/src/client/package.json
index fcfe8827..ba204f5c 100644
--- a/src/client/package.json
+++ b/src/client/package.json
@@ -1,6 +1,6 @@
{
"name": "openlit",
- "version": "1.17.2",
+ "version": "1.17.3",
"private": true,
"scripts": {
"dev": "next dev",
@@ -66,7 +66,7 @@
"next-auth": "^4.24.7",
"next-themes": "^0.3.0",
"openai": "^4.50.0",
- "posthog-js": "^1.261.7",
+ "posthog-js": "^1.364.4",
"react": "^18.3.1",
"react-beautiful-dnd": "^13.1.1",
"react-day-picker": "^8.10.1",
diff --git a/src/client/src/app/(auth)/layout.tsx b/src/client/src/app/(auth)/layout.tsx
index 85fa1333..3242d311 100644
--- a/src/client/src/app/(auth)/layout.tsx
+++ b/src/client/src/app/(auth)/layout.tsx
@@ -1,20 +1,25 @@
import AuthFormContainer from "@/components/(auth)/auth-form-container";
import AutoSignInDemoInstance from "../../components/(auth)/auto-signin-demo-instance";
import AuthDetailsCarousel from "@/components/(auth)/auth-details-carousel";
+import CustomPostHogProvider from "@/components/(playground)/posthog";
export default function AuthLayout({
children,
}: {
children: JSX.Element;
}) {
+ const telemetryEnabled = process.env.TELEMETRY_ENABLED !== "false";
+
return (
- <div className="min-h-screen grid lg:grid-cols-2 bg-white dark:bg-stone-950">
- <AuthDetailsCarousel />
- <AuthFormContainer>
- <AutoSignInDemoInstance demoCreds={{ email: process.env.DEMO_ACCOUNT_EMAIL, password: process.env.DEMO_ACCOUNT_PASSWORD }}>
- {children}
- </AutoSignInDemoInstance>
- </AuthFormContainer>
- </div>
+ <CustomPostHogProvider telemetryEnabled={telemetryEnabled}>
+ <div className="min-h-screen grid lg:grid-cols-2 bg-white dark:bg-stone-950">
+ <AuthDetailsCarousel />
+ <AuthFormContainer>
+ <AutoSignInDemoInstance demoCreds={{ email: process.env.DEMO_ACCOUNT_EMAIL, password: process.env.DEMO_ACCOUNT_PASSWORD }}>
+ {children}
+ </AutoSignInDemoInstance>
+ </AuthFormContainer>
+ </div>
+ </CustomPostHogProvider>
);
}
diff --git a/src/client/src/app/(auth)/login/page.tsx b/src/client/src/app/(auth)/login/page.tsx
index 7735b807..2660a487 100644
--- a/src/client/src/app/(auth)/login/page.tsx
+++ b/src/client/src/app/(auth)/login/page.tsx
@@ -1,7 +1,16 @@
-import { Suspense } from "react";
+"use client";
+import { Suspense, useEffect } from "react";
import { AuthForm } from "@/components/(auth)/auth-form";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
export default function Login() {
+ const posthog = usePostHog();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.LOGIN_PAGE_VISITED);
+ }, []);
+
return (
<Suspense fallback={null}>
<AuthForm type={"login"} />
diff --git a/src/client/src/app/(auth)/register/page.tsx b/src/client/src/app/(auth)/register/page.tsx
index f807218a..b1bf8822 100644
--- a/src/client/src/app/(auth)/register/page.tsx
+++ b/src/client/src/app/(auth)/register/page.tsx
@@ -1,7 +1,16 @@
-import { Suspense } from "react";
+"use client";
+import { Suspense, useEffect } from "react";
import { AuthForm } from "@/components/(auth)/auth-form";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
export default function Register() {
+ const posthog = usePostHog();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.REGISTER_PAGE_VISITED);
+ }, []);
+
return (
<Suspense fallback={null}>
<AuthForm type={"register"} />
diff --git a/src/client/src/app/(playground)/context/[id]/page.tsx b/src/client/src/app/(playground)/context/[id]/page.tsx
index 6dc5ac8f..8bdab0c3 100644
--- a/src/client/src/app/(playground)/context/[id]/page.tsx
+++ b/src/client/src/app/(playground)/context/[id]/page.tsx
@@ -1,4 +1,6 @@
"use client";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { KeyboardEvent, useCallback, useEffect, useState } from "react";
import { useParams } from "next/navigation";
import { toast } from "sonner";
@@ -54,6 +56,7 @@ function parseMeta(raw: any): Record<string, string> {
}
export default function ContextDetailPage() {
+ const posthog = usePostHog();
const params = useParams();
const contextId = params.id as string;
const { setHeader } = usePageHeader();
@@ -130,6 +133,10 @@ export default function ContextDetailPage() {
});
}, [contextId]);
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.CONTEXT_DETAIL_PAGE_VISITED);
+ }, []);
+
useEffect(() => {
fetchContext();
fetchLinkedRules();
diff --git a/src/client/src/app/(playground)/context/new/page.tsx b/src/client/src/app/(playground)/context/new/page.tsx
index 5b930d66..bb120059 100644
--- a/src/client/src/app/(playground)/context/new/page.tsx
+++ b/src/client/src/app/(playground)/context/new/page.tsx
@@ -1,4 +1,6 @@
"use client";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
@@ -24,6 +26,7 @@ import { toast } from "sonner";
import getMessage from "@/constants/messages";
export default function NewContextPage() {
+ const posthog = usePostHog();
const router = useRouter();
const { setHeader } = usePageHeader();
const { fireRequest, isLoading } = useFetchWrapper();
@@ -38,6 +41,7 @@ export default function NewContextPage() {
const [metaProps, setMetaProps] = useState<{ key: string; value: string }[]>([]);
useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.CONTEXT_NEW_PAGE_VISITED);
setHeader({
title: m.CONTEXT_CREATE,
breadcrumbs: [{ title: m.CONTEXT_TITLE, href: "/context" }],
diff --git a/src/client/src/app/(playground)/context/page.tsx b/src/client/src/app/(playground)/context/page.tsx
index e9c3f469..5623ec0d 100644
--- a/src/client/src/app/(playground)/context/page.tsx
+++ b/src/client/src/app/(playground)/context/page.tsx
@@ -1,4 +1,6 @@
"use client";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
import { useCallback, useEffect } from "react";
import { toast } from "sonner";
@@ -79,6 +81,7 @@ const columns: Columns<string, Context> = {
};
export default function ContextPage() {
+ const posthog = usePostHog();
const { data, fireRequest, isFetched, isLoading } =
useFetchWrapper<Context[]>();
const { fireRequest: fireDeleteRequest, isLoading: isDeleting } =
@@ -117,6 +120,10 @@ export default function ContextPage() {
[fetchData]
);
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.CONTEXT_PAGE_VISITED);
+ }, []);
+
useEffect(() => {
if (pingStatus !== "pending") {
fetchData();
diff --git a/src/client/src/app/(playground)/dashboard/page.tsx b/src/client/src/app/(playground)/dashboard/page.tsx
index c32c4e82..90806902 100644
--- a/src/client/src/app/(playground)/dashboard/page.tsx
+++ b/src/client/src/app/(playground)/dashboard/page.tsx
@@ -1,4 +1,7 @@
"use client";
+import { useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import Filter from "@/components/(playground)/filter";
import {
DashboardTypeFilter,
@@ -6,6 +9,12 @@ import {
} from "./dashboard-type";
export default function DashboardPage() {
+ const posthog = usePostHog();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.DASHBOARD_DETAIL_PAGE_VISITED);
+ }, []);
+
return (
<>
<div className="flex items-center w-full justify-between mb-4">
diff --git a/src/client/src/app/(playground)/dashboards/page.tsx b/src/client/src/app/(playground)/dashboards/page.tsx
index 7d66b265..7d25abef 100644
--- a/src/client/src/app/(playground)/dashboards/page.tsx
+++ b/src/client/src/app/(playground)/dashboards/page.tsx
@@ -1,6 +1,15 @@
"use client";
+import { useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import Explorer from "./explorer/page";
export default function DashboardPage() {
+ const posthog = usePostHog();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.DASHBOARDS_PAGE_VISITED);
+ }, []);
+
return <Explorer />;
}
diff --git a/src/client/src/app/(playground)/evaluations/page.tsx b/src/client/src/app/(playground)/evaluations/page.tsx
index aa8ee2c3..d89dc4a4 100644
--- a/src/client/src/app/(playground)/evaluations/page.tsx
+++ b/src/client/src/app/(playground)/evaluations/page.tsx
@@ -1,5 +1,18 @@
-import { redirect } from "next/navigation";
+"use client";
+
+import { useEffect } from "react";
+import { useRouter } from "next/navigation";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
export default function EvaluationsPage() {
- redirect("/evaluations/settings");
+ const posthog = usePostHog();
+ const router = useRouter();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.EVALUATIONS_PAGE_VISITED);
+ router.replace("/evaluations/settings");
+ }, []);
+
+ return null;
}
diff --git a/src/client/src/app/(playground)/evaluations/types/[id]/page.tsx b/src/client/src/app/(playground)/evaluations/types/[id]/page.tsx
index 8597a469..b426fe11 100644
--- a/src/client/src/app/(playground)/evaluations/types/[id]/page.tsx
+++ b/src/client/src/app/(playground)/evaluations/types/[id]/page.tsx
@@ -14,6 +14,8 @@ import {
import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
import { useEffect, useState } from "react";
import { EVALUATION_TYPES } from "@/constants/evaluation-types";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { Rule } from "@/types/rule-engine";
import { toast } from "sonner";
import { Link2, Plus, Trash2, ExternalLink, ArrowLeft, Sparkles } from "lucide-react";
@@ -37,6 +39,7 @@ interface EvaluationTypeConfig {
}
export default function EvaluationTypeDetailPage() {
+ const posthog = usePostHog();
const params = useParams();
const router = useRouter();
const typeId = params.id as string;
@@ -58,6 +61,7 @@ export default function EvaluationTypeDetailPage() {
.map((e) => e.rule_id);
useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.EVALUATION_TYPE_EDIT_PAGE_VISITED);
getType({
requestType: "GET",
url: `/api/evaluation/types/${typeId}`,
diff --git a/src/client/src/app/(playground)/evaluations/types/new/page.tsx b/src/client/src/app/(playground)/evaluations/types/new/page.tsx
index 1e363b25..f06a3471 100644
--- a/src/client/src/app/(playground)/evaluations/types/new/page.tsx
+++ b/src/client/src/app/(playground)/evaluations/types/new/page.tsx
@@ -1,5 +1,6 @@
"use client";
+import { useEffect, useState } from "react";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -7,11 +8,13 @@ import { Button } from "@/components/ui/button";
import { ArrowLeft, Sparkles, Info } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
-import { useState } from "react";
import { toast } from "sonner";
import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
export default function CreateCustomEvaluationTypePage() {
+ const posthog = usePostHog();
const router = useRouter();
const [typeId, setTypeId] = useState("");
const [label, setLabel] = useState("");
@@ -21,6 +24,10 @@ export default function CreateCustomEvaluationTypePage() {
const { fireRequest: getTypes } = useFetchWrapper();
const { fireRequest: saveTypes, isLoading: isSaving } = useFetchWrapper();
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.EVALUATION_TYPE_NEW_PAGE_VISITED);
+ }, []);
+
const handleCreate = async () => {
const id = typeId.trim().toLowerCase().replace(/[^a-z0-9_]/g, "_");
if (!id) {
diff --git a/src/client/src/app/(playground)/evaluations/types/page.tsx b/src/client/src/app/(playground)/evaluations/types/page.tsx
index 65f155a3..b922cc84 100644
--- a/src/client/src/app/(playground)/evaluations/types/page.tsx
+++ b/src/client/src/app/(playground)/evaluations/types/page.tsx
@@ -5,6 +5,8 @@ import { Badge } from "@/components/ui/badge";
import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
import { useEffect, useState } from "react";
import { EVALUATION_TYPES } from "@/constants/evaluation-types";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { Rule } from "@/types/rule-engine";
import { Layers, CheckCircle2, ChevronRight, ArrowLeft, Plus, Sparkles } from "lucide-react";
import Link from "next/link";
@@ -22,6 +24,7 @@ interface EvaluationTypeDisplay {
}
export default function EvaluationTypesPage() {
+ const posthog = usePostHog();
const { fireRequest: getTypes, data: typesResponse } = useFetchWrapper<
EvaluationTypeDisplay[] | { data: any[] }
>();
@@ -41,6 +44,7 @@ export default function EvaluationTypesPage() {
}, {});
useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.EVALUATION_TYPES_PAGE_VISITED);
getTypes({
requestType: "GET",
url: "/api/evaluation/types",
diff --git a/src/client/src/app/(playground)/exceptions/page.tsx b/src/client/src/app/(playground)/exceptions/page.tsx
index b195c6e9..ba62e27e 100644
--- a/src/client/src/app/(playground)/exceptions/page.tsx
+++ b/src/client/src/app/(playground)/exceptions/page.tsx
@@ -17,6 +17,8 @@ import { columns } from "@/components/(playground)/exceptions/columns";
import { getVisibilityColumnsOfPage } from "@/selectors/page";
import TracesFilter from "@/components/(playground)/filter/traces-filter";
import ExceptionsGettingStarted from "@/components/(playground)/getting-started/tracing";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
function ExceptionPage() {
const filter = useRootStore(getFilterDetails);
@@ -106,6 +108,12 @@ function ExceptionPage() {
}
export default function Page() {
+ const posthog = usePostHog();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.EXCEPTIONS_PAGE_VISITED);
+ }, []);
+
return (
<RequestProvider>
<ExceptionPage />
diff --git a/src/client/src/app/(playground)/getting-started/page.tsx b/src/client/src/app/(playground)/getting-started/page.tsx
index 4377fce8..19bf5a6f 100644
--- a/src/client/src/app/(playground)/getting-started/page.tsx
+++ b/src/client/src/app/(playground)/getting-started/page.tsx
@@ -1,8 +1,16 @@
"use client";
+import { useEffect } from "react";
import CodeBlock from "@/components/common/code-block";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
export default function GettingStarted() {
+ const posthog = usePostHog();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.GETTING_STARTED_PAGE_VISITED);
+ }, []);
const code = [
{
key: "python",
diff --git a/src/client/src/app/(playground)/onboarding/page.tsx b/src/client/src/app/(playground)/onboarding/page.tsx
index 916333ac..47a2d318 100644
--- a/src/client/src/app/(playground)/onboarding/page.tsx
+++ b/src/client/src/app/(playground)/onboarding/page.tsx
@@ -2,6 +2,8 @@
import { useState, useEffect } from "react";
import { useSession } from "next-auth/react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -30,6 +32,7 @@ import getMessage from "@/constants/messages";
import { DEFAULT_LOGGED_IN_ROUTE } from "@/constants/route";
export default function OnboardingPage() {
+ const posthog = usePostHog();
const { update: updateSession } = useSession();
const messages = getMessage();
const [orgName, setOrgName] = useState("");
@@ -44,6 +47,7 @@ export default function OnboardingPage() {
const existingMemberships = organisationList?.filter((org) => !org.isCurrent) || [];
useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.ONBOARDING_PAGE_VISITED);
// Fetch organisations and invitations on mount
fetchOrganisationList();
fetchPendingInvitations();
diff --git a/src/client/src/app/(playground)/openground/[id]/page.tsx b/src/client/src/app/(playground)/openground/[id]/page.tsx
index d719006f..d56bd212 100644
--- a/src/client/src/app/(playground)/openground/[id]/page.tsx
+++ b/src/client/src/app/(playground)/openground/[id]/page.tsx
@@ -1,4 +1,6 @@
"use client";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import OpengroundHeader from "@/components/(playground)/openground/header";
import { OpengroundRecord } from "@/lib/platform/openground-clickhouse";
import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
@@ -19,6 +21,7 @@ export default function OpengroundRequest({
}: {
params: { id: string };
}) {
+ const posthog = usePostHog();
const { data, fireRequest, isFetched, isLoading } = useFetchWrapper<OpengroundRecord>();
const fetchData = useCallback(async () => {
@@ -34,6 +37,7 @@ export default function OpengroundRequest({
}, []);
useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.OPENGROUND_DETAIL_PAGE_VISITED);
fetchData();
}, []);
diff --git a/src/client/src/app/(playground)/openground/models/page.tsx b/src/client/src/app/(playground)/openground/models/page.tsx
index e1ee4039..f755e82a 100644
--- a/src/client/src/app/(playground)/openground/models/page.tsx
+++ b/src/client/src/app/(playground)/openground/models/page.tsx
@@ -1,5 +1,18 @@
-import { redirect } from "next/navigation";
+"use client";
+
+import { useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
+import { useRouter } from "next/navigation";
export default function OpengroundModelsPage() {
- redirect("/settings/manage-models");
+ const posthog = usePostHog();
+ const router = useRouter();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.OPENGROUND_MODELS_PAGE_VISITED);
+ router.replace("/settings/manage-models");
+ }, []);
+
+ return null;
}
diff --git a/src/client/src/app/(playground)/openground/new/page.tsx b/src/client/src/app/(playground)/openground/new/page.tsx
index 35fb272d..2f6a30f6 100644
--- a/src/client/src/app/(playground)/openground/new/page.tsx
+++ b/src/client/src/app/(playground)/openground/new/page.tsx
@@ -1,5 +1,8 @@
"use client";
+import { useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { useRootStore } from "@/store";
@@ -18,6 +21,7 @@ import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
import getMessage from "@/constants/messages";
export default function OpengroundNew() {
+ const posthog = usePostHog();
const promptSource = useRootStore((state) => state.openground.promptSource);
const selectedProvidersNew = useRootStore((state) => state.openground.selectedProvidersNew);
const evaluatedResponse = useRootStore((state) => state.openground.evaluatedResponse);
@@ -27,6 +31,10 @@ export default function OpengroundNew() {
const { fireRequest: fireEvaluateRequest } = useFetchWrapper();
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.OPENGROUND_NEW_PAGE_VISITED);
+ }, []);
+
const handleEvaluate = () => {
// Validation
if (selectedProvidersNew.length === 0) {
diff --git a/src/client/src/app/(playground)/openground/page.tsx b/src/client/src/app/(playground)/openground/page.tsx
index 5bdf7b86..d5495b43 100644
--- a/src/client/src/app/(playground)/openground/page.tsx
+++ b/src/client/src/app/(playground)/openground/page.tsx
@@ -1,5 +1,7 @@
"use client";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
import Link from "next/link";
import { useCallback, useEffect } from "react";
@@ -132,6 +134,7 @@ const columns: Columns<string, OpengroundRecord> = {
}
export default function Openground() {
+ const posthog = usePostHog();
const router = useRouter();
const { data, fireRequest, isFetched, isLoading } = useFetchWrapper<OpengroundRecord[]>();
const setPromptSource = useRootStore((state) => state.openground.setPromptSource);
@@ -170,6 +173,7 @@ export default function Openground() {
}, [reset, setPromptSource, router]);
useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.OPENGROUND_PAGE_VISITED);
fetchData();
}, []);
diff --git a/src/client/src/app/(playground)/prompt-hub/[id]/page.tsx b/src/client/src/app/(playground)/prompt-hub/[id]/page.tsx
index f090e952..c07d4e4a 100644
--- a/src/client/src/app/(playground)/prompt-hub/[id]/page.tsx
+++ b/src/client/src/app/(playground)/prompt-hub/[id]/page.tsx
@@ -1,4 +1,6 @@
"use client";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import PromptHubHeader from "@/components/(playground)/prompt-hub/header";
import RuleForm from "@/components/(playground)/rule-engine/form";
import getMessage from "@/constants/messages";
@@ -43,6 +45,7 @@ import { toast } from "sonner";
const m = getMessage();
export default function PromptHub() {
+ const posthog = usePostHog();
const pingStatus = useRootStore(getPingStatus);
const params = useParams();
const searchParams = useSearchParams();
@@ -85,6 +88,10 @@ export default function PromptHub() {
});
}, [params.id]);
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.PROMPT_HUB_DETAIL_PAGE_VISITED);
+ }, []);
+
useEffect(() => {
if (pingStatus === "success") fetchData();
}, [version, pingStatus]);
diff --git a/src/client/src/app/(playground)/prompt-hub/page.tsx b/src/client/src/app/(playground)/prompt-hub/page.tsx
index 94353efe..c2cccb4a 100644
--- a/src/client/src/app/(playground)/prompt-hub/page.tsx
+++ b/src/client/src/app/(playground)/prompt-hub/page.tsx
@@ -1,5 +1,7 @@
"use client";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
import { useCallback, useEffect } from "react";
import { useRouter } from "next/navigation";
@@ -79,6 +81,7 @@ const columns: Columns<string, PromptList> = {
};
export default function PromptHub() {
+ const posthog = usePostHog();
const { data, fireRequest, isFetched, isLoading } = useFetchWrapper<PromptList[]>();
const { fireRequest: fireDeleteRequest, isLoading: isDeleting } =
useFetchWrapper();
@@ -118,6 +121,10 @@ export default function PromptHub() {
[fetchData]
);
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.PROMPT_HUB_PAGE_VISITED);
+ }, []);
+
useEffect(() => {
if (pingStatus !== "pending") {
fetchData();
diff --git a/src/client/src/app/(playground)/requests/page.tsx b/src/client/src/app/(playground)/requests/page.tsx
index 205bc693..9e2ac7c6 100644
--- a/src/client/src/app/(playground)/requests/page.tsx
+++ b/src/client/src/app/(playground)/requests/page.tsx
@@ -17,6 +17,8 @@ import { normalizeTrace } from "@/helpers/client/trace";
import { getVisibilityColumnsOfPage } from "@/selectors/page";
import TracesFilter from "@/components/(playground)/filter/traces-filter";
import TracingGettingStarted from "@/components/(playground)/getting-started/tracing";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
function RequestPage() {
const [, updateRequest] = useRequest();
@@ -123,6 +125,12 @@ function RequestPage() {
}
export default function Page() {
+ const posthog = usePostHog();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.REQUESTS_PAGE_VISITED);
+ }, []);
+
return (
<RequestProvider>
<RequestPage />
diff --git a/src/client/src/app/(playground)/rule-engine/[id]/page.tsx b/src/client/src/app/(playground)/rule-engine/[id]/page.tsx
index 8b47ae08..f586feab 100644
--- a/src/client/src/app/(playground)/rule-engine/[id]/page.tsx
+++ b/src/client/src/app/(playground)/rule-engine/[id]/page.tsx
@@ -1,5 +1,7 @@
"use client";
import { useCallback, useEffect, useState } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { useParams } from "next/navigation";
import { toast } from "sonner";
import { CheckIcon } from "lucide-react";
@@ -33,6 +35,7 @@ const DEFAULT_CONDITION_GROUP: ConditionGroupState = {
};
export default function RuleDetailPage() {
+ const posthog = usePostHog();
const params = useParams();
const ruleId = params.id as string;
const { setHeader } = usePageHeader();
@@ -93,6 +96,10 @@ export default function RuleDetailPage() {
});
}, [ruleId]);
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.RULE_ENGINE_DETAIL_PAGE_VISITED);
+ }, []);
+
useEffect(() => {
fetchRule();
}, [ruleId]);
diff --git a/src/client/src/app/(playground)/rule-engine/page.tsx b/src/client/src/app/(playground)/rule-engine/page.tsx
index a9e72003..51beee8a 100644
--- a/src/client/src/app/(playground)/rule-engine/page.tsx
+++ b/src/client/src/app/(playground)/rule-engine/page.tsx
@@ -1,6 +1,8 @@
"use client";
import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
import { useCallback, useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { toast } from "sonner";
import { format } from "date-fns";
import { useRootStore } from "@/store";
@@ -86,6 +88,7 @@ const columns: Columns<string, Rule> = {
};
export default function RuleEnginePage() {
+ const posthog = usePostHog();
const { data, fireRequest, isFetched, isLoading } =
useFetchWrapper<Rule[]>();
const { fireRequest: fireDeleteRequest, isLoading: isDeleting } =
@@ -124,6 +127,10 @@ export default function RuleEnginePage() {
[fetchData]
);
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.RULE_ENGINE_PAGE_VISITED);
+ }, []);
+
useEffect(() => {
if (pingStatus !== "pending") {
fetchData();
diff --git a/src/client/src/app/(playground)/settings/api-keys/page.tsx b/src/client/src/app/(playground)/settings/api-keys/page.tsx
index 007af839..6c06b2e3 100644
--- a/src/client/src/app/(playground)/settings/api-keys/page.tsx
+++ b/src/client/src/app/(playground)/settings/api-keys/page.tsx
@@ -1,9 +1,18 @@
"use client";
+import { useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import ManageKeys from "@/components/(playground)/api-keys/manage";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Key, Shield, RotateCcw, Trash2 } from "lucide-react";
export default function APIKeys() {
+ const posthog = usePostHog();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.SETTINGS_API_KEYS_PAGE_VISITED);
+ }, []);
+
return (
<div className="flex w-full flex-1 overflow-hidden">
<div className="flex flex-col grow w-full rounded overflow-hidden text-sm text-stone-900 dark:text-stone-300 gap-6 p-4">
diff --git a/src/client/src/app/(playground)/settings/evaluation/page.tsx b/src/client/src/app/(playground)/settings/evaluation/page.tsx
index f5ccee3b..270e48d4 100644
--- a/src/client/src/app/(playground)/settings/evaluation/page.tsx
+++ b/src/client/src/app/(playground)/settings/evaluation/page.tsx
@@ -1,5 +1,17 @@
-import { redirect } from "next/navigation";
+"use client";
+import { useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
+import { useRouter } from "next/navigation";
export default function SettingsEvaluationPage() {
- redirect("/evaluations/settings");
+ const posthog = usePostHog();
+ const router = useRouter();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.SETTINGS_EVALUATION_PAGE_VISITED);
+ router.replace("/evaluations/settings");
+ }, []);
+
+ return null;
}
diff --git a/src/client/src/app/(playground)/settings/manage-models/page.tsx b/src/client/src/app/(playground)/settings/manage-models/page.tsx
index 15877c65..98daacd3 100644
--- a/src/client/src/app/(playground)/settings/manage-models/page.tsx
+++ b/src/client/src/app/(playground)/settings/manage-models/page.tsx
@@ -1,6 +1,8 @@
"use client";
import { useState, useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { Card } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { ArrowLeftIcon, SettingsIcon } from "lucide-react";
@@ -18,6 +20,7 @@ interface CustomModel extends ModelMetadata {
}
export default function SettingsManageModelsPage() {
+ const posthog = usePostHog();
const router = useRouter();
const [selectedProvider, setSelectedProvider] = useState<string | null>(null);
const [selectedModel, setSelectedModel] = useState<ModelMetadata | null>(null);
@@ -29,6 +32,10 @@ export default function SettingsManageModelsPage() {
const { data: customModels, fireRequest: fetchCustomModels, isLoading: loadingCustom } =
useFetchWrapper<Record<string, CustomModel[]>>();
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.SETTINGS_MANAGE_MODELS_PAGE_VISITED);
+ }, []);
+
useEffect(() => {
loadProviders();
loadAllCustomModels();
diff --git a/src/client/src/app/(playground)/settings/organisation/page.tsx b/src/client/src/app/(playground)/settings/organisation/page.tsx
index 3264bcc0..914e5a8e 100644
--- a/src/client/src/app/(playground)/settings/organisation/page.tsx
+++ b/src/client/src/app/(playground)/settings/organisation/page.tsx
@@ -1,6 +1,8 @@
"use client";
import { useState, useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -103,6 +105,7 @@ interface PendingInvite {
}
export default function OrganisationSettingsPage() {
+ const posthog = usePostHog();
const router = useRouter();
const messages = getMessage();
const currentOrg = useRootStore(getCurrentOrganisation);
@@ -130,6 +133,10 @@ export default function OrganisationSettingsPage() {
const currentUserRole = currentUserMember?.role;
const hasAdminPermissions = currentUserRole === 'owner' || currentUserRole === 'admin';
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.SETTINGS_ORGANISATION_PAGE_VISITED);
+ }, []);
+
// Fetch organisations on mount
useEffect(() => {
const fetchData = async () => {
diff --git a/src/client/src/app/(playground)/settings/page.tsx b/src/client/src/app/(playground)/settings/page.tsx
index 9324c336..27e7feae 100644
--- a/src/client/src/app/(playground)/settings/page.tsx
+++ b/src/client/src/app/(playground)/settings/page.tsx
@@ -1,5 +1,17 @@
-import { redirect } from 'next/navigation'
+"use client";
+import { useEffect } from "react";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
+import { useRouter } from "next/navigation";
export default function DefaultSettingsPage() {
- redirect('/settings/profile')
+ const posthog = usePostHog();
+ const router = useRouter();
+
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.SETTINGS_PAGE_VISITED);
+ router.replace("/settings/profile");
+ }, []);
+
+ return null;
}
\ No newline at end of file
diff --git a/src/client/src/app/(playground)/vault/page.tsx b/src/client/src/app/(playground)/vault/page.tsx
index 5b8e5328..e150c95e 100644
--- a/src/client/src/app/(playground)/vault/page.tsx
+++ b/src/client/src/app/(playground)/vault/page.tsx
@@ -1,4 +1,6 @@
"use client";
+import { usePostHog } from "posthog-js/react";
+import { CLIENT_EVENTS } from "@/constants/events";
import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
import { useCallback, useEffect } from "react";
import { toast } from "sonner";
@@ -57,6 +59,7 @@ const columns: Columns<string, Secret> = {
}
export default function Vault() {
+ const posthog = usePostHog();
const { data, fireRequest, isFetched, isLoading } = useFetchWrapper<Secret[]>();
const { fireRequest: fireDeleteRequest, isLoading: isDeleting } =
useFetchWrapper();
@@ -95,6 +98,10 @@ export default function Vault() {
[fetchData]
);
+ useEffect(() => {
+ posthog?.capture(CLIENT_EVENTS.VAULT_PAGE_VISITED);
+ }, []);
+
useEffect(() => {
if (pingStatus !== "pending") {
fetchData();
diff --git a/src/client/src/app/api/context/[id]/route.ts b/src/client/src/app/api/context/[id]/route.ts
index 8f58a76d..8a3d2545 100644
--- a/src/client/src/app/api/context/[id]/route.ts
+++ b/src/client/src/app/api/context/[id]/route.ts
@@ -1,18 +1,30 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { ContextInput } from "@/types/context";
import { getContextById, updateContext, deleteContext } from "@/lib/platform/context";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
export async function GET(_: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const { err, data }: any = await getContextById(id);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_GET_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_GET_SUCCESS,
+ startTimestamp,
+ });
return Response.json(data);
}
export async function PUT(request: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const formData = await request.json();
@@ -27,18 +39,35 @@ export async function PUT(request: Request, context: any) {
const [err, res]: any = await asaw(updateContext(id, contextInput));
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_UPDATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_UPDATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
export async function DELETE(_: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const [err, res] = await deleteContext(id);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_DELETE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_DELETE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/context/route.ts b/src/client/src/app/api/context/route.ts
index bab15a98..eabd817d 100644
--- a/src/client/src/app/api/context/route.ts
+++ b/src/client/src/app/api/context/route.ts
@@ -1,17 +1,29 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { ContextInput } from "@/types/context";
import { getContexts, createContext } from "@/lib/platform/context";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
export async function GET() {
+ const startTimestamp = Date.now();
const { err, data }: any = await getContexts();
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_LIST_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_LIST_SUCCESS,
+ startTimestamp,
+ });
return Response.json(data);
}
export async function POST(request: Request) {
+ const startTimestamp = Date.now();
const formData = await request.json();
const contextInput: Partial<ContextInput> = {
@@ -25,8 +37,16 @@ export async function POST(request: Request) {
const [err, res]: any = await asaw(createContext(contextInput));
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_CREATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.CONTEXT_CREATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/evaluation/[spanId]/feedback/route.ts b/src/client/src/app/api/evaluation/[spanId]/feedback/route.ts
index d15c6bce..9d60cfb4 100644
--- a/src/client/src/app/api/evaluation/[spanId]/feedback/route.ts
+++ b/src/client/src/app/api/evaluation/[spanId]/feedback/route.ts
@@ -1,9 +1,12 @@
import { storeManualFeedback } from "@/lib/platform/evaluation";
+import { SERVER_EVENTS } from "@/constants/events";
+import PostHogServer from "@/lib/posthog";
export async function POST(
request: Request,
{ params }: { params: { spanId: string } }
) {
+ const startTimestamp = Date.now();
const { spanId } = params;
const body = await request.json();
const { rating, comment } = body as {
@@ -25,7 +28,15 @@ export async function POST(
);
if (res?.err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_FEEDBACK_FAILURE,
+ startTimestamp,
+ });
return Response.json(res, { status: 500 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_FEEDBACK_SUCCESS,
+ startTimestamp,
+ });
return Response.json({ success: true });
}
diff --git a/src/client/src/app/api/evaluation/[spanId]/route.ts b/src/client/src/app/api/evaluation/[spanId]/route.ts
index 8bcd795f..a2517eb2 100644
--- a/src/client/src/app/api/evaluation/[spanId]/route.ts
+++ b/src/client/src/app/api/evaluation/[spanId]/route.ts
@@ -1,13 +1,20 @@
import { getEvaluationsForSpanId, setEvaluationsForSpanId } from "@/lib/platform/evaluation";
+import { SERVER_EVENTS } from "@/constants/events";
+import PostHogServer from "@/lib/posthog";
import { NextRequest } from "next/server";
export async function GET(
_: NextRequest,
{ params }: { params: { spanId: string } }
) {
+ const startTimestamp = Date.now();
const { spanId } = params;
const res: any = await getEvaluationsForSpanId(spanId);
+ PostHogServer.fireEvent({
+ event: res.err ? SERVER_EVENTS.EVALUATION_GET_FAILURE : SERVER_EVENTS.EVALUATION_GET_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
@@ -15,9 +22,14 @@ export async function POST(
request: Request,
{ params }: { params: { spanId: string } }
) {
+ const startTimestamp = Date.now();
const { spanId } = params;
const res: any = await setEvaluationsForSpanId(spanId);
+ PostHogServer.fireEvent({
+ event: res.err ? SERVER_EVENTS.EVALUATION_CREATE_FAILURE : SERVER_EVENTS.EVALUATION_CREATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/evaluation/config/route.ts b/src/client/src/app/api/evaluation/config/route.ts
index 4e826ddf..356f6920 100644
--- a/src/client/src/app/api/evaluation/config/route.ts
+++ b/src/client/src/app/api/evaluation/config/route.ts
@@ -2,16 +2,24 @@ import {
getEvaluationConfig,
setEvaluationConfig,
} from "@/lib/platform/evaluation/config";
+import { SERVER_EVENTS } from "@/constants/events";
+import PostHogServer from "@/lib/posthog";
import { EvaluationConfigInput } from "@/types/evaluation";
import { NextRequest } from "next/server";
import asaw from "@/utils/asaw";
export async function GET(_: NextRequest) {
+ const startTimestamp = Date.now();
const res: any = await getEvaluationConfig(undefined, true, false);
+ PostHogServer.fireEvent({
+ event: res.err ? SERVER_EVENTS.EVALUATION_CONFIG_GET_FAILURE : SERVER_EVENTS.EVALUATION_CONFIG_GET_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
export async function POST(request: NextRequest) {
+ const startTimestamp = Date.now();
const formData = await request.json();
const evaluationConfig: EvaluationConfigInput = {
id: formData.id,
@@ -28,10 +36,18 @@ export async function POST(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_CONFIG_CREATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, {
status: 400,
});
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_CONFIG_CREATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(data);
}
diff --git a/src/client/src/app/api/evaluation/llm/[evalType]/route.ts b/src/client/src/app/api/evaluation/llm/[evalType]/route.ts
index 00c391c3..ccca0ea3 100644
--- a/src/client/src/app/api/evaluation/llm/[evalType]/route.ts
+++ b/src/client/src/app/api/evaluation/llm/[evalType]/route.ts
@@ -4,12 +4,15 @@ import {
validateMetricsRequest,
validateMetricsRequestType,
} from "@/helpers/server/platform";
+import { SERVER_EVENTS } from "@/constants/events";
+import PostHogServer from "@/lib/posthog";
import { NextRequest } from "next/server";
export async function POST(
request: NextRequest,
{ params: { evalType } }: { params: { evalType: string } }
) {
+ const startTimestamp = Date.now();
const formData = await request.json();
const timeLimit = formData.timeLimit as TimeLimit;
@@ -28,5 +31,9 @@ export async function POST(
});
const res: any = await getEvaluationDetectedByType(params, evalType);
+ PostHogServer.fireEvent({
+ event: res.err ? SERVER_EVENTS.EVALUATION_LLM_RUN_FAILURE : SERVER_EVENTS.EVALUATION_LLM_RUN_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/evaluation/types/[id]/route.ts b/src/client/src/app/api/evaluation/types/[id]/route.ts
index cf735f6f..a5dccb0a 100644
--- a/src/client/src/app/api/evaluation/types/[id]/route.ts
+++ b/src/client/src/app/api/evaluation/types/[id]/route.ts
@@ -1,5 +1,7 @@
import { getEvaluationConfig } from "@/lib/platform/evaluation/config";
import { syncRuleEntitiesFromConfig } from "@/lib/platform/evaluation/sync-rule-entities";
+import { SERVER_EVENTS } from "@/constants/events";
+import PostHogServer from "@/lib/posthog";
import { NextRequest } from "next/server";
import asaw from "@/utils/asaw";
import { jsonParse, jsonStringify } from "@/utils/json";
@@ -34,9 +36,14 @@ export async function GET(
_: NextRequest,
{ params }: { params: { id: string } }
) {
+ const startTimestamp = Date.now();
const typeId = params.id;
const [err, config] = await asaw(getEvaluationConfig(undefined, true, false));
if (err || !config?.id) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_GET_FAILURE,
+ startTimestamp,
+ });
return Response.json(
{ err: "Evaluation config not found" },
{ status: 404 }
@@ -45,11 +52,19 @@ export async function GET(
const types = (config as any).evaluationTypes ?? [];
const typeConfig = types.find((t: any) => t.id === typeId);
if (!typeConfig) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_GET_FAILURE,
+ startTimestamp,
+ });
return Response.json(
{ err: "Evaluation type not found" },
{ status: 404 }
);
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_GET_SUCCESS,
+ startTimestamp,
+ });
return Response.json({ data: typeConfig });
}
@@ -57,10 +72,15 @@ export async function PATCH(
request: NextRequest,
{ params }: { params: { id: string } }
) {
+ const startTimestamp = Date.now();
const typeId = params.id;
const body = await request.json();
const [err, config] = await asaw(getEvaluationConfig(undefined, true, false));
if (err || !config?.id) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_UPDATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(
{ err: "Evaluation config not found" },
{ status: 400 }
@@ -95,6 +115,10 @@ export async function PATCH(
data: { meta: jsonStringify(meta) },
});
await syncRuleEntitiesFromConfig();
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_UPDATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json({ data: updated });
}
@@ -102,9 +126,14 @@ export async function DELETE(
_: NextRequest,
{ params }: { params: { id: string } }
) {
+ const startTimestamp = Date.now();
const typeId = params.id;
const [err, config] = await asaw(getEvaluationConfig(undefined, true, false));
if (err || !config?.id) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_DELETE_FAILURE,
+ startTimestamp,
+ });
return Response.json(
{ err: "Evaluation config not found" },
{ status: 400 }
@@ -117,6 +146,10 @@ export async function DELETE(
const typeToDelete = types.find((t) => t.id === typeId);
if (!typeToDelete?.isCustom) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_DELETE_FAILURE,
+ startTimestamp,
+ });
return Response.json(
{ err: "Only custom evaluation types can be deleted" },
{ status: 400 }
@@ -129,5 +162,9 @@ export async function DELETE(
data: { meta: jsonStringify(meta) },
});
await syncRuleEntitiesFromConfig();
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_DELETE_SUCCESS,
+ startTimestamp,
+ });
return Response.json({ data: { deleted: typeId } });
}
diff --git a/src/client/src/app/api/evaluation/types/route.ts b/src/client/src/app/api/evaluation/types/route.ts
index 42757396..88173412 100644
--- a/src/client/src/app/api/evaluation/types/route.ts
+++ b/src/client/src/app/api/evaluation/types/route.ts
@@ -1,5 +1,7 @@
import { getEvaluationConfig } from "@/lib/platform/evaluation/config";
import { syncRuleEntitiesFromConfig } from "@/lib/platform/evaluation/sync-rule-entities";
+import { SERVER_EVENTS } from "@/constants/events";
+import PostHogServer from "@/lib/posthog";
import { NextRequest } from "next/server";
import asaw from "@/utils/asaw";
import { jsonParse, jsonStringify } from "@/utils/json";
@@ -49,8 +51,13 @@ function normalizeTypeConfig(t: any): EvaluationTypeConfig {
}
export async function GET(_: NextRequest) {
+ const startTimestamp = Date.now();
const [err, config] = await asaw(getEvaluationConfig(undefined, true, false));
if (err || !config?.id) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_LIST_FAILURE,
+ startTimestamp,
+ });
return Response.json(
{ err: "Evaluation config not found", data: [] },
{ status: 200 }
@@ -58,18 +65,31 @@ export async function GET(_: NextRequest) {
}
const types = (config as any).evaluationTypes ?? [];
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_LIST_SUCCESS,
+ startTimestamp,
+ });
return Response.json({ data: types });
}
export async function POST(request: NextRequest) {
+ const startTimestamp = Date.now();
const body = await request.json();
const types = body.types as any[] | undefined;
if (!Array.isArray(types)) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_CREATE_FAILURE,
+ startTimestamp,
+ });
return Response.json({ err: "Invalid types array" }, { status: 400 });
}
const [err, config] = await asaw(getEvaluationConfig(undefined, true, false));
if (err || !config?.id) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_CREATE_FAILURE,
+ startTimestamp,
+ });
return Response.json({ err: "Evaluation config not found" }, { status: 400 });
}
@@ -86,5 +106,9 @@ export async function POST(request: NextRequest) {
await syncRuleEntitiesFromConfig();
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.EVALUATION_TYPE_CREATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json({ data: normalizedTypes });
}
diff --git a/src/client/src/app/api/fleet-hub/[id]/config/route.ts b/src/client/src/app/api/fleet-hub/[id]/config/route.ts
index 5a45b551..a8969fc9 100644
--- a/src/client/src/app/api/fleet-hub/[id]/config/route.ts
+++ b/src/client/src/app/api/fleet-hub/[id]/config/route.ts
@@ -1,16 +1,27 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { updateAgentConfig } from "@/lib/platform/fleet-hub";
+import PostHogServer from "@/lib/posthog";
export async function POST(request: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const { config } = await request.json();
const res = await updateAgentConfig(id, config);
// Check if there was an error from the OpAMP server
if (res.err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.FLEET_HUB_CONFIG_UPDATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(res.err,
{ status: res.status || 500 }
);
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.FLEET_HUB_CONFIG_UPDATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
\ No newline at end of file
diff --git a/src/client/src/app/api/fleet-hub/[id]/route.ts b/src/client/src/app/api/fleet-hub/[id]/route.ts
index 12f7a716..50643213 100644
--- a/src/client/src/app/api/fleet-hub/[id]/route.ts
+++ b/src/client/src/app/api/fleet-hub/[id]/route.ts
@@ -1,7 +1,14 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { getAgentByInstanceId } from "@/lib/platform/fleet-hub";
+import PostHogServer from "@/lib/posthog";
export async function GET(_: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const res = await getAgentByInstanceId(id);
+ PostHogServer.fireEvent({
+ event: res.err ? SERVER_EVENTS.FLEET_HUB_GET_FAILURE : SERVER_EVENTS.FLEET_HUB_GET_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/fleet-hub/[id]/tls-connection/route.ts b/src/client/src/app/api/fleet-hub/[id]/tls-connection/route.ts
index 96543011..6d0db7ca 100644
--- a/src/client/src/app/api/fleet-hub/[id]/tls-connection/route.ts
+++ b/src/client/src/app/api/fleet-hub/[id]/tls-connection/route.ts
@@ -1,8 +1,15 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { updateTlsConnection } from "@/lib/platform/fleet-hub";
+import PostHogServer from "@/lib/posthog";
export async function POST(request: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const { tlsMin } = await request.json();
const res = await updateTlsConnection(id, tlsMin);
+ PostHogServer.fireEvent({
+ event: res.err ? SERVER_EVENTS.FLEET_HUB_TLS_CONNECTION_FAILURE : SERVER_EVENTS.FLEET_HUB_TLS_CONNECTION_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
\ No newline at end of file
diff --git a/src/client/src/app/api/fleet-hub/route.ts b/src/client/src/app/api/fleet-hub/route.ts
index 1b3731fb..9a07a59b 100644
--- a/src/client/src/app/api/fleet-hub/route.ts
+++ b/src/client/src/app/api/fleet-hub/route.ts
@@ -1,6 +1,13 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { getAllAgents } from "@/lib/platform/fleet-hub";
+import PostHogServer from "@/lib/posthog";
export async function GET() {
+ const startTimestamp = Date.now();
const res: any = await getAllAgents();
+ PostHogServer.fireEvent({
+ event: res.err ? SERVER_EVENTS.FLEET_HUB_LIST_FAILURE : SERVER_EVENTS.FLEET_HUB_LIST_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
\ No newline at end of file
diff --git a/src/client/src/app/api/manage-dashboard/query/run/route.ts b/src/client/src/app/api/manage-dashboard/query/run/route.ts
index 0c471813..f7165e82 100644
--- a/src/client/src/app/api/manage-dashboard/query/run/route.ts
+++ b/src/client/src/app/api/manage-dashboard/query/run/route.ts
@@ -1,6 +1,6 @@
-// import { SERVER_EVENTS } from "@/constants/events";
+import { SERVER_EVENTS } from "@/constants/events";
import { runWidgetQuery } from "@/lib/platform/manage-dashboard/widget";
-// import PostHogServer from "@/lib/posthog";
+import PostHogServer from "@/lib/posthog";
import { NextRequest } from "next/server";
export async function POST(request: NextRequest) {
@@ -14,10 +14,9 @@ export async function POST(request: NextRequest) {
userQuery,
filter,
});
- // Commenting out PostHogServer.fireEvent to avoid sending events to PostHog
- // PostHogServer.fireEvent({
- // event: res.err ? SERVER_EVENTS.DASHBOARD_QUERY_RUN_FAILURE : SERVER_EVENTS.DASHBOARD_QUERY_RUN_SUCCESS,
- // startTimestamp,
- // });
+ PostHogServer.fireEvent({
+ event: res.err ? SERVER_EVENTS.DASHBOARD_QUERY_RUN_FAILURE : SERVER_EVENTS.DASHBOARD_QUERY_RUN_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/openground/[id]/route.ts b/src/client/src/app/api/openground/[id]/route.ts
index 74ab702d..412062ac 100644
--- a/src/client/src/app/api/openground/[id]/route.ts
+++ b/src/client/src/app/api/openground/[id]/route.ts
@@ -1,10 +1,13 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { getOpengroundEvaluationById } from "@/lib/platform/openground-clickhouse";
import { getCurrentUser } from "@/lib/session";
import { getDBConfigByUser } from "@/lib/db-config";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
import getMessage from "@/constants/messages";
export async function GET(_: Request, { params }: { params: { id: string } }) {
+ const startTimestamp = Date.now();
const user = await getCurrentUser();
if (!user) {
return Response.json({ error: getMessage().UNAUTHORIZED_USER }, { status: 401 });
@@ -21,8 +24,16 @@ export async function GET(_: Request, { params }: { params: { id: string } }) {
const { data, err } = await getOpengroundEvaluationById(params.id, dbConfig.id);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_GET_FAILURE,
+ startTimestamp,
+ });
return Response.json({ error: err }, { status: 404 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_GET_SUCCESS,
+ startTimestamp,
+ });
return Response.json(data);
}
diff --git a/src/client/src/app/api/openground/config/route.ts b/src/client/src/app/api/openground/config/route.ts
index 5cfa3e75..45a6c4d0 100644
--- a/src/client/src/app/api/openground/config/route.ts
+++ b/src/client/src/app/api/openground/config/route.ts
@@ -1,6 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
+import { SERVER_EVENTS } from "@/constants/events";
import { getCurrentUser } from "@/lib/session";
import { getDBConfigByUser } from "@/lib/db-config";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
import {
getOpenGroundConfigs,
@@ -15,6 +17,7 @@ import * as messages from "@/constants/messages/en";
* Get all provider configurations for the current user
*/
export async function GET(request: NextRequest) {
+ const startTimestamp = Date.now();
try {
const user = await getCurrentUser();
if (!user) {
@@ -35,11 +38,23 @@ export async function GET(request: NextRequest) {
const { data, err } = await getOpenGroundConfigs(user.id, dbConfig.id);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_GET_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json({ error: err }, { status: 500 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_GET_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json(data);
} catch (error: any) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_GET_FAILURE,
+ startTimestamp,
+ });
console.error("Config GET error:", error);
return NextResponse.json(
{ error: messages.OPERATION_FAILED },
@@ -53,6 +68,7 @@ export async function GET(request: NextRequest) {
* Create or update a provider configuration
*/
export async function POST(request: NextRequest) {
+ const startTimestamp = Date.now();
try {
const user = await getCurrentUser();
if (!user) {
@@ -90,11 +106,23 @@ export async function POST(request: NextRequest) {
});
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_CREATE_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json({ error: err }, { status: 500 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_CREATE_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json(data);
} catch (error: any) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_CREATE_FAILURE,
+ startTimestamp,
+ });
console.error("Config POST error:", error);
return NextResponse.json(
{ error: messages.OPERATION_FAILED },
@@ -108,6 +136,7 @@ export async function POST(request: NextRequest) {
* Delete a provider configuration
*/
export async function DELETE(request: NextRequest) {
+ const startTimestamp = Date.now();
try {
const user = await getCurrentUser();
if (!user) {
@@ -138,11 +167,23 @@ export async function DELETE(request: NextRequest) {
const { data, err } = await deleteOpenGroundConfig(configId, user.id, dbConfig.id);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_DELETE_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json({ error: err }, { status: 500 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_DELETE_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json({ message: data });
} catch (error: any) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_DELETE_FAILURE,
+ startTimestamp,
+ });
console.error("Config DELETE error:", error);
return NextResponse.json(
{ error: messages.OPERATION_FAILED },
@@ -156,6 +197,7 @@ export async function DELETE(request: NextRequest) {
* Toggle active status of a configuration
*/
export async function PATCH(request: NextRequest) {
+ const startTimestamp = Date.now();
try {
const user = await getCurrentUser();
if (!user) {
@@ -191,11 +233,23 @@ export async function PATCH(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_UPDATE_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json({ error: err }, { status: 500 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_UPDATE_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json(data);
} catch (error: any) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CONFIG_UPDATE_FAILURE,
+ startTimestamp,
+ });
console.error("Config PATCH error:", error);
return NextResponse.json(
{ error: messages.OPERATION_FAILED },
diff --git a/src/client/src/app/api/openground/models/route.ts b/src/client/src/app/api/openground/models/route.ts
index 20644af2..c30a59b9 100644
--- a/src/client/src/app/api/openground/models/route.ts
+++ b/src/client/src/app/api/openground/models/route.ts
@@ -1,9 +1,11 @@
import { NextRequest, NextResponse } from "next/server";
import { getServerSession } from "next-auth";
+import { SERVER_EVENTS } from "@/constants/events";
import { authOptions } from "@/app/auth";
import { dataCollector } from "@/lib/platform/common";
import { getDBConfigByUser } from "@/lib/db-config";
import getMessage from "@/constants/messages";
+import PostHogServer from "@/lib/posthog";
import Sanitizer from "@/utils/sanitizer";
import { OPENLIT_OPENGROUND_CUSTOM_MODELS_TABLE_NAME } from "@/lib/platform/openground/table-details";
import asaw from "@/utils/asaw";
@@ -20,6 +22,7 @@ interface SessionWithId {
// GET: List all custom models for a provider (or all providers if no provider specified)
export async function GET(request: NextRequest) {
+ const startTimestamp = Date.now();
const session = (await getServerSession(authOptions)) as SessionWithId;
if (!session?.user?.id) {
@@ -65,6 +68,10 @@ export async function GET(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_LIST_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json(
{ error: getMessage().OPERATION_FAILED },
{ status: 500 }
@@ -98,6 +105,10 @@ export async function GET(request: NextRequest) {
console.log("GET /api/openground/models - Returning grouped models:", JSON.stringify(grouped, null, 2));
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_LIST_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json(grouped);
}
@@ -126,6 +137,10 @@ export async function GET(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_LIST_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json(
{ error: getMessage().OPERATION_FAILED },
{ status: 500 }
@@ -142,11 +157,16 @@ export async function GET(request: NextRequest) {
return isValid;
});
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_LIST_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json(validModels);
}
// POST: Create or update a custom model
export async function POST(request: NextRequest) {
+ const startTimestamp = Date.now();
const session = (await getServerSession(authOptions)) as SessionWithId;
if (!session?.user?.id) {
@@ -218,6 +238,10 @@ export async function POST(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_CREATE_FAILURE,
+ startTimestamp,
+ });
console.error("Error updating model:", err);
return NextResponse.json(
{ error: err || getMessage().OPERATION_FAILED },
@@ -225,6 +249,10 @@ export async function POST(request: NextRequest) {
);
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_CREATE_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json({ success: true, updated: true });
}
@@ -251,6 +279,10 @@ export async function POST(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_CREATE_FAILURE,
+ startTimestamp,
+ });
console.error("Error inserting custom model:", err);
return NextResponse.json(
{ error: err || getMessage().OPERATION_FAILED },
@@ -286,6 +318,10 @@ export async function POST(request: NextRequest) {
console.log("Newly created model:", JSON.stringify(newModel, null, 2));
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_CREATE_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json({
success: true,
created: true,
@@ -295,6 +331,7 @@ export async function POST(request: NextRequest) {
// DELETE: Remove a custom model
export async function DELETE(request: NextRequest) {
+ const startTimestamp = Date.now();
const session = (await getServerSession(authOptions)) as SessionWithId;
if (!session?.user?.id) {
@@ -350,6 +387,10 @@ export async function DELETE(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_DELETE_FAILURE,
+ startTimestamp,
+ });
console.error("Delete error:", err);
return NextResponse.json(
{ error: err || getMessage().OPERATION_FAILED },
@@ -357,5 +398,9 @@ export async function DELETE(request: NextRequest) {
);
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_MODELS_DELETE_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json({ success: true, deleted: true });
}
diff --git a/src/client/src/app/api/openground/providers/route.ts b/src/client/src/app/api/openground/providers/route.ts
index b181ebc6..353c28e1 100644
--- a/src/client/src/app/api/openground/providers/route.ts
+++ b/src/client/src/app/api/openground/providers/route.ts
@@ -1,7 +1,9 @@
import { NextRequest, NextResponse } from "next/server";
+import { SERVER_EVENTS } from "@/constants/events";
import { getCurrentUser } from "@/lib/session";
import { getDBConfigByUser } from "@/lib/db-config";
import getMessage from "@/constants/messages";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
import {
getAllProvidersWithCustomModels,
@@ -14,6 +16,7 @@ import {
* Get all available LLM providers with custom models merged in
*/
export async function GET(request: NextRequest) {
+ const startTimestamp = Date.now();
try {
const user = await getCurrentUser();
if (!user) {
@@ -45,9 +48,17 @@ export async function GET(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_PROVIDERS_LIST_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json({ error: err }, { status: 404 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_PROVIDERS_LIST_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json(provider);
}
@@ -60,9 +71,17 @@ export async function GET(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_PROVIDERS_LIST_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json({ error: err }, { status: 500 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_PROVIDERS_LIST_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json(providers);
}
@@ -73,11 +92,23 @@ export async function GET(request: NextRequest) {
);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_PROVIDERS_LIST_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json({ error: err }, { status: 500 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_PROVIDERS_LIST_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json(providers);
} catch (error: any) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_PROVIDERS_LIST_FAILURE,
+ startTimestamp,
+ });
console.error("Providers GET error:", error);
return NextResponse.json(
{ error: getMessage().OPERATION_FAILED },
diff --git a/src/client/src/app/api/openground/route.ts b/src/client/src/app/api/openground/route.ts
index 92d84153..a28ea239 100644
--- a/src/client/src/app/api/openground/route.ts
+++ b/src/client/src/app/api/openground/route.ts
@@ -1,11 +1,14 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { evaluate } from "@/lib/platform/openground/evaluate";
import { getOpengroundEvaluations } from "@/lib/platform/openground-clickhouse";
import { getCurrentUser } from "@/lib/session";
import { getDBConfigByUser } from "@/lib/db-config";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
import getMessage from "@/constants/messages";
export async function GET() {
+ const startTimestamp = Date.now();
const user = await getCurrentUser();
if (!user) {
return Response.json({ error: getMessage().UNAUTHORIZED_USER }, { status: 401 });
@@ -25,13 +28,22 @@ export async function GET() {
});
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_LIST_FAILURE,
+ startTimestamp,
+ });
return Response.json({ error: err }, { status: 500 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_LIST_SUCCESS,
+ startTimestamp,
+ });
return Response.json(data);
}
export async function POST(request: Request) {
+ const startTimestamp = Date.now();
const user = await getCurrentUser();
if (!user) {
return Response.json({ error: getMessage().UNAUTHORIZED_USER }, { status: 401 });
@@ -63,8 +75,16 @@ export async function POST(request: Request) {
});
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CREATE_FAILURE,
+ startTimestamp,
+ });
return Response.json({ error: err }, { status: 500 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.OPENGROUND_CREATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(data);
}
diff --git a/src/client/src/app/api/rule-engine/entities/route.ts b/src/client/src/app/api/rule-engine/entities/route.ts
index 82f3a3c9..134184f8 100644
--- a/src/client/src/app/api/rule-engine/entities/route.ts
+++ b/src/client/src/app/api/rule-engine/entities/route.ts
@@ -1,12 +1,15 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { RuleEntityInput } from "@/types/rule-engine";
import { getRuleEntities, addRuleEntity, deleteRuleEntity } from "@/lib/platform/rule-engine";
import {
addRuleToEvaluationType,
removeRuleFromEvaluationType,
} from "@/lib/platform/evaluation/sync-rule-entities";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
export async function GET(request: Request) {
+ const startTimestamp = Date.now();
const { searchParams } = new URL(request.url);
const filters = {
rule_id: searchParams.get("rule_id") || undefined,
@@ -16,13 +19,22 @@ export async function GET(request: Request) {
const { err, data }: any = await getRuleEntities(filters);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_ENTITIES_LIST_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_ENTITIES_LIST_SUCCESS,
+ startTimestamp,
+ });
return Response.json(data);
}
export async function POST(request: Request) {
+ const startTimestamp = Date.now();
const formData = await request.json();
const entityInput: Partial<RuleEntityInput> = {
@@ -33,6 +45,10 @@ export async function POST(request: Request) {
const [err, res]: any = await asaw(addRuleEntity(entityInput));
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_ENTITIES_CREATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
if (
@@ -46,10 +62,15 @@ export async function POST(request: Request) {
0
);
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_ENTITIES_CREATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
export async function DELETE(request: Request) {
+ const startTimestamp = Date.now();
const { searchParams } = new URL(request.url);
let id = searchParams.get("id");
if (!id) {
@@ -67,6 +88,10 @@ export async function DELETE(request: Request) {
const [err, res] = await deleteRuleEntity(id);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_ENTITIES_DELETE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
if (
@@ -77,5 +102,9 @@ export async function DELETE(request: Request) {
) {
await removeRuleFromEvaluationType(entity.rule_id, entity.entity_id);
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_ENTITIES_DELETE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/rule-engine/evaluate/route.ts b/src/client/src/app/api/rule-engine/evaluate/route.ts
index f5e9e209..7e66e507 100644
--- a/src/client/src/app/api/rule-engine/evaluate/route.ts
+++ b/src/client/src/app/api/rule-engine/evaluate/route.ts
@@ -1,11 +1,14 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { EvaluateInput } from "@/types/rule-engine";
import { evaluateRules } from "@/lib/platform/rule-engine/evaluate";
import { getAPIKeyInfo } from "@/lib/platform/api-keys";
import { getCurrentUser } from "@/lib/session";
import getMessage from "@/constants/messages";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
export async function POST(request: Request) {
+ const startTimestamp = Date.now();
// --- Authentication ---
// Prefer Bearer token (external API usage); fall back to session auth.
const authorizationHeader = request.headers.get("Authorization") || "";
@@ -109,10 +112,18 @@ export async function POST(request: Request) {
const [err, res]: any = await asaw(evaluateRules(evaluateInput, databaseConfigId));
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_EVALUATE_FAILURE,
+ startTimestamp,
+ });
// Return a generic message — do not expose internal ClickHouse errors to callers.
return Response.json({ err: "Failed to evaluate rules" }, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_EVALUATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/rule-engine/field-values/route.ts b/src/client/src/app/api/rule-engine/field-values/route.ts
index 594f8393..4254d808 100644
--- a/src/client/src/app/api/rule-engine/field-values/route.ts
+++ b/src/client/src/app/api/rule-engine/field-values/route.ts
@@ -1,6 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
+import { SERVER_EVENTS } from "@/constants/events";
import { getCurrentUser } from "@/lib/session";
import { dataCollector, OTEL_TRACES_TABLE_NAME } from "@/lib/platform/common";
+import PostHogServer from "@/lib/posthog";
// Maps condition field names to ClickHouse column expressions
const FIELD_COLUMN_MAP: Record<string, string> = {
@@ -15,6 +17,7 @@ const FIELD_COLUMN_MAP: Record<string, string> = {
};
export async function GET(request: NextRequest) {
+ const startTimestamp = Date.now();
const user = await getCurrentUser();
if (!user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
@@ -37,9 +40,17 @@ export async function GET(request: NextRequest) {
const { data, err } = await dataCollector({ query }, "query");
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_FIELD_VALUES_FAILURE,
+ startTimestamp,
+ });
return NextResponse.json({ values: [] });
}
const values = ((data as any[]) || []).map((row: any) => String(row.val)).filter(Boolean);
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_FIELD_VALUES_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json({ values });
}
diff --git a/src/client/src/app/api/rule-engine/rules/[id]/conditions/route.ts b/src/client/src/app/api/rule-engine/rules/[id]/conditions/route.ts
index 0035ff31..c24e28b6 100644
--- a/src/client/src/app/api/rule-engine/rules/[id]/conditions/route.ts
+++ b/src/client/src/app/api/rule-engine/rules/[id]/conditions/route.ts
@@ -1,8 +1,11 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { RuleConditionGroupInput } from "@/types/rule-engine";
import { addConditionGroupsToRule } from "@/lib/platform/rule-engine";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
export async function POST(request: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const formData = await request.json();
@@ -10,8 +13,16 @@ export async function POST(request: Request, context: any) {
const [err, res]: any = await asaw(addConditionGroupsToRule(id, conditionGroups));
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_CONDITIONS_UPDATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_CONDITIONS_UPDATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/rule-engine/rules/[id]/preview/route.ts b/src/client/src/app/api/rule-engine/rules/[id]/preview/route.ts
index dbe87a1a..7e842869 100644
--- a/src/client/src/app/api/rule-engine/rules/[id]/preview/route.ts
+++ b/src/client/src/app/api/rule-engine/rules/[id]/preview/route.ts
@@ -1,7 +1,9 @@
import { NextRequest, NextResponse } from "next/server";
+import { SERVER_EVENTS } from "@/constants/events";
import { getCurrentUser } from "@/lib/session";
import { getRuleById } from "@/lib/platform/rule-engine";
import { dataCollector, OTEL_TRACES_TABLE_NAME } from "@/lib/platform/common";
+import PostHogServer from "@/lib/posthog";
type Condition = {
field: string;
@@ -98,6 +100,7 @@ export async function POST(
_req: NextRequest,
{ params }: { params: { id: string } }
) {
+ const startTimestamp = Date.now();
try {
const user = await getCurrentUser();
if (!user) {
@@ -171,8 +174,16 @@ export async function POST(
matched: true,
}));
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_PREVIEW_SUCCESS,
+ startTimestamp,
+ });
return NextResponse.json({ results });
} catch (err: any) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_PREVIEW_FAILURE,
+ startTimestamp,
+ });
const message = err?.message || "Internal server error";
return NextResponse.json({ error: message }, { status: 500 });
}
diff --git a/src/client/src/app/api/rule-engine/rules/[id]/route.ts b/src/client/src/app/api/rule-engine/rules/[id]/route.ts
index 3c8a564e..41e74dc8 100644
--- a/src/client/src/app/api/rule-engine/rules/[id]/route.ts
+++ b/src/client/src/app/api/rule-engine/rules/[id]/route.ts
@@ -1,18 +1,30 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { RuleInput } from "@/types/rule-engine";
import { getRuleById, updateRule, deleteRule } from "@/lib/platform/rule-engine";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
export async function GET(_: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const { err, data }: any = await getRuleById(id);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_GET_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_GET_SUCCESS,
+ startTimestamp,
+ });
return Response.json(data);
}
export async function PUT(request: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const formData = await request.json();
@@ -25,18 +37,35 @@ export async function PUT(request: Request, context: any) {
const [err, res]: any = await asaw(updateRule(id, ruleInput));
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_UPDATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_UPDATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
export async function DELETE(_: Request, context: any) {
+ const startTimestamp = Date.now();
const { id } = context.params;
const [err, res] = await deleteRule(id);
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_DELETE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_DELETE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/rule-engine/rules/route.ts b/src/client/src/app/api/rule-engine/rules/route.ts
index 0fd78e01..5d04e442 100644
--- a/src/client/src/app/api/rule-engine/rules/route.ts
+++ b/src/client/src/app/api/rule-engine/rules/route.ts
@@ -1,17 +1,29 @@
+import { SERVER_EVENTS } from "@/constants/events";
import { RuleInput } from "@/types/rule-engine";
import { getRules, createRule } from "@/lib/platform/rule-engine";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
export async function GET() {
+ const startTimestamp = Date.now();
const { err, data }: any = await getRules();
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_LIST_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_LIST_SUCCESS,
+ startTimestamp,
+ });
return Response.json(data);
}
export async function POST(request: Request) {
+ const startTimestamp = Date.now();
const formData = await request.json();
const ruleInput: Partial<RuleInput> = {
@@ -23,8 +35,16 @@ export async function POST(request: Request) {
const [err, res]: any = await asaw(createRule(ruleInput));
if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_CREATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, { status: 400 });
}
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.RULE_CREATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/app/api/user/complete-onboarding/route.ts b/src/client/src/app/api/user/complete-onboarding/route.ts
index 3c6c14c4..e5199db8 100644
--- a/src/client/src/app/api/user/complete-onboarding/route.ts
+++ b/src/client/src/app/api/user/complete-onboarding/route.ts
@@ -1,11 +1,18 @@
import prisma from "@/lib/prisma";
import { getCurrentUser } from "@/lib/session";
+import { SERVER_EVENTS } from "@/constants/events";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
export async function POST() {
+ const startTimestamp = Date.now();
const [err, user] = await asaw(getCurrentUser());
if (err || !user) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.USER_ONBOARDING_COMPLETE_FAILURE,
+ startTimestamp,
+ });
return Response.json("Unauthorized", {
status: 401,
});
@@ -16,5 +23,9 @@ export async function POST() {
data: { hasCompletedOnboarding: true },
});
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.USER_ONBOARDING_COMPLETE_SUCCESS,
+ startTimestamp,
+ });
return Response.json({ success: true });
}
diff --git a/src/client/src/app/api/user/profile/route.ts b/src/client/src/app/api/user/profile/route.ts
index 71c7a654..664cdd37 100644
--- a/src/client/src/app/api/user/profile/route.ts
+++ b/src/client/src/app/api/user/profile/route.ts
@@ -1,5 +1,7 @@
import { getCurrentUser } from "@/lib/session";
import { updateUserProfile } from "@/lib/user";
+import { SERVER_EVENTS } from "@/constants/events";
+import PostHogServer from "@/lib/posthog";
import asaw from "@/utils/asaw";
export async function GET() {
@@ -14,6 +16,7 @@ export async function GET() {
}
export async function POST(request: Request) {
+ const startTimestamp = Date.now();
const formData = await request.json();
const formObject = {
currentPassword: formData.currentPassword,
@@ -23,10 +26,19 @@ export async function POST(request: Request) {
const [err, res]: any = await asaw(updateUserProfile(formObject));
- if (err)
+ if (err) {
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.USER_PROFILE_UPDATE_FAILURE,
+ startTimestamp,
+ });
return Response.json(err, {
status: 400,
});
+ }
+ PostHogServer.fireEvent({
+ event: SERVER_EVENTS.USER_PROFILE_UPDATE_SUCCESS,
+ startTimestamp,
+ });
return Response.json(res);
}
diff --git a/src/client/src/constants/events.ts b/src/client/src/constants/events.ts
index 1e8fb858..cbd6691a 100644
--- a/src/client/src/constants/events.ts
+++ b/src/client/src/constants/events.ts
@@ -89,6 +89,39 @@ export const CLIENT_EVENTS = {
ORGANISATION_INVITATION_ACCEPTED: "ORGANISATION_INVITATION_ACCEPTED",
ORGANISATION_INVITATION_DECLINED: "ORGANISATION_INVITATION_DECLINED",
ORGANISATION_INVITATION_CANCELLED: "ORGANISATION_INVITATION_CANCELLED",
+
+ // Page visits
+ LOGIN_PAGE_VISITED: "LOGIN_PAGE_VISITED",
+ REGISTER_PAGE_VISITED: "REGISTER_PAGE_VISITED",
+ ONBOARDING_PAGE_VISITED: "ONBOARDING_PAGE_VISITED",
+ GETTING_STARTED_PAGE_VISITED: "GETTING_STARTED_PAGE_VISITED",
+ HOME_PAGE_VISITED: "HOME_PAGE_VISITED",
+ REQUESTS_PAGE_VISITED: "REQUESTS_PAGE_VISITED",
+ EXCEPTIONS_PAGE_VISITED: "EXCEPTIONS_PAGE_VISITED",
+ EVALUATIONS_PAGE_VISITED: "EVALUATIONS_PAGE_VISITED",
+ EVALUATION_SETTINGS_PAGE_VISITED: "EVALUATION_SETTINGS_PAGE_VISITED",
+ EVALUATION_TYPES_PAGE_VISITED: "EVALUATION_TYPES_PAGE_VISITED",
+ EVALUATION_TYPE_NEW_PAGE_VISITED: "EVALUATION_TYPE_NEW_PAGE_VISITED",
+ EVALUATION_TYPE_EDIT_PAGE_VISITED: "EVALUATION_TYPE_EDIT_PAGE_VISITED",
+ PROMPT_HUB_PAGE_VISITED: "PROMPT_HUB_PAGE_VISITED",
+ PROMPT_HUB_DETAIL_PAGE_VISITED: "PROMPT_HUB_DETAIL_PAGE_VISITED",
+ VAULT_PAGE_VISITED: "VAULT_PAGE_VISITED",
+ OPENGROUND_PAGE_VISITED: "OPENGROUND_PAGE_VISITED",
+ OPENGROUND_NEW_PAGE_VISITED: "OPENGROUND_NEW_PAGE_VISITED",
+ OPENGROUND_DETAIL_PAGE_VISITED: "OPENGROUND_DETAIL_PAGE_VISITED",
+ OPENGROUND_MODELS_PAGE_VISITED: "OPENGROUND_MODELS_PAGE_VISITED",
+ CONTEXT_PAGE_VISITED: "CONTEXT_PAGE_VISITED",
+ CONTEXT_NEW_PAGE_VISITED: "CONTEXT_NEW_PAGE_VISITED",
+ CONTEXT_DETAIL_PAGE_VISITED: "CONTEXT_DETAIL_PAGE_VISITED",
+ RULE_ENGINE_PAGE_VISITED: "RULE_ENGINE_PAGE_VISITED",
+ RULE_ENGINE_DETAIL_PAGE_VISITED: "RULE_ENGINE_DETAIL_PAGE_VISITED",
+ SETTINGS_PAGE_VISITED: "SETTINGS_PAGE_VISITED",
+ SETTINGS_API_KEYS_PAGE_VISITED: "SETTINGS_API_KEYS_PAGE_VISITED",
+ SETTINGS_EVALUATION_PAGE_VISITED: "SETTINGS_EVALUATION_PAGE_VISITED",
+ SETTINGS_MANAGE_MODELS_PAGE_VISITED: "SETTINGS_MANAGE_MODELS_PAGE_VISITED",
+ SETTINGS_ORGANISATION_PAGE_VISITED: "SETTINGS_ORGANISATION_PAGE_VISITED",
+ DASHBOARDS_PAGE_VISITED: "DASHBOARDS_PAGE_VISITED",
+ DASHBOARD_DETAIL_PAGE_VISITED: "DASHBOARD_DETAIL_PAGE_VISITED",
};
export const SERVER_EVENTS = {
@@ -149,4 +182,106 @@ export const SERVER_EVENTS = {
DASHBOARD_WIDGET_CREATE_FAILURE: "DASHBOARD_WIDGET_CREATE_FAILURE",
DASHBOARD_WIDGET_LIST_SUCCESS: "DASHBOARD_WIDGET_LIST_SUCCESS",
DASHBOARD_WIDGET_LIST_FAILURE: "DASHBOARD_WIDGET_LIST_FAILURE",
+
+ // Context
+ CONTEXT_LIST_SUCCESS: "CONTEXT_LIST_SUCCESS",
+ CONTEXT_LIST_FAILURE: "CONTEXT_LIST_FAILURE",
+ CONTEXT_CREATE_SUCCESS: "CONTEXT_CREATE_SUCCESS",
+ CONTEXT_CREATE_FAILURE: "CONTEXT_CREATE_FAILURE",
+ CONTEXT_GET_SUCCESS: "CONTEXT_GET_SUCCESS",
+ CONTEXT_GET_FAILURE: "CONTEXT_GET_FAILURE",
+ CONTEXT_UPDATE_SUCCESS: "CONTEXT_UPDATE_SUCCESS",
+ CONTEXT_UPDATE_FAILURE: "CONTEXT_UPDATE_FAILURE",
+ CONTEXT_DELETE_SUCCESS: "CONTEXT_DELETE_SUCCESS",
+ CONTEXT_DELETE_FAILURE: "CONTEXT_DELETE_FAILURE",
+
+ // Rule Engine
+ RULE_LIST_SUCCESS: "RULE_LIST_SUCCESS",
+ RULE_LIST_FAILURE: "RULE_LIST_FAILURE",
+ RULE_CREATE_SUCCESS: "RULE_CREATE_SUCCESS",
+ RULE_CREATE_FAILURE: "RULE_CREATE_FAILURE",
+ RULE_GET_SUCCESS: "RULE_GET_SUCCESS",
+ RULE_GET_FAILURE: "RULE_GET_FAILURE",
+ RULE_UPDATE_SUCCESS: "RULE_UPDATE_SUCCESS",
+ RULE_UPDATE_FAILURE: "RULE_UPDATE_FAILURE",
+ RULE_DELETE_SUCCESS: "RULE_DELETE_SUCCESS",
+ RULE_DELETE_FAILURE: "RULE_DELETE_FAILURE",
+ RULE_CONDITIONS_UPDATE_SUCCESS: "RULE_CONDITIONS_UPDATE_SUCCESS",
+ RULE_CONDITIONS_UPDATE_FAILURE: "RULE_CONDITIONS_UPDATE_FAILURE",
+ RULE_PREVIEW_SUCCESS: "RULE_PREVIEW_SUCCESS",
+ RULE_PREVIEW_FAILURE: "RULE_PREVIEW_FAILURE",
+ RULE_ENTITIES_LIST_SUCCESS: "RULE_ENTITIES_LIST_SUCCESS",
+ RULE_ENTITIES_LIST_FAILURE: "RULE_ENTITIES_LIST_FAILURE",
+ RULE_ENTITIES_CREATE_SUCCESS: "RULE_ENTITIES_CREATE_SUCCESS",
+ RULE_ENTITIES_CREATE_FAILURE: "RULE_ENTITIES_CREATE_FAILURE",
+ RULE_ENTITIES_DELETE_SUCCESS: "RULE_ENTITIES_DELETE_SUCCESS",
+ RULE_ENTITIES_DELETE_FAILURE: "RULE_ENTITIES_DELETE_FAILURE",
+ RULE_EVALUATE_SUCCESS: "RULE_EVALUATE_SUCCESS",
+ RULE_EVALUATE_FAILURE: "RULE_EVALUATE_FAILURE",
+ RULE_FIELD_VALUES_SUCCESS: "RULE_FIELD_VALUES_SUCCESS",
+ RULE_FIELD_VALUES_FAILURE: "RULE_FIELD_VALUES_FAILURE",
+
+ // Fleet Hub
+ FLEET_HUB_LIST_SUCCESS: "FLEET_HUB_LIST_SUCCESS",
+ FLEET_HUB_LIST_FAILURE: "FLEET_HUB_LIST_FAILURE",
+ FLEET_HUB_GET_SUCCESS: "FLEET_HUB_GET_SUCCESS",
+ FLEET_HUB_GET_FAILURE: "FLEET_HUB_GET_FAILURE",
+ FLEET_HUB_CONFIG_UPDATE_SUCCESS: "FLEET_HUB_CONFIG_UPDATE_SUCCESS",
+ FLEET_HUB_CONFIG_UPDATE_FAILURE: "FLEET_HUB_CONFIG_UPDATE_FAILURE",
+ FLEET_HUB_TLS_CONNECTION_SUCCESS: "FLEET_HUB_TLS_CONNECTION_SUCCESS",
+ FLEET_HUB_TLS_CONNECTION_FAILURE: "FLEET_HUB_TLS_CONNECTION_FAILURE",
+
+ // Openground
+ OPENGROUND_LIST_SUCCESS: "OPENGROUND_LIST_SUCCESS",
+ OPENGROUND_LIST_FAILURE: "OPENGROUND_LIST_FAILURE",
+ OPENGROUND_CREATE_SUCCESS: "OPENGROUND_CREATE_SUCCESS",
+ OPENGROUND_CREATE_FAILURE: "OPENGROUND_CREATE_FAILURE",
+ OPENGROUND_GET_SUCCESS: "OPENGROUND_GET_SUCCESS",
+ OPENGROUND_GET_FAILURE: "OPENGROUND_GET_FAILURE",
+ OPENGROUND_CONFIG_GET_SUCCESS: "OPENGROUND_CONFIG_GET_SUCCESS",
+ OPENGROUND_CONFIG_GET_FAILURE: "OPENGROUND_CONFIG_GET_FAILURE",
+ OPENGROUND_CONFIG_CREATE_SUCCESS: "OPENGROUND_CONFIG_CREATE_SUCCESS",
+ OPENGROUND_CONFIG_CREATE_FAILURE: "OPENGROUND_CONFIG_CREATE_FAILURE",
+ OPENGROUND_CONFIG_DELETE_SUCCESS: "OPENGROUND_CONFIG_DELETE_SUCCESS",
+ OPENGROUND_CONFIG_DELETE_FAILURE: "OPENGROUND_CONFIG_DELETE_FAILURE",
+ OPENGROUND_CONFIG_UPDATE_SUCCESS: "OPENGROUND_CONFIG_UPDATE_SUCCESS",
+ OPENGROUND_CONFIG_UPDATE_FAILURE: "OPENGROUND_CONFIG_UPDATE_FAILURE",
+ OPENGROUND_PROVIDERS_LIST_SUCCESS: "OPENGROUND_PROVIDERS_LIST_SUCCESS",
+ OPENGROUND_PROVIDERS_LIST_FAILURE: "OPENGROUND_PROVIDERS_LIST_FAILURE",
+ OPENGROUND_MODELS_LIST_SUCCESS: "OPENGROUND_MODELS_LIST_SUCCESS",
+ OPENGROUND_MODELS_LIST_FAILURE: "OPENGROUND_MODELS_LIST_FAILURE",
+ OPENGROUND_MODELS_CREATE_SUCCESS: "OPENGROUND_MODELS_CREATE_SUCCESS",
+ OPENGROUND_MODELS_CREATE_FAILURE: "OPENGROUND_MODELS_CREATE_FAILURE",
+ OPENGROUND_MODELS_DELETE_SUCCESS: "OPENGROUND_MODELS_DELETE_SUCCESS",
+ OPENGROUND_MODELS_DELETE_FAILURE: "OPENGROUND_MODELS_DELETE_FAILURE",
+
+ // Evaluation
+ EVALUATION_CONFIG_GET_SUCCESS: "EVALUATION_CONFIG_GET_SUCCESS",
+ EVALUATION_CONFIG_GET_FAILURE: "EVALUATION_CONFIG_GET_FAILURE",
+ EVALUATION_CONFIG_CREATE_SUCCESS: "EVALUATION_CONFIG_CREATE_SUCCESS",
+ EVALUATION_CONFIG_CREATE_FAILURE: "EVALUATION_CONFIG_CREATE_FAILURE",
+ EVALUATION_GET_SUCCESS: "EVALUATION_GET_SUCCESS",
+ EVALUATION_GET_FAILURE: "EVALUATION_GET_FAILURE",
+ EVALUATION_CREATE_SUCCESS: "EVALUATION_CREATE_SUCCESS",
+ EVALUATION_CREATE_FAILURE: "EVALUATION_CREATE_FAILURE",
+ EVALUATION_FEEDBACK_SUCCESS: "EVALUATION_FEEDBACK_SUCCESS",
+ EVALUATION_FEEDBACK_FAILURE: "EVALUATION_FEEDBACK_FAILURE",
+ EVALUATION_TYPE_LIST_SUCCESS: "EVALUATION_TYPE_LIST_SUCCESS",
+ EVALUATION_TYPE_LIST_FAILURE: "EVALUATION_TYPE_LIST_FAILURE",
+ EVALUATION_TYPE_CREATE_SUCCESS: "EVALUATION_TYPE_CREATE_SUCCESS",
+ EVALUATION_TYPE_CREATE_FAILURE: "EVALUATION_TYPE_CREATE_FAILURE",
+ EVALUATION_TYPE_GET_SUCCESS: "EVALUATION_TYPE_GET_SUCCESS",
+ EVALUATION_TYPE_GET_FAILURE: "EVALUATION_TYPE_GET_FAILURE",
+ EVALUATION_TYPE_UPDATE_SUCCESS: "EVALUATION_TYPE_UPDATE_SUCCESS",
+ EVALUATION_TYPE_UPDATE_FAILURE: "EVALUATION_TYPE_UPDATE_FAILURE",
+ EVALUATION_TYPE_DELETE_SUCCESS: "EVALUATION_TYPE_DELETE_SUCCESS",
+ EVALUATION_TYPE_DELETE_FAILURE: "EVALUATION_TYPE_DELETE_FAILURE",
+ EVALUATION_LLM_RUN_SUCCESS: "EVALUATION_LLM_RUN_SUCCESS",
+ EVALUATION_LLM_RUN_FAILURE: "EVALUATION_LLM_RUN_FAILURE",
+
+ // User
+ USER_PROFILE_UPDATE_SUCCESS: "USER_PROFILE_UPDATE_SUCCESS",
+ USER_PROFILE_UPDATE_FAILURE: "USER_PROFILE_UPDATE_FAILURE",
+ USER_ONBOARDING_COMPLETE_SUCCESS: "USER_ONBOARDING_COMPLETE_SUCCESS",
+ USER_ONBOARDING_COMPLETE_FAILURE: "USER_ONBOARDING_COMPLETE_FAILURE",
};
diff --git a/src/client/src/lib/posthog.ts b/src/client/src/lib/posthog.ts
index d7c94a05..05ff9e3a 100644
--- a/src/client/src/lib/posthog.ts
+++ b/src/client/src/lib/posthog.ts
@@ -31,7 +31,7 @@ export default class PostHogServer {
body: jsonStringify({
api_key: POSTHOG_API_KEY,
...options,
- distinctId: this.distinctId,
+ distinct_id: this.distinctId,
properties: {
...(options.properties || {}),
isServer: true,