Configure Customer.io CI/CD integration with automated testing.
Use when setting up GitHub Actions, integration test suites,
or pre-commit validation for Customer.io code.
Trigger: "customer.io ci", "customer.io github actions",
"customer.io pipeline", "customer.io automated testing".
Configure Customer.io CI/CD integration with automated testing.
Use when setting up GitHub Actions, integration test suites,
or pre-commit validation for Customer.io code.
Trigger: "customer.io ci", "customer.io github actions",
"customer.io pipeline", "customer.io automated testing".
Designed for Claude Code, also compatible with Codex and OpenClaw
Customer.io CI Integration
Overview
Set up CI/CD pipelines for Customer.io integrations: GitHub Actions workflow with unit + integration tests, test fixtures with automatic cleanup, pre-commit hooks, and environment-specific credential management.
Prerequisites
GitHub repository with Node.js project
Separate Customer.io workspace for CI testing (do NOT use production)
// scripts/cio-cleanup-test-users.tsimport { TrackClient, RegionUS } from"customerio-node";
const cio = newTrackClient(
process.env.CUSTOMERIO_SITE_ID!,
process.env.CUSTOMERIO_TRACK_API_KEY!,
{ region: RegionUS }
);
// Clean up any test users from failed CI runs// This uses the ci- prefix convention from testUserId()asyncfunctioncleanup() {
console.log("Cleaning up CI test users...");
console.log("Note: Customer.io doesn't have a list/search API via Track API.");
console.log("Cleanup relies on suppress+destroy for known test user IDs.");
console.log("For bulk cleanup, use the Customer.io dashboard People filter.");
}
cleanup();
Step 5: GitHub Secrets Setup
# Set up CI secrets (use a dedicated test workspace — NEVER production)
gh secret set CIO_TEST_SITE_ID --body "your-test-site-id"
gh secret set CIO_TEST_TRACK_API_KEY --body "your-test-track-key"
gh secret set CIO_TEST_APP_API_KEY --body "your-test-app-key"
// package.json{"lint-staged":{"lib/customerio-*.ts":["eslint --fix","vitest related --run"],"services/customerio-*.ts":["eslint --fix","vitest related --run"]}}
CI Best Practices
Practice
Rationale
Dedicated test workspace
Prevents CI from polluting dev/staging data
Unique test user IDs
Prevents collisions between parallel CI runs
Always cleanup in afterAll
Prevents accumulating stale test profiles
Rate limit awareness
Add small delays between batched API calls in CI
Skip integration tests if no creds
PRs from forks won't have secrets
Error Handling
Issue
Solution
Secrets not available in PR
Fork PRs don't get secrets — skip integration tests gracefully