Guides
Production Checklist
Everything you need before going live with CogniKin.
Pre-Launch Checklist
✅ API Keys
- [ ] Switch to production API key (
ck_sk_live_) - [ ] Store key securely in environment variables
- [ ] Never commit keys to version control
- [ ] Set up key rotation schedule (every 90 days)
✅ Error Handling
- [ ] Implement fallback for CogniKin outages
- [ ] Add retry logic with exponential backoff
- [ ] Log errors to monitoring service
- [ ] Test graceful degradation
✅ Outcome Reporting
- [ ] Verify outcomes are being reported
- [ ] Report in background (non-blocking)
- [ ] Include optional fields when available
- [ ] Test with real user behaviour
✅ Performance
- [ ] Monitor CogniKin latency (should be < 50ms)
- [ ] Set appropriate timeouts
- [ ] Consider caching for high-traffic (< 5min TTL)
- [ ] Load test with expected traffic
✅ Monitoring
- [ ] Track CogniKin API success rate
- [ ] Monitor user completion rates
- [ ] Alert on error rate spikes
- [ ] Dashboard for CogniKin metrics
Monitoring Setup
import { CogniKin } from '@cognikin/client';
const brain = new CogniKin({
apiKey: process.env.COGNIKIN_API_KEY,
// Add instrumentation
onRequest: (params) => {
metrics.increment('cognikin.request');
metrics.timing('cognikin.request.start', Date.now());
},
onResponse: (context, duration) => {
metrics.timing('cognikin.latency', duration);
metrics.gauge('cognikin.confidence', context.confidence);
},
onError: (error) => {
metrics.increment('cognikin.error', {
code: error.code
});
logger.error('CogniKin Error', error);
}
});Rate Limiting
// Implement client-side rate limiting
import { RateLimiter } from 'limiter';
const limiter = new RateLimiter({
tokensPerInterval: 100,
interval: 'second'
});
async function getContextWithLimit(params) {
await limiter.removeTokens(1);
return brain.getContext(params);
}Security
API Key Management
.env.production
# Production
COGNIKIN_API_KEY=ck_sk_live_your_production_key
# Rotate every 90 days
# Last rotated: 2024-01-15
# Next rotation: 2024-04-15User ID Hashing
import crypto from 'crypto';
// Hash sensitive user IDs
function hashUserId(userId: string): string {
return crypto
.createHash('sha256')
.update(userId + process.env.HASH_SALT)
.digest('hex')
.slice(0, 32);
}
const context = await brain.getContext({
userId: hashUserId(user.email), // Don't send PII
task: query
});Deployment
Gradual Rollout
// Roll out to percentage of users
const ROLLOUT_PERCENTAGE = 25;
async function handleRequest(userId: string, query: string) {
const useCogniKin = hashUserId(userId) % 100 < ROLLOUT_PERCENTAGE;
if (useCogniKin) {
const context = await brain.getContext({ userId, task: query });
return generateAdaptiveResponse(query, context);
} else {
return generateDefaultResponse(query);
}
}A/B Testing
// Compare CogniKin vs non-CogniKin
const variant = assignVariant(userId);
if (variant === 'cognikin') {
const context = await brain.getContext({ userId, task: query });
response = generateAdaptiveResponse(query, context);
analytics.track('variant', { type: 'cognikin', userId });
} else {
response = generateDefaultResponse(query);
analytics.track('variant', { type: 'control', userId });
}Post-Launch
Monitor These Metrics
- Task Completion Rate: Higher with CogniKin?
- Time to Start: Are users starting faster?
- User Engagement: More flow states?
- CogniKin Confidence: Increasing over time?
Weekly Reviews
- Check CogniKin error rates
- Review profile evolution for sample users
- Compare completion rates: CogniKin vs control
- Identify and fix integration issues
💡 Success Metric: If task completion rates increase by 20%+ within 30 days, CogniKin is working well.