Release: Staging to Production - 2025.10.23 - #627
Conversation
…469) ## 📋 Overview This PR implements comprehensive enhancements to the export/import functionality as specified in [AAI-501](https://lastrev.atlassian.net/browse/AAI-501), providing users with robust data portability capabilities while maintaining enterprise-grade security controls. ## 🎯 AAI-501 Implementation Details ### Core Functionality Delivered - **Complete data export/import system** supporting all major resource types - **Enhanced UI components** with comprehensive data type selection - **Robust error handling** and user feedback mechanisms - **Security-first architecture** with multi-tenant isolation - **Production-ready codebase** with optimized performance ### 📊 Data Types Supported The implementation now supports export/import of: - ✅ **Agentflows** (MULTIAGENT type) - ✅ **Agentflows V2** (AGENTFLOW type) - ✅ **Assistants Custom, OpenAI, Azure** (all assistant types) - ✅ **Chatflows** (standard chatflow type) - ✅ **Chats** (conversation histories) - ✅ **Chat Messages** (individual message records) - ✅ **Chat Feedbacks** (user feedback data) - ✅ **Custom Templates** (marketplace templates) - ✅ **Document Stores** (document storage systems) - ✅ **Executions** (workflow execution records) - ✅ **Tools** (custom tool definitions) - ✅ **Variables** (environment variables) ## 🔧 Technical Implementation ### Backend Enhancements - **`packages/server/src/services/export-import/index.ts`**: Core export/import engine with security controls - **`packages/server/src/services/chat-messages/index.ts`**: Enhanced chat message handling with organizationId filtering - **`packages/server/src/services/tools/index.ts`**: Export mode implementation for tools - **`packages/server/src/services/variables/index.ts`**: Export mode implementation for variables - **`packages/server/src/routes/export-import/index.ts`**: RESTful API endpoints ### Frontend Enhancements - **`packages-answers/ui/src/components/ExportImportComponent.tsx`**: Comprehensive export/import UI - **`packages/ui/src/layout/MainLayout/Header/ProfileSection/index.jsx`**: Integrated export/import menu - **`packages/ui/src/utils/exportImport.js`**: Data sanitization utilities ## 🔒 Security & Compliance ### Multi-Tenant Isolation - ✅ **User ownership validation** on all export operations - ✅ **Organization-level data isolation** enforced - ✅ **Defense-in-depth filtering** by both `userId` and `organizationId` - ✅ **Secure import process** with proper ownership assignment ### Data Protection - ✅ **Export restricted to user-owned resources only** - ✅ **Import assigns all data to importing user** - ✅ **No cross-organization data leakage possible** - ✅ **Audit trail with comprehensive logging** ## 🚀 User Experience Improvements ### Enhanced Export Flow - **Granular selection** of data types to export - **Visual feedback** during export process with loading states - **Automatic file download** with structured JSON format - **Error handling** with user-friendly notifications ### Streamlined Import Process - **Drag-and-drop file selection** - **JSON validation** with clear error messages - **Progress indication** during import operations - **Success confirmation** with navigation to imported data ## 📈 Performance Optimizations ### Code Quality Improvements - **Removed 71+ lines of debug logging** for production performance - **Optimized database queries** with proper filtering - **Enhanced error handling** without performance impact - **Cleaned console.log statements** throughout codebase ### Memory & Processing - **Efficient data serialization** with proper JSON handling - **Transaction-based imports** ensuring data integrity - **Optimized export queries** reducing server load - **Streamlined UI rendering** with better state management ## 🧪 Quality Assurance ### Testing Coverage - ✅ **All export/import operations tested** - ✅ **Security validation verified** - ✅ **UI component functionality confirmed** - ✅ **Error scenarios handled properly** - ✅ **Cross-browser compatibility ensured** ### Code Standards - ✅ **No linting errors** - ✅ **TypeScript compliance** - ✅ **Security best practices followed** - ✅ **Documentation updated** - ✅ **Consistent code style** ## 📋 Files Changed Summary ``` 15 files changed, 45,086 insertions(+), 45,015 deletions(-) Core Changes: - packages/server/src/services/export-import/index.ts: +167 lines (core functionality) - packages-answers/ui/src/components/ExportImportComponent.tsx: +121 lines (UI enhancement) - packages/ui/src/layout/MainLayout/Header/ProfileSection/index.jsx: +77 lines (integration) - packages/server/src/services/chat-messages/index.ts: +16 lines (security) - Multiple service files: Enhanced with export mode and security controls ``` ## 🔄 Commits Included ### 1. Core Feature Implementation **Commit**: `c3c7dbd2` - feat: enhance export/import functionality with comprehensive logging and improved data handling - Added detailed logging for export/import operations - Enhanced ExportImportComponent with expanded data types - Fixed chatflow sanitization and flowData handling - Added user and organization ID preservation - Updated asset import paths and comprehensive logging ### 2. User Data Integration **Commit**: `1762e68c` - Add user data on import - Implemented proper user data assignment during import process - Enhanced data ownership and organization mapping ### 3. Security & Code Quality **Commit**: `52f818d6` - refactor: clean logging, enhance security, and fix imports - Removed excessive debug logging for production readiness - Enhanced security with organizationId filtering in chat messages - Fixed import paths for useAuth0, useNotifier, and getErrorMessage - Translated Spanish comments to English for consistency - Implemented proper error handling with user-friendly notifications ## 🎉 Deliverable Status - ✅ **AAI-501 Requirements Fully Implemented** - ✅ **Production-Ready Code Quality** - ✅ **Enterprise Security Standards Met** - ✅ **Comprehensive User Experience Delivered** - ✅ **Performance Optimized** - ✅ **Documentation Complete** ## 🚀 Deployment Readiness This implementation is **production-ready** and delivers the complete export/import functionality specified in AAI-501. The code has been thoroughly tested, security-reviewed, and optimized for enterprise deployment. **Recommended for immediate staging deployment and subsequent production release.** ## 🔗 Related - **Issue**: [AAI-501](https://lastrev.atlassian.net/browse/AAI-501) - Export/Import Functionality Enhancement - **Target Branch**: `staging` - **Ready for**: Production deployment ## ✅ Checklist - [x] All requirements from AAI-501 implemented - [x] Security review completed - [x] Code quality standards met - [x] UI/UX testing passed - [x] Performance optimization applied - [x] Documentation updated - [x] No breaking changes introduced - [x] Backwards compatibility maintained [AAI-501]: https://lastrev.atlassian.net/browse/AAI-501?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [AAI-501]: https://lastrev.atlassian.net/browse/AAI-501?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Max Techera <maxi.techerag@gmail.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cameron Taylor <50385537+ct3685@users.noreply.github.com>
Co-authored-by: Cameron Taylor <50385537+ct3685@users.noreply.github.com>
## Summary
This PR fixes the Stripe meter event 35-day limitation error that
prevents processing of historical billing data older than 35 days.
### Problem
Stripe's billing meter API rejects events with timestamps older than 35
days:
```
error: 'The event timestamp cannot be more than 35 days in past. Expected a timestamp greater than or equal to 1758141836.'
```
### Solution
Implemented **Option 1: Batch to "Historical Catch-up" Date**
- Events older than 35 days are adjusted to have a timestamp of 34 days
ago
- Original timestamp is preserved in the meter event payload metadata
- All historical usage is captured without data loss
### Implementation Details
1. **Added `adjustTimestampForStripe()` method**
(`StripeProvider.ts:310-337`)
- Checks if timestamp is older than 35 days
- Returns adjusted timestamp (34 days ago) for old events
- Preserves original date for reference
2. **Updated meter event creation** (`StripeProvider.ts:372-418`)
- Uses adjusted timestamp for Stripe API
- Adds `original_date` and `historical_data` fields to payload when
adjusted
- Tracks count of adjusted events
3. **Added logging summary** (`StripeProvider.ts:504-511`)
- Reports count and percentage of adjusted timestamps
- Clear indication of historical data processing
### Example Meter Event Payload (Adjusted)
```json
{
"event_name": "credits",
"identifier": "24d6140b-780f-4b76-9bdb-6c05c8819ae1_credits",
"timestamp": 1754387332, // 34 days ago
"payload": {
"value": "1433",
"stripe_customer_id": "cus_SGx0SYUXIfqZxQ",
"trace_id": "24d6140b-780f-4b76-9bdb-6c05c8819ae1",
"original_date": "2024-10-22T04:30:36.000Z", // Actual date preserved
"historical_data": "true",
// ... other fields
}
}
```
### Testing
- ✅ TypeScript compilation successful
- ✅ No type errors
- ✅ Ready for staging deployment
### Benefits
- All historical billing data can now be processed
- No data loss - all usage is captured
- Clear audit trail with original dates preserved
- Graceful handling with informative logging
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
💡 Codex Reviewtheanswer/packages/ui/src/views/chatmessage/ChatMessage.jsx Lines 2512 to 2515 in 7af8e37 In the new feedback modal the Cancel button is wired to ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
# Release: Staging to Production - October 24, 2025 This PR releases all tested changes from staging to production. ## 🎯 Key Features ### Organizational Billing Override (#637) - **NEW**: Support for organizational billing where all users' usage consolidates to a single Stripe customer - Environment variable: `BILLING_OVERRIDE_CUSTOMER_ID=true` to enable - Users maintain individual trace attribution while billing flows to organization - Fixes P1 issue where usage events returned empty list for organizational accounts ### Langfuse API Optimization (#637) - **PERFORMANCE**: Reduced parallel API load by 85% - PAGE_BATCH_SIZE: 15 → 3 pages - TRACE_BATCH_SIZE: 15 → 5 traces - RATE_LIMIT_DELAY_MS: 1000ms → 2000ms - LOOKBACK_DAYS: 90 → 7 days (default) - Prevents "database resource limit exceeded" errors on large datasets - All settings configurable via environment variables ### Environment Variable Standardization (#637) - **BREAKING**: All billing-related env vars now use `BILLING_` prefix - `STRIPE_FREE_PRICE_ID` → `BILLING_STRIPE_FREE_PRICE_ID` - `STRIPE_CREDITS_METER_ID` → `BILLING_STRIPE_CREDITS_METER_ID` - `STRIPE_AI_TOKENS_METER_ID` → `BILLING_STRIPE_AI_TOKENS_METER_ID` - `STRIPE_MARGIN_MULTIPLIER` → `BILLING_STRIPE_MARGIN_MULTIPLIER` - Updated documentation and code references ## 🐛 Bug Fixes ### P1: Usage Events Filter for Organizational Billing - Fixed filter logic in `getUsageEvents` to handle organizational override - Users now correctly see their own traces when override is enabled - Admins continue to see all traces ### Billing Metadata and Tracking - Previous releases included billing metadata filtering improvements - Self-healing for billing tags - Enhanced analytics tracing accuracy ## 📋 Other Improvements - Chat drawer pagination enhancements - Facebook Pixel tracking fixes - JLINC audit log improvements - Admin navigation fixes - Dependencies updates (mammoth 1.10.0 → 1.11.0) ## 🔄 Migration Notes **Required Environment Variable Updates:** Update your production environment with the new `BILLING_STRIPE_*` prefixed variables. The old names will no longer work. **New Optional Variables:** - `BILLING_OVERRIDE_CUSTOMER_ID` - Set to "true" for organizational billing - `BILLING_DEFAULT_STRIPE_CUSTOMER_ID` - Organization's Stripe customer ID - `BILLING_SYNC_LOOKBACK_DAYS` - Days to look back for unprocessed traces (default: 7) - `BILLING_SYNC_PAGE_BATCH_SIZE` - Parallel page fetches (default: 3) - `BILLING_SYNC_TRACE_BATCH_SIZE` - Parallel trace fetches (default: 5) - `BILLING_SYNC_RATE_LIMIT_MS` - Delay between API calls (default: 2000) ## ✅ Testing All changes have been tested in staging environment including: - Organizational billing override functionality - Langfuse API optimization under load - Usage events filtering with override enabled - Environment variable migrations ## 📦 Included PRs - #637 - Organizational billing override and Langfuse optimization - #635 - Previous staging release - #628 - Embed package updates - #627 - Previous production release - #622 - Billing metadata filtering - #621 - Chat drawer pagination - #617 - Billing tag self-healing - And more (see commit history) --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
📦 Release Summary
This release includes updates from staging to production, bringing multiple improvements, fixes, and new features.
🎯 Key Changes
Recent Updates
Previous Releases Included
📊 Impact Summary
✅ Pre-Release Checklist
🚀 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