# GitHub Actions sample
jobs:
build-test:
steps:
- run: npm ci
- run: npm run lint && npm test
deploy:
steps:
- run: npm run build
- run: npm run deploy:staging
.env.dev, .env.staging).main → prod, develop → dev).
if [ "$ENV" == "staging" ]; then
npm run deploy:staging
fi
steps:
- run: npm test -- --coverage
- run: npx cypress run
aws s3 cp s3://backups/last-good-build ./ && npm run deploy
- uses: actions/cache@v3
with:
path: node_modules
npm audit)
if (user.isInCanaryGroup) {
return <NewComponent />
}
- run: npm run lint && npm run type-check
package-lock.json)web-vitals package to send metrics to a backend or analytics provider:
import { onCLS, onFID, onLCP } from 'web-vitals';
onCLS(sendToAnalytics); onLCP(sendToAnalytics); onFID(sendToAnalytics);
performance.now())x-request-id)
const start = performance.now();
fetch('/api/data').finally(() => {
const duration = performance.now() - start;
if (duration > 1000) logSlowAPI('/api/data', duration);
});
export const log = (msg) => {
if (process.env.NODE_ENV === "production") {
sendToLoggingService(msg);
} else {
console.log(msg);
}
};
fetch("/api", {
headers: { "x-trace-id": currentTraceId },
});
if (performance.memory) {
log(performance.memory.usedJSHeapSize);
}
analytics.track("feature_used", { variant: "B" });