Migrating from v2.2.0 to v2.3.0
This guide will help you migrate your existing Altitude Platform projects from v2.2.0 to v2.3.0. Version 2.3.0 introduces several new features and some breaking changes that you need to be aware of.
Breaking Changes
KV Store API Changes
The KV Store API has been updated in v2.3.0 to support TTL and atomic operations:
v2.2.0 (Old)
export default {
async fetch(request, env) {
// Store data
await env.MY_KV_STORE.put('key', 'value');
// Retrieve data
const value = await env.MY_KV_STORE.get('key');
return new Response(value);
}
}
v2.3.0 (New)
export default {
async fetch(request, env) {
// Store data with TTL (time-to-live in seconds)
await env.MY_KV_STORE.put('key', 'value', { expirationTtl: 86400 });
// Atomic operations
await env.MY_KV_STORE.atomic()
.put('counter', '1')
.add('visits', 1)
.commit();
// Retrieve data with metadata
const { value, metadata } = await env.MY_KV_STORE.getWithMetadata('key');
return new Response(value);
}
}
Monitoring API Changes
The Monitoring API has been updated to support real-time metrics:
v2.2.0 (Old)
export default {
async fetch(request, env, ctx) {
// Log an event
ctx.log.info('Request received', { url: request.url });
return new Response('Hello World');
}
}
v2.3.0 (New)
export default {
async fetch(request, env, ctx) {
// Log an event with enhanced metadata
ctx.log.info('Request received', {
url: request.url,
country: request.cf.country,
browser: request.headers.get('user-agent')
});
// Record a custom metric
ctx.metrics.increment('requests', 1, {
path: new URL(request.url).pathname
});
return new Response('Hello World');
}
}
Migration Steps
1. Update KV Store Usage
Update all your KV store operations to use the new API:
- Review all KV store operations in your code
- Add TTL for keys that should expire
- Use atomic operations for counters and other values that need atomic updates
- Update any code that relies on the old API
2. Update Monitoring Code
- Update your logging code to include enhanced metadata
- Add custom metrics for important events
- Update any dashboards or alerts to use the new metrics
3. Update Configuration Files
- Update the
altitude.yamlconfiguration file to include new monitoring settings:
version: 2.3
provider: cloudflare
monitoring:
alerts:
- name: high-error-rate
metric: error_rate
threshold: 0.05
duration: 60
dashboards: true
4. Update Deployment Settings
- Log in to the Altitude Platform dashboard
- Go to your site settings
- Update the deployment configuration to use v2.3.0
- Configure new features like role-based access control
- Set up real-time monitoring alerts
- Re-deploy your site
5. Test Thoroughly
After migration, thoroughly test your site to ensure everything works as expected:
- Test all KV store operations
- Verify monitoring and metrics are working
- Test any custom domains with HTTP/3
- Check team permissions and access control
- Verify CI/CD integration
New Features in v2.3.0
Take advantage of these new features after migrating:
Enhanced KV Store
// Set a key with metadata
await env.MY_KV_STORE.put('user:123', JSON.stringify(userData), {
expirationTtl: 3600,
metadata: { lastUpdated: new Date().toISOString() }
});
// List keys with a prefix
const keys = await env.MY_KV_STORE.list({ prefix: 'user:' });
Real-time Monitoring
Access the new monitoring dashboard to:
- View real-time request logs
- Track custom metrics
- Set up alerts for critical events
- Analyze performance trends
- Export metrics to external systems
Role-based Access Control
Configure fine-grained permissions for team members:
- Create custom roles with specific permissions
- Assign roles to team members
- Control access to specific environments
- Audit access and changes
Need Help?
If you encounter any issues during migration:
- Check the troubleshooting guide
- Contact support through the new in-app chat feature
- Join our community forum