Skip to content

Commit e52a42f

Browse files
STRATCONN-5939 - Cleanup flagon gate (#3097)
1 parent ff986b4 commit e52a42f

File tree

2 files changed

+9
-59
lines changed

2 files changed

+9
-59
lines changed

packages/destination-actions/src/destinations/braze-cohorts/syncAudiences/__tests__/index.test.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,6 @@ describe('BrazeCohorts.syncAudiences', () => {
654654
external_id: {
655655
'@path': '$.notGiven'
656656
}
657-
},
658-
features: {
659-
'dedupe-braze-cohorts-v2': true
660657
}
661658
})
662659

@@ -733,9 +730,6 @@ describe('BrazeCohorts.syncAudiences', () => {
733730
'@path': '$.context.traits.email'
734731
}
735732
}
736-
},
737-
features: {
738-
'dedupe-braze-cohorts-v2': true
739733
}
740734
})
741735

@@ -799,9 +793,6 @@ describe('BrazeCohorts.syncAudiences', () => {
799793
useDefaultMappings: true,
800794
mapping: {
801795
personas_audience_key: 'j_o_jons__step_1_ns3i7'
802-
},
803-
features: {
804-
'dedupe-braze-cohorts-v2': true
805796
}
806797
})
807798

@@ -875,9 +866,6 @@ describe('BrazeCohorts.syncAudiences', () => {
875866
external_id: {
876867
'@path': '$.notGiven'
877868
}
878-
},
879-
features: {
880-
'dedupe-braze-cohorts-v2': true
881869
}
882870
})
883871

@@ -954,9 +942,6 @@ describe('BrazeCohorts.syncAudiences', () => {
954942
'@path': '$.context.traits.email'
955943
}
956944
}
957-
},
958-
features: {
959-
'dedupe-braze-cohorts-v2': true
960945
}
961946
})
962947

@@ -1035,9 +1020,6 @@ describe('BrazeCohorts.syncAudiences', () => {
10351020
external_id: {
10361021
'@path': '$.notGiven'
10371022
}
1038-
},
1039-
features: {
1040-
'dedupe-braze-cohorts-v2': true
10411023
}
10421024
})
10431025

@@ -1113,9 +1095,6 @@ describe('BrazeCohorts.syncAudiences', () => {
11131095
'@path': '$.context.traits.email'
11141096
}
11151097
}
1116-
},
1117-
features: {
1118-
'dedupe-braze-cohorts-v2': true
11191098
}
11201099
})
11211100

packages/destination-actions/src/destinations/braze-cohorts/syncAudiences/index.ts

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ActionDefinition, RequestClient, PayloadValidationError, Features } from '@segment/actions-core'
1+
import { ActionDefinition, RequestClient, PayloadValidationError } from '@segment/actions-core'
22
import type { Settings } from '../generated-types'
33
import type { Payload } from './generated-types'
44
import { SyncAudiences } from '../api'
@@ -112,19 +112,18 @@ const action: ActionDefinition<Settings, Payload> = {
112112
required: false
113113
}
114114
},
115-
perform: async (request, { settings, payload, stateContext, features }) => {
116-
return processPayload(request, settings, [payload], stateContext, features)
115+
perform: async (request, { settings, payload, stateContext }) => {
116+
return processPayload(request, settings, [payload], stateContext)
117117
},
118-
performBatch: async (request, { settings, payload, stateContext, features }) => {
119-
return processPayload(request, settings, payload, stateContext, features)
118+
performBatch: async (request, { settings, payload, stateContext }) => {
119+
return processPayload(request, settings, payload, stateContext)
120120
}
121121
}
122122
async function processPayload(
123123
request: RequestClient,
124124
settings: Settings,
125125
payloads: Payload[],
126-
stateContext?: StateContext,
127-
features?: Features
126+
stateContext?: StateContext
128127
) {
129128
validate(payloads)
130129
const syncAudiencesApiClient: SyncAudiences = new SyncAudiences(request, settings)
@@ -136,12 +135,8 @@ async function processPayload(
136135
//setting cohort_name in cache context with ttl 0 so that it can keep the value as long as possible.
137136
stateContext?.setResponseContext?.(`cohort_name`, cohort_name, {})
138137
}
139-
let addUsers: CohortChanges, removeUsers: CohortChanges
140-
if (features?.['dedupe-braze-cohorts-v2']) {
141-
;({ addUsers, removeUsers } = extractUsersV2(payloads))
142-
} else {
143-
;({ addUsers, removeUsers } = extractUsers(payloads))
144-
}
138+
const { addUsers, removeUsers } = extractUsers(payloads)
139+
145140
const hasAddUsers = hasUsersToAddOrRemove(addUsers)
146141
const hasRemoveUsers = hasUsersToAddOrRemove(removeUsers)
147142

@@ -169,7 +164,7 @@ function validate(payloads: Payload[]): void {
169164
}
170165
}
171166

172-
function extractUsersV2(payloads: Payload[]) {
167+
function extractUsers(payloads: Payload[]) {
173168
// sort by time in descending order
174169
// This is important because if a user is added and removed in the same batch,
175170
// we want to ensure that the last action is taken.
@@ -215,30 +210,6 @@ function extractUsersV2(payloads: Payload[]) {
215210
}
216211
}
217212

218-
function extractUsers(payloads: Payload[]) {
219-
const addUsers: CohortChanges = { user_ids: [], device_ids: [], aliases: [] }
220-
const removeUsers: CohortChanges = { user_ids: [], device_ids: [], aliases: [], should_remove: true }
221-
222-
payloads.forEach((payload: Payload) => {
223-
const { event_properties, external_id, device_id, user_alias, personas_audience_key } = payload
224-
const userEnteredOrRemoved: boolean = event_properties[`${personas_audience_key}`] as boolean
225-
const user = userEnteredOrRemoved ? addUsers : removeUsers
226-
227-
if (external_id) {
228-
user?.user_ids?.push(external_id)
229-
} else if (device_id) {
230-
user?.device_ids?.push(device_id)
231-
} else if (user_alias) {
232-
user?.aliases?.push(user_alias)
233-
}
234-
})
235-
236-
return {
237-
addUsers,
238-
removeUsers
239-
}
240-
}
241-
242213
function transformAliases(aliases: Map<string, UserAlias> | undefined): UserAlias[] | undefined {
243214
if (!aliases) return undefined
244215
return Array.from(aliases.values()).map((alias) => ({

0 commit comments

Comments
 (0)