Skip to content

STRATCONN-6832 - [MNTN] - New audience destination#3809

Open
joe-ayoub-segment wants to merge 6 commits into
mainfrom
mntn-audiences
Open

STRATCONN-6832 - [MNTN] - New audience destination#3809
joe-ayoub-segment wants to merge 6 commits into
mainfrom
mntn-audiences

Conversation

@joe-ayoub-segment

@joe-ayoub-segment joe-ayoub-segment commented May 22, 2026

Copy link
Copy Markdown
Contributor

New Audience destination for MNTN

Testing

Unit tests added.
Testing will be done in private beta

Original Partner PR here: #3796

Partner testing.
image

Security Review

Please ensure sensitive data is properly protected in your integration.

  • Reviewed all field definitions for sensitive data (API keys, tokens, passwords, client secrets) and confirmed they use type: 'password'

New Destination Checklist

  • Extracted all action API versions to verioning-info.ts file. example

Copilot AI 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.

Pull request overview

Adds a new cloud-mode Audience Destination for MNTN Audiences to support Segment Engage audience syncing (adds/removes), including destination-level audience creation/lookup and unit tests.

Changes:

  • Introduces the mntn-audiences destination definition with custom auth, request extension, and audience lifecycle methods (testAuthentication, createAudience, getAudience).
  • Implements the syncAudience action with identity construction (email/phone normalization + hashing), add/remove routing, and batch support via MultiStatusResponse.
  • Adds unit tests covering destination audience lifecycle and sync behavior (single + batch, normalization, duplicate detection).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/destination-actions/src/destinations/mntn-audiences/index.ts Defines the MNTN Audiences destination, auth fields, request headers, audience config, and actions.
packages/destination-actions/src/destinations/mntn-audiences/constants.ts Adds the MNTN API base URL constant (and a good place to centralize API versioning).
packages/destination-actions/src/destinations/mntn-audiences/functions.ts Implements testAuthentication, createAudience, and getAudience helpers.
packages/destination-actions/src/destinations/mntn-audiences/types.ts Adds destination-level helper input/response TypeScript types.
packages/destination-actions/src/destinations/mntn-audiences/generated-types.ts Generated Settings/AudienceSettings types for the destination.
packages/destination-actions/src/destinations/mntn-audiences/syncAudience/index.ts Defines the Sync Audience action fields, defaults, and perform/performBatch wiring.
packages/destination-actions/src/destinations/mntn-audiences/syncAudience/functions.ts Core sync logic: build identity payloads, route adds/removes, handle batching and per-index errors.
packages/destination-actions/src/destinations/mntn-audiences/syncAudience/types.ts Adds types for identity payloads and internal batching bookkeeping.
packages/destination-actions/src/destinations/mntn-audiences/syncAudience/generated-types.ts Generated action payload type for Sync Audience.
packages/destination-actions/src/destinations/mntn-audiences/tests/destination.test.ts Unit tests for auth + audience lifecycle methods.
packages/destination-actions/src/destinations/mntn-audiences/tests/syncAudience.test.ts Unit tests for sync behavior (add/remove, batch, normalization, duplicate handling, error paths).
Comments suppressed due to low confidence (1)

packages/destination-actions/src/destinations/mntn-audiences/syncAudience/functions.ts:98

  • Batch add/remove routing uses a truthy check (if (audienceMemberships[index]) ... else ...). If audienceMemberships[index] is undefined (missing membership info), this will be treated as a removal and send a DELETE. Handle membership explicitly (=== true for add, === false for remove) and mark undefined as a validation error (for batch: set an error response at that index; for non-batch: throw a PayloadValidationError).
    const identity = buildIdentity(p)
    if (audienceMemberships[index]) {
      adds.push({ index, p, identity })
    } else {
      removes.push({ index, p, identity })
    }

joe-ayoub-segment and others added 2 commits May 25, 2026 09:02
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 25, 2026 08:07

Copilot AI 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.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Comment thread packages/destination-actions/src/destinations/mntn-audiences/index.ts Outdated
@joe-ayoub-segment

