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.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
simplify posthog and use observability instead of posthog
ali-inkco21be642f1781
diff --git a/packages/app/src/builder-ui/components/APIEndpoint.class.ts b/packages/app/src/builder-ui/components/APIEndpoint.class.tsindex a9b97ebf..d5a4a0ce 100644--- a/packages/app/src/builder-ui/components/APIEndpoint.class.ts+++ b/packages/app/src/builder-ui/components/APIEndpoint.class.ts@@ -379,7 +379,7 @@ export class APIEndpoint extends Component {const missingSettings = requiredSettings.filter((setting) => !this.data[setting.id]);if (missingSettings.length === 0 && this.properties?.inputProps?.length > 0) {- Observability.userBehavior.recordInteraction('app_form_preview_impression', {});+ Observability.observeInteraction('app_form_preview_impression', {});this.formPreviewButton = this.addComponentButton(`<div class="fa-solid fa-play" id="form-preview-button-icon"></div><p class="ml-2 font-semibold">Form Preview</p>`,' ',@@ -666,7 +666,7 @@ export class APIEndpoint extends Component {}private async handleFormPreviewBtnClick() {- Observability.userBehavior.recordInteraction('app_form_preview_click', {});+ Observability.observeInteraction('app_form_preview_click', {});let autoFillDataJson = this.cachedAutoFillDataJson;const formPreviewButton = this.domElement.querySelector(diff --git a/packages/app/src/builder-ui/components/AgentCard.class.ts b/packages/app/src/builder-ui/components/AgentCard.class.tsindex 18475074..d4aabb56 100644--- a/packages/app/src/builder-ui/components/AgentCard.class.ts+++ b/packages/app/src/builder-ui/components/AgentCard.class.ts@@ -608,7 +608,7 @@ export class AgentCard extends EventEmitter {destroyCanvasContextMenu();e.stopPropagation();- Observability.userBehavior.recordInteraction('app_preview_as_chatbot_click', {});+ Observability.observeInteraction('app_preview_as_chatbot_click', {});const embodimentTestButton = document.querySelector('#btn-emb-chatbot-main');const embodimentOpened = document.querySelector(diff --git a/packages/app/src/builder-ui/components/Component.class/index.ts b/packages/app/src/builder-ui/components/Component.class/index.tsindex a3a54a4c..dc37848c 100644--- a/packages/app/src/builder-ui/components/Component.class/index.ts+++ b/packages/app/src/builder-ui/components/Component.class/index.ts@@ -525,7 +525,7 @@ export class Component extends EventEmitter {`Missing Settings ${missingSettings.map((e) => e.name).join(', ')}`,'alert pointer',() => {- Observability.userBehavior.recordInteraction('app_component_alert_click', {+ Observability.observeInteraction('app_component_alert_click', {type: 'missing settings',});this.editSettings();@@ -625,7 +625,7 @@ export class Component extends EventEmitter {if (missingSettings.length > 0) {this.addComponentMessage(`Missing Settings`, 'alert pointer', () => {- Observability.userBehavior.recordInteraction('app_component_alert_click', {+ Observability.observeInteraction('app_component_alert_click', {type: 'missing settings',});this.editSettings();@@ -747,7 +747,7 @@ export class Component extends EventEmitter {`Missing Key "${keyName}"`,'alert pointer',() => {- Observability.userBehavior.recordInteraction('app_component_alert_click', {+ Observability.observeInteraction('app_component_alert_click', {type: 'missing key',});missingKeyMessageClickHandler.bind(this, keyName)();@@ -2935,7 +2935,7 @@ export class Component extends EventEmitter {operation: 'step' | 'run' = 'step',prefillValues?: Record<string, any>,) {- Observability.userBehavior.recordInteraction('app_debug_inject_click', {});+ Observability.observeInteraction('app_debug_inject_click', {});event.stopPropagation();event.stopImmediatePropagation();const debugBtn = this.domElement.querySelector('.btn-debug');@@ -3515,7 +3515,7 @@ function addMissingKey({await saveKey({ ...fieldValues, apiKey: mockKey }, dialog);// #region enable mock data- Observability.userBehavior.recordInteraction('app_mock_screen_impression', {+ Observability.observeInteraction('app_mock_screen_impression', {source: 'skip_and_set_mock_data',});await saveMockOutputs(component);diff --git a/packages/app/src/builder-ui/components/Component.class/mock-data-handler.ts b/packages/app/src/builder-ui/components/Component.class/mock-data-handler.tsindex 423b655a..d9737f68 100644--- a/packages/app/src/builder-ui/components/Component.class/mock-data-handler.ts+++ b/packages/app/src/builder-ui/components/Component.class/mock-data-handler.ts@@ -210,7 +210,7 @@ export function saveMockOutputs(component: Component) {try {await insertOrUpdateMockData(component.uid, { enabled: true, data: { outputs } });- Observability.userBehavior.recordFeatureUsage('app_set_mock_data', {});+ Observability.observeInteraction('app_set_mock_data', {});resolve('saved');} finally {@@ -441,7 +441,7 @@ export async function addMockDataToggleButton(component: Component) {await insertOrUpdateMockData(component.uid, { enabled: false });MockDataToggleButtonState.turnOff(component);} else {- Observability.userBehavior.recordInteraction('app_mock_screen_impression', {+ Observability.observeInteraction('app_mock_screen_impression', {source: 'use_mock_data_button',});await saveMockOutputs(component);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.tsindex b8c37cbb..d0ef29d9 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@@ -112,7 +112,7 @@ async function onComponentLoad(sidebar) {const isDebugCurrentlyOn = debugSwitcher && debugSwitcher.classList.contains('active');// Fire telemetry event- Observability.userBehavior.recordInteraction('test_with_debug_component_sidebar_clicked', {+ Observability.observeInteraction('test_with_debug_component_sidebar_clicked', {source: 'component_settings_sidebar',componentType: component.constructor.name,componentId: component.uid,diff --git a/packages/app/src/builder-ui/debugger.ts b/packages/app/src/builder-ui/debugger.tsindex d7a293a6..31b36d63 100644--- a/packages/app/src/builder-ui/debugger.ts+++ b/packages/app/src/builder-ui/debugger.ts@@ -1,6 +1,5 @@import { errorToast, successToast, warningToast } from '@src/shared/components/toast';import { Observability } from '@src/shared/observability';-import { PostHog } from '@enterprise/shared/posthog';import interact from 'interactjs';import { jsonrepair } from 'jsonrepair';import { Component } from './components/Component.class';@@ -143,7 +142,7 @@ function toggleSwitch(on: boolean) {const debugSwitcherMessage = document?.querySelector('.debug-switcher-message');if (on) {- Observability.userBehavior.recordInteraction('debug_button_click', {+ Observability.observeInteraction('debug_button_click', {position: 'bottom center of builder',type: 'debug',});@@ -255,7 +254,7 @@ function applyDebugButtonStyles(debugLogBtn: HTMLElement, fixWithAIBtn: HTMLElemfunction runDebugInjectButtonExperiment() {try {- const featureVariant = PostHog.getFeatureFlag(+ const featureVariant = Observability.features.getFeatureFlag(FEATURE_FLAGS.DEBUG_INJECT_TEXT_EXPERIMENT,) as string;handleDebugButtons(featureVariant);@@ -265,7 +264,7 @@ function runDebugInjectButtonExperiment() {}function runFixWithAIEExperiment() {- const featureVariant = PostHog.getFeatureFlag(+ const featureVariant = Observability.features.getFeatureFlag(FEATURE_FLAGS.POSTHOG_EXPERIMENT_FIX_WITH_AI,) as string;if (featureVariant === FIX_WITH_AI_EXPERIMENT_VARIANTS.VARIANT_1) {@@ -396,7 +395,7 @@ export async function init() {const attachBtn = document.getElementById('debug-menubtn-attach');runBtn?.addEventListener('click', async (event) => {console.log('debug run');- Observability.userBehavior.recordInteraction('debug_button_click', {+ Observability.observeInteraction('debug_button_click', {position: 'bottom center of builder',type: 'run',});@@ -439,7 +438,7 @@ export async function init() {});stepBtn.addEventListener('click', async (event) => {console.log('debug Step');- Observability.userBehavior.recordInteraction('debug_button_click', {+ Observability.observeInteraction('debug_button_click', {position: 'bottom center of builder',type: 'step',});@@ -497,7 +496,7 @@ export async function init() {attachBtn.addEventListener('click', async (e) => {//attach to a live debug session- Observability.userBehavior.recordInteraction('debug_button_click', {+ Observability.observeInteraction('debug_button_click', {position: 'bottom center of builder',type: 'attach',});@@ -535,7 +534,7 @@ export async function init() {});document.getElementById('debug-menubtn-stop').addEventListener('click', async (e) => {- Observability.userBehavior.recordInteraction('debug_button_click', {+ Observability.observeInteraction('debug_button_click', {position: 'bottom center of builder',type: 'stop',});@@ -626,7 +625,7 @@ export async function runDebug() {runBtn.classList.add('running');isRunning = true;- Observability.userBehavior.recordFeatureUsage('app_run_agent', {});+ Observability.observeInteraction('app_run_agent', {});let sessionID;let processComponents = true;@@ -668,7 +667,7 @@ export async function runDebug() {}console.log('debug run end');- Observability.userBehavior.recordWorkflowCompletion('app_workflow_test_completed', {+ Observability.observeInteraction('app_workflow_test_completed', {status: workflowStatus,source: 'debugger',});diff --git a/packages/app/src/builder-ui/pages/builder/agent-settings.ts b/packages/app/src/builder-ui/pages/builder/agent-settings.tsindex 443bf603..7c28e1e3 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 { Observability } from '@src/shared/observability';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';@@ -638,7 +638,7 @@ function updateWorkspaceEmbodiments(agent) {if (btnAgentLLM) {btnAgentLLM.onclick = () => {- // PostHog.track('agentLLM_embodiment_click', {+ // Observability.userBehavior.recordInteraction('agentLLM_embodiment_click', {// position: 'top right of builder inside dropdown',// });openLLMEmbodiment(workspace, openEmbodimentDialog);@@ -792,7 +792,7 @@ export async function openEmbodimentDialog(content, actions = {}, title, tooltip}export async function openChatGPTEmbodiment() {- // PostHog.track('chatgpt_embodiment_click', { position: 'top right of builder inside dropdown' });+ // Observability.userBehavior.recordInteraction('chatgpt_embodiment_click', { position: 'top right of builder inside dropdown' });const { dev: testDomain, prod: prodDomain, scheme } = builderStore.getState().agentDomains;if (!testDomain && !prodDomain) {@@ -848,7 +848,7 @@ export async function openChatGPTEmbodiment() {}export async function openPostmanEmbodiment() {- // PostHog.track('postman_embodiment_click', { position: 'top right of builder inside dropdown' });+ // Observability.userBehavior.recordInteraction('postman_embodiment_click', { position: 'top right of builder inside dropdown' });const { dev: testDomain, prod: prodDomain, scheme } = builderStore.getState().agentDomains;@@ -906,7 +906,9 @@ export async function openPostmanEmbodiment() {}export async function openAlexaEmbodiment() {- PostHog.track('alexa_embodiment_click', { position: 'top right of builder inside dropdown' });+ Observability.userBehavior.recordInteraction('alexa_embodiment_click', {+ position: 'top right of builder inside dropdown',+ });const { dev: testDomain, prod: prodDomain, scheme } = builderStore.getState().agentDomains;const wrapContent = (content) => `<div id="alexa-embodiment-wrapper">${content}</div>`;@@ -1144,7 +1146,7 @@ export async function openAlexaEmbodiment() {}export async function openChatbotEmbodiment() {- // PostHog.track('chatbot_embodiment_click', { position: 'top right of builder inside dropdown' });+ // Observability.userBehavior.recordInteraction('chatbot_embodiment_click', { position: 'top right of builder inside dropdown' });const { dev: testDomain, scheme } = builderStore.getState().agentDomains;const modalBox: HTMLElement = document.querySelector('.modalBox');@@ -1262,7 +1264,7 @@ export async function openChatbotEmbodiment() {}export async function openAPIEmbodiment() {- // PostHog.track('api_embodiment_click', { position: 'top right of builder inside dropdown' });+ // Observability.userBehavior.recordInteraction('api_embodiment_click', { position: 'top right of builder inside dropdown' });const { dev: testDomain, scheme } = builderStore.getState().agentDomains;console.log('test domain found,', testDomain, 'Store:', builderStore.getState());const modalBox: HTMLElement = document.querySelector('.modalBox');@@ -1330,7 +1332,9 @@ export async function openAPIEmbodiment() {}export async function openMCPEmbodiment() {- PostHog.track('mcp_embodiment_click', { position: 'top right of builder inside dropdown' });+ Observability.userBehavior.recordInteraction('mcp_embodiment_click', {+ position: 'top right of builder inside dropdown',+ });const { dev: testDomain, prod: prodDomain, scheme } = builderStore.getState().agentDomains;const wrapContent = (content) => `<div id="mcp-embodiment-wrapper">${content}</div>`;@@ -1444,7 +1448,7 @@ export async function openMCPEmbodiment() {}async function openFormPreviewEmbodiment() {- // PostHog.track('form_preview_embodiment_click', { position: 'top right of builder inside dropdown' });+ // Observability.userBehavior.recordInteraction('form_preview_embodiment_click', { position: 'top right of builder inside dropdown' });const modalBox: HTMLElement = document.querySelector('.modalBox');if (modalBox) {modalBox.style.width = '800px';diff --git a/packages/app/src/builder-ui/pages/builder/components-menu.ts b/packages/app/src/builder-ui/pages/builder/components-menu.tsindex 9e63d652..82cf780d 100644--- a/packages/app/src/builder-ui/pages/builder/components-menu.ts+++ b/packages/app/src/builder-ui/pages/builder/components-menu.ts@@ -748,7 +748,7 @@ function setupBuilderMenuDragDrop() {return;}- Observability.userBehavior.recordFeatureUsage('app_component_used', {+ Observability.observeInteraction('app_component_used', {name: event.relatedTarget.getAttribute('smt-component'),type: !!templateId ? 'integration' : 'component',});@@ -914,7 +914,7 @@ function setupBuilderMenuDragDrop() {}function renderUpgradeModal() {- Observability.userBehavior.recordInteraction('upgrade_impression', {+ Observability.observeInteraction('upgrade_impression', {page_url: '/builder',source: 'adding integrations to the agent',});@@ -940,7 +940,7 @@ function renderUpgradeModal() {cssClass:'bg-primary-100 text-white rounded-md px-4 py-1.5 hover:opacity-75 cursor-pointer w-full',callback: (_, dialog) => {- Observability.userBehavior.recordInteraction('upgrade_click', {+ Observability.observeInteraction('upgrade_click', {page_url: '/builder',source: 'adding integrations in the agent',});@@ -977,7 +977,7 @@ function renderCompUpgradeModal({page_url: string;};}) {- Observability.userBehavior.recordInteraction('upgrade_impression', {+ Observability.observeInteraction('upgrade_impression', {page_url: analytics.page_url,source: analytics.source,});@@ -1090,7 +1090,7 @@ function isLegacyPlan() {}function renderRestrictedAccessModal(feature: string) {- Observability.userBehavior.recordInteraction('upgrade_impression', {+ Observability.observeInteraction('upgrade_impression', {page_url: '/builder',source: `adding ${feature}`,});@@ -1148,7 +1148,7 @@ function renderRestrictedAccessModal(feature: string) {}function renderRestrictedAccessModalWebTools() {- Observability.userBehavior.recordInteraction('upgrade_impression', {+ Observability.observeInteraction('upgrade_impression', {page_url: '/builder',source: 'adding web tools',});diff --git a/packages/app/src/builder-ui/pages/builder/index.ts b/packages/app/src/builder-ui/pages/builder/index.tsindex 4ca801c3..d5f68e31 100644--- a/packages/app/src/builder-ui/pages/builder/index.ts+++ b/packages/app/src/builder-ui/pages/builder/index.ts@@ -329,7 +329,7 @@ export default async function scripts() {// handle A/B testing for help button// const helpButton = document.querySelector('#help-button') as HTMLElement;// if (helpButton) {- // if (PostHog.getFeatureFlag('app-help-button') === 'show') {+ // if (Observability.features.getFeatureFlag('app-help-button') === 'show') {// helpButton.classList.remove('hidden');// helpButton.classList.add('flex');// } else {diff --git a/packages/app/src/builder-ui/tutorials/index.ts b/packages/app/src/builder-ui/tutorials/index.tsindex c481335b..76079e40 100644--- a/packages/app/src/builder-ui/tutorials/index.ts+++ b/packages/app/src/builder-ui/tutorials/index.ts@@ -32,7 +32,7 @@ export const builderPageTutorialWorkflow = async () => {},onReset: () => {// Called when overlay is about to be cleared- Observability.userBehavior.recordWorkflowCompletion('builder_page_tutorial_completed', {+ Observability.observeInteraction('builder_page_tutorial_completed', {page_url: '/builder',source: 'Tutorial completed on builder page onboarding',});diff --git a/packages/app/src/builder-ui/ui/dialogs.ts b/packages/app/src/builder-ui/ui/dialogs.tsindex f9d41c45..75ec87a6 100644--- a/packages/app/src/builder-ui/ui/dialogs.ts+++ b/packages/app/src/builder-ui/ui/dialogs.ts@@ -289,7 +289,7 @@ document.addEventListener('DOMContentLoaded', async () => {const chatbotButton = document.getElementById('btn-emb-chatbot-main');if (chatbotButton) {chatbotButton.addEventListener('click', async (event) => {- Observability.userBehavior.recordInteraction('test_embodiment_click', {+ Observability.observeInteraction('test_embodiment_click', {position: 'top right of builder dropdown',});@@ -431,14 +431,14 @@ export async function createEmbodimentSidebar(title?, content?, actions?, tooltiswitch (key.toLowerCase()) {case 'llm':if (window.workspace) {- Observability.userBehavior.recordInteraction('agentLLM_embodiment_click', {+ Observability.observeInteraction('agentLLM_embodiment_click', {position: 'embodiment sidebar tab',});openLLMEmbodiment(window.workspace, embodimentHandlers.openEmbodimentDialog);}break;case 'api':- Observability.userBehavior.recordInteraction('api_embodiment_click', {+ Observability.observeInteraction('api_embodiment_click', {position: 'embodiment sidebar tab',});embodimentHandlers.openAPIEmbodiment?.();@@ -446,7 +446,7 @@ export async function createEmbodimentSidebar(title?, content?, actions?, toolticase 'chat':const chatContCls = convertTitleToClass(EMBODIMENT_DESCRIPTIONS.chat.title);if (!sidebarContent.querySelector(`.${chatContCls}`)) {- Observability.userBehavior.recordInteraction('chatbot_embodiment_click', {+ Observability.observeInteraction('chatbot_embodiment_click', {position: 'embodiment sidebar tab',});embodimentHandlers.openChatbotEmbodiment?.();@@ -471,26 +471,26 @@ export async function createEmbodimentSidebar(title?, content?, actions?, toolti}break;case 'chatgpt':- Observability.userBehavior.recordInteraction('chatgpt_embodiment_click', {+ Observability.observeInteraction('chatgpt_embodiment_click', {position: 'embodiment sidebar tab',});embodimentHandlers.openChatGPTEmbodiment?.();break;case 'postman':- Observability.userBehavior.recordInteraction('postman_embodiment_click', {+ Observability.observeInteraction('postman_embodiment_click', {position: 'embodiment sidebar tab',});embodimentHandlers.openPostmanEmbodiment?.();break;case 'alexa':- Observability.userBehavior.recordInteraction('alexa_embodiment_click', {+ Observability.observeInteraction('alexa_embodiment_click', {position: 'embodiment sidebar tab',});embodimentHandlers.openAlexaEmbodiment?.();break;case 'agent_skill':const agentSkillContCls = convertTitleToClass(EMBODIMENT_DESCRIPTIONS.agent_skill.title);- Observability.userBehavior.recordInteraction('form_preview_embodiment_click', {+ Observability.observeInteraction('form_preview_embodiment_click', {position: 'embodiment sidebar tab',});if (!sidebarContent.querySelector(`.${agentSkillContCls}`)) {@@ -511,7 +511,7 @@ export async function createEmbodimentSidebar(title?, content?, actions?, tooltibreak;case 'mcp':- Observability.userBehavior.recordInteraction('mcp_embodiment_click', {+ Observability.observeInteraction('mcp_embodiment_click', {position: 'embodiment sidebar tab',});embodimentHandlers.openMCPEmbodiment?.();diff --git a/packages/app/src/react/app/App.tsx b/packages/app/src/react/app/App.tsxindex 9b7757eb..bae1567c 100644--- a/packages/app/src/react/app/App.tsx+++ b/packages/app/src/react/app/App.tsx@@ -2,24 +2,13 @@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';import { BrowserRouter as Router } from 'react-router-dom';import { ToastContainer } from 'react-toastify';import { routeMap } from './routeMap';import RoutesWrapper from './routes';const App = () => {- useEffect(() => {- // 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>diff --git a/packages/app/src/react/app/routes.tsx b/packages/app/src/react/app/routes.tsxindex cc7c8e68..ccae9c0c 100644--- a/packages/app/src/react/app/routes.tsx+++ b/packages/app/src/react/app/routes.tsx@@ -28,7 +28,9 @@ const RoutesWrapper = ({ pages }: { pages: IPageRoute[] }) => {const { subs } = userInfoCtx?.userInfo ?? {};const planNameLower = subs?.plan?.name?.toLowerCase() || '';const isBuilderPlan = planNameLower === PRICING_PLANS_V4.BUILDER.toLowerCase();- const flagValue = PostHog.getFeatureFlag(FEATURE_FLAGS.ONBOARDING_CALLS_FOR_BUILDER_PLAN);+ const flagValue = Observability.features.getFeatureFlag(+ FEATURE_FLAGS.ONBOARDING_CALLS_FOR_BUILDER_PLAN,+ );if (isBuilderPlan && typeof flagValue !== 'boolean' && flagValue !== 'variant_1') {useGetBookAnIntroCall({@@ -88,7 +90,7 @@ const RoutesWrapper = ({ pages }: { pages: IPageRoute[] }) => {});// Reload feature flags after user identification- PostHog.reloadFeatureFlags();+ Observability.features.reloadFeatureFlags();// Wait a bit longer for flags to reload before checking featuressetTimeout(checkFeatureFlag, 2000);diff --git a/packages/app/src/react/features/agent-settings/components/Assignments/ChatWithAgentWidget.tsx b/packages/app/src/react/features/agent-settings/components/Assignments/ChatWithAgentWidget.tsxindex c94a6cb3..237598e8 100644--- a/packages/app/src/react/features/agent-settings/components/Assignments/ChatWithAgentWidget.tsx+++ b/packages/app/src/react/features/agent-settings/components/Assignments/ChatWithAgentWidget.tsx@@ -115,12 +115,9 @@ const ChatWithAgentWidget = ({ isWriteAccess, isAgentDeployed }: Props) => {`${isAgentDeployed ? PRIMARY_BUTTON_STYLE : SECONDARY_BUTTON_STYLE}`,)}onClick={(e) => {- Observability.userBehavior.recordFeatureUsage(- EVENTS.AGENT_SETTINGS_EVENTS.app_chat_with_agent,- {- source: 'agent settings',- },- );+ Observability.observeInteraction(EVENTS.AGENT_SETTINGS_EVENTS.app_chat_with_agent, {+ source: 'agent settings',+ });!isAgentDeployed && e.preventDefault();}}target="_blank"diff --git a/packages/app/src/react/features/agent-settings/components/CapabilitiesWidget/index.tsx b/packages/app/src/react/features/agent-settings/components/CapabilitiesWidget/index.tsxindex 46e4ff3c..aa7281a8 100644--- a/packages/app/src/react/features/agent-settings/components/CapabilitiesWidget/index.tsx+++ b/packages/app/src/react/features/agent-settings/components/CapabilitiesWidget/index.tsx@@ -121,7 +121,7 @@ function Endpoint({ component }: { component: Component }) {<buttonclassName=" flex group-hover:flex items-center"onClick={() => {- Observability.userBehavior.recordFeatureUsage(+ Observability.observeInteraction(EVENTS.AGENT_SETTINGS_EVENTS.app_agent_skills_click,{button: 'call',diff --git a/packages/app/src/react/features/agent-settings/components/OverviewWidgetsContainer/index.tsx b/packages/app/src/react/features/agent-settings/components/OverviewWidgetsContainer/index.tsxindex 182c18c5..cd6e3ac3 100644--- a/packages/app/src/react/features/agent-settings/components/OverviewWidgetsContainer/index.tsx+++ b/packages/app/src/react/features/agent-settings/components/OverviewWidgetsContainer/index.tsx@@ -363,12 +363,9 @@ const OverviewWidgetsContainer = ({ isWriteAccess }: { isWriteAccess: boolean })await Promise.all(promises);if (postHogEvent.app_LLM_selected) {- await Observability.userBehavior.recordFeatureUsage(- EVENTS.AGENT_SETTINGS_EVENTS.app_LLM_selected,- {- model: formik.values.chatGptModel,- },- );+ await Observability.observeInteraction(EVENTS.AGENT_SETTINGS_EVENTS.app_LLM_selected, {+ model: formik.values.chatGptModel,+ });setPostHogEvent((prev) => ({ ...prev, app_LLM_selected: null }));}diff --git a/packages/app/src/react/features/agent-settings/components/widget-subscribe-info.tsx b/packages/app/src/react/features/agent-settings/components/widget-subscribe-info.tsxindex 89135175..e0c3ddc2 100644--- a/packages/app/src/react/features/agent-settings/components/widget-subscribe-info.tsx+++ b/packages/app/src/react/features/agent-settings/components/widget-subscribe-info.tsx@@ -14,14 +14,14 @@ type Props = {const WidgetSubscribeInfo = ({ infoText, analytics }: Props) => {useEffect(() => {- Observability.userBehavior.recordInteraction('upgrade_impression', {+ Observability.observeInteraction('upgrade_impression', {page_url: analytics?.page_url,source: analytics?.source,});}, []);const handleUpgrade = () => {- Observability.userBehavior.recordInteraction('upgrade_click', {+ Observability.observeInteraction('upgrade_click', {page_url: analytics?.page_url,source: analytics?.source,});diff --git a/packages/app/src/react/features/agent-settings/dialogs/ChatBot.tsx b/packages/app/src/react/features/agent-settings/dialogs/ChatBot.tsxindex 651c88bc..3480425a 100644--- a/packages/app/src/react/features/agent-settings/dialogs/ChatBot.tsx+++ b/packages/app/src/react/features/agent-settings/dialogs/ChatBot.tsx@@ -601,7 +601,7 @@ const ChatBotDialog = ({onChange={(e) => {setIsChatBotFullScreen(e.target.checked);if (e.target.checked) {- Observability.userBehavior.recordFeatureUsage(+ Observability.observeInteraction('app_chatbot_message_view_enabled',{description:diff --git a/packages/app/src/react/features/agent-settings/pages/AgentSettingsPage.tsx b/packages/app/src/react/features/agent-settings/pages/AgentSettingsPage.tsxindex 11896ce2..dff2efe6 100644--- a/packages/app/src/react/features/agent-settings/pages/AgentSettingsPage.tsx+++ b/packages/app/src/react/features/agent-settings/pages/AgentSettingsPage.tsx@@ -172,7 +172,7 @@ export const AgentSettingsPageBody = (props: Props) => {);const handleUpgrade = () => {- Observability.userBehavior.recordInteraction('upgrade_click', {+ Observability.observeInteraction('upgrade_click', {page_url: '/agent_settings',source: 'upgrade button displayed alongside My Workflow',});@@ -180,7 +180,7 @@ export const AgentSettingsPageBody = (props: Props) => {};useEffect(() => {- Observability.userBehavior.recordInteraction('upgrade_impression', {+ Observability.observeInteraction('upgrade_impression', {page_url: '/agent_settings',source: 'upgrade button displayed alongside My Workflow',});diff --git a/packages/app/src/react/features/agents/components/agentCard/AgentCard.tsx b/packages/app/src/react/features/agents/components/agentCard/AgentCard.tsxindex f65cb123..ffcaafe4 100644--- a/packages/app/src/react/features/agents/components/agentCard/AgentCard.tsx+++ b/packages/app/src/react/features/agents/components/agentCard/AgentCard.tsx@@ -54,7 +54,7 @@ export function AgentCard({ agent, loadAgents, updateAgentInPlace }: AgentCardPrconst [featureFlagPayload, setFeatureFlagPayload] = useState<unknown>(undefined);// Load feature flag payload- // Use PostHog's onFeatureFlags callback to wait for flags to be ready+ // Use Observability API to wait for flags to be readyuseEffect(() => {const loadFeatureFlag = () => {const payload = Observability.features.getFeatureFlagPayload(@@ -63,14 +63,8 @@ export function AgentCard({ agent, loadAgents, updateAgentInPlace }: AgentCardPrsetFeatureFlagPayload(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();- }+ // Wait for feature flags to be fully loaded before reading payload+ Observability.features.onFeatureFlagsReady(loadFeatureFlag);}, []);// Modal statesdiff --git a/packages/app/src/react/features/agents/components/meta/up-sell.tsx b/packages/app/src/react/features/agents/components/meta/up-sell.tsxindex 8b63f6bd..eabab4e6 100644--- a/packages/app/src/react/features/agents/components/meta/up-sell.tsx+++ b/packages/app/src/react/features/agents/components/meta/up-sell.tsx@@ -14,14 +14,14 @@ type Props = {const UpSellModal = ({ onClose, children, analytics }: Props) => {const navigate = useNavigate();useEffect(() => {- Observability.userBehavior.recordInteraction('upgrade_impression', {+ Observability.observeInteraction('upgrade_impression', {page_url: analytics?.page_url,source: analytics.source,});}, []); // eslint-disable-line react-hooks/exhaustive-depsconst handleUpgradeClick = () => {- Observability.userBehavior.recordInteraction('upgrade_click', {+ Observability.observeInteraction('upgrade_click', {page_url: analytics?.page_url,source: analytics?.source,});diff --git a/packages/app/src/react/features/agents/components/modals/deploy-agent-modal.tsx b/packages/app/src/react/features/agents/components/modals/deploy-agent-modal.tsxindex 722ec67f..3d7b0422 100644--- a/packages/app/src/react/features/agents/components/modals/deploy-agent-modal.tsx+++ b/packages/app/src/react/features/agents/components/modals/deploy-agent-modal.tsx@@ -339,14 +339,14 @@ function DeployAgentModal({ userInfo, deploymentSidebarCtx }) {},operation: 'insertOrUpdate',});- Observability.userBehavior.recordWorkflowCompletion('app_deploy_first_agent', {+ Observability.observeInteraction('app_deploy_first_agent', {createdAt: new Date().toISOString().split('T')[0],});- Observability.userBehavior.recordFeatureUsage('app_deploy_agent', {+ Observability.observeInteraction('app_deploy_agent', {createdAt: new Date().toISOString().split('T')[0],});} else {- Observability.userBehavior.recordFeatureUsage('app_deploy_agent', {+ Observability.observeInteraction('app_deploy_agent', {createdAt: new Date().toISOString().split('T')[0],});}diff --git a/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts b/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.tsindex ef45c0f9..0c4856bb 100644--- a/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts+++ b/packages/app/src/react/features/agents/hooks/useAgentsPageTutorial.ts@@ -68,7 +68,7 @@ export function useAgentsPageTutorial(options: UseAgentsPageTutorialOptions = {}},onReset: () => {// Called when overlay is about to be cleared- Observability.userBehavior.recordWorkflowCompletion('home_page_tutorial_completed', {+ Observability.observeInteraction('home_page_tutorial_completed', {page_url: '/agents',source: 'Tutorial completed on home page onboarding',});diff --git a/packages/app/src/react/features/agents/pages/AgentsPage.tsx b/packages/app/src/react/features/agents/pages/AgentsPage.tsxindex 43ae07c8..7c0220c1 100644--- a/packages/app/src/react/features/agents/pages/AgentsPage.tsx+++ b/packages/app/src/react/features/agents/pages/AgentsPage.tsx@@ -94,7 +94,7 @@ function AgentsPage() {},operation: 'insertOrUpdate',});- Observability.userBehavior.recordWorkflowCompletion('app_build_first_agent', {+ Observability.observeInteraction('app_build_first_agent', {createdAt: sortedAgents[0]?.createdAt,});}diff --git a/packages/app/src/react/features/ai-chat/pages/ai-chat.tsx b/packages/app/src/react/features/ai-chat/pages/ai-chat.tsxindex 82f6b43b..083d7e9b 100644--- a/packages/app/src/react/features/ai-chat/pages/ai-chat.tsx+++ b/packages/app/src/react/features/ai-chat/pages/ai-chat.tsx@@ -118,8 +118,8 @@ const AIChat = () => {clearMessages();await createNewChatSession();chatInputRef.current?.focus();- Observability.userBehavior.recordInteraction(EVENTS.CHAT_EVENTS.SESSION_END);- Observability.userBehavior.recordInteraction(EVENTS.CHAT_EVENTS.SESSION_START);+ Observability.observeInteraction(EVENTS.CHAT_EVENTS.SESSION_END);+ Observability.observeInteraction(EVENTS.CHAT_EVENTS.SESSION_START);}, [createNewChatSession, clearMessages, stopGenerating, setShowScrollButton]);useEffect(() => {@@ -138,8 +138,8 @@ const AIChat = () => {}, [isAgentLoading, inputDisabled]);useEffect(() => {- Observability.userBehavior.recordInteraction(EVENTS.CHAT_EVENTS.SESSION_START);- return () => Observability.userBehavior.recordInteraction(EVENTS.CHAT_EVENTS.SESSION_END);+ Observability.observeInteraction(EVENTS.CHAT_EVENTS.SESSION_START);+ return () => Observability.observeInteraction(EVENTS.CHAT_EVENTS.SESSION_END);}, []);// Fast context value - minimal dependenciesdiff --git a/packages/app/src/react/features/builder/components/agent-deployment-sidebar/DeploymentsHistory.tsx b/packages/app/src/react/features/builder/components/agent-deployment-sidebar/DeploymentsHistory.tsxindex 5c5158a5..2b3dff00 100644--- a/packages/app/src/react/features/builder/components/agent-deployment-sidebar/DeploymentsHistory.tsx+++ b/packages/app/src/react/features/builder/components/agent-deployment-sidebar/DeploymentsHistory.tsx@@ -28,7 +28,7 @@ const DeploymentsHistory = () => {const restoreVersionConfirmation = async (deploymentId: string) => {if (!userInfo?.subs?.plan?.paid) {- Observability.userBehavior.recordInteraction('upgrade_impression', {+ Observability.observeInteraction('upgrade_impression', {page_url: '/builder',source: 'restoring previous version',});diff --git a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/FormFill.tsx b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/FormFill.tsxindex d495b830..91ebf221 100644--- a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/FormFill.tsx+++ b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/FormFill.tsx@@ -17,10 +17,10 @@ const FormFill = ({ setIsFormVisible }: { setIsFormVisible: (value: boolean) =>const dynamicValidationSchema = generateComponentInputsSchema(selectedSkill?.inputsTypes);const handleSubmit = async (values: any, { resetForm }: { resetForm: () => void }) => {setIsFormVisible(false);- Observability.userBehavior.recordInteraction('app_form_preview_run_button_click', {});+ Observability.observeInteraction('app_form_preview_run_button_click', {});callSkillMutation.mutate(values, {onSuccess: () => {- Observability.userBehavior.recordWorkflowCompletion('app_workflow_test_completed', {+ Observability.observeInteraction('app_workflow_test_completed', {status: 'success',source: 'form preview',});@@ -28,7 +28,7 @@ const FormFill = ({ setIsFormVisible }: { setIsFormVisible: (value: boolean) =>setView('home');},onError: () => {- Observability.systemInsight.recordError('app_workflow_test_completed', {+ Observability.observeInteraction('app_workflow_test_completed', {status: 'failed',source: 'form preview',});diff --git a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsxindex 0effc929..1a552c61 100644--- a/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx+++ b/packages/app/src/react/features/builder/components/endpoint-form-preview-sidebar/views/ResponseView.tsx@@ -40,7 +40,7 @@ const ResponseView = () => {if (component && typeof component.openDebugDialog === 'function') {// Fire telemetry eventconst { PostHog } = await import('@src/shared/posthog');- Observability.userBehavior.recordInteraction('debug_modal_opened', {+ Observability.observeInteraction('debug_modal_opened', {source: 'test_as_form',});@@ -56,7 +56,7 @@ const ResponseView = () => {<spanclassName="font-semibold border-b border-solid pb-0.5 cursor-pointer text-blue-500 border-blue-500"onClick={() => {- Observability.userBehavior.recordInteraction('debug_api_modal_opened_test_as_form', {+ Observability.observeInteraction('debug_api_modal_opened_test_as_form', {source: 'test_as_form',variant: 'control',});@@ -74,7 +74,7 @@ const ResponseView = () => {<buttonclassName="font-semibold cursor-pointer text-blue-500 bg-transparent hover:text-smythos-blue focus:outline-none py-2 rounded-lg text-sm transition-colors"onClick={() => {- Observability.userBehavior.recordInteraction('debug_api_modal_opened_test_as_form', {+ Observability.observeInteraction('debug_api_modal_opened_test_as_form', {source: 'test_as_form',variant: 'variant_1',});@@ -94,7 +94,7 @@ const ResponseView = () => {const getDebugComponent = () => {try {- const featureVariant = PostHog.getFeatureFlag(+ const featureVariant = Observability.features.getFeatureFlag(FEATURE_FLAGS.TEST_FORM_TRY_DEBUG_BUTTON_EXPERIMENT,) as string;diff --git a/packages/app/src/react/features/embodiments/embodiment-settings.ts b/packages/app/src/react/features/embodiments/embodiment-settings.tsindex 3361b556..5fd4cd94 100644--- a/packages/app/src/react/features/embodiments/embodiment-settings.ts+++ b/packages/app/src/react/features/embodiments/embodiment-settings.ts@@ -342,12 +342,9 @@ export const useAgentEmbodimentSettings = (await updateEmbodiment(agentId, embodimentType, status);if (status) {- Observability.userBehavior.recordFeatureUsage(- EVENTS.AGENT_SETTINGS_EVENTS.app_work_location_toggle,- {- locationType: embodimentType.toLowerCase(),- },- );+ Observability.observeInteraction(EVENTS.AGENT_SETTINGS_EVENTS.app_work_location_toggle, {+ locationType: embodimentType.toLowerCase(),+ });}updateAgentSettingsCache(embodimentType, formattedValue, false);callCallback();diff --git a/packages/app/src/shared/observability/index.ts b/packages/app/src/shared/observability/index.tsindex f498ebba..536d5b7c 100644--- a/packages/app/src/shared/observability/index.ts+++ b/packages/app/src/shared/observability/index.ts@@ -13,7 +13,7 @@* // In community code - works with or without enterprise plugin* import { Observability } from '@src/shared/observability';*- * Observability.userBehavior.recordInteraction('button_clicked', { buttonId: 'submit' });+ * Observability.observeInteraction('button_clicked', { buttonId: 'submit' });* ```*/@@ -65,55 +65,27 @@ function getObservabilityProvider(): IObservabilityProvider {*/export const Observability = {/**- * User behavior observability methods- * Records user interactions, feature usage, and workflow completions+ * Observes and tracks any interaction, event, or behavior in the system+ *+ * This unified method handles all types of observability events including+ * user interactions, feature usage, workflow completions, system events,+ * and errors.+ *+ * @param eventName - Descriptive name of the event, interaction, or behavior+ * @param properties - Additional context about the event+ *+ * @example+ * ```typescript+ * Observability.observeInteraction('agent_created', { agentType: 'chatbot', source: 'template' });+ * Observability.observeInteraction('debug_button_click', { position: 'bottom center', type: 'run' });+ * Observability.observeInteraction('workflow_test_completed', { status: 'success', source: 'debugger' });+ * ```*/- userBehavior: {- recordInteraction: (eventName: string, properties?: Record<string, unknown>) => {- getObservabilityProvider().recordInteraction(- eventName,- properties as ObservabilityEventProperties,- );- },- recordFeatureUsage: (featureName: string, properties?: Record<string, unknown>) => {- getObservabilityProvider().recordFeatureUsage(- featureName,- properties as ObservabilityEventProperties,- );- },- recordWorkflowCompletion: (workflowName: string, properties?: Record<string, unknown>) => {- getObservabilityProvider().recordWorkflowCompletion(- workflowName,- properties as ObservabilityEventProperties,- );- },- },-- /**- * System insight capture methods- * Records system events, errors, and performance metrics- */- systemInsight: {- recordSystemEvent: (eventName: string, properties?: Record<string, unknown>) => {- getObservabilityProvider().recordSystemEvent(- eventName,- properties as ObservabilityEventProperties,- );- },- recordError: (errorName: string, properties?: Record<string, unknown>) => {- getObservabilityProvider().recordError(errorName, properties as ObservabilityEventProperties);- },- recordPerformanceMetric: (- metricName: string,- value: number,- properties?: Record<string, unknown>,- ) => {- getObservabilityProvider().recordPerformanceMetric(- metricName,- value,- properties as ObservabilityEventProperties,- );- },+ observeInteraction: (eventName: string, properties?: Record<string, unknown>) => {+ getObservabilityProvider().observeInteraction(+ eventName,+ properties as ObservabilityEventProperties,+ );},/**@@ -152,6 +124,9 @@ export const Observability = {reloadFeatureFlags: () => {getObservabilityProvider().reloadFeatureFlags();},+ onFeatureFlagsReady: (callback: () => void) => {+ getObservabilityProvider().onFeatureFlagsReady(callback);+ },},};@@ -161,3 +136,6 @@ export type {ObservabilityEventProperties,UserIdentityContext,} from './types';++// Export the observability instance getter for advanced usage+export { getObservabilityProvider as getObservabilityInstance };diff --git a/packages/app/src/shared/observability/no-op-providers.ts b/packages/app/src/shared/observability/no-op-providers.tsindex 48a2aba1..447fdadc 100644--- a/packages/app/src/shared/observability/no-op-providers.ts+++ b/packages/app/src/shared/observability/no-op-providers.ts@@ -25,36 +25,12 @@ import type {* All methods are no-ops that do nothing or return safe defaults.*/export class NoOpObservabilityProvider implements IObservabilityProvider {- // User Behavior Observability- recordInteraction(_eventName: string, _properties?: ObservabilityEventProperties): void {- // No operation - disabled by default- }-- recordFeatureUsage(_featureName: string, _properties?: ObservabilityEventProperties): void {- // No operation - disabled by default- }-- recordWorkflowCompletion(- _workflowName: string,- _properties?: ObservabilityEventProperties,- ): void {- // No operation - disabled by default- }-- // System Insight Capture- recordSystemEvent(_eventName: string, _properties?: ObservabilityEventProperties): void {- // No operation - disabled by default- }-- recordError(_errorName: string, _properties?: ObservabilityEventProperties): void {- // No operation - disabled by default- }-- recordPerformanceMetric(- _metricName: string,- _value: number,- _properties?: ObservabilityEventProperties,- ): void {+ // Unified Event Tracking+ /**+ * No-op implementation of observeInteraction+ * Does nothing, ensuring zero overhead+ */+ observeInteraction(_eventName: string, _properties?: ObservabilityEventProperties): void {// No operation - disabled by default}@@ -87,4 +63,9 @@ export class NoOpObservabilityProvider implements IObservabilityProvider {reloadFeatureFlags(): void {// No operation - disabled by default}++ onFeatureFlagsReady(callback: () => void): void {+ // Execute immediately in no-op mode (no flags to load)+ callback();+ }}diff --git a/packages/app/src/shared/observability/types.ts b/packages/app/src/shared/observability/types.tsindex 414e615d..e4cc14ad 100644--- a/packages/app/src/shared/observability/types.ts+++ b/packages/app/src/shared/observability/types.ts@@ -33,7 +33,7 @@ export interface UserIdentityContext {** This interface provides complete observability capabilities:* - User behavior tracking (interactions, feature usage, workflows)- * - System insights (events, errors, performance metrics)+ * - System insights (events, errors)* - User identity management (identification, context correlation)* - Feature configuration (flags, A/B testing, rollouts)*@@ -41,70 +41,29 @@ export interface UserIdentityContext {* Community edition uses a no-op implementation by default.*/export interface IObservabilityProvider {- // User Behavior Tracking+ // Unified Event Tracking/**- * Records a user interaction or behavior event+ * Observes and tracks any interaction, event, or behavior in the system*- * @param eventName - Descriptive name of the user action or behavior- * @param properties - Additional context about the event- *- * @example- * ```typescript- * recordInteraction('agent_created', { agentType: 'chatbot', source: 'template' });- * ```- */- recordInteraction(eventName: string, properties?: ObservabilityEventProperties): void;-- /**- * Records a feature usage event- *- * @param featureName - Name of the feature being used- * @param properties - Additional context about feature usage- */- recordFeatureUsage(featureName: string, properties?: ObservabilityEventProperties): void;-- /**- * Records a workflow completion event- *- * @param workflowName - Name of the completed workflow- * @param properties - Additional context about the workflow- */- recordWorkflowCompletion(workflowName: string, properties?: ObservabilityEventProperties): void;-- // System Insights- /**- * Records a system-level event+ * This unified method handles all types of observability events including:+ * - User interactions (button clicks, form submissions, etc.)+ * - Feature usage+ * - Workflow completions+ * - System events+ * - Errors and exceptions*- * @param eventName - Descriptive name of the system event+ * @param eventName - Descriptive name of the event, interaction, or behavior* @param properties - Additional context about the event** @example* ```typescript- * recordSystemEvent('deployment_completed', { duration: 1200, success: true });+ * observeInteraction('agent_created', { agentType: 'chatbot', source: 'template' });+ * observeInteraction('debug_button_click', { position: 'bottom center', type: 'run' });+ * observeInteraction('workflow_test_completed', { status: 'success', source: 'debugger' });+ * observeInteraction('deployment_error', { errorType: 'timeout', duration: 30000 });* ```*/- recordSystemEvent(eventName: string, properties?: ObservabilityEventProperties): void;-- /**- * Records an error or exception- *- * @param errorName - Name or type of the error- * @param properties - Additional context about the error- */- recordError(errorName: string, properties?: ObservabilityEventProperties): void;-- /**- * Records a performance metric- *- * @param metricName - Name of the performance metric- * @param value - Numeric value of the metric- * @param properties - Additional context about the metric- */- recordPerformanceMetric(- metricName: string,- value: number,- properties?: ObservabilityEventProperties,- ): void;+ observeInteraction(eventName: string, properties?: ObservabilityEventProperties): void;// User Identity Management/**@@ -178,4 +137,20 @@ export interface IObservabilityProvider {* Reloads feature flags from the server*/reloadFeatureFlags(): void;++ /**+ * Registers a callback to be executed when feature flags are fully loaded+ * In community edition (no-op), the callback is executed immediately+ *+ * @param callback - Function to call when flags are ready+ *+ * @example+ * ```typescript+ * Observability.features.onFeatureFlagsReady(() => {+ * const payload = Observability.features.getFeatureFlagPayload('my-flag');+ * console.log('Flag loaded:', payload);+ * });+ * ```+ */+ onFeatureFlagsReady(callback: () => void): void;}diff --git a/packages/app/src/shared/posthog/services/analytics.ts b/packages/app/src/shared/posthog/services/analytics.tsindex 91c6f767..905db535 100644--- a/packages/app/src/shared/posthog/services/analytics.ts+++ b/packages/app/src/shared/posthog/services/analytics.ts@@ -3,9 +3,7 @@* This service is kept for backward compatibility but forwards all calls to the new Observability API** Migration:- * - Replace Analytics.track() with Observability.userBehavior.recordInteraction()- * - Or use Observability.userBehavior.recordFeatureUsage() for feature-specific events- * - Or use Observability.userBehavior.recordWorkflowCompletion() for workflow events+ * - Replace Analytics.track() with Observability.observeInteraction()*/import { Observability } from '@src/shared/observability';@@ -13,7 +11,7 @@ import { isProdEnv } from '@src/shared/utils';export const Analytics = {/**- * @deprecated Use Observability.userBehavior.recordInteraction() instead+ * @deprecated Use Observability.observeInteraction() instead*/track: (eventName: string, properties: Record<string, unknown> = {}) => {try {@@ -26,7 +24,7 @@ export const Analytics = {}// Forward to new Observability API- Observability.userBehavior.recordInteraction(eventName, enhancedProperties);+ Observability.observeInteraction(eventName, enhancedProperties);} catch (error) {console.info('Error tracking event', error);}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.tsindex fbe5f2a0..294ebd32 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,4 +1,3 @@-import { PostHog } from '@enterprise/shared/posthog';import {getProperTeamSubs,getTeamMembers,@@ -10,6 +9,7 @@ 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 { Observability } from '@src/shared/observability';import { StateCreator } from 'zustand';import { FEATURE_FLAGS } from '../../../constants/featureflags';import { userSettingKeys } from '../../../userSettingKeys';@@ -205,7 +205,7 @@ export const baseSlice: StateCreator<AuthStore, [], [], AuthSlice> = (set, get)aclUtils = new ACLUtils(authInfo, pageAcl, apiAcl);// get feature flag for staff domains- const staffDomains = PostHog.getFeatureFlag(+ const staffDomains = Observability.features.getFeatureFlag(FEATURE_FLAGS.DONT_DELETE_IMPORTANT_SMYTH_STAFF_DOMAINS,);const isStaffUser =