Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/customerio-performance-tuning

@0d57af8
Run it yourself

Optimize Customer.io API performance for high throughput. Use when improving response times, implementing connection pooling, batching, caching, or regional routing. Trigger: "customer.io performance", "optimize customer.io", "customer.io latency", "customer.io connection pooling".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/customerio-performance-tuning

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesimplementation.md

≈953 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Customer.io Performance Tuning - Implementation Details

Configuration

Optimized Client Setup

import { TrackClient, RegionUS } from '@customerio/track';

const cio = new TrackClient(
  process.env.CIO_SITE_ID!,
  process.env.CIO_API_KEY!,
  {
    region: RegionUS,
    timeout: 5000,
  }
);

Advanced Patterns

Batch Event Processing

class CustomerIOBatcher {
  private buffer: Array<{ userId: string; event: string; data: any }> = [];
  private flushInterval: NodeJS.Timeout;

  constructor(
    private cio: TrackClient,
    private maxSize = 100,
    private flushMs = 5000
  ) {
    this.flushInterval = setInterval(() => this.flush(), flushMs);
  }

  add(userId: string, event: string, data: any) {
    this.buffer.push({ userId, event, data });
    if (this.buffer.length >= this.maxSize) this.flush();
  }

  async flush() {
    if (this.buffer.length === 0) return;
    const batch = this.buffer.splice(0, this.maxSize);
    const results = await Promise.allSettled(
      batch.map((item) => this.cio.track(item.userId, { name: item.event, data: item.data }))
    );
    const failed = results.filter((r) => r.status === 'rejected');
    if (failed.length > 0) console.warn(`${failed.length}/${batch.length} events failed`);
  }

  destroy() {
    clearInterval(this.flushInterval);
    return this.flush();
  }
}

Connection Pooling for High Throughput

import { Agent } from 'https';

const keepAliveAgent = new Agent({
  keepAlive: true,
  maxSockets: 50,
  maxFreeSockets: 10,
  timeout: 10000,
});

// Pass to the underlying HTTP client
const cio = new TrackClient(siteId, apiKey, {
  region: RegionUS,
  agent: keepAliveAgent,
});

Attribute Update Debouncing

class AttributeDebouncer {
  private pending = new Map<string, { attrs: Record<string, any>; timer: NodeJS.Timeout }>();

  constructor(private cio: TrackClient, private debounceMs = 2000) {}

  update(userId: string, attrs: Record<string, any>) {
    const existing = this.pending.get(userId);
    if (existing) {
      clearTimeout(existing.timer);
      Object.assign(existing.attrs, attrs);
    }

    const entry = existing ?? { attrs: { ...attrs }, timer: null as any };
    entry.timer = setTimeout(() => {
      this.cio.identify(userId, entry.attrs);
      this.pending.delete(userId);
    }, this.debounceMs);

    this.pending.set(userId, entry);
  }
}

Response Time Monitoring

async function timedTrack(userId: string, event: string, data: any) {
  const start = performance.now();
  try {
    await cio.track(userId, { name: event, data });
    const duration = performance.now() - start;
    metrics.histogram('cio.track.duration_ms', duration, { event });
    if (duration > 1000) console.warn(`Slow CIO track: ${event} took ${duration}ms`);
  } catch (err) {
    metrics.increment('cio.track.errors', { event });
    throw err;
  }
}

Troubleshooting

Identifying Bottlenecks

# Check Customer.io API response times
for i in $(seq 1 5); do
  curl -o /dev/null -s -w "Response: %{http_code} Time: %{time_total}s\n" \
    -X POST -H "Authorization: Bearer $CIO_API_KEY" \
    -d '{"email":"test@test.com"}' \
    https://track.customer.io/api/v2/entity
done

# Monitor connection reuse
ss -tn | grep "track.customer.io" | wc -l

Diagnosing High Latency

Check these in order: DNS resolution, TLS handshake, server response time:

curl -w "DNS: %{time_namelookup}s\nTLS: %{time_appconnect}s\nResponse: %{time_starttransfer}s\nTotal: %{time_total}s\n" \
  -o /dev/null -s https://track.customer.io/api/v2/entity

Tons of Skills by Intent Solutions | jeremylongshore.com

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides implementation templates and best practices for optimizing Customer.io API performance, including connection pooling, batching, and caching. It follows secure practices for secret management by using environment variables. A potential surface for indirect prompt injection was identified as the skill processes user-provided data attributes, though no active exploitation was detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago
What it can do
Reads files Edits files Runs commands
version
1.14.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
[
  "saas",
  "customer-io",
  "performance",
  "optimization"
]
All 7 allowed tools
ReadWriteEditBash(npm:*)Bash(npx:*)GlobGrep
Other metadata
compatibility
Designed for Claude Code

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/customerio-performance-tuning