Copy link
Copy Markdown
Contributor Author

Hi @valerie-mntn,

Please review the code in this PR. Some important changes.

  1. I removed advertiser_id as it wasn't being used anywhere in the code.
  2. I updated the comment on phone and email to say that both text and hashed versions are sent (as this is what your original code was doing).

Best regards,
Joe

@valerie-mntn

Copy link
Copy Markdown

Hi @joe-ayoub-segment apologies for the delay as it was a US holiday today. ACK on the changes you made (advertiser_id not needed in the code and phone & email hashed and un-hashed versions accepted).

Regarding this comment:
The IP default mapping ignores the canonical Segment location $.context.ip (it only checks $.traits.ip and $.properties.ip). As a result, the default mapping will miss IPs for most events. Update the default to read from $.context.ip (optionally falling back to traits/properties if needed).

I think the correct default for IP should be $.context.ip, which is where Segment automatically captures the user's IP address. Can you confirm please? I believe this is correct in the original submission as $.traits.ip would almost always be empty since customers don't typically set IP manually in traits.

Thank you

@joe-ayoub-segment

Copy link
Copy Markdown
Contributor Author

Hi @joe-ayoub-segment apologies for the delay as it was a US holiday today. ACK on the changes you made (advertiser_id not needed in the code and phone & email hashed and un-hashed versions accepted).

Regarding this comment: The IP default mapping ignores the canonical Segment location $.context.ip (it only checks $.traits.ip and $.properties.ip). As a result, the default mapping will miss IPs for most events. Update the default to read from $.context.ip (optionally falling back to traits/properties if needed).

I think the correct default for IP should be . c o n t e x t . i p , w h i c h i s w h e r e S e g m e n t a u t o m a t i c a l l y c a p t u r e s t h e u s e r ′ s I P a d d r e s s . C a n y o u c o n f i r m p l e a s e ? I b e l i e v e t h i s i s c o r r e c t i n t h e o r i g i n a l s u b m i s s i o n a s .traits.ip would almost always be empty since customers don't typically set IP manually in traits.

Thank you

Thanks Valerie,

I changed the defaults for IP as context.ip is not the location where these values will be when when a user is added or removed from an Audience. context.ip is just for events coming in to Segment from various source platforms.

If you are happy with the code then I will label it for deploy.
Did you get a chance to run it locally and test it?

@valerie-mntn

Copy link
Copy Markdown

got it, thanks @joe-ayoub-segment. We are running into issues testing our batch DELETE endpoint, so our team is currently looking into it. I hope to have an update for you some time tomorrow (Wednesday US timezone). Apologies for the delay!

@valerie-mntn

Copy link
Copy Markdown

Hi @joe-ayoub-segment , just a quick update from our side - we're making a fix to our batch delete API and it will be deployed on Monday. I was able to successfully run all other tests locally, so all good there. I'll send another update on Monday when I've tested the batch delete, and we should be good to go for you to deploy. Thanks for the patience!

@valerie-mntn

Copy link
Copy Markdown

hi @joe-ayoub-segment , batch delete was fixed on our end and I ran this code locally and all tests passed successfully. We can proceed with having you deploy our integration. please let us know of any next steps after deployment. thank you!

@joe-ayoub-segment

Copy link
Copy Markdown
Contributor Author

hi @joe-ayoub-segment , batch delete was fixed on our end and I ran this code locally and all tests passed successfully. We can proceed with having you deploy our integration. please let us know of any next steps after deployment. thank you!

Thanks for testing the integration @valerie-mntn . Glad the issue was caught before deploying the change.
Could you add some proof of tesitng to the PR please? As much as you can add (within reason) would be great.
Thank you so much,
Joe

@valerie-mntn

Copy link
Copy Markdown

Hi @joe-ayoub-segment , here is the output from running a live integration test script against the MNTN Audience API (all endpoints, real API key, no mocking):

