Skip to main content
customerio-observability Set up Customer.io monitoring and observability.
Use when implementing metrics, structured logging, alerting,
or Grafana dashboards for Customer.io integrations.
Trigger: "customer.io monitoring", "customer.io metrics",
"customer.io dashboard", "customer.io alerts", "customer.io observability".
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill customerio-observability命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... 同仓库更多 Skills Implement user sign-up and sign-in flows with Clerk.
Use when building authentication UI, customizing sign-in experience,
or implementing OAuth social login.
Trigger with phrases like "clerk sign-in", "clerk sign-up",
"clerk login flow", "clerk OAuth", "clerk social login".
Implement session management and middleware with Clerk.
Use when managing user sessions, configuring route protection,
or implementing token refresh and custom JWT templates.
Trigger with phrases like "clerk session", "clerk middleware",
"clerk route protection", "clerk token", "clerk JWT".
Configure enterprise SSO, role-based access control, and organization management.
Use when implementing SSO integration, configuring role-based permissions,
or setting up organization-level controls.
Trigger with phrases like "clerk SSO", "clerk RBAC",
"clerk enterprise", "clerk roles", "clerk permissions", "clerk organizations".
jeremylongshore
jeremylongshore/claude-code-plugins-plus-skills
打开 GitHub 仓库 name customerio-observability description Set up Customer.io monitoring and observability.
Use when implementing metrics, structured logging, alerting,
or Grafana dashboards for Customer.io integrations.
Trigger: "customer.io monitoring", "customer.io metrics",
"customer.io dashboard", "customer.io alerts", "customer.io observability".
allowed-tools Read, Write, Edit, Bash(npm:*), Bash(npx:*), Glob, Grep version 1.14.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","customer-io","monitoring","observability","prometheus"] compatibility Designed for Claude Code, also compatible with Codex and OpenClaw
Customer.io Observability
Overview
Implement comprehensive observability for Customer.io integrations: Prometheus metrics (latency, error rates, delivery funnel), structured JSON logging with PII redaction, OpenTelemetry tracing, and Grafana dashboard definitions.
Prerequisites
Customer.io integration deployed
Prometheus + Grafana (or compatible metrics stack)
Structured logging system (pino recommended)
Key Metrics to Track
Metric Type Description Alert Threshold cio_api_duration_msHistogram API call latency p99 > 5000ms cio_api_requests_totalCounter Total API requests by operation N/A (rate) cio_api_errors_totalCounter API errors by status code > 1% error rate cio_email_sent_totalCounter Transactional + campaign emails N/A cio_email_bounced_totalCounter Bounce count > 5% of sends cio_email_complained_totalCounter Spam complaints > 0.1% of sends cio_webhook_received_totalCounter Webhook events by metric type N/A cio_queue_depthGauge Pending items in event queue > 10K
Instructions
Step 1: Prometheus Metrics
import { Counter , Histogram , Gauge , Registry } from "prom-client" ;
const registry = new Registry ();
cioMetrics = {
: ({
: ,
: ,
: [ , ] ,
: [ , , , , , , , , ],
: [registry],
}),
: ({
: ,
: ,
: [ ] ,
: [registry],
}),
: ({
: ,
: ,
: [ , ] ,
: [registry],
}),
: ({
: ,
: ,
: [ ] ,
: [registry],
}),
: ({
: ,
: ,
: [registry],
}),
: ({
: ,
: ,
: [registry],
}),
: ({
: ,
: ,
: [ ] ,
: [registry],
}),
: ({
: ,
: ,
: [ ] ,
: [registry],
}),
};
{ registry };
export
const
apiDuration
new
Histogram
name
"cio_api_duration_ms"
help
"Customer.io API call duration in milliseconds"
labelNames
"operation"
"status"
as
const
buckets
10
25
50
100
250
500
1000
2500
5000
registers
apiRequests
new
Counter
name
"cio_api_requests_total"
help
"Total Customer.io API requests"
labelNames
"operation"
as
const
registers
apiErrors
new
Counter
name
"cio_api_errors_total"
help
"Customer.io API errors"
labelNames
"operation"
"status_code"
as
const
registers
emailSent
new
Counter
name
"cio_email_sent_total"
help
"Emails sent via Customer.io"
labelNames
"type"
as
const
registers
emailBounced
new
Counter
name
"cio_email_bounced_total"
help
"Email bounces from Customer.io webhooks"
registers
emailComplained
new
Counter
name
"cio_email_complained_total"
help
"Spam complaints from Customer.io webhooks"
registers
webhookReceived
new
Counter
name
"cio_webhook_received_total"
help
"Webhook events received"
labelNames
"metric"
as
const
registers
queueDepth
new
Gauge
name
"cio_queue_depth"
help
"Pending items in Customer.io event queue"
labelNames
"queue"
as
const
registers
export
Step 2: Instrumented Client
import { TrackClient , APIClient , SendEmailRequest , RegionUS } from "customerio-node" ;
import { cioMetrics } from "./customerio-metrics" ;
export class InstrumentedCioClient {
private track : TrackClient ;
private app : APIClient ;
constructor (siteId : string , trackKey : string , appKey : string ) {
this .track = new TrackClient (siteId, trackKey, { region : RegionUS });
this .app = new APIClient (appKey, { region : RegionUS });
}
async identify (userId : string , attrs : Record <string , any >): Promise <void > {
const timer = cioMetrics.apiDuration .startTimer ({ operation : "identify" });
cioMetrics.apiRequests .inc ({ operation : "identify" });
try {
await this .track .identify (userId, attrs);
timer ({ status : "success" });
} catch (err : any ) {
const code = String (err.statusCode ?? "unknown" );
timer ({ status : "error" });
cioMetrics.apiErrors .inc ({ operation : "identify" , status_code : code });
throw err;
}
}
async trackEvent (
userId : string ,
name : string ,
data ?: Record <string , any >
): Promise <void > {
const timer = cioMetrics.apiDuration .startTimer ({ operation : "track" });
cioMetrics.apiRequests .inc ({ operation : "track" });
try {
await this .track .track (userId, { name, data });
timer ({ status : "success" });
} catch (err : any ) {
timer ({ status : "error" });
cioMetrics.apiErrors .inc ({
operation : "track" ,
status_code : String (err.statusCode ?? "unknown" ),
});
throw err;
}
}
async sendEmail (request : SendEmailRequest ): Promise <any > {
const timer = cioMetrics.apiDuration .startTimer ({ operation : "send_email" });
cioMetrics.apiRequests .inc ({ operation : "send_email" });
try {
const result = await this .app .sendEmail (request);
timer ({ status : "success" });
cioMetrics.emailSent .inc ({ type : "transactional" });
return result;
} catch (err : any ) {
timer ({ status : "error" });
cioMetrics.apiErrors .inc ({
operation : "send_email" ,
status_code : String (err.statusCode ?? "unknown" ),
});
throw err;
}
}
}
Step 3: Structured Logging with PII Redaction
import pino from "pino" ;
const logger = pino ({
name : "customerio" ,
level : process.env .CUSTOMERIO_LOG_LEVEL ?? "info" ,
redact : {
paths : [
"*.email" ,
"*.phone" ,
"*.ip_address" ,
"*.password" ,
"attrs.email" ,
"attrs.phone" ,
],
censor : "[REDACTED]" ,
},
});
export function logCioOperation (
operation : string ,
data : {
userId?: string ;
event?: string ;
latencyMs?: number ;
statusCode?: number ;
error?: string ;
attrs?: Record<string , any >;
}
): void {
if (data.error ) {
logger.error ({ operation, ...data }, `CIO ${operation} failed` );
} else {
logger.info ({ operation, ...data }, `CIO ${operation} completed` );
}
}
Step 4: Webhook Metrics Collection
function recordWebhookMetrics (event : { metric: string } ): void {
cioMetrics.webhookReceived .inc ({ metric : event.metric });
switch (event.metric ) {
case "bounced" :
cioMetrics.emailBounced .inc ();
break ;
case "spammed" :
cioMetrics.emailComplained .inc ();
break ;
case "sent" :
cioMetrics.emailSent .inc ({ type : "campaign" });
break ;
}
}
Step 5: Prometheus Metrics Endpoint
import { Router } from "express" ;
import { registry } from "../lib/customerio-metrics" ;
const router = Router ();
router.get ("/metrics" , async (_req, res) => {
res.set ("Content-Type" , registry.contentType );
res.end (await registry.metrics ());
});
export default router;
Step 6: Grafana Dashboard (JSON Model) {
"title" : "Customer.io Integration" ,
"panels" : [
{
"title" : "API Latency (p50/p95/p99)" ,
"type" : "timeseries" ,
"targets" : [
{ "expr" : "histogram_quantile(0.50, rate(cio_api_duration_ms_bucket[5m]))" } ,
{ "expr" : "histogram_quantile(0.95, rate(cio_api_duration_ms_bucket[5m]))" } ,
{ "expr" : "histogram_quantile(0.99, rate(cio_api_duration_ms_bucket[5m]))" }
]
} ,
{
"title" : "Request Rate by Operation" ,
"type" : "timeseries" ,
"targets" : [
{ "expr" : "rate(cio_api_requests_total[5m])" }
]
} ,
{
"title" : "Error Rate %" ,
"type" : "stat" ,
"targets" : [
{ "expr" : "rate(cio_api_errors_total[5m]) / rate(cio_api_requests_total[5m]) * 100" }
]
} ,
{
"title" : "Email Delivery Funnel" ,
"type" : "bargauge" ,
"targets" : [
{ "expr" : "cio_email_sent_total" } ,
{ "expr" : "cio_email_bounced_total" } ,
{ "expr" : "cio_email_complained_total" }
]
}
]
}
Step 7: Alerting Rules
groups:
- name: customerio
rules:
- alert: CioHighErrorRate
expr: rate(cio_api_errors_total[5m]) / rate(cio_api_requests_total[5m]) > 0.05
for: 5m
labels: { severity: critical }
annotations:
summary: "Customer.io API error rate > 5%"
- alert: CioHighLatency
expr: histogram_quantile(0.99, rate(cio_api_duration_ms_bucket[5m])) > 5000
for: 5m
labels: { severity: warning }
annotations:
summary: "Customer.io p99 latency > 5 seconds"
- alert: CioHighBounceRate
expr: rate(cio_email_bounced_total[1h]) / rate(cio_email_sent_total[1h]) > 0.05
for: 15m
labels: { severity: warning }
annotations:
summary: "Email bounce rate > 5%"
- alert: CioSpamComplaints
expr: rate(cio_email_complained_total[1h]) / rate(cio_email_sent_total[1h]) > 0.001
for: 5m
labels: { severity: critical }
annotations:
summary: "Spam complaint rate > 0.1% — sender reputation at risk"
Error Handling Issue Solution High cardinality metrics Don't use userId as a label — use operation + status only Log volume too high Set CUSTOMERIO_LOG_LEVEL=warn in production Missing metrics Check metric registration and scrape config PII in logs Verify pino redact paths cover all sensitive fields
Resources
Next Steps After observability setup, proceed to customerio-advanced-troubleshooting for debugging.