Skill站外收录 @skilllib/skill-2014279396838813698
customerio-debug-bundle
自动收集 Customer.io 集成的诊断信息,包括 API 连通性测试、SDK 版本检查、环境配置快照、用户行为追踪验证、应用日志捕获及敏感数据脱敏打包,生成标准化支持工单附件。
效率工具 AI 技能
Skills.MD
# Customer.io Debug Bundle
## Overview
Collect comprehensive debug information for Customer.io support tickets and troubleshooting.
## Prerequisites
- Customer.io API credentials
- Access to application logs
- User ID or email of affected user
## Instructions
### Step 1: Create Debug Script
```bash
#!/bin/bash
# debug-customerio.sh
OUTPUT_DIR="customerio-debug-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$OUTPUT_DIR"
echo "Customer.io Debug Bundle" > "$OUTPUT_DIR/report.txt"
echo "Generated: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$OUTPUT_DIR/report.txt"
echo "" >> "$OUTPUT_DIR/report.txt"
# 1. API Connectivity Test
echo "=== API Connectivity ===" >> "$OUTPUT_DIR/report.txt"
curl -s -o "$OUTPUT_DIR/api-test.json" -w "%{http_code}" \
-X GET "https://track.customer.io/api/v1/accounts" \
-u "$CUSTOMERIO_SITE_ID:$CUSTOMERIO_API_KEY" \
>> "$OUTPUT_DIR/report.txt"
echo "" >> "$OUTPUT_DIR/report.txt"
# 2. SDK Version
echo "=== SDK Version ===" >> "$OUTPUT_DIR/report.txt"
npm list @customerio/track 2>/dev/null >> "$OUTPUT_DIR/report.txt" || echo "Not using npm" >> "$OUTPUT_DIR/report.txt"
pip show customerio 2>/dev/null >> "$OUTPUT_DIR/report.txt" || echo "Not using pip" >> "$OUTPUT_DIR/report.txt"
echo "" >> "$OUTPUT_DIR/report.txt"
# 3. Environment (redacted)
echo "=== Environment ===" >> "$OUTPUT_DIR/report.txt"
echo "CUSTOMERIO_SITE_ID: ${CUSTOMERIO_SITE_ID:0:8}..." >> "$OUTPUT_DIR/report.txt"
echo "CUSTOMERIO_API_KEY: ${CUSTOMERIO_API_KEY:0:8}..." >> "$OUTPUT_DIR/report.txt"
echo "NODE_ENV: $NODE_ENV" >> "$OUTPUT_DIR/report.txt"
echo "" >> "$OUTPUT_DIR/report.txt"
echo "Debug bundle created: $OUTPUT_DIR"
```
### Step 2: Collect User-Specific Data
```typescript
// scripts/debug-user.ts
import { TrackClient, RegionUS } from '@customerio/track';
async function debugUser(userId: string) {
const debug: Record<string, any> = {
timestamp: new Date().toISOString(),
userId,
checks: {}
};
const client = new TrackClient(
process.env.CUSTOMERIO_SITE_ID!,
process.env.CUSTOMERIO_API_KEY!,
{ region: RegionUS }
);
// Test identify call
try {
await client.identify(userId, { _debug_check: true });
debug.checks.identify = { status: 'success' };
} catch (error: any) {
debug.checks.identify = {
status: 'failed',
error: error.message,
code: error.statusCode
};
}
// Test track call
try {
await client.track(userId, {
name: '_debug_event',
data: { timestamp: Date.now() }
});
debug.checks.track = { status: 'success' };
} catch (error: any) {
debug.checks.track = {
status: 'failed',
error: error.message,
code: error.statusCode
};
}
console.log(JSON.stringify(debug, null, 2));
return debug;
}
// Run with: npx ts-node scripts/debug-user.ts user-123
debugUser(process.argv[2] || 'debug-user');
```
### Step 3: Collect Application Logs
```typescript
// lib/customerio-logger.ts
import { createWriteStream } from 'fs';
class CustomerIOLogger {
private logStream: NodeJS.WritableStream;
constructor(logPath: string = './customerio-debug.log') {
this.logStream = createWriteStream(logPath, { flags: 'a' });
}
log(event: {
type: 'identify' | 'track' | 'error';
userId?: string;
data?: any;
error?: any;
duration?: number;
}) {
const logEntry = {
timestamp: new Date().toISOString(),
...event
};
this.logStream.write(JSON.stringify(logEntry) + '\n');
}
// Wrap SDK calls with logging
async wrapIdentify(
client: TrackClient,
userId: string,
attributes: any
) {
const start = Date.now();
try {
await client.identify(userId, attributes);
this.log({
type: 'identify',
userId,
data: attributes,
duration: Date.now() - start
});
} catch (error: any) {
this.log({
type: 'error',
userId,
data: attributes,
error: { message: error.message, code: error.statusCode },
duration: Date.now() - start
});
throw error;
}
}
}
```
### Step 4: Generate Support Report
```typescript
// scripts/generate-support-report.ts
interface SupportReport {
summary: string;
environment: {
sdkVersion: string;
nodeVersion: string;
region: string;
};
timeline: Array<{
timestamp: string;
event: string;
details: string;
}>;
reproduction: {
steps: string[];
expected: string;
actual: string;
};
evidence: {
logs: string[];
screenshots: string[];
apiResponses: string[];
};
}
function generateReport(): SupportReport {
return {
summary: 'Brief description of the issue',
environment: {
sdkVersion: require('@customerio/track/package.json').version,
nodeVersion: process.version,
region: process.env.CUSTOMERIO_REGION || 'us'
},
timeline: [
{ timestamp: '2024-01-15T10:00:00Z', event: 'First occurrence', details: '...' }
],
reproduction: {
steps: [
'1. Call identify with user data',
'2. Call track with event',
'3. Check dashboard for user'
],
expected: 'User appears in People section',
actual: 'User not found, 401 error returned'
},
evidence: {
logs: ['./customerio-debug.log'],
screenshots: [],
apiResponses: ['./debug-bundle/api-test.json']
}
};
}
```
### Step 5: Bundle and Submit
```bash
#!/bin/bash
# Create debug bundle archive
DEBUG_DIR="customerio-debug-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$DEBUG_DIR"
# Collect all debug files
cp customerio-debug.log "$DEBUG_DIR/" 2>/dev/null
cp -r debug-bundle/* "$DEBUG_DIR/" 2>/dev/null
# Redact sensitive data
sed -i 's/api_key=.*/api_key=REDACTED/g' "$DEBUG_DIR"/*.log 2>/dev/null
sed -i 's/"api_key":"[^"]*"/"api_key":"REDACTED"/g' "$DEBUG_DIR"/*.json 2>/dev/null
# Create archive
tar -czf "$DEBUG_DIR.tar.gz" "$DEBUG_DIR"
echo "Debug bundle ready: $DEBUG_DIR.tar.gz"
echo "Submit to: support@customer.io"
```
## Output
- Debug script for API testing
- User-specific diagnostic data
- Application log collection
- Support report template
- Compressed debug bundle
## Error Handling
| Issue | Solution |
|-------|----------|
| Logs too large | Use `tail -n 1000` to limit |
| Sensitive data | Use redaction script |
| Missing permissions | Check file read access |
## Resources
- [Customer.io Support](https://customer.io/contact/)
- [API Status](https://status.customer.io/)
## Next Steps
After creating debug bundle, proceed to `customerio-rate-limits` to understand API limits.
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「customerio-debug-bundle」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次