── 1. testAuthentication ──────────────────────────────
✅ GET /audience/segments?limit=1 returns 2xx (got 200)
── 2. createAudience ──────────────────────────────────
✅ POST /audience/segments returns 201 (got 201)
✅ Response includes segment.id
✅ Response includes segment.name
ℹ️ Created segment ID: f1e2edac-7aa6-4fec-9e77-216aac7d875b
── 3. getAudience ─────────────────────────────────────
✅ GET /audience/segments/f1e2edac-7aa6-4fec-9e77-216aac7d875b returns 200 (got 200)
✅ Response segment.id matches created ID
── 4. syncAudience — add single identity ──────────────
✅ POST .../identities returns 202 (got 202)
── 5. syncAudience — batch add identities ─────────────
✅ POST .../identities with { identities: [...] } returns 202 (got 202)
── 6. syncAudience — remove single identity ───────────
✅ DELETE .../identities/test-user-1780369890864 returns 202 (got 202)
── 7. syncAudience — batch remove identities ──────────
✅ DELETE .../identities/{id1}%2C{id2} returns 202 (got 202)
── 8. Cleanup ─────────────────────────────────────────
✅ DELETE /audience/segments/f1e2edac-7aa6-4fec-9e77-216aac7d875b returns 200 (got 200)
──────────────────────────────────────────────────────
Results: 11 passed, 0 failed
Tests cover: testAuthentication, createAudience, getAudience, single add, batch add, single remove, and batch remove (including the previously failing batch DELETE which is now fixed on our API). Happy to share the test script if helpful.

@joe-ayoub-segment

Copy link
Copy Markdown
Contributor Author

Thanks @valerie-mntn . We're in a deploy freeze at the moment. But I'll deploy this code as soon as I can. I've labelled it for release - so nothing left to do until I deploy it.
Best regads,
Joe

@valerie-mntn

Copy link
Copy Markdown

Hi @joe-ayoub-segment , any new updates here? thanks so much

@joe-ayoub-segment

Copy link
Copy Markdown
Contributor Author

Not yet @valerie-mntn . There's a lot of changes which need to be shipped and this one is in the queue. I'm hopefully that it will happen this week, but I can't be sure.
I'll notify you here once I know more.
Best regards,
Joe

@valerie-mntn

Copy link
Copy Markdown

Hi @joe-ayoub-segment hope all is well. I just submitted our documentation PR here as well: segment-boneyard/segment-docs#8212

Just wanted to confirm that is the right place to submit for review since I noticed the repo is no longer maintained?

@joe-ayoub-segment

joe-ayoub-segment commented Jun 17, 2026 via email

Copy link
Copy Markdown
Contributor Author

@valerie-mntn

Copy link
Copy Markdown

Thanks @joe-ayoub-segment . Email is valerie@mountain.com

@valerie-mntn

Copy link
Copy Markdown

Thanks @joe-ayoub-segment , I'll work on that docs submission today. Any updates you can share about this specific deployment and when your deploy freeze would be lifted? Appreciate it!

Copilot AI 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.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

@valerie-mntn

Copy link
Copy Markdown

HI @joe-ayoub-segment - I noticed Copilot ran some automated checks/reviews on this PR. Do I need to take any action given your green light / go-ahead on my submission (and the updated changes per your comments) a few weeks ago? Please let me know - thanks

Defaulting audienceMembership to `[]` (and treating an undefined entry as
falsey) meant a missing membership classified an identity as a removal,
risking unintended DELETEs. syncAudience now requires an explicit boolean
per entry: `perform` throws a PayloadValidationError, and `performBatch`
marks the entry as a 400 in the MultiStatusResponse instead of deleting it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 7, 2026 15:47
@joe-ayoub-segment

Copy link
Copy Markdown
Contributor Author

HI @joe-ayoub-segment - I noticed Copilot ran some automated checks/reviews on this PR. Do I need to take any action given your green light / go-ahead on my submission (and the updated changes per your comments) a few weeks ago? Please let me know - thanks

Hi @valerie-mntn - thanks for pointing out. One of them was worth looking at. I pushed a commit.

Copilot AI 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.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants