customerio-local-dev-loop
Configure Customer.io local development workflow. Use when setting up local testing, development environment, or offline development for Customer.io integrations. Trigger with phrases like "customer.io local dev", "test customer.io locally", "customer.io development environment", "customer.io sandbox".
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 2.0k
- Forks
- 233
01 前言 Front Matter
- name
- customerio-local-dev-loop
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- description
- Configure Customer.io local development workflow. Use when setting up local testing, development environment, or offline development for Customer.io integrations. Trigger with phrases like "customer.io local dev", "test customer.io locally", "customer.io development environment", "customer.io sandbox".
- allowed-tools
- Read, Write, Edit, Bash(npm:*), Bash(pip:*), Grep
03 SKILL.md 正文
Customer.io Local Dev Loop
Overview
Set up an efficient local development workflow for Customer.io integrations with proper testing and isolation.
Prerequisites
- Customer.io SDK installed
- Separate development workspace in Customer.io (recommended)
- Environment variable management tool (dotenv)
Instructions
Step 1: Create Environment Configuration
# .env.development
CUSTOMERIO_SITE_ID=dev-site-id
CUSTOMERIO_API_KEY=dev-api-key
CUSTOMERIO_REGION=us
# .env.production
CUSTOMERIO_SITE_ID=prod-site-id
CUSTOMERIO_API_KEY=prod-api-key
CUSTOMERIO_REGION=us
Step 2: Create Dev Client Wrapper
// lib/customerio.ts
import { TrackClient, RegionUS, RegionEU } from '@customerio/track';
const getRegion = () => {
return process.env.CUSTOMERIO_REGION === 'eu' ? RegionEU : RegionUS;
};
const isDevelopment = process.env.NODE_ENV !== 'production';
class CustomerIOClient {
private client: TrackClient;
private dryRun: boolean;
constructor() {
this.client = new TrackClient(
process.env.CUSTOMERIO_SITE_ID!,
process.env.CUSTOMERIO_API_KEY!,
{ region: getRegion() }
);
this.dryRun = process.env.CUSTOMERIO_DRY_RUN === 'true';
}
async identify(userId: string, attributes: Record<string, any>) {
if (this.dryRun) {
console.log('[DRY RUN] Identify:', { userId, attributes });
return;
}
if (isDevelopment) {
attributes._dev = true;
attributes._dev_timestamp = new Date().toISOString();
}
return this.client.identify(userId, attributes);
}
async track(userId: string, eventName: string, data?: Record<string, any>) {
if (this.dryRun) {
console.log('[DRY RUN] Track:', { userId, eventName, data });
return;
}
const eventData = {
name: isDevelopment ? `dev_${eventName}` : eventName,
data: { ...data, _dev: isDevelopment }
};
return this.client.track(userId, eventData);
}
}
export const cio = new CustomerIOClient();
Step 3: Set Up Test Helpers
// test/helpers/customerio-mock.ts
import { vi } from 'vitest';
export const mockCustomerIO = () => {
const mocks = {
identify: vi.fn().mockResolvedValue(undefined),
track: vi.fn().mockResolvedValue(undefined),
trackAnonymous: vi.fn().mockResolvedValue(undefined),
};
vi.mock('@customerio/track', () => ({
TrackClient: vi.fn().mockImplementation(() => mocks),
RegionUS: 'us',
RegionEU: 'eu',
}));
return mocks;
};
// Usage in tests
import { mockCustomerIO } from './helpers/customerio-mock';
describe('User Registration', () => {
const cioMocks = mockCustomerIO();
it('identifies user on signup', async () => {
await registerUser({ email: 'test@example.com' });
expect(cioMocks.identify).toHaveBeenCalledWith(
expect.any(String),
expect.objectContaining({ email: 'test@example.com' })
);
});
});
Step 4: Create Dev Scripts
{
"scripts": {
"dev:cio": "CUSTOMERIO_DRY_RUN=true ts-node scripts/test-customerio.ts",
"dev:cio:live": "dotenv -e .env.development ts-node scripts/test-customerio.ts",
"test:cio": "vitest run --reporter=verbose tests/customerio/"
}
}
Output
- Environment-aware Customer.io client
- Dry-run mode for safe testing
- Test mocks for unit testing
- Prefixed events for development isolation
Error Handling
| Error | Cause | Solution |
|---|---|---|
| Wrong environment | Env vars not loaded | Use dotenv or env-specific files |
| Dev events in prod | Environment check failed | Verify NODE_ENV is set correctly |
| Mock not working | Import order issue | Mock before importing client |
Resources
Next Steps
After setting up local dev, proceed to customerio-sdk-patterns for production-ready patterns.
04 同仓库更多 Skills
web-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
neuropixels-analysis
Neuropixels neural recording analysis. Load SpikeGLX/OpenEphys data, preprocess, motion correction, Kilosort4 spike sorting, quality metrics, Allen/IBL curation, AI-assisted visual analysis, for Neuropixels 1.0/2.0 extracellular electrophysiology. Use when working with neural recordings, spike sorting, extracellular electrophysiology, or when the user mentions Neuropixels, SpikeGLX, Open Ephys, Kilosort, quality metrics, or unit curation.
skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
notebooklm
Use this skill to query your Google NotebookLM notebooks directly from Claude Code for source-grounded, citation-backed answers from Gemini. Browser automation, library management, persistent auth. Drastically reduced hallucinations through document-only responses.
slack-gif-creator
Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."