environment-setup-guide
Guide developers through setting up development environments with proper tools, dependencies, and configurations
customerio-cost-tuning
Optimize Customer.io costs and usage. Use when reducing expenses, optimizing usage, or right-sizing your Customer.io plan. Trigger with phrases like "customer.io cost", "reduce customer.io spend", "customer.io billing", "customer.io pricing".
Full skill instructions
Optimize Customer.io costs by managing profiles, reducing unnecessary operations, and right-sizing your usage.
| Component | Pricing Basis |
|---|---|
| Profiles | Number of people tracked |
| Emails | Volume sent (included amount varies) |
| SMS | Per message sent |
| Push | Volume sent |
| Objects | Included with plan |
// scripts/profile-audit.ts
import { APIClient, RegionUS } from '@customerio/track';
interface ProfileAudit {
total: number;
inactive30Days: number;
inactive90Days: number;
noEmail: number;
suppressed: number;
recommendations: string[];
}
async function auditProfiles(): Promise<ProfileAudit> {
const audit: ProfileAudit = {
total: 0,
inactive30Days: 0,
inactive90Days: 0,
noEmail: 0,
suppressed: 0,
recommendations: []
};
// Query via Customer.io App API or export
// Analyze profile data
const now = Math.floor(Date.now() / 1000);
const thirtyDaysAgo = now - (30 * 24 * 60 * 60);
const ninetyDaysAgo = now - (90 * 24 * 60 * 60);
// Example analysis
if (audit.inactive90Days > audit.total * 0.3) {
audit.recommendations.push(
'Consider archiving profiles inactive >90 days to reduce costs'
);
}
if (audit.noEmail > audit.total * 0.1) {
audit.recommendations.push(
'Remove profiles without email addresses (cannot receive communications)'
);
}
return audit;
}
// lib/profile-management.ts
import { TrackClient, RegionUS } from '@customerio/track';
const client = new TrackClient(
process.env.CUSTOMERIO_SITE_ID!,
process.env.CUSTOMERIO_API_KEY!,
{ region: RegionUS }
);
// Suppress users who haven't engaged
async function suppressInactiveUsers(
userIds: string[],
dryRun: boolean = true
): Promise<{ suppressed: string[]; errors: string[] }> {
const results = { suppressed: [] as string[], errors: [] as string[] };
for (const userId of userIds) {
if (dryRun) {
console.log(`[DRY RUN] Would suppress: ${userId}`);
results.suppressed.push(userId);
continue;
}
try {
await client.suppress(userId);
results.suppressed.push(userId);
} catch (error: any) {
results.errors.push(`${userId}: ${error.message}`);
}
}
return results;
}
// Delete users to fully remove from billing
async function deleteUsers(
userIds: string[],
dryRun: boolean = true
): Promise<{ deleted: string[]; errors: string[] }> {
const results = { deleted: [] as string[], errors: [] as string[] };
for (const userId of userIds) {
if (dryRun) {
console.log(`[DRY RUN] Would delete: ${userId}`);
results.deleted.push(userId);
continue;
}
try {
await client.destroy(userId);
results.deleted.push(userId);
} catch (error: any) {
results.errors.push(`${userId}: ${error.message}`);
}
}
return results;
}
// lib/smart-tracking.ts
import { LRUCache } from 'lru-cache';
import { TrackClient } from '@customerio/track';
const recentEvents = new LRUCache<string, number>({
max: 100000,
ttl: 3600000 // 1 hour
});
interface TrackingConfig {
dedupWindowMs: number;
skipEvents: string[];
sampleRate: Record<string, number>;
}
const config: TrackingConfig = {
dedupWindowMs: 60000, // 1 minute dedup window
skipEvents: [
'page_viewed', // High volume, low value
'heartbeat'
],
sampleRate: {
'feature_used': 0.1, // Sample 10% of feature usage
'search_performed': 0.5 // Sample 50% of searches
}
};
export function shouldTrackEvent(
userId: string,
eventName: string,
data?: Record<string, any>
): boolean {
// Skip excluded events
if (config.skipEvents.includes(eventName)) {
return false;
}
// Apply sampling for high-volume events
const sampleRate = config.sampleRate[eventName];
if (sampleRate !== undefined && Math.random() > sampleRate) {
return false;
}
// Deduplicate identical events
const eventKey = `${userId}:${eventName}:${JSON.stringify(data || {})}`;
if (recentEvents.has(eventKey)) {
return false;
}
recentEvents.set(eventKey, Date.now());
return true;
}
// lib/email-optimization.ts
interface EmailOptimizationConfig {
// Skip transactional emails for users who never open
skipInactiveAfterDays: number;
// Consolidate multiple notifications
batchNotifications: boolean;
batchWindowMinutes: number;
// Suppress bounced emails
suppressAfterBounces: number;
}
const emailConfig: EmailOptimizationConfig = {
skipInactiveAfterDays: 180, // Skip users inactive 6 months
batchNotifications: true,
batchWindowMinutes: 30,
suppressAfterBounces: 3
};
// Check if user should receive emails
async function shouldSendEmail(
userId: string,
emailType: 'transactional' | 'marketing'
): Promise<boolean> {
// Always send critical transactional (password reset, security)
if (emailType === 'transactional') {
return true;
}
// Check engagement history
const user = await getUserMetrics(userId);
// Skip users who haven't opened in 6 months
const sixMonthsAgo = Date.now() - (180 * 24 * 60 * 60 * 1000);
if (user.lastEmailOpenedAt < sixMonthsAgo) {
return false;
}
// Skip users with high bounce count
if (user.bounceCount >= emailConfig.suppressAfterBounces) {
return false;
}
return true;
}
// lib/usage-monitor.ts
interface UsageMetrics {
period: string;
profiles: {
total: number;
new: number;
deleted: number;
};
events: {
total: number;
byType: Record<string, number>;
};
emails: {
sent: number;
delivered: number;
opened: number;
bounced: number;
};
estimatedCost: number;
}
async function getUsageMetrics(
startDate: Date,
endDate: Date
): Promise<UsageMetrics> {
// Query Customer.io Reporting API
// or aggregate from your tracking
return {
period: `${startDate.toISOString()} - ${endDate.toISOString()}`,
profiles: {
total: 10000,
new: 500,
deleted: 100
},
events: {
total: 50000,
byType: {
'signed_up': 500,
'feature_used': 20000,
'page_viewed': 25000 // Candidate for sampling
}
},
emails: {
sent: 15000,
delivered: 14500,
opened: 4350,
bounced: 150
},
estimatedCost: 299 // Monthly estimate
};
}
// Alert on unexpected usage spikes
function checkUsageAlerts(metrics: UsageMetrics): string[] {
const alerts: string[] = [];
// Profile growth alert
if (metrics.profiles.new > metrics.profiles.total * 0.1) {
alerts.push('Unusual profile growth detected');
}
// Event volume alert
if (metrics.events.total > 100000) {
alerts.push('High event volume - consider sampling');
}
// Bounce rate alert
if (metrics.emails.bounced / metrics.emails.sent > 0.05) {
alerts.push('High bounce rate - clean email list');
}
return alerts;
}
## Monthly Cost Review Checklist
### Profile Optimization
- [ ] Remove profiles with no email
- [ ] Archive inactive profiles (>90 days)
- [ ] Suppress hard bounced emails
- [ ] Merge duplicate profiles
### Event Optimization
- [ ] Identify high-volume, low-value events
- [ ] Implement sampling for analytics events
- [ ] Deduplicate redundant events
- [ ] Remove deprecated event types
### Email Optimization
- [ ] Clean suppression list
- [ ] Re-engage or remove inactive subscribers
- [ ] Consolidate notification emails
- [ ] Optimize send frequency
### Plan Optimization
- [ ] Review plan vs actual usage
- [ ] Consider annual billing for discount
- [ ] Evaluate feature usage vs plan tier
| Optimization | Typical Savings |
|---|---|
| Profile cleanup | 10-30% |
| Event deduplication | 5-15% |
| Email list hygiene | 5-10% |
| Sampling high-volume events | 10-20% |
| Annual billing | 10-20% |
| Issue | Solution |
|---|---|
| Accidental deletion | Customer.io has 30-day recovery |
| Over-suppression | Track suppression reasons |
| Usage spike | Set up usage alerts |
After cost optimization, proceed to customerio-reference-architecture for architecture patterns.
Guide developers through setting up development environments with proper tools, dependencies, and configurations
Implement Exa lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Exa integrations, implementing pre-commit hooks, or configuring CI policy checks for Exa best practices. Trigger with phrases like "exa policy", "exa lint", "exa guardrails", "exa be...
Configure CI/CD pipelines for Documenso integrations. Use when setting up automated testing, deployment pipelines, or continuous integration for Documenso projects. Trigger with phrases like "documenso CI", "documenso GitHub Actions", "documenso pipeline", "documenso automated testing".
Build check model availability and implement fallback chains. Use when building resilient systems or handling model outages. Trigger with phrases like 'openrouter availability', 'openrouter fallback', 'openrouter model down', 'openrouter health check'.
Configure Langfuse enterprise organization management and access control. Use when implementing team access controls, configuring organization settings, or setting up role-based permissions for Langfuse projects. Trigger with phrases like "langfuse RBAC", "langfuse teams", "langfuse organization"...
Execute compliance and security auditing for Cursor usage. Triggers on "cursor compliance", "cursor audit", "cursor security review", "cursor soc2", "cursor gdpr". Use when analyzing or auditing cursor compliance audit. Trigger with phrases like "cursor compliance audit", "cursor audit", "cursor".
Configure Apollo.io CI/CD integration. Use when setting up automated testing, continuous integration, or deployment pipelines for Apollo integrations. Trigger with phrases like "apollo ci", "apollo github actions", "apollo pipeline", "apollo ci/cd", "apollo automated tests".
Create robust Python automation with full logging and safety checks. Use when tasks need complex data processing, authenticated API work, conditional file operations, or error handling beyond simple shell commands.
Configure PostHog across development, staging, and production environments. Use when setting up multi-environment deployments, configuring per-environment secrets, or implementing environment-specific PostHog configurations. Trigger with phrases like "posthog environments", "posthog staging", "po...
Expert in designing and building autonomous AI agents. Masters tool use, memory systems, planning strategies, and multi-agent orchestration. Use when: build agent, AI agent, autonomous agent, tool use, function calling.
Validate insecure deserialization checker operations. Auto-activating skill for Security Fundamentals. Triggers on: insecure deserialization checker, insecure deserialization checker Part of the Security Fundamentals skill category. Use when working with insecure deserialization checker functiona...
Manage path traversal finder operations. Auto-activating skill for Security Fundamentals. Triggers on: path traversal finder, path traversal finder Part of the Security Fundamentals skill category. Use when working with path traversal finder functionality. Trigger with phrases like "path traversa...
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience