Skip to content

feat: iterable audience implementation - #5230

Merged
am6010 merged 22 commits into
developfrom
feat.iterable_audience
Jun 4, 2026
Merged

am6010 merged 22 commits into
developfrom
feat.iterable_audience

Conversation

@am6010

@am6010 am6010 commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the iterable_audience destination — a VDM Next audience integration that pushes users to Iterable lists via the lists/subscribe and lists/unsubscribe APIs. Built on the native BatchDestination framework so per-event transforms are auto-grouped, chunked at
Iterable's 1,000-record limit, and dispatched as a single batched proxy request.

Key Changes

  • v0 router transform (src/v0/destinations/iterable_audience/): IterableAudienceIntegration extends BatchDestination, validates project type (email-based / userId-based / hybrid) against the connection's identifierMappings at construction, and selects
    the correct subscriber identifier per row. Subscribe/unsubscribe routing comes from the record action (insert/update → subscribe, delete → unsubscribe).
  • v1 delivery layer (src/v1/destinations/iterable_audience/): AudienceListStrategy extends the shared Iterable BaseStrategy and overrides per-subscriber error classification — GDPR-forgotten identifiers return 200 + metric (never retried), notFound on
    unsubscribe is a no-op success, everything else delegates to the shared abortability checker. handleError sets AuthErrorCategory: 'AUTH' on 401 so the platform can flag the destination.
  • Registration: added to features.ts#supportedSourceTypes and batchedDestinationsMap.ts so the router uses the batching framework path.
  • Endpoint reuse: getSubscribeEndpoint / getUnsubscribeEndpoint delegate to the existing iterable destination's constructEndpoint, translating the UX-facing US/EU data-center labels into Iterable's internal USDC/EUDC keys.
  • Tests: unit tests for routerTransform, utils, and networkHandler strategies; integration fixtures under test/integrations/destinations/iterable_audience/.
  • Knowledge base: doc/loom/knowledge/*.md documents architecture, conventions, patterns, mistakes, and known concerns for future work on this destination.

Things to Note

  • Header-only auth: Api-Key is sent as a header, never as a query-string parameter. Iterable applies stricter rate limits to query-string auth — flagged in conventions.md.
  • GDPR identifiers are never tagged: the iterable_forgotten_user_violations metric tags identifierType (email/userId) only, never the value.
  • MAX_BATCH_SIZE = 1000 comes from Iterable's documented per-request maximum but has not been verified against the live API (see concerns.md).
  • Auto-disable on persistent 401 is out of M1 scope — only the AuthErrorCategory: 'AUTH' signal is emitted; platform-side handling will land separately.
  • Knowledge files committed to repo: doc/loom/knowledge/ and the M1 plan under doc/plans/ are tracked deliberately so future iterations have ground truth; .prettierignore is updated to skip them.

am6010 added 11 commits May 22, 2026 21:59
Implements the BatchDestination-based router transform for the new
iterable_audience destination. Splits record events by action into
subscribe/unsubscribe endpoint groups, batches subscribers up to 1000
per request, and selects an Iterable identifier (email or userId) per
row based on the configured project type (email-based / userId-based /
hybrid). Cross-field validation between projectType and identifierMappings
runs at construction time and throws ConfigurationError.

- config: BASE_URL routing via constructEndpoint, MAX_BATCH_SIZE,
  ACTION_RECORD_MAP, PROJECT_TYPES
- types: Zod schemas for Account/Connection config, RecordMessage,
  IterableAudiencePayload and tagged-union IterableSubscriber
- utils: IDENTIFIER_FIELD_CONFIG (email lowercased+trimmed, userId
  case-preserved with whitespace rejection), remapToIterableFields,
  selectIdentifierForRow (hybrid prefers userId), buildSubscribeBody,
  buildUnsubscribeBody with explicit channelUnsubscribe: false,
  validateProjectTypeMappings
- routerTransform: IterableAudienceIntegration extends BatchDestination,
  ChunkBatchStrategy per endpoint with listId+branch captured in closure
- tests: 47 cases covering identifier remap, normalize/validate, project-
  type-vs-mappings, batch overflow, mixed actions, datacenter routing
Implements the v1 networkHandler and AudienceListStrategy for parsing
Iterable's list subscribe/unsubscribe responses into per-jobId statuses.
Reuses the existing iterable destination's BaseStrategy and
createBatchErrorChecker (O(1) lookup over failedUpdates.* paths) and
adds audience-specific carve-outs:

- GDPR-forgotten users (forgottenEmails/forgottenUserIds) -> 200 with
  a counter metric tagged identifierType only, never the value itself.
- notFound on unsubscribe -> 200 (no-op success, user already off list);
  notFound on subscribe -> 400 via the shared checker.
- Email matching is case-insensitive (Iterable lowercases server-side);
  userId matching is case-sensitive.

handleError throws TransformerProxyError with every metadata entry at
the same status and AuthErrorCategory: AUTH on 401.

- types: IterableAudienceProxyInput, IterableAudienceRequestBody,
  IterableSubscriber tagged union
- strategies/audience-list: AudienceListStrategy extends BaseStrategy
  from existing iterable/strategies/base
- networkHandler: thin mixin (prepareProxy, proxy, processAxiosResponse,
  responseHandler -> AudienceListStrategy.handleResponse)
- tests: 22 cases covering forgotten/invalid/conflict/notFound paths,
  case-folding semantics, mixed batches, and 401/404/429/500 error paths
…t fixtures

Adds ITERABLE_AUDIENCE: true to the batched destinations map so the
BatchDestination loader instantiates IterableAudienceIntegration via
the new path. Without this entry the destination would silently fall
back to the legacy router pipeline and the BatchDestination class
would never be constructed.

Adds data-driven router integration fixtures under
test/integrations/destinations/iterable_audience/:
- common.ts: shared destination/connection configs for email-based,
  userId-based, hybrid, and EU datacenter variants
- maskedSecrets.ts: test-only API key
- router/data.ts: 6 RouterTestData cases covering email-based and
  userId-based subscribe/unsubscribe batching, hybrid identifier
  selection (userId preferred when both columns present), EU
  datacenter routing, per-row missing identifier returning 400 while
  valid rows batch, and schema validation errors
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
@coderabbitai

coderabbitai Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "auto_resolve_threads"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

This PR implements the iterable_audience destination integration for the Rudder transformer, enabling batched list management operations. The implementation spans v0 router transformation for event validation and request construction, v1 delivery handling for response processing, feature flags for GA activation, comprehensive unit and integration tests, and test fixtures supporting multiple project type and datacenter configurations.

Changes

Iterable Audience Destination Transformer

Layer / File(s) Summary
Batching framework feature enablement and formatting
src/constants/batchedDestinationsMap.ts, src/features.ts, .prettierignore
ITERABLE_AUDIENCE is added to the batching destinations map and routerTransform feature config, enabling the batching framework for this destination. Prettier formatting is excluded for the .claude/ directory.
V0 router contracts and destination configuration
src/v0/destinations/iterable_audience/config.ts, src/v0/destinations/iterable_audience/types.ts
Destination constants export type, datacenters (US/EU), endpoint builders with datacenter translation (USDC/EUDC), action mapping (INSERT/UPDATE → subscribe, DELETE → unsubscribe), and batch sizing (1000). Account config schema requires apiKey, dataCenter, and projectType; connection config requires audienceId, identifier mappings, and optional updateExistingUsersOnly. Router input schema enforces record type with INSERT/UPDATE/DELETE actions and optional identifiers. Subscriber payload requires at least one identifier field (email or userId, supporting both for hybrid projects).
V0 identifier normalization and request builders
src/v0/destinations/iterable_audience/utils.ts
IDENTIFIER_FIELD_CONFIG defines email normalization (trim + lowercase) with email validation, and userId normalization (case-preserved) rejecting whitespace. selectIdentifierForRow implements project-type-aware identifier selection, preferring userId in hybrid mode and throwing InstrumentationError when required identifiers are absent. buildSubscribeBody and buildUnsubscribeBody construct Iterable API payloads, with updateExistingUsersOnly conditionally included on subscribe and channelUnsubscribe always set to false on unsubscribe.
V0 router transformation implementation
src/v0/destinations/iterable_audience/routerTransform.ts
IterableAudienceIntegration constructor precomputes connection-level JSON headers with Api-Key. transformEvent maps action to subscribe/unsubscribe, normalizes and validates identifiers via processAudienceRecord, derives subscriber from projectType, and selects the endpoint by dataCenter, returning a POST request. getBatchStrategy coerces audienceId to a number, determines action from endpoint suffix, wraps event bodies into Iterable subscribe/unsubscribe payloads, and enforces MAX_BATCH_SIZE (1000).
V1 delivery response handling and network wiring
src/v1/destinations/iterable_audience/types.ts, src/v1/destinations/iterable_audience/networkHandler.ts, src/v1/destinations/iterable_audience/strategies/audience-list.ts
Proxy input types model the typed request body (listId, subscribers, channelUnsubscribe). networkHandler instantiates AudienceListStrategy and wires network adapters. AudienceListStrategy.handleSuccess matches subscribers against forgotten/not-found identifier sets from failedUpdates, emitting iterable_forgotten_user_violations metrics and returning success for GDPR-forgotten and unsubscribe not-found cases; other cases are checked via BatchErrorChecker for abortability. handleError normalizes error messages into per-job entries and throws TransformerProxyError with dynamic error typing.
Unit tests for router transformation and utilities
src/v0/destinations/iterable_audience/__tests__/routerTransform.test.ts, src/v0/destinations/iterable_audience/__tests__/utils.test.ts
Tests validate email/userId normalization and validation, identifier selection across EMAIL_BASED/USERID_BASED/HYBRID types with hybrid precedence, request body builders (conditional updateExistingUsersOnly on subscribe, always channelUnsubscribe:false on unsubscribe), end-to-end router transformation for insert/update/delete actions, batching with chunking by MAX_BATCH_SIZE, subscription/unsubscribe batch separation, per-row validation errors controlled via environment variables, identifier/project-type mismatch detection, EU endpoint routing, header derivation, and email lowercasing.
Integration test fixtures and end-to-end scenarios
test/integrations/destinations/iterable_audience/common.ts, test/integrations/destinations/iterable_audience/maskedSecrets.ts, test/integrations/destinations/iterable_audience/router/data.ts
Test helpers export destination type, email-based/userId-based/hybrid/EU connection variants with identifier mappings, endpoint URLs, request headers (Api-Key and Content-Type), and instrumentation stat tags. Six router scenarios validate batched subscribe/unsubscribe with updateExistingUsersOnly propagation, userId and email identifier handling, hybrid identifier preference (userId over email), EU datacenter routing, missing mapped identifier error handling, and schema validation failures (invalid action and event type).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • krishna2020
  • ItsSudip
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is comprehensive and well-structured. It includes a clear summary of changes, key implementation details across v0 and v1 layers, registration points, test coverage, and important implementation notes. However, it is missing the required template sections: explicit Linear task reference (Resolves INT-XXX), developer/reviewer checklists, and structured sections for dependencies and utility changes. Ensure the PR description follows the required template by adding: (1) Linear task reference under 'What is the related Linear task?', (2) new dependencies section, (3) new utilities section, (4) developer and reviewer checklists, or confirm the template is optional for this repository.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat: iterable audience implementation' directly describes the main change—adding a new Iterable Audience destination integration. It is concise, specific, and clearly conveys the primary purpose of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat.iterable_audience

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented May 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.15951% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.52%. Comparing base (498793d) to head (5a2611f).

Files with missing lines Patch % Lines
.../destinations/iterable_audience/routerTransform.ts 93.47% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5230      +/-   ##
===========================================
+ Coverage    92.49%   92.52%   +0.02%     
===========================================
  Files          681      687       +6     
  Lines        37355    37518     +163     
  Branches      8722     8794      +72     
===========================================
+ Hits         34552    34712     +160     
+ Misses        2586     2571      -15     
- Partials       217      235      +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@am6010 am6010 changed the title Feat.iterable_audience feat: iterable audience implementation May 26, 2026
am6010 added 2 commits May 26, 2026 19:10
Fixes CI format check (`prettier --check .`) that was failing on
doc/plans/DONE-PLAN-iterable-audience-m1.md.
@am6010
am6010 marked this pull request as ready for review May 28, 2026 13:09
@am6010
am6010 requested review from a team as code owners May 28, 2026 13:09
@am6010
am6010 requested review from ItsSudip and shekhar-rudder May 28, 2026 13:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/integrations/destinations/iterable_audience/maskedSecrets.ts (1)

1-4: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Use the required integration-test mocks.ts structure for masked credentials.

Please fold this helper into the destination’s mocks.ts (or rename accordingly) to match the mandated integration folder layout.

As per coding guidelines "test/integrations/destinations/**: Structure integration test sub-folders with processor/, router/, dataDelivery/, network.ts, and mocks.ts".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/integrations/destinations/iterable_audience/maskedSecrets.ts` around
lines 1 - 4, The masked apiKey constant in maskedSecrets.ts should be moved into
the destination's integration-test mocks.ts to match the required folder layout:
create or update mocks.ts to export the same symbol (export const apiKey =
'****-test-iterable-api-key';), remove or delete maskedSecrets.ts, and update
any imports that reference maskedSecrets.ts to import { apiKey } from './mocks';
ensure the exported name remains unchanged so tests continue to consume the
masked credential.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@doc/loom/knowledge/architecture.md`:
- Around line 21-34: The fenced code block in doc/loom/knowledge/architecture.md
containing the "rudder-server router" / "rudder-server proxy" diagram is missing
a fence language and triggers MD040; update the opening triple-backtick to
include a language (e.g., ```text) so the block becomes fenced as text, leaving
the contents unchanged (refer to the block that begins with "rudder-server
router" and ends after "per-jobId statusCodes returned").

In `@doc/loom/knowledge/entry-points.md`:
- Around line 105-116: The fenced code block containing the directory listing
for src/v0/destinations/iterable_audience/ and
src/v1/destinations/iterable_audience/ needs a language specified to satisfy
MD040; update the code fence around that block to include a language label
(e.g., "text") so the block becomes ```text ... ```, leaving the content
unchanged; this affects the fenced block that documents files like config.ts,
types.ts, utils.ts, routerTransform.ts, networkHandler.ts and
strategies/audience-list.ts.

In `@doc/loom/knowledge/stack.md`:
- Around line 11-13: The doc currently contradicts itself by saying "Package
manager: `bun` (NEVER npm/yarn)" while later referencing `npm test` and other
npm commands; update the document for consistency by choosing one
package-manager approach: if you standardize on bun, replace all npm/yarn
command mentions (e.g., `npm test`, `npm install`, `npm run ...`) with their bun
equivalents (`bun test`, `bun install`/`bun add`, `bun run ...`) and soften the
absolute ban wording (change "NEVER npm/yarn" to a recommendation like "prefer
bun; npm/yarn not recommended") so the guidance is consistent across the
"Package manager: `bun`" line and the occurrences around the original `npm test`
and the references at lines ~55-56.

In `@doc/plans/DONE-PLAN-iterable-audience-m1.md`:
- Around line 436-453: Update the plan to require the full destination test
folder structure instead of only router/data.ts: add a mandate that generated
tests create the processor/, router/, dataDelivery/ subfolders plus network.ts
and mocks.ts for each destination integration; ensure the
batchedDestinationsMap.ts change still includes ITERABLE_AUDIENCE: true for the
destination and keep the original guidance to add data-driven router integration
cases covering subscribe/unsubscribe (verify unsubscribe body has
channelUnsubscribe: false and subscribe body omits it).
- Around line 50-55: The plan places unit tests under __tests__/ directories
which violates the repo co-location rule; move the tests referenced (e.g.,
src/v0/destinations/iterable_audience/__tests__/routerTransform.test.ts and
utils.test.ts and
src/v1/destinations/iterable_audience/__tests__/networkHandler.test.ts) so each
*.test.ts file is adjacent to its implementation (e.g., routerTransform.test.ts
next to routerTransform.ts, utils.test.ts next to utils.ts,
networkHandler.test.ts next to networkHandler.ts), and update any references in
the plan and test manifests (lines noted around 222-224 and 359) to the new
co-located paths.

In `@src/v0/destinations/iterable_audience/__tests__/routerTransform.test.ts`:
- Line 1: The test file
src/v0/destinations/iterable_audience/__tests__/routerTransform.test.ts should
be moved to sit next to the source module as
src/v0/destinations/iterable_audience/routerTransform.test.ts to follow the
co-located *.test.ts convention; relocate the file, update any relative imports
inside the test (e.g., imports referencing routerTransform or other symbols) to
the new relative path, and remove the __tests__ directory entry if empty so the
test runner picks up the co-located test.

In `@src/v0/destinations/iterable_audience/__tests__/utils.test.ts`:
- Line 1: Test file is misplaced under __tests__; move
src/v0/destinations/iterable_audience/__tests__/utils.test.ts so it is
co-located with the source file as
src/v0/destinations/iterable_audience/utils.test.ts, update any relative imports
in the test to import from ./utils (or appropriate relative path to utils.ts),
and ensure the test filename remains utils.test.ts so the existing Jest/ts-jest
config discovers it automatically.

In `@src/v1/destinations/iterable_audience/__tests__/networkHandler.test.ts`:
- Line 1: Move the test file networkHandler.test.ts out of the __tests__ folder
and co-locate it next to the implementation (the strategy/network handler source
files) so it follows the "*.test.ts" convention; update any relative import
paths in the test to point to the local files (e.g., imports referencing the
network handler or strategy modules such as networkHandler,
IterableAudienceStrategy, or the module that uses ../../../../util/stats) and
adjust jest.mock paths if necessary so they resolve from the new location;
ensure test runner still discovers it and run tests to verify imports/mocks are
correct.

---

Outside diff comments:
In `@test/integrations/destinations/iterable_audience/maskedSecrets.ts`:
- Around line 1-4: The masked apiKey constant in maskedSecrets.ts should be
moved into the destination's integration-test mocks.ts to match the required
folder layout: create or update mocks.ts to export the same symbol (export const
apiKey = '****-test-iterable-api-key';), remove or delete maskedSecrets.ts, and
update any imports that reference maskedSecrets.ts to import { apiKey } from
'./mocks'; ensure the exported name remains unchanged so tests continue to
consume the masked credential.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1b6e7816-81ab-46d2-890f-7372c48b91e9

📥 Commits

Reviewing files that changed from the base of the PR and between 4b43422 and 9eb0d33.

📒 Files selected for processing (24)
  • .prettierignore
  • doc/loom/knowledge/architecture.md
  • doc/loom/knowledge/concerns.md
  • doc/loom/knowledge/conventions.md
  • doc/loom/knowledge/entry-points.md
  • doc/loom/knowledge/mistakes.md
  • doc/loom/knowledge/patterns.md
  • doc/loom/knowledge/stack.md
  • doc/plans/DONE-PLAN-iterable-audience-m1.md
  • src/constants/batchedDestinationsMap.ts
  • src/features.ts
  • src/v0/destinations/iterable_audience/__tests__/routerTransform.test.ts
  • src/v0/destinations/iterable_audience/__tests__/utils.test.ts
  • src/v0/destinations/iterable_audience/config.ts
  • src/v0/destinations/iterable_audience/routerTransform.ts
  • src/v0/destinations/iterable_audience/types.ts
  • src/v0/destinations/iterable_audience/utils.ts
  • src/v1/destinations/iterable_audience/__tests__/networkHandler.test.ts
  • src/v1/destinations/iterable_audience/networkHandler.ts
  • src/v1/destinations/iterable_audience/strategies/audience-list.ts
  • src/v1/destinations/iterable_audience/types.ts
  • test/integrations/destinations/iterable_audience/common.ts
  • test/integrations/destinations/iterable_audience/maskedSecrets.ts
  • test/integrations/destinations/iterable_audience/router/data.ts

Comment thread doc/loom/knowledge/architecture.md Resolved
Comment thread doc/loom/knowledge/entry-points.md Resolved
Comment thread doc/loom/knowledge/stack.md Resolved
Comment thread doc/loom/knowledge/architecture.md Resolved
am6010 added 5 commits June 2, 2026 16:20
Add a behavior-focused README (project types, identifier selection, endpoints, error handling) and drop the internal M1 plan doc from the PR.
…entifiers directly

- Hybrid projects now send both email and userId when a row has both (was userId-only); widen IterableSubscriber accordingly.
- Read email/userId straight from message.identifiers (rudder-sources maps upstream); drop extractIterableIdentifiers and validateProjectTypeMappings — a mismatched identifier is now a per-row 400.
- Keep identifierMappings in the connection schema as documented (unused) metadata.
Cover direct identifier extraction, the per-row 400 on project-type mismatch, and hybrid sending both identifiers.
…ither identifier

- 401 no longer sets AuthErrorCategory 'AUTH' — Iterable uses Api-Key header auth, not OAuth.
- handleSuccess matching now handles subscribers carrying both email and userId (forgotten/notFound match on either field).
…livery

- Relocate v1 response-handler coverage from the co-located unit test into the component suite (network mocks + dataDelivery scenarios), adding dual-identifier and invalidData cases.
- Update router fixtures for direct identifier reading and hybrid both-identifier output.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/v1/destinations/iterable_audience/strategies/audience-list.ts (1)

82-98: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

identifierType metric tag can be mislabeled for hybrid subscribers.

identifierType is derived solely from the presence of subscriber.email, so any hybrid subscriber (carrying both email and userId) is always tagged as 'email'. When such a subscriber matches forgottenLookups only on its userId (email not forgotten), the iterable_forgotten_user_violations metric records identifierType: 'email', skewing GDPR-violation observability. Consider deriving the tag from the identifier that actually matched.

📊 Proposed fix to label the matched identifier
-      const identifierType: 'email' | 'userId' = subscriber.email ? 'email' : 'userId';
       const eventForCheck = {
         email: subscriber.email ? subscriber.email.toLowerCase() : undefined,
         userId: subscriber.userId,
       };

       // 1. GDPR-forgotten user → success + metric.
       if (matchesIdentifier(subscriber, forgottenLookups)) {
+        const emailForgotten =
+          !!subscriber.email && forgottenLookups.emails.has(subscriber.email.toLowerCase());
+        const identifierType: 'email' | 'userId' = emailForgotten ? 'email' : 'userId';
         stats.counter('iterable_forgotten_user_violations', 1, {
           destType: DEST_TYPE,
           destinationId,
           workspaceId,
           identifierType,
           // NEVER tag the identifier VALUE — it is GDPR-protected.
         });
         return { statusCode: 200, metadata, error: SUCCESS };
       }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/v1/destinations/iterable_audience/strategies/audience-list.ts` around
lines 82 - 98, The metric tag identifierType is currently set from
subscriber.email and mislabels hybrid subscribers; change it to reflect the
identifier that actually matched forgottenLookups by computing the matched
identifier before logging: use the same matching logic (matchesIdentifier or
explicit checks against forgottenLookups using eventForCheck.email and
eventForCheck.userId) to set matchedIdentifier = 'email' or 'userId' (or
undefined if none) and pass that matchedIdentifier to stats.counter for
iterable_forgotten_user_violations; update the return path that logs
GDPR-forgotten violations to use this matchedIdentifier instead of the original
identifierType.
🧹 Nitpick comments (1)
src/v0/destinations/iterable_audience/utils.ts (1)

9-11: ⚡ Quick win

Stale reference to a removed helper in the doc comment.

This comment refers to remapToIterableFields, which was removed in this PR. Identifiers now flow directly through processAudienceRecord, so the comment may mislead future maintainers. Consider updating it to describe the current keying source (rudder-sources resolving the mapping upstream).

📝 Suggested wording tweak
-// `processAudienceRecord` consumes this map keyed by the same names returned by
-// `remapToIterableFields`. Every field is `HashingType.NONE` because Iterable's
-// list API does not accept hashed identifiers.
+// `processAudienceRecord` consumes this map keyed by the Iterable field names
+// (`email` / `userId`) that rudder-sources resolves upstream. Every field is
+// `HashingType.NONE` because Iterable's list API does not accept hashed identifiers.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/v0/destinations/iterable_audience/utils.ts` around lines 9 - 11, Update
the doc comment above the map consumed by processAudienceRecord to remove the
stale reference to remapToIterableFields and instead state that keys are the raw
identifiers passed into processAudienceRecord (not hashed — HashingType.NONE)
because mapping is resolved upstream by rudder-sources; keep the note that
Iterable's list API does not accept hashed identifiers and clarify the current
source of the keys.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/v1/destinations/iterable_audience/strategies/audience-list.ts`:
- Around line 82-98: The metric tag identifierType is currently set from
subscriber.email and mislabels hybrid subscribers; change it to reflect the
identifier that actually matched forgottenLookups by computing the matched
identifier before logging: use the same matching logic (matchesIdentifier or
explicit checks against forgottenLookups using eventForCheck.email and
eventForCheck.userId) to set matchedIdentifier = 'email' or 'userId' (or
undefined if none) and pass that matchedIdentifier to stats.counter for
iterable_forgotten_user_violations; update the return path that logs
GDPR-forgotten violations to use this matchedIdentifier instead of the original
identifierType.

---

Nitpick comments:
In `@src/v0/destinations/iterable_audience/utils.ts`:
- Around line 9-11: Update the doc comment above the map consumed by
processAudienceRecord to remove the stale reference to remapToIterableFields and
instead state that keys are the raw identifiers passed into
processAudienceRecord (not hashed — HashingType.NONE) because mapping is
resolved upstream by rudder-sources; keep the note that Iterable's list API does
not accept hashed identifiers and clarify the current source of the keys.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3d541da2-7cdb-49eb-8667-81b2086fd440

📥 Commits

Reviewing files that changed from the base of the PR and between 9eb0d33 and 23eab41.

⛔ Files ignored due to path filters (4)
  • src/v0/destinations/iterable_audience/README.md is excluded by !**/*.md
  • test/integrations/destinations/iterable_audience/dataDelivery/data.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable_audience/dataDelivery/network.ts is excluded by !**/test/**
  • test/integrations/destinations/iterable_audience/router/data.ts is excluded by !**/test/**
📒 Files selected for processing (7)
  • src/v0/destinations/iterable_audience/__tests__/routerTransform.test.ts
  • src/v0/destinations/iterable_audience/__tests__/utils.test.ts
  • src/v0/destinations/iterable_audience/routerTransform.ts
  • src/v0/destinations/iterable_audience/types.ts
  • src/v0/destinations/iterable_audience/utils.ts
  • src/v1/destinations/iterable_audience/strategies/audience-list.ts
  • src/v1/destinations/iterable_audience/types.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/v0/destinations/iterable_audience/types.ts

am6010 added 2 commits June 2, 2026 17:32
…d AudienceField

Coerce email/userId to string in normalize and guard the validators to match the unknown-typed AudienceField from develop, restoring a clean tsc build.
@am6010
am6010 force-pushed the feat.iterable_audience branch from c0a1298 to 3aedea1 Compare June 2, 2026 15:13
@am6010
am6010 requested a review from krishna2020 June 3, 2026 07:24
Drop doc/loom/ knowledge base and its now-orphaned .prettierignore entry.
…ation config

Add IterableDestinationConfigSchema extending the account schema with a
`name` field and consume it as the BatchDestination destination-config
type, matching the <Dest>DestinationConfig naming convention used by the
other audience destinations. Addresses PR review feedback.
@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

@am6010
am6010 requested a review from krishna2020 June 4, 2026 08:50
@am6010
am6010 merged commit 9ecc8b6 into develop Jun 4, 2026
34 checks passed
@am6010
am6010 deleted the feat.iterable_audience branch June 4, 2026 09:01
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.

2 participants