Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
225 commits
Select commit Hold shift + click to select a range
81e4b17
Braze cloud mode -New merge users action
segment-voliveira Apr 15, 2026
9ea55a1
addressing issues raised by copilot
segment-voliveira Apr 15, 2026
538097d
addressing issues raised by copilot
segment-voliveira Apr 15, 2026
dd570f6
updating the new action as per review session with Rohan and Joe
joe-ayoub-segment Apr 21, 2026
599739a
changes to parameters
segment-voliveira Apr 22, 2026
a9e73d5
updating types
segment-voliveira Apr 22, 2026
983d641
New unit tests
segment-voliveira May 6, 2026
d816513
Merge branch 'main' into feat/braze-merge-users
joe-ayoub-segment May 6, 2026
9b0f722
fixing some issues and tests
joe-ayoub-segment May 7, 2026
361a7f3
adding batching
joe-ayoub-segment May 7, 2026
3e2e2f2
adding batch size field
joe-ayoub-segment May 7, 2026
0ecc645
batch tests added
joe-ayoub-segment May 7, 2026
686ecdc
copilot review changes
joe-ayoub-segment May 7, 2026
04fc1e6
fixing batch size
joe-ayoub-segment May 8, 2026
fd5f34e
remove prioritization if type is not phone or email
segment-voliveira May 8, 2026
affea50
[Google Enhanced Conversions] - Journeysv2 support
joe-ayoub-segment May 12, 2026
8fc2226
tweak
joe-ayoub-segment May 12, 2026
4a1395a
changes
joe-ayoub-segment May 12, 2026
a17ff73
changes
joe-ayoub-segment May 12, 2026
96439d2
code OK by Claude
joe-ayoub-segment May 12, 2026
774344d
adding tests
joe-ayoub-segment May 12, 2026
34f46ed
lint change
joe-ayoub-segment May 12, 2026
e3cb32b
tested all flows locally
joe-ayoub-segment May 13, 2026
71fb32c
adding unit tests
joe-ayoub-segment May 13, 2026
93461a4
addressing copilot comments
joe-ayoub-segment May 14, 2026
2141885
Facebook AppendValue support for custom and purchase events
joe-ayoub-segment May 14, 2026
8ef9e3f
adding additional validation
joe-ayoub-segment May 14, 2026
c33e505
adding beta labels for new fields
joe-ayoub-segment May 14, 2026
bca1b87
Adding ctwa_clid field to user_data
joe-ayoub-segment May 15, 2026
9f662f0
unit tests
joe-ayoub-segment May 15, 2026
c3f50c6
Potential fix for pull request finding
joe-ayoub-segment May 15, 2026
3403cbb
Potential fix for pull request finding
joe-ayoub-segment May 15, 2026
a9bd160
Potential fix for pull request finding
joe-ayoub-segment May 15, 2026
2e9d6d4
Potential fix for pull request finding
joe-ayoub-segment May 15, 2026
77572ee
Potential fix for pull request finding
joe-ayoub-segment May 15, 2026
41726ed
Potential fix for pull request finding
joe-ayoub-segment May 15, 2026
11afe23
Potential fix for pull request finding
joe-ayoub-segment May 15, 2026
50b29b1
copilot feedback changes
joe-ayoub-segment May 15, 2026
5e6be46
adding multistatusResponse support
joe-ayoub-segment May 15, 2026
24a74a3
adding multistatus unit tests
joe-ayoub-segment May 15, 2026
a07fa17
starting work on SHA256 support
joe-ayoub-segment May 20, 2026
41fbdda
configure hash type
joe-ayoub-segment May 20, 2026
4332176
letting all cols be hashed
joe-ayoub-segment May 20, 2026
0437e2a
adding validation
joe-ayoub-segment May 20, 2026
e4d2fc1
decompose validation
joe-ayoub-segment May 20, 2026
31fc13e
linting issues
joe-ayoub-segment May 20, 2026
1fd8ccb
unit tests
joe-ayoub-segment May 20, 2026
394c71a
adding flag in case feature needs to be disabled
joe-ayoub-segment May 20, 2026
41a5f84
copilot comments fixed
joe-ayoub-segment May 20, 2026
90ce507
copilot comment fix
joe-ayoub-segment May 20, 2026
f943395
STRATCONN-6824 - [Braze] - add ecommerce addtocart event
joe-ayoub-segment May 21, 2026
bca9f37
adding add to cart
joe-ayoub-segment May 21, 2026
4418b24
some fields not needed for refunds
joe-ayoub-segment May 21, 2026
bab79f2
adding type field for product viewed event
joe-ayoub-segment May 21, 2026
602dff7
unit tests
joe-ayoub-segment May 21, 2026
0827a38
making cart_id conditionally required
joe-ayoub-segment May 21, 2026
69f512a
adding presets
joe-ayoub-segment May 21, 2026
f18f2b6
STRATCONN-6789 - [LinkIn Conversions API] - new identifier suppport
joe-ayoub-segment May 22, 2026
217a5dd
removing default ip address mapping
joe-ayoub-segment May 22, 2026
2fff7f3
adding unit tests
joe-ayoub-segment May 22, 2026
cb08f62
fixing string trim bug with rokt capi
joe-ayoub-segment May 22, 2026
778280a
unit test
joe-ayoub-segment May 22, 2026
d68ccf8
fix: reuse trimmed value in rokt helper
Copilot May 25, 2026
f6841e4
mixpanel secret deprecation
joe-ayoub-segment May 25, 2026
62db2c4
Iterable - updateEmail
joe-ayoub-segment May 25, 2026
bd5f3c5
supporting updateEmail for batches
joe-ayoub-segment May 25, 2026
00289c5
fixing test
joe-ayoub-segment May 25, 2026
70db1f8
correcting a test
joe-ayoub-segment May 25, 2026
fa95a67
addressing Copilot feedback
joe-ayoub-segment May 25, 2026
f0db32f
STRATCONN-6823 - [Hubspot] - Oauth upgrade
joe-ayoub-segment May 26, 2026
7032db4
STRATCONN-6540 - [Iterable] - new subscription management Action
joe-ayoub-segment May 26, 2026
f00784b
refactoring
joe-ayoub-segment May 26, 2026
429de79
refactor
joe-ayoub-segment May 26, 2026
e4c7667
Copilot feedback
joe-ayoub-segment May 26, 2026
c8f2beb
Copilot comment
joe-ayoub-segment May 27, 2026
631a876
STRATCONN-6833 - [Customerio] - Multistatus response
joe-ayoub-segment May 27, 2026
a2a719a
tests
joe-ayoub-segment May 27, 2026
5f1b8ba
fixing tests
joe-ayoub-segment May 27, 2026
08a95b6
correcting test
joe-ayoub-segment May 27, 2026
0e9aa0e
copilot review updates
joe-ayoub-segment May 27, 2026
c048844
update to createUpdateObject action
joe-ayoub-segment May 27, 2026
3651dc4
feat: add e2e test types and Iterable fixtures
joe-ayoub-segment May 28, 2026
9cbda9c
refactor: prefix HTTP status code types with E2E
joe-ayoub-segment May 28, 2026
ae166ac
refactor: consolidate e2e fixtures to one file per action
joe-ayoub-segment May 28, 2026
6f472fe
refactor: remove fixture registry from e2e index
joe-ayoub-segment May 28, 2026
36f6d0c
feat: add dynamic value markers ($now, $guid) for e2e fixtures
joe-ayoub-segment May 28, 2026
d9657c3
refactor: use defaultValues() for e2e fixture mappings
joe-ayoub-segment May 28, 2026
43b8504
feat: add createE2EEvent helper for fixture event generation
joe-ayoub-segment May 28, 2026
729b957
refactor: separate e2e types from helper functions
joe-ayoub-segment May 28, 2026
79e483e
fix: omit email/userId from mapping instead of setting undefined
joe-ayoub-segment May 28, 2026
e28b1e4
feat: add e2e fixtures for Amplitude logEventV2 and identifyUser
joe-ayoub-segment May 28, 2026
f17604c
feat: add createE2EEngageAudienceEvent helper
joe-ayoub-segment May 29, 2026
8ef2426
refactor: improve createE2EEngageAudienceEvent
joe-ayoub-segment May 29, 2026
d25fb33
feat: add generic K to audience event types
joe-ayoub-segment May 29, 2026
1179102
refactor: rename generic K to ComputationKey for clarity
joe-ayoub-segment May 29, 2026
279ff90
feat: add audience fixture types and Amplitude Cohorts e2e fixtures
joe-ayoub-segment May 29, 2026
d9fa0d2
feat: add subscribe and mapping fields to E2EAudienceFixture
joe-ayoub-segment May 29, 2026
9471c9d
feat: add E2ETeardownAudienceStep type
joe-ayoub-segment May 29, 2026
c376880
refactor: move audience fixtures to syncAudience/__e2e__/fixtures.ts
joe-ayoub-segment May 29, 2026
552c737
feat: add description field to audience step types
joe-ayoub-segment May 29, 2026
34a6694
feat: add E2EExecutionMode type for single/batch step mode
joe-ayoub-segment May 29, 2026
6055ef2
refactor: use full SegmentEvent in audience sync steps
joe-ayoub-segment May 29, 2026
06454ac
fix: use E2EEngageAudienceEvent type in audience sync steps
joe-ayoub-segment May 29, 2026
16a6d8c
feat: add $externalAudienceId dynamic value marker
joe-ayoub-segment May 29, 2026
b05c06a
refactor: simplify audience testing to config + regular fixtures
joe-ayoub-segment May 29, 2026
c2d3ca1
docs: add JSDoc comments to E2EAudienceConfig fields
joe-ayoub-segment May 29, 2026
8615cce
feat: split E2EFixture into discriminated union with mode field
joe-ayoub-segment May 29, 2026
dfe3906
adding latest amplitude cohorts
joe-ayoub-segment May 29, 2026
f2e5498
fix: restore amplitude-cohorts e2e fixtures
joe-ayoub-segment May 29, 2026
cd7771a
fix: restore amplitude-cohorts e2e config
joe-ayoub-segment May 29, 2026
0d03939
feat: add verboseFailureHint to fixture types
joe-ayoub-segment May 29, 2026
df6746e
feat: add jsonContains to E2EExpectation types
joe-ayoub-segment May 29, 2026
d63b198
refactor: replace responseType with 3 execution modes + BaseFixture
joe-ayoub-segment May 29, 2026
f74927e
feat: add jsonContains assertion to batch fixture
joe-ayoub-segment May 29, 2026
5e1163e
feat: add e2e fixtures for Iterable Audiences destination
joe-ayoub-segment Jun 2, 2026
5da9316
feat: add sent/body assertions to Iterable Audiences batch fixture
joe-ayoub-segment Jun 2, 2026
8dccb65
fix: fix Iterable Audiences batch assertion and disable getAudience
joe-ayoub-segment Jun 2, 2026
672ba45
iterable fixture
joe-ayoub-segment Jun 2, 2026
a04f9f2
feat: add e2e fixtures for Google Enhanced Conversions userList
joe-ayoub-segment Jun 2, 2026
41b7363
feat: add batch test for Google Enhanced Conversions userList
joe-ayoub-segment Jun 2, 2026
b01b5fc
feat: assert sent/body objects in Google userList batch multistatus
joe-ayoub-segment Jun 2, 2026
3ff0efb
adding google enhanced conversions example test
joe-ayoub-segment Jun 2, 2026
a4135c0
adding comment to e2e test
joe-ayoub-segment Jun 2, 2026
c59590a
adding JourneysV1 helpers
joe-ayoub-segment Jun 2, 2026
01365f6
new file convention for e2e tests
joe-ayoub-segment Jun 2, 2026
d050fab
adding retl initial tests
joe-ayoub-segment Jun 2, 2026
59e8bbc
types
joe-ayoub-segment Jun 2, 2026
835dc74
refactor: extract shared builder in e2e helpers, remove unused action…
joe-ayoub-segment Jun 3, 2026
b59c9dd
refactor: move AudienceEventBase to e2e-types.ts
joe-ayoub-segment Jun 3, 2026
fd57a5b
rename fixture file
joe-ayoub-segment Jun 3, 2026
3698977
STRATCONN-6780 - [Pinterest] - new events
joe-ayoub-segment Jun 3, 2026
f589a84
tweaks to default mappings
joe-ayoub-segment Jun 3, 2026
1942c9c
fix default mappings and install_time type
joe-ayoub-segment Jun 3, 2026
5c7733b
build app_info externally and omit if empty
joe-ayoub-segment Jun 3, 2026
30845f7
restore full body assertion for hashed data test
joe-ayoub-segment Jun 3, 2026
70cf765
add data_format toggle to switch between legacy and structured fields
joe-ayoub-segment Jun 3, 2026
23c2f35
extract custom_data_2 and contents as separate structured fields
joe-ayoub-segment Jun 3, 2026
5bd9360
move contents_field to pinterest-capi-custom-data.ts
joe-ayoub-segment Jun 3, 2026
9468877
rename to latest, rename field factories to getX pattern
joe-ayoub-segment Jun 3, 2026
8c984d5
rename toggle label to Use Latest Fields with simpler description
joe-ayoub-segment Jun 3, 2026
703ecb2
types
joe-ayoub-segment Jun 3, 2026
528cfad
more unit tests
joe-ayoub-segment Jun 3, 2026
896ccc4
Copilot review changes
joe-ayoub-segment Jun 3, 2026
a44dac8
copilot fix
joe-ayoub-segment Jun 3, 2026
d268f8a
add Pinterest API payload types and address Copilot feedback
joe-ayoub-segment Jun 3, 2026
2dc3c32
addressing Copilot comments
joe-ayoub-segment Jun 4, 2026
65c3ad4
add Pinterest e2e tests, fix createE2EEvent for page/identify types
joe-ayoub-segment Jun 4, 2026
3dfc67d
fix e2e fixture expectations for validation errors and timestamp
joe-ayoub-segment Jun 4, 2026
22fd0db
pinterest tests passing
joe-ayoub-segment Jun 4, 2026
183bada
adding teardown for google enhanced conversions
joe-ayoub-segment Jun 4, 2026
cc77ba7
updating e2e for iterable audiences
joe-ayoub-segment Jun 4, 2026
1c1e698
Merge remote-tracking branch 'origin/main' into feat/e2e-test-types-a…
joe-ayoub-segment Jun 9, 2026
7c7250c
adding facebook conversions api e2e - untested
joe-ayoub-segment Jun 9, 2026
88b32ba
facebook custom audiences - update e2e
joe-ayoub-segment Jun 9, 2026
feae745
updating tests
joe-ayoub-segment Jun 10, 2026
8f8a9aa
Merge branch 'pinterest-new-events' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
4dbda30
Merge branch 'customerio-msresponse' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
9b6149d
Merge branch 'iterable-subscription-management' into e2e-framework-pl…
joe-ayoub-segment Jun 11, 2026
7ba5102
Merge branch 'hubspot-oauth-upgrade' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
1096889
Merge branch 'iterable-update-email' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
991a83f
Merge branch 'mixpanel-secret-deprecation' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
b19f46c
Merge branch 'rokt-capi-bug' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
a81477d
Merge branch 'linkedin-new-identifiers' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
bc859b7
Merge branch 'braze-ecommerce-addtocart' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
24ffb71
Merge branch 's3-shah256-support' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
9e4226d
Merge branch 'fb-appendvalue' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
fe4c505
Merge branch 'gec-journeys2-support' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
6ab5b44
Merge branch 'feat/braze-merge-users' into e2e-framework-plus-tests
joe-ayoub-segment Jun 11, 2026
58e8ecd
Add Journeys V2 e2e support and google-enhanced-conversions journeysV…
joe-ayoub-segment Jun 11, 2026
ade536b
Fix journey_step computation_class and membership for V1/V2 e2e events
joe-ayoub-segment Jun 11, 2026
8d35601
Simplify e2e types: inline personas shapes into track/identify events
joe-ayoub-segment Jun 11, 2026
11e369e
Rename facebook-custom-audiences e2e fixtures to *.e2e.ts so they are…
joe-ayoub-segment Jun 11, 2026
6499b14
Rename facebook journeys e2e fixture to journeysV1 for clarity
joe-ayoub-segment Jun 11, 2026
a8e8cf6
Use createE2EJourneysV1AudienceEvent helper in facebook journeysV1 fi…
joe-ayoub-segment Jun 11, 2026
a4bdb55
e2e framework: journey_step V1 events + facebook journeysV1 fixture
joe-ayoub-segment Jun 12, 2026
768fc9e
Populate sent operation in g-e-c batch multistatus + flag on/off e2e …
joe-ayoub-segment Jun 12, 2026
3045532
updating unit tests
joe-ayoub-segment Jun 12, 2026
36fa68c
adding link to JIRA for known bug
joe-ayoub-segment Jun 12, 2026
e97267c
fixing tests
joe-ayoub-segment Jun 12, 2026
266fa67
facebook-custom-audiences: remove journeys feature flag, rename to ge…
joe-ayoub-segment Jun 12, 2026
a3c70fd
adding e2e test coverage and fixing some other code issues
joe-ayoub-segment Jun 12, 2026
e148908
fixing e2e test
joe-ayoub-segment Jun 12, 2026
9f888d6
tightening fbca journeys handling
joe-ayoub-segment Jun 15, 2026
a667e67
google-enhanced-conversions: add error stats for audience-membership …
joe-ayoub-segment Jun 16, 2026
e3a4472
facebook-custom-audiences: remove dead getJourneysV1Memberships unit …
joe-ayoub-segment Jun 16, 2026
21f0f93
facebook-custom-audiences: fix isJourney always-true after rename
joe-ayoub-segment Jun 16, 2026
59ec5d0
google-enhanced-conversions: tag audience-membership error stats with…
joe-ayoub-segment Jun 16, 2026
4c46871
google-enhanced-conversions: namespace new error stats with slug+action
joe-ayoub-segment Jun 16, 2026
3ee0f5f
marketo-private: copy destination into e2e branch for testing
joe-ayoub-segment Jun 17, 2026
d3c14bb
marketo-private: add e2e config and sendForm fixtures
joe-ayoub-segment Jun 17, 2026
ec926a8
marketo-private: use REST field names in e2e success fixture
joe-ayoub-segment Jun 17, 2026
ccd05fb
mixpanel: flag-gate /import auth (apiSecret vs projectToken) + add e2…
joe-ayoub-segment Jun 17, 2026
c35d9b8
Remove .env.example
joe-ayoub-segment Jun 17, 2026
ea1ff46
Restore .env.example to original content
joe-ayoub-segment Jun 17, 2026
c18567e
marketo-private: seed oauth in e2e config so reactive token refresh p…
joe-ayoub-segment Jun 17, 2026
b576f80
marketo-private: use one shared dynamic lead across sendForm e2e fixt…
joe-ayoub-segment Jun 17, 2026
4442525
mixpanel: expand trackEvent/trackPurchase e2e field coverage + multis…
joe-ayoub-segment Jun 17, 2026
e7fcf49
mixpanel: sync /import auth fallback + credential tests from producti…
joe-ayoub-segment Jun 17, 2026
e7b4796
more tests
joe-ayoub-segment Jun 17, 2026
b42e6fd
copilot feedback
joe-ayoub-segment Jun 17, 2026
a472aa3
iterable: add updateUser newEmail e2e fixtures
joe-ayoub-segment Jun 19, 2026
f4df092
pendo-audiences: fix sent/body in multistatus response items
joe-ayoub-segment Jun 19, 2026
05607aa
updating pendo-audiences to use native audience membership
joe-ayoub-segment Jun 19, 2026
ae7d5ce
pendo-audiences: add e2e config and syncAudience fixtures
joe-ayoub-segment Jun 19, 2026
2b4e696
pendo-audiences: e2e batch-only fixture with per-operation success codes
joe-ayoub-segment Jun 19, 2026
0c9c8be
adding retries to types
joe-ayoub-segment Jun 19, 2026
811cd78
adding e2e tests for pendo-audiences
joe-ayoub-segment Jun 19, 2026
58d7ec2
sync s3 destination from s3-shah256-support
joe-ayoub-segment Jul 2, 2026
da2f80d
Add S3 destination e2e fixtures (hashing, batching, fields, audiences)
joe-ayoub-segment Jul 2, 2026
ba24934
Refine S3 e2e fixtures: dedicated formats file, simpler audiences, la…
joe-ayoub-segment Jul 2, 2026
f93853e
trim column_name and hash_algorithm in validateColumnsToHash
joe-ayoub-segment Jul 3, 2026
34f7c41
Remove redundant validateAction from iterable updateSubscriptions
joe-ayoub-segment Jul 6, 2026
c1ca2e8
Assert batch subscriptions invariant in iterable updateSubscriptions
joe-ayoub-segment Jul 6, 2026
6be9705
Add e2e fixtures for iterable updateSubscriptions
joe-ayoub-segment Jul 6, 2026
df93f27
[Amplitude Cohorts] e2e: cover nonexistent user in batch cohort add
joe-ayoub-segment Jul 6, 2026
3c82d93
Port updateCompanyAudience action from PR #3856 into e2e branch
joe-ayoub-segment Jul 7, 2026
09c16ef
tests working
joe-ayoub-segment Jul 7, 2026
2300c18
Dedupe same-company payloads before sending to LinkedIn
joe-ayoub-segment Jul 7, 2026
a00f9eb
Unit test: assert exact per-item MultiStatusResponse for company dedup
joe-ayoub-segment Jul 7, 2026
3450b0f
Address Copilot review: version header, 2xx check, identifier normali…
joe-ayoub-segment Jul 8, 2026
d682388
Add 350-company large-batch e2e fixture for updateCompanyAudience
joe-ayoub-segment Jul 8, 2026
51b40c0
Refine amplitude-cohorts user_id copy and narrow id_type
joe-ayoub-segment Jul 8, 2026
a15c4a4
Fill updateCompanyAudience hook unit-test gaps
joe-ayoub-segment Jul 8, 2026
cdbcfcc
S3 syncToS3: add per-column normalization + optional hashing
joe-ayoub-segment Jul 9, 2026
194b6ad
S3 syncToS3: clarify normalize field description (re-hash guarantee)
joe-ayoub-segment Jul 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/core/src/destination-kit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ interface AuthSettings<Settings> {
interface RefreshAuthSettings<Settings> {
settings: Settings
auth: OAuth2ClientCredentials
features?: Features
}

interface Authentication<Settings> {
Expand Down Expand Up @@ -564,7 +565,8 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
async refreshAccessToken(
settings: Settings,
oauthData: OAuth2ClientCredentials,
synchronizeRefreshAccessToken?: () => Promise<void>
synchronizeRefreshAccessToken?: () => Promise<void>,
features?: Features
): Promise<RefreshAccessTokenResult | undefined> {
if (!(this.authentication?.scheme === 'oauth2' || this.authentication?.scheme === 'oauth-managed')) {
throw new IntegrationError(
Expand All @@ -590,7 +592,7 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
// Invoke synchronizeRefreshAccessToken handler if synchronizeRefreshAccessToken option is passed.
// This will ensure that there is only one active refresh happening at a time.
await synchronizeRefreshAccessToken?.()
return this.authentication.refreshAccessToken(requestClient, { settings, auth: oauthData })
return this.authentication.refreshAccessToken(requestClient, { settings, auth: oauthData, features })
}

private partnerAction(
Expand Down Expand Up @@ -1062,7 +1064,8 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
const newTokens = await this.refreshAccessToken(
destinationSettings,
oauthSettings,
options?.synchronizeRefreshAccessToken
options?.synchronizeRefreshAccessToken,
options?.features
)

if (!newTokens) {
Expand Down
252 changes: 252 additions & 0 deletions packages/core/src/e2e-helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
import type { SegmentEvent } from './segment-event'
import type { JSONValue } from './json-object'
import type {
E2EAudienceEventBase,
E2EEngageAudienceEventOptions,
E2EEngageAudienceEvent,
E2EJourneysV1AudienceEventOptions,
E2EJourneysV1AudienceTrackEvent,
E2EJourneysV2AudienceEventOptions,
E2EJourneysV2AudienceTrackEvent,
E2ERetlAudienceEventOptions,
E2ERetlAudienceTrackEvent
} from './e2e-types'

/*
* Regular Segment Connections event
*/
export function createE2EEvent(
type: SegmentEvent['type'],
name?: string,
overrides?: Partial<Omit<SegmentEvent, 'type' | 'event' | 'name' | 'messageId' | 'timestamp'>>
): SegmentEvent {
if (type === 'track') {
return {
type,
event: name,
messageId: '$guid',
timestamp: '$now',
...overrides
}
}

if (type === 'page' || type === 'screen') {
return {
type,
name,
messageId: '$guid',
timestamp: '$now',
...overrides
}
}

if (name) {
throw new Error(
`createE2EEvent: "name" is not supported for "${type}" events. Only track, page, and screen accept a name.`
)
}

return {
type,
messageId: '$guid',
timestamp: '$now',
...overrides
}
}

function buildAudienceEventBase(options: E2EAudienceEventBase) {
const {
computationKey,
computationId,
externalAudienceId,
userId,
anonymousId,
email,
audienceFields,
includeContextTraits = true
} = options
return {
messageId: '$guid',
timestamp: '$now',
...(userId && { userId }),
...(anonymousId && { anonymousId }),
context: {
personas: {
computation_class: 'audience',
computation_key: computationKey,
computation_id: computationId,
...(externalAudienceId && { external_audience_id: externalAudienceId })
},
...(audienceFields && { audienceFields }),
...(includeContextTraits && email && { traits: { email } })
}
}
}

/*
* Engage Audience event
* Supports identify and track events
*/
export function createE2EEngageAudienceEvent<ComputationKey extends string>(
options: E2EEngageAudienceEventOptions<ComputationKey>
): E2EEngageAudienceEvent<ComputationKey> {
const { type, action, computationKey, eventName, email, enrichedTraits } = options

if (type === 'identify' && eventName) {
throw new Error('createE2EEngageAudienceEvent: "eventName" is not supported for identify events.')
}

const membership = action === 'add'
const base = buildAudienceEventBase({ ...options, includeContextTraits: type === 'track' })

const event = {
...base,
...(type === 'track' && {
type: 'track',
event: eventName ?? 'Test Engage Audience Membership Event',
properties: {
[computationKey]: membership,
...(enrichedTraits as { [k: string]: JSONValue })
}
}),
...(type === 'identify' && {
type: 'identify',
traits: {
[computationKey]: membership,
...(enrichedTraits as { [k: string]: JSONValue }),
...(email && { email })
}
})
}

return event as E2EEngageAudienceEvent<ComputationKey>
}

/*
* Journeys V1 events (preset journeys_step_entered_track) do not have properties[<computation_key>] value.
* All Journeys V1 events enter the user to the audience, never remove them.
* Only track events supported
*/
export function createE2EJourneysV1AudienceEvent<ComputationKey extends string>(
options: E2EJourneysV1AudienceEventOptions<ComputationKey>
): E2EJourneysV1AudienceTrackEvent<ComputationKey> {
const {
computationKey,
computationId,
externalAudienceId,
userId,
anonymousId,
email,
audienceFields,
enrichedTraits
} = options

const event = {
messageId: '$guid',
timestamp: '$now',
...(userId && { userId }),
...(anonymousId && { anonymousId }),
type: 'track',
event: 'Audience Entered',
properties: {
...(enrichedTraits as { [k: string]: JSONValue })
},
context: {
personas: {
computation_class: 'journey_step',
computation_key: computationKey,
computation_id: computationId,
...(externalAudienceId && { external_audience_id: externalAudienceId })
},
...(audienceFields && { audienceFields }),
...(email && { traits: { email } })
}
}

return event as E2EJourneysV1AudienceTrackEvent<ComputationKey>
}

/*
* Journeys V2 events use computation_class 'journey_step' (not 'audience') and carry
* journey_context / journey_metadata in properties alongside properties[<computation_key>],
* the membership boolean (true = entering the step / add, false = exiting / remove).
* Only track events supported.
*/
export function createE2EJourneysV2AudienceEvent<ComputationKey extends string>(
options: E2EJourneysV2AudienceEventOptions<ComputationKey>
): E2EJourneysV2AudienceTrackEvent<ComputationKey> {
const {
action = 'add',
computationKey,
computationId,
externalAudienceId,
eventName,
journeyId,
journeyName,
userId,
anonymousId,
email,
audienceFields,
enrichedTraits
} = options

const membership = action === 'add'

const event = {
messageId: '$guid',
timestamp: '$now',
...(userId && { userId }),
...(anonymousId && { anonymousId }),
type: 'track',
event: eventName ?? 'Test Journeys V2 Audience Membership Event',
properties: {
[computationKey]: membership,
journey_context: {
[computationKey]: {}
},
journey_metadata: {
epoch_id: '$guid',
journey_id: journeyId ?? 'jver_e2e_journey',
journey_name: journeyName ?? 'e2e journey'
},
...(enrichedTraits as { [k: string]: JSONValue })
},
context: {
personas: {
computation_class: 'journey_step',
computation_key: computationKey,
computation_id: computationId,
...(externalAudienceId && { external_audience_id: externalAudienceId })
},
...(audienceFields && { audienceFields }),
...(email && { traits: { email } })
}
}

return event as E2EJourneysV2AudienceTrackEvent<ComputationKey>
}

/*
* Reverse ETL Audience event
* Same payload structure as Engage track events but uses RETL-specific event names: 'new', 'updated', 'deleted'
* Only track events supported
*/
export function createE2ERetlAudienceEvent<ComputationKey extends string>(
options: E2ERetlAudienceEventOptions<ComputationKey>
): E2ERetlAudienceTrackEvent<ComputationKey> {
const { eventName, computationKey, enrichedTraits } = options
const membership = eventName !== 'deleted'
const base = buildAudienceEventBase(options)

const event = {
...base,
type: 'track',
event: eventName,
properties: {
[computationKey]: membership,
...(enrichedTraits as { [k: string]: JSONValue })
}
}

return event as E2ERetlAudienceTrackEvent<ComputationKey>
}
Loading
Loading