Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.
JavaScript agent-skillsai-agentsai-seoclaudeclaude-codeclaude-code-pluginclaude-skillscodexcontent-marketingconversion-rate-optimizationcopywritingcursoremail-marketinggenerative-engine-optimizationgrowth-marketingmarketingmarketing-automationsaas-marketingseoskill-md
feat(customer-io): expose explicit suppression lifecycle
Rudy Celeklif7c8cef25107
diff --git a/tests/clis/customer-io-suppression.test.cjs b/tests/clis/customer-io-suppression.test.cjsnew file mode 100644index 0000000..8d3c9c1--- /dev/null+++ b/tests/clis/customer-io-suppression.test.cjs@@ -0,0 +1,49 @@+const { test } = require('node:test')+const assert = require('node:assert/strict')+const { spawnSync } = require('node:child_process')+const path = require('node:path')+const cli = path.resolve(__dirname, '../../tools/clis/customer-io.js')+function run(args, allowFetch = true, trackAuth = true) {+ const code = `global.fetch=async(url,options)=>{if(!${allowFetch})throw new Error('unexpected fetch');return {status:200,text:async()=>JSON.stringify({url,method:options.method,body:options.body ?? null,authorization:options.headers.Authorization})}};process.argv=['node',${JSON.stringify(cli)},...${JSON.stringify(args)}];require(${JSON.stringify(cli)});`+ const env = { ...process.env, CUSTOMERIO_APP_KEY: 'app-fixture', CUSTOMERIO_SITE_ID: trackAuth ? 'site-fixture' : '', CUSTOMERIO_API_KEY: trackAuth ? 'track-fixture' : '' }+ return spawnSync(process.execPath, ['-e', code], { encoding: 'utf8', env })+}+for (const action of ['suppress', 'unsuppress']) {+ test(`${action} uses documented no-body Track API operation with encoded identifier`, () => {+ const id = '[email protected]/path?segment=one'+ const r = run(['customers', action, id])+ assert.equal(r.status, 0, r.stderr)+ const out = JSON.parse(r.stdout)+ assert.equal(out.url, `https://track.customer.io/api/v1/customers/${encodeURIComponent(id)}/${action}`)+ assert.equal(out.method, 'POST')+ assert.equal(out.body, null)+ assert.equal(out.authorization, `Basic ${Buffer.from('site-fixture:track-fixture').toString('base64')}`)+ })+ test(`${action} preview and --id support preserve authentication redaction`, () => {+ const r = run(['customers', action, '--id', 'customer-123', '--dry-run'], false)+ assert.equal(r.status, 0, r.stderr)+ const out = JSON.parse(r.stdout)+ assert.equal(out.method, 'POST')+ assert.equal(out.headers.Authorization, '***')+ assert.equal(Object.hasOwn(out, 'body'), false)+ assert.equal(out.url, `https://track.customer.io/api/v1/customers/customer-123/${action}`)+ })+}+test('suppression requires Track authentication rather than substituting an App API key', () => {+ const r = run(['customers', 'suppress', 'customer-123'], false, false)+ assert.match(JSON.parse(r.stdout).error, /Track API requires/)+})+test('missing or bare identifiers fail before dispatching suppression', () => {+ for (const extra of [[], ['--id'], ['--id', '']]) {+ const r = run(['customers', 'suppress', ...extra], false)+ assert.equal(r.status, 1)+ assert.match(JSON.parse(r.stderr).error, /Customer ID must be a non-empty string/)+ }+})+test('existing delete keeps its distinct DELETE operation', () => {+ const r = run(['customers', 'delete', 'customer-123'])+ assert.equal(r.status, 0, r.stderr)+ const out = JSON.parse(r.stdout)+ assert.equal(out.method, 'DELETE')+ assert.equal(out.url, 'https://track.customer.io/api/v1/customers/customer-123')+})diff --git a/tools/clis/customer-io.js b/tools/clis/customer-io.jsindex b72485f..e468abb 100755--- a/tools/clis/customer-io.js+++ b/tools/clis/customer-io.js@@ -118,6 +118,13 @@ async function main() {result = await trackApi('DELETE', `/customers/${customerId}`)break}+ case 'suppress':+ case 'unsuppress': {+ const customerId = rest[0] || args.id+ if (typeof customerId !== 'string' || customerId.trim().length === 0) throw new Error('Customer ID must be a non-empty string (positional arg or --id)')+ result = await trackApi('POST', `/customers/${encodeURIComponent(customerId)}/${sub}`)+ break+ }case 'track-event': {const customerId = rest[0] || args.idif (!customerId) { result = { error: 'Customer ID required (positional arg or --id)' }; break }@@ -128,7 +135,7 @@ async function main() {break}default:- result = { error: 'Unknown customers subcommand. Use: identify, get, delete, track-event' }+ result = { error: 'Unknown customers subcommand. Use: identify, get, delete, suppress, unsuppress, track-event' }}break@@ -190,7 +197,7 @@ async function main() {result = {error: 'Unknown command',usage: {- customers: 'customers [identify|get|delete|track-event] <customer_id> [--email <email>] [--first-name <name>] [--plan <plan>] [--data <json>] [--name <event>]',+ customers: 'customers [identify|get|delete|suppress|unsuppress|track-event] <customer_id> [--email <email>] [--first-name <name>] [--plan <plan>] [--data <json>] [--name <event>]',campaigns: 'campaigns [list|get|metrics|trigger] [campaign_id] [--emails <e1,e2>] [--ids <id1,id2>] [--data <json>]',send: 'send email --message-id <id> --to <email> [--identifier-id <id>] [--identifier-email <email>] [--data <json>]',}diff --git a/tools/integrations/customer-io.md b/tools/integrations/customer-io.mdindex febf32d..6d6d09f 100644--- a/tools/integrations/customer-io.md+++ b/tools/integrations/customer-io.md@@ -185,3 +185,24 @@ _cio.page();- emails- onboarding- analytics++## Suppression lifecycle++For an explicit erasure/suppression request, `customers suppress` invokes the+Track API operation that permanently deletes the profile and blocks its+identifier from being re-added. This is different from the existing+`customers delete` operation. Preview the request first:++```bash+node tools/clis/customer-io.js customers suppress --id customer-123 --dry-run+node tools/clis/customer-io.js customers unsuppress --id customer-123 --dry-run+```++Both commands require the Track API Site ID and API key. Unsuppressing only+releases the identifier; it does not recreate the deleted profile or restore+history. For ordinary message preferences while keeping a profile, update its+`unsubscribed` attribute instead. Use the operation appropriate to the person's+request and your workspace identifier configuration. See the official+[suppress](https://docs.customer.io/integrations/api/track/tag/track-customers/suppress/)+and [unsuppress](https://docs.customer.io/integrations/api/track/tag/track-customers/unsuppress/)+contracts. Neither operation is a substitute for handling data in other systems.