From c99fd8c04e076a69093aa339d7205dd20e589152 Mon Sep 17 00:00:00 2001 From: sonpiaz Date: Thu, 15 Oct 2026 21:42:46 -0700 Subject: [PATCH 1/3] feat: init writes the program's partner link parameter to ref_param (0.4.4) The init response now carries link_param (via for new programs, aff for older ones); the CLI writes it as ref_param, with aff when an older server omits it. Setup notes name the parameter and say the tracker reads both aff and via. Co-Authored-By: Claude Opus 5.5 (1M context) --- node_modules | 1 + packages/cli/CHANGELOG.md | 3 +++ packages/cli/package.json | 2 +- packages/cli/src/commands/init.ts | 7 ++++++- packages/cli/src/lib/config.ts | 2 +- packages/cli/src/types.ts | 2 ++ packages/cli/tests/init-ref-param.test.ts | 17 +++++++++++++++++ 7 files changed, 31 insertions(+), 3 deletions(-) create mode 120000 node_modules create mode 100644 packages/cli/tests/init-ref-param.test.ts diff --git a/node_modules b/node_modules new file mode 120000 index 0000000..02d9ad6 --- /dev/null +++ b/node_modules @@ -0,0 +1 @@ +../../node_modules \ No newline at end of file diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 85258ff..909139f 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog — affitor (CLI) +## 0.4.4 +- `affitor init` writes the program's partner link parameter to `ref_param` (`via` for programs created from now on, `aff` for older ones), from the server's answer. An older server without that field still gives `aff`. The setup notes say which parameter partner links use; the tracker reads both `?aff=` and `?via=`. + ## 0.4.3 - `affitor setup stripe` now points to the dashboard (program Settings, Connect Stripe) and exits 1 (`{"error": "stripe_setup_moved"}` with `--json`). The old flow could not complete: its token exchange needed Affitor's platform secret, the API that saved the connection is retired (410), and the webhook it created pointed at a URL the API does not serve. It no longer creates anything on your Stripe account. The unused `stripe` dependency is removed. diff --git a/packages/cli/package.json b/packages/cli/package.json index e5b2770..d6b6b76 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "affitor", - "version": "0.4.3", + "version": "0.4.4", "description": "CLI-native affiliate tracking. Connect Stripe, track commissions, manage partners — all from your terminal.", "type": "module", "bin": { diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index 39a72db..496f786 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -203,7 +203,7 @@ export async function runInit( name: "_aff", duration_days: cookieDuration, }, - ref_param: "aff", + ref_param: refParamFrom(response), api_url: apiUrl, created_at: new Date().toISOString(), }; @@ -307,3 +307,8 @@ function formatCommission( } return `${value} per sale`; } + +/** The program's partner-code parameter from the init response; aff when an older server omits it. */ +export function refParamFrom(response: { link_param?: string }): string { + return response.link_param === "via" || response.link_param === "aff" ? response.link_param : "aff"; +} diff --git a/packages/cli/src/lib/config.ts b/packages/cli/src/lib/config.ts index a876802..7370737 100644 --- a/packages/cli/src/lib/config.ts +++ b/packages/cli/src/lib/config.ts @@ -326,7 +326,7 @@ This project uses Affitor for affiliate/partner tracking. Affitor tracks clicks, ### 1. Click Tracking -Add this script tag to every page in \`\`. It auto-detects affiliate visits via \`?aff=\` parameter and stores a first-party cookie. +Add this script tag to every page in \`\`. It auto-detects affiliate visits via \`?${config.ref_param}=\` (it also reads \`?aff=\` and \`?via=\`) and stores a first-party cookie. \`\`\`html