Guides

Production Checklist

Everything you need before going live with AMP.

Pre-Launch Checklist

✅ API Keys

  • [ ] Switch to production API key (amp_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 AMP 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 AMP latency (should be < 50ms)
  • [ ] Set appropriate timeouts
  • [ ] Consider caching for high-traffic (< 5min TTL)
  • [ ] Load test with expected traffic

✅ Monitoring

  • [ ] Track AMP API success rate
  • [ ] Monitor user completion rates
  • [ ] Alert on error rate spikes
  • [ ] Dashboard for AMP metrics

Monitoring Setup

import { AMP } from '@amp-protocol/client';

const amp = new AMP({
  apiKey: process.env.AMP_API_KEY,

  // Add instrumentation
  onRequest: (params) => {
    metrics.increment('amp.request');
    metrics.timing('amp.request.start', Date.now());
  },

  onResponse: (context, duration) => {
    metrics.timing('amp.latency', duration);
    metrics.gauge('amp.confidence', context.confidence);
  },

  onError: (error) => {
    metrics.increment('amp.error', {
      code: error.code
    });

    logger.error('AMP 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 amp.getContext(params);
}

Security

API Key Management

.env.production
# Production
AMP_API_KEY=amp_sk_live_your_production_key

# Rotate every 90 days
# Last rotated: 2024-01-15
# Next rotation: 2024-04-15

User 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 amp.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 useAMP = hashUserId(userId) % 100 < ROLLOUT_PERCENTAGE;

  if (useAMP) {
    const context = await amp.getContext({ userId, task: query });
    return generateAdaptiveResponse(query, context);
  } else {
    return generateDefaultResponse(query);
  }
}

A/B Testing

// Compare AMP vs non-AMP
const variant = assignVariant(userId);

if (variant === 'amp') {
  const context = await amp.getContext({ userId, task: query });
  response = generateAdaptiveResponse(query, context);

  analytics.track('variant', { type: 'amp', userId });
} else {
  response = generateDefaultResponse(query);

  analytics.track('variant', { type: 'control', userId });
}

Post-Launch

Monitor These Metrics

  • Task Completion Rate: Higher with AMP?
  • Time to Start: Are users starting faster?
  • User Engagement: More flow states?
  • AMP Confidence: Increasing over time?

Weekly Reviews

  • Check AMP error rates
  • Review profile evolution for sample users
  • Compare completion rates: AMP vs control
  • Identify and fix integration issues

💡 Success Metric: If task completion rates increase by 20%+ within 30 days, AMP is working well.

See Also