Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Remove posthog from community edition

ali-inkco92e101284bbb
diff --git a/packages/app/src/backend/config.ts b/packages/app/src/backend/config.ts
index c69d3c0b..28a819b1 100644
--- a/packages/app/src/backend/config.ts
+++ b/packages/app/src/backend/config.ts
@@ -80,6 +80,7 @@ const config = {
LOGTO_API_RESOURCE: process.env.LOGTO_API_RESOURCE,
LOGTO_M2M_APP_ID: process.env.LOGTO_M2M_APP_ID,
LOGTO_M2M_APP_SECRET: process.env.LOGTO_M2M_APP_SECRET,
+ POSTHOG_API_KEY: process.env.POSTHOG_API_KEY,
PUB_API_SERVER: process.env.PUB_API_SERVER,
},
api: {
diff --git a/packages/app/src/backend/routes/pages/router.ts b/packages/app/src/backend/routes/pages/router.ts
index 135cb0bb..ad9e3106 100644
--- a/packages/app/src/backend/routes/pages/router.ts
+++ b/packages/app/src/backend/routes/pages/router.ts
@@ -46,7 +46,6 @@ router.use(async (req, res, next) => {
res.locals.env = config.env.NODE_ENV;
res.locals.isSmythStaff = ejsHelper.isSmythStaff(req._user);
res.locals.isSmythAlpha = ejsHelper.isSmythAlpha(req._user);
- res.locals.postHogSignupEvents = [];
res.locals.isCallBooked = true;
res.locals.SMYTHOS_DOCS_URL = SMYTHOS_DOCS_URL;
next();
diff --git a/packages/app/src/builder-ui/app.ts b/packages/app/src/builder-ui/app.ts
index 5684b1e0..fded99f7 100644
--- a/packages/app/src/builder-ui/app.ts
+++ b/packages/app/src/builder-ui/app.ts
@@ -1,6 +1,7 @@
// import 'flowbite/dist/flowbite.js';
import { TEAM_ID_HEADER } from '../backend/constants';
import { FRONTEND_USER_SETTINGS } from '../react/shared/enums';
+import { Observability } from '../shared/observability';
import { authStore } from '../shared/state_stores/auth';
import { builderStore } from '../shared/state_stores/builder/store';
import config from './config';
@@ -15,6 +16,11 @@ export function initApp() {
// TODO: move this to a script that runs on the page immediately better
builderStore.getState().init();
authStore.getState().init();
+
+ // Expose Observability API globally for EJS templates (only if tracking is enabled)
+ if ((window as any).isObservability === true) {
+ (window as any).Observability = Observability;
+ }
}
{
diff --git a/packages/app/src/builder-ui/components/Component.class/settings-editor.ts b/packages/app/src/builder-ui/components/Component.class/settings-editor.ts
index c295ccc9..b8c37cbb 100644
--- a/packages/app/src/builder-ui/components/Component.class/settings-editor.ts
+++ b/packages/app/src/builder-ui/components/Component.class/settings-editor.ts
@@ -85,7 +85,7 @@ async function onComponentLoad(sidebar) {
deleteButton.onclick = component.delete.bind(this, false);
// Add Test with Debug button based on feature flag
- const testWithDebugFeatureFlag = PostHog.getFeatureFlag(
+ const testWithDebugFeatureFlag = Observability.features.getFeatureFlag(
FEATURE_FLAGS.TEST_WITH_DEBUG_COMPONENT_SIDEBAR,
);
if (testWithDebugFeatureFlag === 'variant_1' && !component.workspace?.locked) {
diff --git a/packages/app/src/builder-ui/debugger.ts b/packages/app/src/builder-ui/debugger.ts
index 6b9634c0..d7a293a6 100644
--- a/packages/app/src/builder-ui/debugger.ts
+++ b/packages/app/src/builder-ui/debugger.ts
@@ -1,6 +1,6 @@
import { errorToast, successToast, warningToast } from '@src/shared/components/toast';
import { Observability } from '@src/shared/observability';
-import { PostHog } from '@src/shared/posthog';
+import { PostHog } from '@enterprise/shared/posthog';
import interact from 'interactjs';
import { jsonrepair } from 'jsonrepair';
import { Component } from './components/Component.class';
diff --git a/packages/app/src/builder-ui/pages/builder/agent-settings.ts b/packages/app/src/builder-ui/pages/builder/agent-settings.ts
index 97561542..443bf603 100644
--- a/packages/app/src/builder-ui/pages/builder/agent-settings.ts
+++ b/packages/app/src/builder-ui/pages/builder/agent-settings.ts
@@ -1,7 +1,7 @@
+import { PostHog } from '@enterprise/shared/posthog';
import { PRIMARY_BUTTON_STYLE } from '@src/react/shared/constants/style';
import { plugins, PluginTarget, PluginType } from '@src/react/shared/plugins/Plugins';
import { errorToast, successToast } from '@src/shared/components/toast';
-import { PostHog } from '@src/shared/posthog';
import { EMBODIMENT_DESCRIPTIONS, SMYTHOS_DOCS_URL } from '../../../shared/constants/general';
import { EmbodimentRPCManager } from '../../../shared/services/embodiment_rpc_manager';
import { builderStore } from '../../../shared/state_stores/builder/store';
diff --git a/packages/app/src/react/app/App.tsx b/packages/app/src/react/app/App.tsx
index 2b6d6693..9b7757eb 100644
--- a/packages/app/src/react/app/App.tsx
+++ b/packages/app/src/react/app/App.tsx
@@ -2,6 +2,7 @@
import { OnboardingProvider } from '@src/react/features/agents/contexts/OnboardingContext';
import { SidebarProvider } from '@src/react/shared/contexts/SidebarContext';
import { queryClient } from '@src/react/shared/query-client';
+import { Observability } from '@src/shared/observability';
import { PostHog } from '@src/shared/posthog/index';
import { QueryClientProvider } from '@tanstack/react-query';
import { useEffect } from 'react';
@@ -12,20 +13,24 @@ import RoutesWrapper from './routes';
const App = () => {
useEffect(() => {
- PostHog.initialize();
+ // Only initialize PostHog if observability is enabled
+ if ((window as any).isObservability === true) {
+ PostHog.initialize();
+ (window as any).Observability = Observability;
+ }
}, []);
return (
- <QueryClientProvider client={queryClient}>
- <Router>
- <SidebarProvider>
- <OnboardingProvider>
- <RoutesWrapper pages={routeMap} />
- </OnboardingProvider>
- </SidebarProvider>
- </Router>
- <ToastContainer />
- </QueryClientProvider>
+ <QueryClientProvider client={queryClient}>
+ <Router>
+ <SidebarProvider>
+ <OnboardingProvider>
+ <RoutesWrapper pages={routeMap} />
+ </OnboardingProvider>
+ </SidebarProvider>
+ </Router>
+ <ToastContainer />
+ </QueryClientProvider>
);
};
diff --git a/packages/app/src/react/features/agents/components/agentCard/AgentCard.tsx b/packages/app/src/react/features/agents/components/agentCard/AgentCard.tsx
index 37373a85..f65cb123 100644
--- a/packages/app/src/react/features/agents/components/agentCard/AgentCard.tsx
+++ b/packages/app/src/react/features/agents/components/agentCard/AgentCard.tsx
@@ -16,10 +16,10 @@ import {
import { Button } from '@src/react/shared/components/ui/newDesign/button';
import { useAuthCtx } from '@src/react/shared/contexts/auth.context';
import { FEATURE_FLAGS } from '@src/shared/constants/featureflags';
+import { Observability } from '@src/shared/observability';
import classNames from 'classnames';
import { Tooltip } from 'flowbite-react';
-import { useFeatureFlagPayload } from 'posthog-js/react';
-import { useRef, useState } from 'react';
+import { useEffect, useRef, useState } from 'react';
import {
FaCircleNotch,
FaClockRotateLeft,
@@ -48,9 +48,31 @@ interface AgentCardProps {
*/
export function AgentCard({ agent, loadAgents, updateAgentInPlace }: AgentCardProps) {
const navigate = useNavigate();
- const featureFlagPayload = useFeatureFlagPayload(FEATURE_FLAGS.AGENT_KEY_DROPDOWN);
const { isStaffUser } = useAuthCtx();
+ // Feature flag payload state
+ const [featureFlagPayload, setFeatureFlagPayload] = useState<unknown>(undefined);
+
+ // Load feature flag payload
+ // Use PostHog's onFeatureFlags callback to wait for flags to be ready
+ useEffect(() => {
+ const loadFeatureFlag = () => {
+ const payload = Observability.features.getFeatureFlagPayload(
+ FEATURE_FLAGS.AGENT_KEY_DROPDOWN,
+ );
+ setFeatureFlagPayload(payload);
+ };
+
+ // Use PostHog's built-in callback for when flags are ready
+ const posthog = (window as { posthog?: any }).posthog;
+ if (posthog?.onFeatureFlags) {
+ posthog.onFeatureFlags(loadFeatureFlag);
+ } else {
+ // Fallback: if PostHog already loaded or not available, try immediately
+ loadFeatureFlag();
+ }
+ }, []);
+
// Modal states
const [isContributorsModalOpen, setIsContributorsModalOpen] = useState(false);
const [isActivityModalOpen, setIsActivityModalOpen] = useState(false);
diff --git a/packages/app/src/react/index.html b/packages/app/src/react/index.html
index 541a7f0d..9a5ecd0c 100644
--- a/packages/app/src/react/index.html
+++ b/packages/app/src/react/index.html
@@ -1,222 +1,168 @@
<!doctype html>
<html lang="en" class="">
-
-<head>
- <meta charset="UTF-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0" />
- <link rel="shortcut icon" href="/img/favicon.png" type="image/x-icon" />
- <title>SmythOS</title>
- <link rel="preconnect" href="https://fonts.googleapis.com" />
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
- <link
- href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700&family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300&display=swap"
- rel="stylesheet" />
- <!-- <link rel="stylesheet" href="/metroui/css/metro-all.css" /> -->
-
- <link rel="stylesheet" href="/metroui/css/metro-reset.css" />
- <!-- <link rel="stylesheet" href="/metroui/css/metro-common.css" /> -->
- <!-- <link rel="stylesheet" href="/metroui/css/metro-colors.css" /> -->
- <link rel="stylesheet" href="/metroui/css/metro-components.css" />
- <link rel="stylesheet" href="/metroui/css/metro-icons.css" />
- <link rel="stylesheet" href="/css/smyth-metro-override.css" />
-
- <link rel="stylesheet" href="/css/smyth-global.css" />
- <link rel="stylesheet" href="/css/smyth-builder.css" />
- <link rel="stylesheet" href="/css/smyth-builder-override.css" />
- <link rel="stylesheet" href="/css/menus.css" />
- <link rel="stylesheet" href="/css/smyth-debugger.css" />
- <link rel="stylesheet" href="/css/smyth-components.css" />
- <!-- <link rel="stylesheet" href="/css/smyth-domain.css" /> -->
- <link rel="stylesheet" href="/css/smyth-vector.css" />
- <link rel="stylesheet" href="/css/smyth-form.css" />
- <link rel="stylesheet" href="/css/react-toastify.css" />
-
- <link rel="stylesheet" href="/css/icons.css" />
-
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.css" />
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
-
- <!-- Conditional loading of Tailwind CSS2 -->
- <link rel="stylesheet" href="/assets/css/tailwind-v2.css" />
-
- <link rel="stylesheet" href="/css/smyth-tailwind.css" />
-
-
-
- <!-- Posthog -->
-<script>
- !(function (t, e) {
- var o, n, p, r;
- e.__SV ||
- ((window.posthog = e),
- (e._i = []),
- (e.init = function (i, s, a) {
- function g(t, e) {
- var o = e.split('.');
- 2 == o.length && ((t = t[o[0]]), (e = o[1])),
- (t[e] = function () {
- t.push([e].concat(Array.prototype.slice.call(arguments, 0)));
- });
- }
- ((p = t.createElement('script')).type = 'text/javascript'),
- (p.async = !0),
- (p.src = s.api_host + '/static/array.js'),
- (r = t.getElementsByTagName('script')[0]).parentNode.insertBefore(p, r);
- var u = e;
- for (
- void 0 !== a ? (u = e[a] = []) : (a = 'posthog'),
- u.people = u.people || [],
- u.toString = function (t) {
- var e = 'posthog';
- return 'posthog' !== a && (e += '.' + a), t || (e += ' (stub)'), e;
- },
- u.people.toString = function () {
- return u.toString(1) + '.people (stub)';
- },
- o =
- 'capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys getNextSurveyStep onSessionId'.split(
- ' ',
- ),
- n = 0;
- n < o.length;
- n++
- )
- g(u, o[n]);
- e._i.push([i, s, a]);
- }),
- (e.__SV = 1));
- })(document, window.posthog || []);
- posthog.init('phc_lxgXwZRs6ySZqrHI4niOdYJlVXJAgMjTOhDau7f7VC3', {
- api_host: 'https://us.i.posthog.com',
- person_profiles: 'identified_only',
- });
-</script>
-
-</head>
-
-<body>
- <div id="preload-overlay"></div>
-
- <div id="root"></div>
-<script type="module" src="/index.tsx"></script>
- <div id="overlay" class="hidden"></div>
- <div class="overlay-secondary hidden"></div>
- <div id="modal-root"></div>
-
- <script>
- window.__LLM_MODELS__ = JSON.parse(
- ``,
- );
- </script>
-
- <script src="/metroui/js/metro.js"></script>
- <script src="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.js"></script>
- <script async
- src="//smythos.com/wp-content/themes/generatepress_child/js/iframeResizer.contentWindow.min.js"></script>
+ <head>
+ <meta charset="UTF-8" />
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+ <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0" />
+ <link rel="shortcut icon" href="/img/favicon.png" type="image/x-icon" />
+ <title>SmythOS</title>
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
+ <link
+ href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700&family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300&display=swap"
+ rel="stylesheet"
+ />
+ <!-- <link rel="stylesheet" href="/metroui/css/metro-all.css" /> -->
+
+ <link rel="stylesheet" href="/metroui/css/metro-reset.css" />
+ <!-- <link rel="stylesheet" href="/metroui/css/metro-common.css" /> -->
+ <!-- <link rel="stylesheet" href="/metroui/css/metro-colors.css" /> -->
+ <link rel="stylesheet" href="/metroui/css/metro-components.css" />
+ <link rel="stylesheet" href="/metroui/css/metro-icons.css" />
+ <link rel="stylesheet" href="/css/smyth-metro-override.css" />
+
+ <link rel="stylesheet" href="/css/smyth-global.css" />
+ <link rel="stylesheet" href="/css/smyth-builder.css" />
+ <link rel="stylesheet" href="/css/smyth-builder-override.css" />
+ <link rel="stylesheet" href="/css/menus.css" />
+ <link rel="stylesheet" href="/css/smyth-debugger.css" />
+ <link rel="stylesheet" href="/css/smyth-components.css" />
+ <!-- <link rel="stylesheet" href="/css/smyth-domain.css" /> -->
+ <link rel="stylesheet" href="/css/smyth-vector.css" />
+ <link rel="stylesheet" href="/css/smyth-form.css" />
+ <link rel="stylesheet" href="/css/react-toastify.css" />
+
+ <link rel="stylesheet" href="/css/icons.css" />
+
+ <link
+ rel="stylesheet"
+ href="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.css"
+ />
+ <link
+ rel="stylesheet"
+ href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
+ />
+
+ <!-- Conditional loading of Tailwind CSS2 -->
+ <link rel="stylesheet" href="/assets/css/tailwind-v2.css" />
+
+ <link rel="stylesheet" href="/css/smyth-tailwind.css" />
+ </head>
+
+ <body>
+ <div id="preload-overlay"></div>
+
+ <div id="root"></div>
+ <script type="module" src="/index.tsx"></script>
+ <div id="overlay" class="hidden"></div>
+ <div class="overlay-secondary hidden"></div>
+ <div id="modal-root"></div>
+
+ <script>
+ window.__LLM_MODELS__ = JSON.parse(``);
+ </script>
+
+ <script src="/metroui/js/metro.js"></script>
+ <script src="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.js"></script>
+ <script
+ async
+ src="//smythos.com/wp-content/themes/generatepress_child/js/iframeResizer.contentWindow.min.js"
+ ></script>
<!-- Should be placed in builder partial so it does not load on other pages -->
-
- <script src="/assets/index.dev.js"></script>
-
- <script src="/js/misc.js"></script>
-
-
-
-
- <div
- id="smythos-v3-march-25"
- class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[999] p-4"
->
- <div class="bg-white rounded-lg p-6 max-w-3xl w-full mx-4 max-h-[90vh] overflow-y-auto">
- <div class="flex justify-between items-center mb-4">
- <h3 class="text-xl font-semibold">What's new? The features you've been asking for!</h3>
- <button onclick="closeSmythosV3March25Modal()" class="text-gray-500 hover:text-gray-700">
- <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M6 18L18 6M6 6l12 12"
- />
- </svg>
- </button>
- </div>
- <div class="mb-6">
- <div class="text-sm mb-6">
- <p class="text-gray-700 mb-3">
- For those of you who are new, welcome! And to those of you who have been here for a while,
- thank you so much for being here. This latest update is loaded with exciting enhancements,
- including <b>one-click access</b> to leading models from OpenAI, Claude, Gemini, and more.
- You'll also find a new <b>Form UI</b> for viewing and testing your agent's Skills,
- <b>tools that require no API configuration</b> for tasks like web scraping and web
- searching, among many other updates!
+
+ <script src="/assets/index.dev.js"></script>
+
+ <script src="/js/misc.js"></script>
+
+ <div
+ id="smythos-v3-march-25"
+ class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[999] p-4"
+ >
+ <div class="bg-white rounded-lg p-6 max-w-3xl w-full mx-4 max-h-[90vh] overflow-y-auto">
+ <div class="flex justify-between items-center mb-4">
+ <h3 class="text-xl font-semibold">What's new? The features you've been asking for!</h3>
+ <button onclick="closeSmythosV3March25Modal()" class="text-gray-500 hover:text-gray-700">
+ <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M6 18L18 6M6 6l12 12"
+ />
+ </svg>
+ </button>
+ </div>
+ <div class="mb-6">
+ <div class="text-sm mb-6">
+ <p class="text-gray-700 mb-3">
+ For those of you who are new, welcome! And to those of you who have been here for a
+ while, thank you so much for being here. This latest update is loaded with exciting
+ enhancements, including <b>one-click access</b> to leading models from OpenAI, Claude,
+ Gemini, and more. You'll also find a new <b>Form UI</b> for viewing and testing your
+ agent's Skills, <b>tools that require no API configuration</b> for tasks like web
+ scraping and web searching, among many other updates!
+ </p>
+ <p class="text-gray-700 mb-3">Want to learn more? Check out this demo video 👇</p>
+ </div>
+ <!--YOUTUBE EMBED START-->
+ <iframe
+ width="100%"
+ height="360"
+ frameborder="0"
+ title="SmythOS March 2025 Update"
+ src="https://www.youtube.com/embed/-Aoog97_nHc?si=k60ZCgGuOqE1MqVn"
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
+ referrerpolicy="strict-origin-when-cross-origin"
+ allowfullscreen
+ ></iframe>
+ <!--YOUTUBE EMBED END-->
+ </div>
+ <p class="text-sm text-gray-600">
+ Thank you for choosing SmythOS to bring your ideas to life. Your feedback drives us to
+ make SmythOS even better every day. Happy building!
</p>
- <p class="text-gray-700 mb-3">Want to learn more? Check out this demo video 👇</p>
</div>
- <!--YOUTUBE EMBED START-->
- <iframe
- width="100%"
- height="360"
- frameborder="0"
- title="SmythOS March 2025 Update"
- src="https://www.youtube.com/embed/-Aoog97_nHc?si=k60ZCgGuOqE1MqVn"
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
- referrerpolicy="strict-origin-when-cross-origin"
- allowfullscreen
- ></iframe>
- <!--YOUTUBE EMBED END-->
</div>
- <p class="text-sm text-gray-600">
- Thank you for choosing SmythOS to bring your ideas to life. Your feedback drives us to make
- SmythOS even better every day. Happy building!
- </p>
- </div>
-</div>
-
-<script>
- document.addEventListener('DOMContentLoaded', () => {
- const checkAndShowSmythosV3March25Modal = () => {
- const now = new Date();
- const startDate = new Date('2025-03-20'); // 20 Mar 2025
- const endDate = new Date('2025-03-31'); // 31 Mar 2025
-
- if (now >= startDate && now <= endDate) {
- const hasSeenModal = localStorage.getItem('smythosV3March25ModalSeen');
-
- if (!hasSeenModal) {
+
+ <script>
+ document.addEventListener('DOMContentLoaded', () => {
+ const checkAndShowSmythosV3March25Modal = () => {
+ const now = new Date();
+ const startDate = new Date('2025-03-20'); // 20 Mar 2025
+ const endDate = new Date('2025-03-31'); // 31 Mar 2025
+
+ if (now >= startDate && now <= endDate) {
+ const hasSeenModal = localStorage.getItem('smythosV3March25ModalSeen');
+
+ if (!hasSeenModal) {
+ const modal = document.getElementById('smythos-v3-march-25');
+ const path = window.location.pathname;
+ // not show on onboarding page
+ if (modal && !path.includes('/welcome')) {
+ modal.classList.remove('hidden');
+ localStorage.setItem('smythosV3March25ModalSeen', 'true');
+ }
+ }
+ }
+ };
+
+ window.closeSmythosV3March25Modal = () => {
const modal = document.getElementById('smythos-v3-march-25');
- const path = window.location.pathname;
- // not show on onboarding page
- if (modal && !path.includes('/welcome')) {
- modal.classList.remove('hidden');
- localStorage.setItem('smythosV3March25ModalSeen', 'true');
- posthog?.capture?.('smythos-v3-march-25-modal-seen');
+ if (modal) {
+ modal.classList.add('hidden');
}
- }
- }
- };
-
- window.closeSmythosV3March25Modal = () => {
- const modal = document.getElementById('smythos-v3-march-25');
- posthog?.capture?.('smythos-v3-march-25-modal-closed');
- if (modal) {
- modal.classList.add('hidden');
- }
- };
-
- setTimeout(checkAndShowSmythosV3March25Modal, 1000);
- });
-</script>
-
-
- <script type="module">
- import { Boarding } from "https://unpkg.com/boarding.js/dist/main.js";
- window.Tutorial = Boarding;
- </script>
- <link rel="stylesheet" href="https://unpkg.com/boarding.js/styles/main.css" />
- <!-- optionally include the base theme -->
- <link rel="stylesheet" href="https://unpkg.com/boarding.js/styles/themes/basic.css" />
-
-</body>
-
-</html>
\ No newline at end of file
+ };
+
+ setTimeout(checkAndShowSmythosV3March25Modal, 1000);
+ });
+ </script>
+
+ <script type="module">
+ import { Boarding } from 'https://unpkg.com/boarding.js/dist/main.js';
+ window.Tutorial = Boarding;
+ </script>
+ <link rel="stylesheet" href="https://unpkg.com/boarding.js/styles/main.css" />
+ <!-- optionally include the base theme -->
+ <link rel="stylesheet" href="https://unpkg.com/boarding.js/styles/themes/basic.css" />
+ </body>
+</html>
diff --git a/packages/app/src/react/shared/components/featureFlags/index.tsx b/packages/app/src/react/shared/components/featureFlags/index.tsx
index b13ad9eb..ed018fd1 100644
--- a/packages/app/src/react/shared/components/featureFlags/index.tsx
+++ b/packages/app/src/react/shared/components/featureFlags/index.tsx
@@ -1,6 +1,6 @@
import { useAuthCtx } from '@react/shared/contexts/auth.context';
-import { useFeatureFlagPayload } from 'posthog-js/react';
-import React, { ReactNode, useMemo } from 'react';
+import { Observability } from '@src/shared/observability';
+import React, { ReactNode, useEffect, useMemo, useState } from 'react';
import {
FEATURE_FLAG_PAYLOAD_RELEASE_TYPE,
FEATURE_FLAGS,
@@ -39,7 +39,15 @@ export const useFeatureVisibility = (
): boolean => {
const isProdEnv = useIsProdEnv();
const { isStaffUser, loading } = useAuthCtx();
- const featureFlagPayload = useFeatureFlagPayload(featureFlag);
+ const [featureFlagPayload, setFeatureFlagPayload] = useState<Record<string, unknown> | undefined>(
+ undefined,
+ );
+
+ // Load feature flag payload from Observability API
+ useEffect(() => {
+ const payload = Observability.features.getFeatureFlagPayload(featureFlag);
+ setFeatureFlagPayload(payload);
+ }, [featureFlag]);
const visibility = useMemo(() => {
if (!featureFlagPayload) {
diff --git a/packages/app/src/react/shared/plugins/Plugins.ts b/packages/app/src/react/shared/plugins/Plugins.ts
index 5d946c5b..279b8875 100644
--- a/packages/app/src/react/shared/plugins/Plugins.ts
+++ b/packages/app/src/react/shared/plugins/Plugins.ts
@@ -15,28 +15,17 @@ export enum PluginTarget {
VaultPageSmythOSRecommendedModels = 'vaultPage/smythOSRecommendedModels',
/**
- * UserBehaviorObservabilityProvider - Injected by enterprise edition to capture user interaction patterns
- * Provides implementation for recording user actions, feature usage, and workflow completion metrics
- * Default: No-op implementation in community edition
- * Enterprise: PostHog-based implementation for product analytics
+ * ObservabilityProvider - Unified observability provider injected by enterprise edition
+ * Provides complete implementation for:
+ * - User behavior tracking (interactions, feature usage, workflows)
+ * - System insights (events, errors, performance metrics)
+ * - User identity management (identification, context correlation)
+ * - Feature configuration (flags, A/B testing, rollouts)
+ *
+ * Default: No-op implementation in community edition (all operations disabled)
+ * Enterprise: PostHog-based implementation for complete observability
*/
- UserBehaviorObservabilityProvider = 'observability/userBehaviorProvider',
-
- /**
- * SystemInsightCaptureProvider - Injected by enterprise edition for system-level event monitoring
- * Enables collection of system performance, error patterns, and operational metrics
- * Default: No-op implementation in community edition
- * Enterprise: PostHog-based implementation for system analytics
- */
- SystemInsightCaptureProvider = 'observability/systemInsightProvider',
-
- /**
- * UserIdentityContextProvider - Injected by enterprise edition to associate user context with observability data
- * Manages user identity correlation across different monitoring surfaces
- * Default: No-op implementation in community edition
- * Enterprise: PostHog-based implementation for user identification
- */
- UserIdentityContextProvider = 'observability/userIdentityProvider',
+ ObservabilityProvider = 'observability/provider',
}
export enum PluginType {
diff --git a/packages/app/src/shared/observability/README.md b/packages/app/src/shared/observability/README.md
index c93462a0..c8cf91b8 100644
--- a/packages/app/src/shared/observability/README.md
+++ b/packages/app/src/shared/observability/README.md
@@ -97,25 +97,23 @@ Observability.userIdentity.identifyUser('user-123', {
## How It Works
1. **Plugin Registration** (Enterprise Only):
- - Enterprise edition registers PostHog providers in `src/react/plugins.tsx`
- - Uses `PluginTarget.UserBehaviorObservabilityProvider` and other targets
+ - Enterprise edition registers a unified PostHog provider in `src/react/plugins.tsx`
+ - Uses `PluginTarget.ObservabilityProvider` for all observability capabilities
- Happens during app initialization
2. **Lazy Loading**:
- - Providers are lazy-loaded on first use
+ - Provider is lazy-loaded on first use
- Falls back to no-op implementation if no plugin registered
3. **Zero Overhead**:
- In community edition, all methods are empty functions
- No performance impact when analytics are disabled
-## Plugin Targets
+## Plugin Target
-Three plugin targets are available for provider registration:
+A single unified plugin target is used for provider registration:
-- `UserBehaviorObservabilityProvider`: User interactions and feature usage
-- `SystemInsightCaptureProvider`: System events and performance metrics
-- `UserIdentityContextProvider`: User identification and context
+- `ObservabilityProvider`: Provides complete observability functionality including user behavior tracking, system insights, user identity management, and feature flags
## Documentation
diff --git a/packages/app/src/shared/observability/index.ts b/packages/app/src/shared/observability/index.ts
index 830116cf..f498ebba 100644
--- a/packages/app/src/shared/observability/index.ts
+++ b/packages/app/src/shared/observability/index.ts
@@ -18,108 +18,41 @@
*/
import { plugins, PluginTarget, PluginType } from '@react/shared/plugins/Plugins';
-import {
- NoOpSystemInsightCapture,
- NoOpUserBehaviorObservability,
- NoOpUserIdentityContext,
-} from './no-op-providers';
-import type {
- ISystemInsightCapture,
- IUserBehaviorObservability,
- IUserIdentityContext,
-} from './types';
-
-/**
- * Lazy-loaded singleton for user behavior observability
- */
-let userBehaviorInstance: IUserBehaviorObservability | null = null;
-
-/**
- * Lazy-loaded singleton for system insight capture
- */
-let systemInsightInstance: ISystemInsightCapture | null = null;
-
-/**
- * Lazy-loaded singleton for user identity context
- */
-let userIdentityInstance: IUserIdentityContext | null = null;
-
-/**
- * Gets the user behavior observability provider from plugins
- * Falls back to no-op implementation if no plugin is registered
- */
-function getUserBehaviorProvider(): IUserBehaviorObservability {
- if (userBehaviorInstance) {
- return userBehaviorInstance;
- }
-
- // Try to get provider from enterprise plugin
- const registeredPlugins = plugins.getPluginsByTarget(
- PluginTarget.UserBehaviorObservabilityProvider,
- PluginType.Config,
- );
-
- if (registeredPlugins.length > 0 && registeredPlugins[0].type === PluginType.Config) {
- const provider = registeredPlugins[0].config as IUserBehaviorObservability;
- userBehaviorInstance = provider;
- return provider;
- }
-
- // Fall back to no-op implementation (default for community edition)
- userBehaviorInstance = new NoOpUserBehaviorObservability();
- return userBehaviorInstance;
-}
+import { NoOpObservabilityProvider } from './no-op-providers';
+import type { IObservabilityProvider, ObservabilityEventProperties } from './types';
/**
- * Gets the system insight capture provider from plugins
- * Falls back to no-op implementation if no plugin is registered
+ * Lazy-loaded singleton for the unified observability provider
*/
-function getSystemInsightProvider(): ISystemInsightCapture {
- if (systemInsightInstance) {
- return systemInsightInstance;
- }
-
- // Try to get provider from enterprise plugin
- const registeredPlugins = plugins.getPluginsByTarget(
- PluginTarget.SystemInsightCaptureProvider,
- PluginType.Config,
- );
-
- if (registeredPlugins.length > 0 && registeredPlugins[0].type === PluginType.Config) {
- const provider = registeredPlugins[0].config as ISystemInsightCapture;
- systemInsightInstance = provider;
- return provider;
- }
-
- // Fall back to no-op implementation (default for community edition)
- systemInsightInstance = new NoOpSystemInsightCapture();
- return systemInsightInstance;
-}
+let observabilityInstance: IObservabilityProvider | null = null;
/**
- * Gets the user identity context provider from plugins
+ * Gets the unified observability provider from plugins
* Falls back to no-op implementation if no plugin is registered
+ *
+ * This function lazily retrieves the provider registered by enterprise editions
+ * or returns a no-op implementation for community edition.
*/
-function getUserIdentityProvider(): IUserIdentityContext {
- if (userIdentityInstance) {
- return userIdentityInstance;
+function getObservabilityProvider(): IObservabilityProvider {
+ if (observabilityInstance) {
+ return observabilityInstance;
}
// Try to get provider from enterprise plugin
const registeredPlugins = plugins.getPluginsByTarget(
- PluginTarget.UserIdentityContextProvider,
+ PluginTarget.ObservabilityProvider,
PluginType.Config,
);
if (registeredPlugins.length > 0 && registeredPlugins[0].type === PluginType.Config) {
- const provider = registeredPlugins[0].config as IUserIdentityContext;
- userIdentityInstance = provider;
+ const provider = registeredPlugins[0].config as IObservabilityProvider;
+ observabilityInstance = provider;
return provider;
}
// Fall back to no-op implementation (default for community edition)
- userIdentityInstance = new NoOpUserIdentityContext();
- return userIdentityInstance;
+ observabilityInstance = new NoOpObservabilityProvider();
+ return observabilityInstance;
}
/**
@@ -137,13 +70,22 @@ export const Observability = {
*/
userBehavior: {
recordInteraction: (eventName: string, properties?: Record<string, unknown>) => {
- getUserBehaviorProvider().recordInteraction(eventName, properties);
+ getObservabilityProvider().recordInteraction(
+ eventName,
+ properties as ObservabilityEventProperties,
+ );
},
recordFeatureUsage: (featureName: string, properties?: Record<string, unknown>) => {
- getUserBehaviorProvider().recordFeatureUsage(featureName, properties);
+ getObservabilityProvider().recordFeatureUsage(
+ featureName,
+ properties as ObservabilityEventProperties,
+ );
},
recordWorkflowCompletion: (workflowName: string, properties?: Record<string, unknown>) => {
- getUserBehaviorProvider().recordWorkflowCompletion(workflowName, properties);
+ getObservabilityProvider().recordWorkflowCompletion(
+ workflowName,
+ properties as ObservabilityEventProperties,
+ );
},
},
@@ -153,17 +95,24 @@ export const Observability = {
*/
systemInsight: {
recordSystemEvent: (eventName: string, properties?: Record<string, unknown>) => {
- getSystemInsightProvider().recordSystemEvent(eventName, properties);
+ getObservabilityProvider().recordSystemEvent(
+ eventName,
+ properties as ObservabilityEventProperties,
+ );
},
recordError: (errorName: string, properties?: Record<string, unknown>) => {
- getSystemInsightProvider().recordError(errorName, properties);
+ getObservabilityProvider().recordError(errorName, properties as ObservabilityEventProperties);
},
recordPerformanceMetric: (
metricName: string,
value: number,
properties?: Record<string, unknown>,
) => {
- getSystemInsightProvider().recordPerformanceMetric(metricName, value, properties);
+ getObservabilityProvider().recordPerformanceMetric(
+ metricName,
+ value,
+ properties as ObservabilityEventProperties,
+ );
},
},
@@ -173,22 +122,42 @@ export const Observability = {
*/
userIdentity: {
identifyUser: (userId: string, properties?: Record<string, unknown>) => {
- getUserIdentityProvider().identifyUser({ userId, properties });
+ getObservabilityProvider().identifyUser({
+ userId,
+ properties: properties as ObservabilityEventProperties,
+ });
},
setUserProperties: (properties: Record<string, unknown>) => {
- getUserIdentityProvider().setUserProperties(properties);
+ getObservabilityProvider().setUserProperties(properties as ObservabilityEventProperties);
},
clearUserIdentity: () => {
- getUserIdentityProvider().clearUserIdentity();
+ getObservabilityProvider().clearUserIdentity();
+ },
+ },
+
+ /**
+ * Feature configuration methods
+ * Manages feature flags and experimentation
+ */
+ features: {
+ getFeatureFlag: (featureName: string) => {
+ return getObservabilityProvider().getFeatureFlag(featureName);
+ },
+ isFeatureEnabled: (featureName: string) => {
+ return getObservabilityProvider().isFeatureEnabled(featureName);
+ },
+ getFeatureFlagPayload: (featureName: string) => {
+ return getObservabilityProvider().getFeatureFlagPayload(featureName);
+ },
+ reloadFeatureFlags: () => {
+ getObservabilityProvider().reloadFeatureFlags();
},
},
};
// Re-export types for convenience
export type {
- ISystemInsightCapture,
- IUserBehaviorObservability,
- IUserIdentityContext,
+ IObservabilityProvider,
ObservabilityEventProperties,
UserIdentityContext,
} from './types';
diff --git a/packages/app/src/shared/observability/no-op-providers.ts b/packages/app/src/shared/observability/no-op-providers.ts
index c9c7003b..48a2aba1 100644
--- a/packages/app/src/shared/observability/no-op-providers.ts
+++ b/packages/app/src/shared/observability/no-op-providers.ts
@@ -1,74 +1,55 @@
/**
* No-Op Observability Providers
*
- * These are the default implementations used in community edition.
- * They implement the observability interfaces but perform no actual operations,
+ * This is the default implementation used in community edition.
+ * It implements the observability interface but performs no actual operations,
* ensuring zero overhead when analytics are not needed.
*
- * Enterprise editions can override these by registering their own implementations
+ * Enterprise editions can override this by registering their own implementation
* via the plugin system.
*/
import type {
- ISystemInsightCapture,
- IUserBehaviorObservability,
- IUserIdentityContext,
+ IObservabilityProvider,
ObservabilityEventProperties,
UserIdentityContext,
} from './types';
/**
- * No-op implementation of user behavior observability
- * All methods are empty functions that do nothing
+ * Unified No-Op Observability Provider
+ *
+ * This is the default implementation for community edition.
+ * It provides complete observability interface but performs no actual operations,
+ * ensuring zero overhead when analytics are not needed.
+ *
+ * All methods are no-ops that do nothing or return safe defaults.
*/
-export class NoOpUserBehaviorObservability implements IUserBehaviorObservability {
- /**
- * Records a user interaction (no-op)
- */
+export class NoOpObservabilityProvider implements IObservabilityProvider {
+ // User Behavior Observability
recordInteraction(_eventName: string, _properties?: ObservabilityEventProperties): void {
// No operation - disabled by default
}
- /**
- * Records feature usage (no-op)
- */
recordFeatureUsage(_featureName: string, _properties?: ObservabilityEventProperties): void {
// No operation - disabled by default
}
- /**
- * Records workflow completion (no-op)
- */
recordWorkflowCompletion(
_workflowName: string,
_properties?: ObservabilityEventProperties,
): void {
// No operation - disabled by default
}
-}
-/**
- * No-op implementation of system insight capture
- * All methods are empty functions that do nothing
- */
-export class NoOpSystemInsightCapture implements ISystemInsightCapture {
- /**
- * Records a system event (no-op)
- */
+ // System Insight Capture
recordSystemEvent(_eventName: string, _properties?: ObservabilityEventProperties): void {
// No operation - disabled by default
}
- /**
- * Records an error (no-op)
- */
recordError(_errorName: string, _properties?: ObservabilityEventProperties): void {
// No operation - disabled by default
}
- /**
- * Records a performance metric (no-op)
- */
recordPerformanceMetric(
_metricName: string,
_value: number,
@@ -76,31 +57,34 @@ export class NoOpSystemInsightCapture implements ISystemInsightCapture {
): void {
// No operation - disabled by default
}
-}
-/**
- * No-op implementation of user identity context
- * All methods are empty functions that do nothing
- */
-export class NoOpUserIdentityContext implements IUserIdentityContext {
- /**
- * Identifies a user (no-op)
- */
+ // User Identity Context
identifyUser(_context: UserIdentityContext): void {
// No operation - disabled by default
}
- /**
- * Sets user properties (no-op)
- */
setUserProperties(_properties: ObservabilityEventProperties): void {
// No operation - disabled by default
}
- /**
- * Clears user identity (no-op)
- */
clearUserIdentity(): void {
// No operation - disabled by default
}
+
+ // Feature Configuration
+ getFeatureFlag(_featureName: string): string | boolean | undefined {
+ return undefined;
+ }
+
+ isFeatureEnabled(_featureName: string): boolean {
+ return false;
+ }
+
+ getFeatureFlagPayload(_featureName: string): unknown {
+ return undefined;
+ }
+
+ reloadFeatureFlags(): void {
+ // No operation - disabled by default
+ }
}
diff --git a/packages/app/src/shared/observability/types.ts b/packages/app/src/shared/observability/types.ts
index 99d9712f..414e615d 100644
--- a/packages/app/src/shared/observability/types.ts
+++ b/packages/app/src/shared/observability/types.ts
@@ -29,13 +29,19 @@ export interface UserIdentityContext {
}
/**
- * Interface for capturing user behavior and interaction patterns
+ * Unified Observability Provider Interface
*
- * This abstraction allows enterprise editions to collect product usage metrics,
- * feature adoption data, and workflow completion analytics without modifying
- * community edition code.
+ * This interface provides complete observability capabilities:
+ * - User behavior tracking (interactions, feature usage, workflows)
+ * - System insights (events, errors, performance metrics)
+ * - User identity management (identification, context correlation)
+ * - Feature configuration (flags, A/B testing, rollouts)
+ *
+ * Enterprise editions implement this interface to provide complete observability.
+ * Community edition uses a no-op implementation by default.
*/
-export interface IUserBehaviorObservability {
+export interface IObservabilityProvider {
+ // User Behavior Tracking
/**
* Records a user interaction or behavior event
*
@@ -64,15 +70,8 @@ export interface IUserBehaviorObservability {
* @param properties - Additional context about the workflow
*/
recordWorkflowCompletion(workflowName: string, properties?: ObservabilityEventProperties): void;
-}
-/**
- * Interface for capturing system-level insights and operational metrics
- *
- * This abstraction allows enterprise editions to monitor system performance,
- * error patterns, and operational health without modifying community edition code.
- */
-export interface ISystemInsightCapture {
+ // System Insights
/**
* Records a system-level event
*
@@ -106,15 +105,8 @@ export interface ISystemInsightCapture {
value: number,
properties?: ObservabilityEventProperties,
): void;
-}
-/**
- * Interface for managing user identity context in observability systems
- *
- * This abstraction allows enterprise editions to correlate events with user identities
- * for better analytics and insights.
- */
-export interface IUserIdentityContext {
+ // User Identity Management
/**
* Associates a user identity with subsequent observability events
*
@@ -138,4 +130,52 @@ export interface IUserIdentityContext {
* Clears the current user identity context
*/
clearUserIdentity(): void;
+
+ // Feature Configuration
+ /**
+ * Retrieves the value of a feature flag
+ *
+ * @param featureName - Name of the feature flag
+ * @returns The feature flag value (string, boolean, or undefined if not set)
+ *
+ * @example
+ * ```typescript
+ * const variant = getFeatureFlag('new-ui-design');
+ * if (variant === 'variant_1') {
+ * // Show new UI
+ * }
+ * ```
+ */
+ getFeatureFlag(featureName: string): string | boolean | undefined;
+
+ /**
+ * Checks if a feature is enabled
+ *
+ * @param featureName - Name of the feature
+ * @returns True if the feature is enabled, false otherwise
+ */
+ isFeatureEnabled(featureName: string): boolean;
+
+ /**
+ * Retrieves the feature flag payload (additional metadata)
+ * Can return any type (string, object, boolean, array, etc.) depending on PostHog configuration
+ *
+ * @param featureName - Name of the feature flag
+ * @returns The feature flag payload (any type) or undefined if not set
+ *
+ * @example
+ * ```typescript
+ * const payload = getFeatureFlagPayload('rollout-config');
+ * // Type assertion based on your specific flag configuration
+ * if ((payload as { percentage?: number })?.percentage > 50) {
+ * // Feature is rolled out to more than 50%
+ * }
+ * ```
+ */
+ getFeatureFlagPayload(featureName: string): unknown;
+
+ /**
+ * Reloads feature flags from the server
+ */
+ reloadFeatureFlags(): void;
}
diff --git a/packages/app/src/shared/posthog/index.ts b/packages/app/src/shared/posthog/index.ts
deleted file mode 100644
index 3a9efceb..00000000
--- a/packages/app/src/shared/posthog/index.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-import config from '@src/builder-ui/config';
-import posthog, { Properties } from 'posthog-js';
-
-const POSTHOG_CLIENT_KEY = 'phc_lxgXwZRs6ySZqrHI4niOdYJlVXJAgMjTOhDau7f7VC3';
-
-let initialized = false;
-
-const lazyInit = () => {
- if (!initialized) {
- // can't disable posthog in dev because feature flags depend on it
- posthog?.init(POSTHOG_CLIENT_KEY, {
- autocapture: !config.env.IS_DEV,
- capture_pageview: !config.env.IS_DEV,
- // debug: config.env.IS_DEV,
- person_profiles: 'identified_only',
- api_host: 'https://us.i.posthog.com',
-
- session_recording: {
- maskAllInputs: true,
- maskInputFn: (text, element) => {
- if (element?.dataset.phMask === 'true') {
- return '*'.repeat(text.length); // Mask text if data-ph-mask is true
- }
- return text; // Don't mask other inputs
- },
- },
- });
- initialized = true;
- }
-};
-
-export const PostHog = {
- initialize: () => {
- if (document.readyState === 'complete') {
- lazyInit();
- } else {
- window.addEventListener('load', lazyInit);
- }
- },
-
- // Check if PostHog is fully loaded using the built-in __loaded property
- isLoaded: () => {
- return initialized && posthog?.__loaded;
- },
-
- identify: (userId, properties = {}) => {
- if (!initialized) lazyInit();
- posthog?.identify(userId, properties);
- },
-
- track: (eventName: string, properties: Properties) => {
- if (!initialized) lazyInit();
- posthog?.capture(eventName, properties);
- },
-
- setUserProperties: (properties) => {
- if (!initialized) lazyInit();
- posthog?.people.set(properties);
- },
-
- getFeatureFlag: (featureFlag: string) => {
- if (!initialized) {
- lazyInit();
- }
-
- // Check if PostHog is fully loaded using the built-in __loaded property
- if (!posthog.__loaded) {
- console.warn(
- `PostHog not fully loaded when checking flag: ${featureFlag}. This may return bootstrap/default values.`,
- );
- }
-
- return posthog.getFeatureFlag(featureFlag);
- },
-
- reloadFeatureFlags: (): void => {
- if (!initialized) {
- lazyInit();
- }
- posthog?.reloadFeatureFlags();
- },
-};
diff --git a/packages/app/src/shared/state_stores/auth/slices/base.slice.ts b/packages/app/src/shared/state_stores/auth/slices/base.slice.ts
index 26138a49..fbe5f2a0 100644
--- a/packages/app/src/shared/state_stores/auth/slices/base.slice.ts
+++ b/packages/app/src/shared/state_stores/auth/slices/base.slice.ts
@@ -1,3 +1,4 @@
+import { PostHog } from '@enterprise/shared/posthog';
import {
getProperTeamSubs,
getTeamMembers,
@@ -9,7 +10,6 @@ import { getUserInfo } from '@src/react/features/account/clients';
import { getUserOnboardingInfo } from '@src/react/features/onboarding/clients';
import { getUserSettings } from '@src/react/shared/hooks/useUserSettings';
import { IMembershipTeam } from '@src/react/shared/types/entities';
-import { PostHog } from '@src/shared/posthog';
import { StateCreator } from 'zustand';
import { FEATURE_FLAGS } from '../../../constants/featureflags';
import { userSettingKeys } from '../../../userSettingKeys';
diff --git a/packages/app/views/index.ejs b/packages/app/views/index.ejs
index f0c0ce8f..aaa36e00 100644
--- a/packages/app/views/index.ejs
+++ b/packages/app/views/index.ejs
@@ -42,9 +42,9 @@
<link rel="stylesheet" href="/css/smyth-tailwind.css" />
+ <%- include('tracking/posthog-init'); -%>
-
- <%- include('tracking/posthog-tracking'); -%> <% if (env !== 'DEV' && typeof includeTracking !==
+ <% if (env !== 'DEV' && typeof includeTracking !==
'undefined' && includeTracking) { %> <%- include('tracking/head-tracking'); -%> <% } %>
</head>
diff --git a/packages/app/views/modals/smythos-v3-march-25.ejs b/packages/app/views/modals/smythos-v3-march-25.ejs
index 18c60812..8dc80966 100644
--- a/packages/app/views/modals/smythos-v3-march-25.ejs
+++ b/packages/app/views/modals/smythos-v3-march-25.ejs
@@ -65,7 +65,6 @@
if (modal && !path.includes('/welcome')) {
modal.classList.remove('hidden');
localStorage.setItem('smythosV3March25ModalSeen', 'true');
- posthog?.capture?.('smythos-v3-march-25-modal-seen');
}
}
}
@@ -73,7 +72,6 @@
window.closeSmythosV3March25Modal = () => {
const modal = document.getElementById('smythos-v3-march-25');
- posthog?.capture?.('smythos-v3-march-25-modal-closed');
if (modal) {
modal.classList.add('hidden');
}
diff --git a/packages/app/views/pages/builder.ejs b/packages/app/views/pages/builder.ejs
index a5648841..37658604 100644
--- a/packages/app/views/pages/builder.ejs
+++ b/packages/app/views/pages/builder.ejs
@@ -153,24 +153,13 @@
window.__LLM_MODELS__ = JSON.parse('<%- JSON.stringify(LLMModels) %>');
window.isSmythStaff = JSON.parse('<%- JSON.stringify(isSmythStaff) %>');
window.isSmythAlpha = JSON.parse('<%- JSON.stringify(isSmythAlpha) %>');
- window.postHogSignupEvents = JSON.parse(
- '<%- typeof postHogSignupEvents !== "undefined" ? JSON.stringify(postHogSignupEvents) : "[]" %>',
- );
+
+ // Observability flag
+ window.isObservability = false;
window.navPages = JSON.parse('<%- JSON.stringify(navPages) %>');
window.user = JSON.parse('<%- JSON.stringify(user) %>');
- function sendPostHogEvents() {
- if (posthog?.capture) {
- window.postHogSignupEvents?.forEach((event) => {
- if (event?.eventType && event?.eventData) {
- posthog.capture(event.eventType, event.eventData);
- }
- });
- } else {
- setTimeout(sendPostHogEvents, 1000);
- }
- }
- sendPostHogEvents();
+
const setup = () => {
const isSmythStaff = window.isSmythStaff || false;
const isSmythAlpha = window.isSmythAlpha || false;
diff --git a/packages/app/views/pages/partials/studio/modals/new-year-2025.ejs b/packages/app/views/pages/partials/studio/modals/new-year-2025.ejs
index a15ea732..a5381ab5 100644
--- a/packages/app/views/pages/partials/studio/modals/new-year-2025.ejs
+++ b/packages/app/views/pages/partials/studio/modals/new-year-2025.ejs
@@ -86,7 +86,6 @@
if (modal) {
modal.classList.remove('hidden');
localStorage.setItem('newYearModal2025Seen', 'true');
- posthog?.capture?.('new-year-modal-2025-seen');
}
}
}
@@ -94,7 +93,7 @@
window.closeNewYearModal2025 = () => {
const modal = document.getElementById('new-year-modal-2025');
- posthog?.capture?.('new-year-modal-2025-closed');
+ // Community edition: No tracking
if (modal) {
modal.classList.add('hidden');
}
diff --git a/packages/app/views/pages/react.ejs b/packages/app/views/pages/react.ejs
index 16a68e52..0e7a7387 100644
--- a/packages/app/views/pages/react.ejs
+++ b/packages/app/views/pages/react.ejs
@@ -7,18 +7,8 @@
<% } %>
<script>
- window.postHogSignupEvents = JSON.parse('<%- typeof postHogSignupEvents !== "undefined" ? JSON.stringify(postHogSignupEvents) : "[]" %>');
+ // Observability flag - determines if tracking is enabled (always false in community edition)
+ window.isObservability = false;
- function sendPostHogEvents() {
- if (posthog?.capture) {
- window.postHogSignupEvents?.forEach((event) => {
- if (event?.eventType && event?.eventData) {
- posthog.capture(event.eventType, event.eventData);
- }
- });
- } else {
- setTimeout(sendPostHogEvents, 1000);
- }
- }
- sendPostHogEvents();
+ // Community edition: No tracking functionality
</script>
diff --git a/packages/app/views/pages/webappv2.ejs b/packages/app/views/pages/webappv2.ejs
index 012f50a5..cdebc964 100644
--- a/packages/app/views/pages/webappv2.ejs
+++ b/packages/app/views/pages/webappv2.ejs
@@ -17,19 +17,6 @@
</script>
<script>
- window.postHogSignupEvents = JSON.parse('<%- typeof postHogSignupEvents !== "undefined" ? JSON.stringify(postHogSignupEvents) : "[]" %>');
-
- function sendPostHogEvents() {
-
- if (posthog?.capture) {
- window.postHogSignupEvents?.forEach((event) => {
- if (event?.eventType && event?.eventData) {
- posthog.capture(event.eventType, event.eventData);
- }
- });
- } else {
- setTimeout(sendPostHogEvents, 1000);
- }
- }
- sendPostHogEvents();
+ // Observability flag
+ window.isObservability = false;
</script>
diff --git a/packages/app/views/tracking/posthog-init.ejs b/packages/app/views/tracking/posthog-init.ejs
new file mode 100644
index 00000000..132f9d75
--- /dev/null
+++ b/packages/app/views/tracking/posthog-init.ejs
@@ -0,0 +1,22 @@
+<!-- PostHog stub (Community Edition) - No tracking -->
+<script>
+ // Community edition: No-op PostHog stub to prevent errors
+ window.posthog = {
+ init: function () {},
+ identify: function () {},
+ capture: function () {},
+ reset: function () {},
+ getFeatureFlag: function () {
+ return false;
+ },
+ isFeatureEnabled: function () {
+ return false;
+ },
+ reloadFeatureFlags: function () {},
+ people: {
+ set: function () {},
+ set_once: function () {},
+ },
+ __loaded: false,
+ };
+</script>
diff --git a/packages/app/views/tracking/posthog-tracking.ejs b/packages/app/views/tracking/posthog-tracking.ejs
deleted file mode 100644
index e679c704..00000000
--- a/packages/app/views/tracking/posthog-tracking.ejs
+++ /dev/null
@@ -1,48 +0,0 @@
-<!-- Posthog -->
-<script>
- !(function (t, e) {
- var o, n, p, r;
- e.__SV ||
- ((window.posthog = e),
- (e._i = []),
- (e.init = function (i, s, a) {
- function g(t, e) {
- var o = e.split('.');
- 2 == o.length && ((t = t[o[0]]), (e = o[1])),
- (t[e] = function () {
- t.push([e].concat(Array.prototype.slice.call(arguments, 0)));
- });
- }
- ((p = t.createElement('script')).type = 'text/javascript'),
- (p.async = !0),
- (p.src = s.api_host + '/static/array.js'),
- (r = t.getElementsByTagName('script')[0]).parentNode.insertBefore(p, r);
- var u = e;
- for (
- void 0 !== a ? (u = e[a] = []) : (a = 'posthog'),
- u.people = u.people || [],
- u.toString = function (t) {
- var e = 'posthog';
- return 'posthog' !== a && (e += '.' + a), t || (e += ' (stub)'), e;
- },
- u.people.toString = function () {
- return u.toString(1) + '.people (stub)';
- },
- o =
- 'capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys getNextSurveyStep onSessionId'.split(
- ' ',
- ),
- n = 0;
- n < o.length;
- n++
- )
- g(u, o[n]);
- e._i.push([i, s, a]);
- }),
- (e.__SV = 1));
- })(document, window.posthog || []);
- posthog.init('phc_lxgXwZRs6ySZqrHI4niOdYJlVXJAgMjTOhDau7f7VC3', {
- api_host: 'https://us.i.posthog.com',
- person_profiles: 'identified_only',
- });
-</script>