Version: 0.10.x → 0.11.0
Status: Current Breaking Change
It is breaking in that we need to migrate data from the old fields to the new fields.
This guide covers breaking changes in version 0.11.0 that require data migration before deployment.
Overview
Section titled “Overview”Version 0.11.0 introduces significant enhancements to session analytics and widget system that require data migration:
- OpenSearch Keyword Fields - New keyword fields for aggregation support in session analytics
- User Type Migration - Add user type classification to chat sessions
Required Migration Steps
Section titled “Required Migration Steps”Prerequisites
Section titled “Prerequisites”Before starting the migration, ensure you have:
Environment Configuration:
services/pika/.env.localwith:stage- Your deployment stagePIKA_DOMAIN_ENDPOINT- OpenSearch endpointAWS_REGION- AWS regionPIKA_SERVICE_PROJ_NAME_KEBAB_CASE- Your project name
AWS Credentials:
- Ensure AWS CLI is configured with credentials that have access to:
- OpenSearch domain
- DynamoDB tables (chat-session, chat-user)
- Ensure AWS CLI is configured with credentials that have access to:
Backup Your Data:
- Consider taking snapshots of your DynamoDB tables and OpenSearch indices before proceeding
Part A: OpenSearch Keyword Field Migration
Section titled “Part A: OpenSearch Keyword Field Migration”Background
Section titled “Background”Session analytics requires aggregations on certain fields (invocation_mode, user_type, source). These fields were auto-indexed as text type by OpenSearch, which doesn't support aggregations. Instead of reindexing all data, we're adding new keyword-specific fields.
Fields being migrated:
invocation_mode→invocation_mode_keyworduser_type→user_type_keywordsource→source_keyword
Step A1: Update OpenSearch Index Mapping
Section titled “Step A1: Update OpenSearch Index Mapping”Add the new keyword fields to your existing OpenSearch session index:
cd services/pikapnpm tsx tools/os/update-session-mapping.tsWhat this does:
- Adds
invocation_mode_keyword,user_type_keyword, andsource_keywordfields to the session index - This is an additive-only operation - no existing data is modified
- The original text fields remain unchanged
Expected output:
Starting session index mapping update...Checking if session exists...Updating mapping for session...✓ Successfully updated mapping for sessionVerifying mapping...✓ Confirmed: invocation_mode_keyword field is now in the mapping✓ Confirmed: user_type_keyword field is now in the mapping✓ Confirmed: source_keyword field is now in the mapping
✅ Mapping update complete!Step A2: Copy Data to Keyword Fields
Section titled “Step A2: Copy Data to Keyword Fields”Copy values from text fields to the new keyword fields for all existing documents:
cd services/pikapnpm tsx tools/os/copy-to-keyword-fields.tsWhat this does:
- Uses OpenSearch's
update_by_queryAPI to bulk-update all session documents - Copies values:
invocation_mode→invocation_mode_keyword,user_type→user_type_keyword,source→source_keyword - Processes documents in batches of 1000 to avoid timeouts
- Original fields remain unchanged (additive-only operation)
Expected output:
Starting field copy from text fields to keyword variants...Checking if session exists...Counting all documents...Found 15234 total documentsCopying fields to keyword variants for 15234 documents... - invocation_mode -> invocation_mode_keyword - user_type -> user_type_keyword - source -> source_keywordThis may take a while for large datasets...✓ Update complete! - Total: 15234 - Updated: 15234 - Deleted: 0 - Batches: 16 - Version conflicts: 0 - Noops: 0 - Failures: 0
Verifying the copy...✓ Verified 5 sample documents: Session abc123: invocation_mode: agent -> invocation_mode_keyword: agent user_type: internal-user -> user_type_keyword: internal-user source: user -> source_keyword: user
✅ Field copy complete!Part B: User Type Migration
Section titled “Part B: User Type Migration”Background
Section titled “Background”Version 0.11.0 adds user type classification to chat sessions, enabling filtering and analytics by user type (e.g., internal-user, external-user).
Step B1: Add User Type to Chat Sessions
Section titled “Step B1: Add User Type to Chat Sessions”Scan all chat sessions and add the user_type field by looking up each user in the chat-user table:
cd services/pikapnpm dlx tsx tools/backfill-session-metadata/index.tsWhat this does:
- Scans the chat-session table
- For each session, looks up the user in the chat-user table
- Adds
user_typefield to the session (e.g.,internal-user,external-user) - Defaults to
external-userif user is not found in chat-user table - Uses caching to minimize DynamoDB reads for users with multiple sessions
Expected output:
Starting migration: Add userType to chat sessionsEnvironment: Stage: prod Project: my-project Chat Session Table: my-project-prod-chat-session Chat User Table: my-project-prod-chat-user
Scanning chat sessions and updating with user types...Progress: 1000 scanned, 950 updated, 50 skippedProgress: 2000 scanned, 1900 updated, 100 skipped...✅ Migration complete!Statistics: Scanned: 15234 Updated: 14500 Skipped: 734 (already had user_type) Errors: 0 User Cache Lookups: 14500 User DB Lookups: 342Deployment Steps
Section titled “Deployment Steps”After completing all required migration steps:
1. Verify Migration Success
Section titled “1. Verify Migration Success”Confirm all migrations completed successfully by checking:
OpenSearch:
cd services/pika# Check a sample session document has keyword fieldspnpm tsx tools/os/os-tools.ts get session <some-session-id># Should show invocation_mode_keyword, user_type_keyword, source_keywordDynamoDB (Chat Sessions):
# Check that sessions have user_type fieldaws dynamodb get-item \ --table-name <your-project>-<stage>-chat-session \ --key '{"session_id": {"S": "<some-session-id>"}}'# Should show user_type field2. Deploy Version 0.11.0
Section titled “2. Deploy Version 0.11.0”Deploy your updated application:
# Deploy infrastructure (CDK stacks)cd services/pikapnpm cdk deploy --all
# Deploy applicationcd ../../pnpm run deploy3. Test Session Analytics
Section titled “3. Test Session Analytics”- Navigate to Site Admin → Session Analytics
- Verify filters work correctly:
- Invocation Mode filter (agent, tool, etc.)
- User Type filter (internal-user, external-user)
- Source filter (user, component)
- Check that charts render correctly with aggregated data
Rollback Plan
Section titled “Rollback Plan”If you need to rollback after deployment:
Code Rollback
Section titled “Code Rollback”Revert the code changes:
Terminal window git revert <commit-hash>git pushRedeploy previous version:
Terminal window pnpm run deploy
Data Considerations
Section titled “Data Considerations”Good News: All migrations are additive-only. No original data was modified or deleted.
- OpenSearch: Original fields (
invocation_mode,user_type,source) remain unchanged. New keyword fields can be ignored by older code. - DynamoDB Sessions:
user_typefield can remain (older code will ignore it).
Troubleshooting
Section titled “Troubleshooting”Migration Script Fails
Section titled “Migration Script Fails”Problem: Script exits with error.
Solutions:
- Check AWS credentials are valid and have required permissions
- Verify environment variables are correctly set in
.env.local - Check CloudWatch logs for detailed error messages
- Ensure DynamoDB tables and OpenSearch indices exist
Partial Migration
Section titled “Partial Migration”Problem: Migration script processed some but not all records.
Solution:
- All scripts are idempotent - simply re-run the script
- Already-migrated records will be skipped
- Script will continue from where it left off
Performance Issues
Section titled “Performance Issues”Problem: Migration taking too long.
Solutions:
- Migrations use batching and are optimized for large datasets
- For very large datasets (>100K sessions), consider increasing batch sizes in scripts
- Monitor CloudWatch for throttling issues
- OpenSearch script uses
update_by_querywithscroll_size: 1000- this can be adjusted if needed
Missing User Data
Section titled “Missing User Data”Problem: Some users don't have userType after migration.
Solution:
- Missing userType: User doesn't exist in
chat-usertable (defaults toexternal-user)
What's New in 0.11.0
Section titled “What's New in 0.11.0”In addition to these data migrations, version 0.11.0 includes:
- Enhanced Session Analytics Dashboard - Filter by invocation mode, user type, and source with aggregated charts
- Widget Metadata System - Dynamic UI chrome for widgets (title, actions, icons, loading states)
- Action Callback Context - Widget actions now receive full context including element reference and widget instance
- Canvas and Dialog Metadata - Metadata support extended beyond spotlight to all rendering contexts
- Dynamic Widget Registration - Auto-generation of tag definitions for canvas and dialog widgets
- Type Improvements - Moved widget-related types to
webcomp-types.tsfor better organization - Automatic User Profile Sync - Framework now detects and updates firstName/lastName when auth provider returns updated values
For complete release notes, see the Changelog.
Getting Help
Section titled “Getting Help”If you encounter issues during migration:
- Check the Troubleshooting section above
- Review CloudWatch logs for detailed error messages
- Consult the Platform Documentation
- Open an issue on GitHub
Migration Complete? Return to the Releases page to learn about the new features in 0.11.0.