Skip to content

[SDK-867] Send the proof through a triggered campaign with proof-push --campaign - #45

Open
franco-zalamena-iterable wants to merge 2 commits into
feature/SDK-867-campaign-consentfrom
feature/SDK-867-campaign-send
Open

franco-zalamena-iterable wants to merge 2 commits into
feature/SDK-867-campaign-consentfrom
feature/SDK-867-campaign-send

Conversation

@franco-zalamena-iterable

@franco-zalamena-iterable franco-zalamena-iterable commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

SDK-867

This PR adds proof-push --campaign, which sends the proof push through a triggered campaign in the developer's Iterable project so G17 has a real pushSend to match. It needs the agent approve campaign consent from #44, and without it the run stops before making any call to Iterable.

It picks a transactional push message type, since frequency caps, quiet hours and opt-outs on a marketing type can turn the proof into a pushSendSkip. If the project only has a marketing type the run stops with nothing created and asks the developer, and --message-type <id> opts in to that type. If the project doesn't let the API activate triggered campaigns, the run ends with the campaign's dashboard link and a proof-push --campaign command that resumes with the same campaign instead of creating another. The send uses recipientUserId for user ID identities and recipientEmail otherwise.

Only a successful send records ITBL_CAMPAIGN_ID for G17 and ITBL_PROOF_MARKER and ITBL_PROOF_SENT_AT for G16 and G17, the marker is carried in the push itself. A plain proof-push afterwards clears ITBL_CAMPAIGN_ID only if campaign mode set it, and warns when one set by the developer is left for G17 to gate on.

The proof campaign is never archived in the run that sends through it, because archiving a Running triggered campaign makes Iterable skip the queued send. The previous proof campaign is archived by the next --campaign run, and only after that run's own send succeeds, so a run that fails before sending leaves the last working campaign running. A failed archive is kept in ITBL_PROOF_CAMPAIGN_STALE and retried on the next run. --keep-campaign reuses the campaign and archives nothing.

The first commit, "Pull the proof send's shared steps into helpers", is a behaviour-neutral refactor of the template proof so campaign mode can reuse it, and it can be reviewed on its own.

This is the third part of SDK-867, after #43 (G17 matching) and #44 (campaign consent). It is stacked on #44 and will be retargeted to main after #44 merges. Plugin version is bumped to 26.11.5.

Type

  • Manual reference-content edit
  • Skill / pipeline / CI change

If this is a skill / pipeline / CI change

  • pnpm check:all green (not run locally, nothing under pipeline/ changed and the manifests are covered by tests/plugin-manifests.sh below)
  • If changing the schema or a validator, tested both the success and the failure case locally (n/a)
  • If changing SKILL.md, sanity-checked the routing table against that skill's reference/ (n/a)

Testing

tests/campaign-push.sh is new. It stubs curl and covers the consent check, the message type choice, activation disabled and resume, the recipientUserId target, what gets recorded for G16 and G17, the archive order and retries, --keep-campaign, and a 2xx with an HTML body on every call.

$ bash tests/campaign-push.sh
  PASS nothing is archived in the run that sends, so the queued push is not aborted
  PASS the next run sends through a new campaign, and only then archives the last run's
  PASS a userId identity is targeted with recipientUserId, not recipientEmail
  PASS only a marketing push type: stops with rc 10, nothing created, nothing sent
  PASS activation disabled: rc 10, and no send to a campaign that is not running
  PASS and ends with the dashboard link and the command that resumes
  PASS and the next run archives it along with the last run's campaign
56 PASS, 0 FAIL, exit 0

$ bash tests/approval-gate.sh
77 PASS, 0 FAIL, exit 0

$ bash tests/android-userid-proof.sh
13 PASS, 0 FAIL, exit 0

$ bash tests/plugin-manifests.sh
  PASS all three manifests name one version             26.11.5
10 PASS, 0 FAIL, exit 0

The last full bash tests/run-all.sh, before the final small fix, gave 51 suites ok and 0 failed. The new endpoint checks in tests/key-types-match-spec.sh were not run, since that suite needs the network.

Anything reviewers should know

Each run that creates a campaign also leaves a cloned template behind, and those accumulate until teardown cleans them up, which comes in a later PR. This hasn't been run against a live Iterable project yet, a live proof send is planned before release.

🤖 Generated with Claude Code

die, count_prior_proof, finish and upserted_id come out of the template
proof path so a second send mode can reuse them, and dash_host moves
from bin/iterable-keys to config.sh so proof-push can build dashboard
links. The template proof behaves exactly as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Campaign mode gives G17 a real pushSend to match. It refuses to touch
Iterable without the campaign approval, picks a transactional push
message type (and stops to ask when only a marketing one exists), and
ends with a dashboard link and a resume command when the project blocks
API activation.

The campaign id is recorded as ITBL_PROOF_CAMPAIGN_ID the moment
campaigns/create answers, so a resumed run looks that one campaign up
instead of listing the project's campaigns, which paginate. The send
targets recipientUserId or recipientEmail to match the identity, and
only a successful send records ITBL_CAMPAIGN_ID, ITBL_PROOF_MARKER and
ITBL_PROOF_SENT_AT.

Archiving a running campaign aborts the push it has queued, so a
campaign is never archived in the run that sends through it. The next
--campaign run archives the previous campaign if a push went through
it, but only after its own send, so a run whose new campaign cannot be
activated leaves the old one running. A campaign Iterable does not list
under success stays recorded in ITBL_PROOF_CAMPAIGN_STALE and is tried
again next run. A recorded campaign this project does not have, as
after a project switch, gets one line naming it. --keep-campaign
reuses the campaign instead.

A 2xx body that is not JSON stops the run with a clear error.
--message-type now applies to an existing base template too, and
itbl_err shows an error's message field. A template proof clears
ITBL_CAMPAIGN_ID only when campaign mode set it, and warns when one is
left for G17 to gate on.

Bumps the manifests to 26.11.5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant