feat: analytics tracing, billing accuracy, and admin navigation fixes (+ streaming demo & Copilot docs) - #591
Conversation
…ndency (#588) chore: bump version of aai-embed-react to 3.0.10 and update peer dependency
- Simplified URL generation for chatflows by consolidating logic in `getCanvasFullUrl` and `getCanvasRoute`. - Updated the back navigation button to use the new `/sidekick-studio/admin` path. - Enhanced data refresh mechanism to avoid full page reloads, improving user experience.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| } | ||
| } | ||
|
|
||
| const getCanvasFullUrl = (chatflow: any) => { | ||
| // Alias for getCanvasRoute for backward compatibility | ||
| // Both now return the same full URL with /sidekick-studio prefix | ||
| return getCanvasRoute(chatflow) |
There was a problem hiding this comment.
Avoid hard-coding sidekick-studio in chatflow routes
The new getCanvasRoute now prepends /sidekick-studio to every chatflow canvas URL and getCanvasFullUrl simply delegates to it. The admin UI’s router defines canvas paths at /canvas/:id and /admin/... (see packages-answers/ui/src/Admin/index.tsx), so when the admin module is served at the default root (e.g., Flowise’s /admin/chatflows), clicking a chatflow or opening a default template now navigates to /sidekick-studio/..., which has no matching route and results in a 404. Consider deriving the prefix from the router’s basename or keeping the relative /canvas paths so both deployments continue working.
Useful? React with 👍 / 👎.
…ath optimization (#548) ## Summary Improves credential ownership detection for billing by adding intelligent caching and fast-path optimization for AAI platform nodes. ## Changes - Added `hasPlatformAINodes` detection to quickly identify AAI platform AI nodes - Implemented caching mechanism (`platformNodeCache`) to reduce database queries - Added validation layer in `calculateCosts` to double-check ownership - Exported `flowCredentialExtractor` for reusability ## Performance Improvements - **Fast-path optimization**: AAI platform nodes are detected early, skipping unnecessary credential lookups - **Smart caching**: Flow platform status cached during sync operations, auto-clears after completion - **Reduced DB queries**: Cache prevents redundant database calls for the same chatflow ## Technical Details - Cache lifecycle managed per sync operation (clears after each sync) - Graceful fallback when chatflow data unavailable - No breaking changes to existing interfaces ## Testing - [x] Verified credential detection works correctly - [x] Tested caching behavior across multiple traces - [x] Confirmed fallback behavior when chatflow not found --------- Co-authored-by: Claude <noreply@anthropic.com>
…ges (#593) ## Problem Multiple navigation issues in admin pages: 1. **Admin Chatflows**: Mixed usage of React Router and window.open() in Next.js environment caused: - Default template view button creating `/sidekick-studio/sidekick-studio/admin` (double prefix) - Chatflow name links generating `/canvas/{id}` instead of `/sidekick-studio/canvas/{id}` (404s) - Inconsistent routing behavior 2. **Organization Credentials**: Missing "Back to admin" button for navigation consistency ## Solution **Admin Chatflows Navigation** (`packages-answers/ui/src/Admin/Chatflows/index.tsx`): - ✅ Standardized all navigation to use absolute URLs with full `/sidekick-studio` prefix - ✅ Replaced React Router `<Link>` with native anchor tags and `window.location` - ✅ Fixed default template view button to use `getCanvasFullUrl()` - ✅ Converted chatflow name link to use `href` with full absolute path - ✅ Updated back-to-admin button to use `window.location.href` - ✅ Removed unused React Router dependency **Organization Credentials** (`packages-answers/ui/src/OrgCredentials/OrgCredentialsManager.tsx`): - ✅ Added "Back to admin" button for consistent navigation UX ## Testing Verified all navigation points correctly route to: - Regular chatflows: `/sidekick-studio/canvas/{id}` ✅ - Multi-agent v1: `/sidekick-studio/agentcanvas/{id}` ✅ - Agent flows v2: `/sidekick-studio/v2/agentcanvas/{id}` ✅ - Admin dashboard: `/sidekick-studio/admin` ✅ - Organization credentials: `/sidekick-studio/admin/org-credentials` ✅ ## Impact - Fixes AAI-682 completely - No more double prefixes or 404 errors - Consistent navigation experience across all admin pages - Improved user experience with back buttons on all admin subpages
## Summary Implements centralized analytics configuration via environment variables, enabling Langfuse (and future providers) to be enabled globally without UI configuration. This provides platform-wide observability without requiring per-chatflow/agentflow setup. ### Problem - Previously, analytics providers (like Langfuse) could only be configured per-chatflow/agentflow via UI - No way to enable analytics globally across all flows for platform-wide observability - Code duplication between `additionalCallbacks()` and `AnalyticHandler` for env var handling - Agentflows didn't respect environment variable overrides ### Solution - Added `applyEnvAnalyticsOverrides()` helper function for DRY env var handling - Added `isAnalyticsEnabled()` to properly gate analytics initialization - Fixed `AnalyticHandler` to respect env overrides in agentflows - Fixed `AnalyticHandler.initializeProvider()` to use `providerConfig` values - Refactored `additionalCallbacks()` to use shared helper ### Changes #### `packages/components/src/handler.ts` - Added `applyEnvAnalyticsOverrides()` - centralized logic for applying env var overrides - Added `isAnalyticsEnabled()` - checks if analytics is enabled via UI or env vars - Refactored `additionalCallbacks()` to use helper (13 lines → 2 lines) - Updated `AnalyticHandler.init()` to apply env overrides - Updated `AnalyticHandler.constructor()` to store processed config - Fixed `AnalyticHandler.initializeProvider()` to respect `providerConfig` values #### `packages/server/src/utils/buildAgentflow.ts` - Fixed gating condition to use `isAnalyticsEnabled()` instead of `chatflow.analytic` check - Ensures agentflows work with env vars only (previously broken) ### Environment Variables When `LANGFUSE_SECRET_KEY` is set, Langfuse will be automatically enabled for **all** chatflows and agentflows: - `LANGFUSE_SECRET_KEY` - Required to enable Langfuse - `LANGFUSE_PUBLIC_KEY` - Optional, Langfuse public key - `LANGFUSE_HOST` - Optional, defaults to `https://cloud.langfuse.com` - `LANGFUSE_RELEASE` - Optional, version/release tag for traces Environment variables take precedence over UI configuration. ### Benefits ✅ Platform-wide observability without UI configuration ✅ Single source of truth for env var handling ✅ Works for chatflows, agentflows, and multi-agent graphs ✅ Extensible pattern for adding more providers (LangSmith, Arize, etc.) ✅ Eliminated 100+ lines of code duplication ### Testing - [x] Chatflows with env vars only - [x] Agentflows with env vars only (previously broken) - [x] Chatflows with UI config only - [x] Agentflows with UI config only - [x] Both env + UI (env wins) - [x] Cache invalidation when config changes ## Test plan - [ ] Deploy to staging - [ ] Set `LANGFUSE_SECRET_KEY` env var - [ ] Execute chatflow - verify trace appears in Langfuse - [ ] Execute agentflow - verify trace appears in Langfuse - [ ] Execute multi-agent graph - verify trace appears in Langfuse --------- Co-authored-by: Brad Taylor <bradtaylorsf@gmail.com>
refactor: remove unused getCanvasRoute function
|
@codex please re-review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
## 📦 Release Summary This release includes updates from staging to production, bringing multiple improvements, fixes, and new features. ## 🎯 Key Changes ### Recent Updates - **HOTFIX**: Remove metadata from Stripe events - **fix**: Handle Stripe 35-day limitation for historical billing data (#624) - **chore**: Updates to fix publish automation (#623) - **feat**: Added automation for publishing aai-embed-react (#616) - **feat**: Comprehensive export/import functionality enhancement (AAI-501) (#469) ### Previous Releases Included - Billing Metadata Filtering - 22.10.2025 (#622) - Chat Drawer Pagination - 22.10.2025 (#621) - Billing Tag Self-Healing and Optimized Trace Fetching (#617) - Facebook Pixel Tracking Fixes (#608) - JLINC audit log, env overrides, and partnership page updates (#597) - Analytics tracing, billing accuracy, and admin navigation fixes (#591) ## 📊 Impact Summary - **Files changed**: 2956 files - **Additions**: 312,083 lines - **Deletions**: 25,803 lines ## ✅ Pre-Release Checklist - [ ] All tests passing on staging environment - [ ] No critical errors in staging logs - [ ] Database migrations reviewed and tested - [ ] Environment variables documented - [ ] Monitoring alerts configured - [ ] Rollback plan documented ## 🚀 Deployment Notes This is a standard release from staging to production. Please ensure all pre-release checks are completed before approving. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: DiegoC <diecoscai@gmail.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cameron Taylor <50385537+ct3685@users.noreply.github.com> Co-authored-by: Jaime Morales <jaime.raul.morales@gmail.com>
Title
feat: analytics tracing, billing accuracy, and admin navigation fixes (+ streaming demo & Copilot docs)
Description
Motivation & Scope
/sidekick-studio.UI — Admin & Org Credentials
packages-answers/ui/src/Admin/Chatflows/index.tsxreact-router-domLinkusage for certain elements; now uses absolute paths andwindow.open/ anchor tags:getCanvasFullUrl(chatflow)centralizes URL generation with/sidekick-studioprefix.getCanvasFullUrl(...).<Typography component="a" href=... target="_blank">.refreshChatflows()for smoother UX./sidekick-studio/adminviawindow.location.href.packages-answers/ui/src/OrgCredentials/OrgCredentialsManager.tsx/sidekick-studio/admin.DevEx — Copilot
.gitignore: trackscripts/copilot-auto-readme.md.copilot/scripts/copilot-auto-readme.md: install & usage forpnpm copilot:auto.Components — Agentflow/LLM/ConditionAgent
additionalCallbacksand wire Langfuse throughoptions._llmCallOptions.callbacks.options._llmCallOptionsto passsignaland callbacks consistently toinvoke/stream.optionsinstead of rawAbortController.optionsand use shared call options.Agent/Agent.tsLangfuseSpanClient; attachoptions._parentToolSpan.createToolSpan) and finalize withfinishToolSpanon success/error.options._llmCallOptions; propagate spans during tool loops.ConditionAgent/ConditionAgent.ts&LLM/LLM.tsllmCallOptions.Components — Utilities & Exports
src/flowCredentialExtractor.tscategory?,visibility?, andhasPlatformAINodesdetection for AAI nodes (Chat Models,Embeddings).ExtractionResultnow includeshasPlatformAINodes.src/followUpPrompts.tssrc/handler.tsapplyEnvAnalyticsOverrides()– env-first analytics config (e.g.,LANGFUSE_*).isAnalyticsEnabled()– centralized enablement check.additionalCallbacks()honors parent trace/span; toggles handler activity flags.AnalyticHandler:createToolSpan/finishToolSpan.flowCredentialExtractor.src/index.tsflowCredentialExtractor.Server — Billing, Interfaces, Predictions, Build
aai-utils/billing/config.ts: default credit price set to $0.00004 (base: $20 / 500k).core/BillingService.ts: readsBILLING_CONFIG.CREDIT_TO_USDfor credit calculations.langfuse/LangfuseProvider.ts:aiCredentialsOwnershipusingextractCredentialsAndModels+ DB check for AAI nodes.server/src/Interface.ts:IExecuteFlowParams.usermade optional.services/predictions/index.ts:usernow optional when building chatflow.utils/buildAgentflow.tsuser.isAnalyticsEnabled(); initializesAnalyticHandlerwithuseNodeLevelLangfuseSpans.spanName=node label/name), attaches inputs/outputs, status, timings.parentLangfuseTrace/spanthrough recursive and iteration paths.utils/buildChatflow.ts:useroptional during util build.Demos
streaming-demo.html: Browser-only SSE demo to connect directly to/api/v1/prediction/:chatflowIdwith live token streaming, node progress, event counters, and structured result rendering.Embed Packages
packages/embed→fa836ede40e0e74fd7df445e367aeaaa2b3d8cfc.packages/embed-react/package.jsonaai-embed^3.0.0 → ^3.0.10.Expected Impact
/sidekick-studiorouting; explicit external links.Breaking Changes
useris now optional in multiple server interfaces (IExecuteFlowParams, execute paths). Callers relying on non-null assertions may need adjustments./sidekick-studio/...paths and direct navigation; any components expectingreact-router-dom Linkwrapping those elements may need review.Config / Env
LANGFUSE_SECRET_KEY,LANGFUSE_PUBLIC_KEY,LANGFUSE_HOST,LANGFUSE_RELEASE,GIT_COMMIT_HASH(env override support).BILLING_CREDIT_PRICE_USDdefault now0.00004.BILLING_MARGIN_MULTIPLIER(existing).Tests / Validation
AGENTFLOW,MULTIAGENT, and default types.refreshChatflows()without full reload./sidekick-studio/admin.aiCredentialsOwnershipresolves toplatformand credits compute viaBILLING_CONFIG.streaming-demo.htmlagainst/api/v1/prediction/:idwithstreaming: trueand confirm live tokens, events, and structured results render.aai-embed-react@3.0.10withaai-embed@^3.0.10; smoke test mounting.