Skip to content

Commit c147007

Browse files
Rename processHashingV2 back to processHashing (#2903)
1 parent d5577ba commit c147007

File tree

30 files changed

+165
-249
lines changed

30 files changed

+165
-249
lines changed

packages/destination-actions/src/destinations/amazon-amc/function.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { AudienceSettings, Settings } from './generated-types'
44
import type { Payload } from './syncAudiencesToDSP/generated-types'
55
import { AudienceRecord, HashedPIIObject } from './types'
66
import { CONSTANTS, RecordsResponseType, REGEX_EXTERNALUSERID } from './utils'
7-
import { processHashingV2 } from '../../lib/hashing-utils'
7+
import { processHashing } from '../../lib/hashing-utils'
88

99
export async function processPayload(
1010
request: RequestClient,
@@ -233,28 +233,28 @@ function hashedPayload(payload: Payload): HashedPIIObject {
233233
const hashedPII: HashedPIIObject = {}
234234

235235
if (payload.firstName) {
236-
hashedPII.firstname = processHashingV2(payload.firstName, 'sha256', 'hex', normalizeStandard)
236+
hashedPII.firstname = processHashing(payload.firstName, 'sha256', 'hex', normalizeStandard)
237237
}
238238
if (payload.lastName) {
239-
hashedPII.lastname = processHashingV2(payload.lastName, 'sha256', 'hex', normalizeStandard)
239+
hashedPII.lastname = processHashing(payload.lastName, 'sha256', 'hex', normalizeStandard)
240240
}
241241
if (payload.address) {
242-
hashedPII.address = processHashingV2(payload.address, 'sha256', 'hex', normalizeStandard)
242+
hashedPII.address = processHashing(payload.address, 'sha256', 'hex', normalizeStandard)
243243
}
244244
if (payload.postal) {
245-
hashedPII.postal = processHashingV2(payload.postal, 'sha256', 'hex', normalizeStandard)
245+
hashedPII.postal = processHashing(payload.postal, 'sha256', 'hex', normalizeStandard)
246246
}
247247
if (payload.phone) {
248-
hashedPII.phone = processHashingV2(payload.phone, 'sha256', 'hex', normalizePhone)
248+
hashedPII.phone = processHashing(payload.phone, 'sha256', 'hex', normalizePhone)
249249
}
250250
if (payload.city) {
251-
hashedPII.city = processHashingV2(payload.city, 'sha256', 'hex', normalizeStandard)
251+
hashedPII.city = processHashing(payload.city, 'sha256', 'hex', normalizeStandard)
252252
}
253253
if (payload.state) {
254-
hashedPII.state = processHashingV2(payload.state, 'sha256', 'hex', normalizeStandard)
254+
hashedPII.state = processHashing(payload.state, 'sha256', 'hex', normalizeStandard)
255255
}
256256
if (payload.email) {
257-
hashedPII.email = processHashingV2(payload.email, 'sha256', 'hex', normalizeEmail)
257+
hashedPII.email = processHashing(payload.email, 'sha256', 'hex', normalizeEmail)
258258
}
259259

260260
return hashedPII

packages/destination-actions/src/destinations/delivrai-activate/utils-rt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Payload } from './updateSegment/generated-types'
22
import { DelivrAIPayload } from './types'
33
import { RequestClient } from '@segment/actions-core'
44
import { DELIVRAI_BASE_URL, DELIVRAI_GET_TOKEN } from './constants'
5-
import { processHashingV2 } from '../../lib/hashing-utils'
5+
import { processHashing } from '../../lib/hashing-utils'
66

77
/**
88
* Generates JWT for Realtime API authentication
@@ -64,7 +64,7 @@ export function gen_update_segment_payload(payloads: Payload[], client_identifie
6464
for (const event of payloads) {
6565
let hashed_email: string | undefined = ''
6666
if (event.email) {
67-
hashed_email = processHashingV2(event.email.toLowerCase(), 'sha256', 'hex')
67+
hashed_email = processHashing(event.email.toLowerCase(), 'sha256', 'hex')
6868
}
6969
let idfa: string | undefined = ''
7070
let gpsaid: string | undefined = ''

packages/destination-actions/src/destinations/dynamic-yield-audiences/helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { processHashingV2 } from '../../lib/hashing-utils'
1+
import { processHashing } from '../../lib/hashing-utils'
22

33
export function hashAndEncode(property: string): string {
4-
return processHashingV2(property, 'sha256', 'hex')
4+
return processHashing(property, 'sha256', 'hex')
55
}
66

77
export function hashAndEncodeToInt(property: string): number {
8-
const hash = processHashingV2(property, 'sha256', 'hex')
8+
const hash = processHashing(property, 'sha256', 'hex')
99
const bigInt = BigInt('0x' + hash)
1010
let integerString = bigInt.toString()
1111
if (integerString.length > 16) {

packages/destination-actions/src/destinations/facebook-conversions-api/fb-capi-user-data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { InputField } from '@segment/actions-core/destination-kit/types'
22
import { US_STATE_CODES, COUNTRY_CODES } from './constants'
33
import { Payload } from './addToCart/generated-types'
44
import isEmpty from 'lodash/isEmpty'
5-
import { processHashingV2 } from '../../lib/hashing-utils'
5+
import { processHashing } from '../../lib/hashing-utils'
66

77
// Implementation of Facebook user data object
88
// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters
@@ -196,10 +196,10 @@ const hash = (value: string | string[] | undefined): string | string[] | undefin
196196
if (value === undefined || !value.length) return
197197

198198
if (typeof value == 'string') {
199-
return processHashingV2(value, 'sha256', 'hex')
199+
return processHashing(value, 'sha256', 'hex')
200200
}
201201

202-
return value.map((el: string) => processHashingV2(el, 'sha256', 'hex'))
202+
return value.map((el: string) => processHashing(el, 'sha256', 'hex'))
203203
}
204204

205205
/**

packages/destination-actions/src/destinations/facebook-custom-audiences/__tests__/fb-operations.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Payload } from '../sync/generated-types'
66
import { normalizationFunctions } from '../fbca-properties'
77
import { Features } from '@segment/actions-core/mapping-kit'
88
import { API_VERSION, BASE_URL, CANARY_API_VERSION } from '../constants'
9-
import { processHashingV2 } from '../../../lib/hashing-utils'
9+
import { processHashing } from '../../../lib/hashing-utils'
1010

1111
const requestClient = createRequestClient()
1212
const settings: Settings = {
@@ -70,14 +70,14 @@ describe('Facebook Custom Audiences', () => {
7070
expect(generateData(payloads)).toEqual([
7171
[
7272
'5', // external_id is not hashed or normalized
73-
processHashingV2(payloads[0].email || '', 'sha256', 'hex', normalizationFunctions.get('email')),
74-
processHashingV2(payloads[0].phone || '', 'sha256', 'hex', normalizationFunctions.get('phone')),
73+
processHashing(payloads[0].email || '', 'sha256', 'hex', normalizationFunctions.get('email')),
74+
processHashing(payloads[0].phone || '', 'sha256', 'hex', normalizationFunctions.get('phone')),
7575
EMPTY, // gender
7676
EMPTY, // year
7777
EMPTY, // month
7878
EMPTY, // day
79-
processHashingV2(payloads[0].name?.last || '', 'sha256', 'hex', normalizationFunctions.get('last')),
80-
processHashingV2(payloads[0].name?.first || '', 'sha256', 'hex', normalizationFunctions.get('first')),
79+
processHashing(payloads[0].name?.last || '', 'sha256', 'hex', normalizationFunctions.get('last')),
80+
processHashing(payloads[0].name?.first || '', 'sha256', 'hex', normalizationFunctions.get('first')),
8181
EMPTY, // first_initial
8282
EMPTY, // city
8383
EMPTY, // state
@@ -128,14 +128,14 @@ describe('Facebook Custom Audiences', () => {
128128
expect(generateData(payloads)).toEqual([
129129
[
130130
'5', // external_id
131-
processHashingV2(payloads[0].email || '', 'sha256', 'hex', normalizationFunctions.get('email')),
131+
processHashing(payloads[0].email || '', 'sha256', 'hex', normalizationFunctions.get('email')),
132132
'89a0af94167fe6b92b614c681cc5599cd23ff45f7e9cc7929ed5fabe26842468',
133133
EMPTY, // gender
134134
EMPTY, // year
135135
EMPTY, // month
136136
EMPTY, // day
137-
processHashingV2(payloads[0].name?.last || '', 'sha256', 'hex', normalizationFunctions.get('last')),
138-
processHashingV2(payloads[0].name?.first || '', 'sha256', 'hex', normalizationFunctions.get('first')),
137+
processHashing(payloads[0].name?.last || '', 'sha256', 'hex', normalizationFunctions.get('last')),
138+
processHashing(payloads[0].name?.first || '', 'sha256', 'hex', normalizationFunctions.get('first')),
139139
EMPTY, // first_initial
140140
EMPTY, // city
141141
EMPTY, // state
@@ -145,25 +145,25 @@ describe('Facebook Custom Audiences', () => {
145145
],
146146
[
147147
'6', // external_id
148-
processHashingV2(payloads[1].email || '', 'sha256', 'hex', normalizationFunctions.get('email')),
148+
processHashing(payloads[1].email || '', 'sha256', 'hex', normalizationFunctions.get('email')),
149149
EMPTY, // phone
150-
processHashingV2(payloads[1].gender || '', 'sha256', 'hex', normalizationFunctions.get('gender')),
151-
processHashingV2(payloads[1].birth?.year || '', 'sha256', 'hex', normalizationFunctions.get('year')),
152-
processHashingV2(payloads[1].birth?.month || '', 'sha256', 'hex', normalizationFunctions.get('month')),
153-
processHashingV2(payloads[1].birth?.day || '', 'sha256', 'hex', normalizationFunctions.get('day')),
154-
processHashingV2(payloads[1].name?.last || '', 'sha256', 'hex', normalizationFunctions.get('last')),
155-
processHashingV2(payloads[1].name?.first || '', 'sha256', 'hex', normalizationFunctions.get('first')),
156-
processHashingV2(
150+
processHashing(payloads[1].gender || '', 'sha256', 'hex', normalizationFunctions.get('gender')),
151+
processHashing(payloads[1].birth?.year || '', 'sha256', 'hex', normalizationFunctions.get('year')),
152+
processHashing(payloads[1].birth?.month || '', 'sha256', 'hex', normalizationFunctions.get('month')),
153+
processHashing(payloads[1].birth?.day || '', 'sha256', 'hex', normalizationFunctions.get('day')),
154+
processHashing(payloads[1].name?.last || '', 'sha256', 'hex', normalizationFunctions.get('last')),
155+
processHashing(payloads[1].name?.first || '', 'sha256', 'hex', normalizationFunctions.get('first')),
156+
processHashing(
157157
payloads[1].name?.firstInitial || '',
158158
'sha256',
159159
'hex',
160160
normalizationFunctions.get('firstInitial')
161161
),
162-
processHashingV2(payloads[1].city || '', 'sha256', 'hex', normalizationFunctions.get('city')),
163-
processHashingV2(payloads[1].state || '', 'sha256', 'hex', normalizationFunctions.get('state')),
164-
processHashingV2(payloads[1].zip || '', 'sha256', 'hex', normalizationFunctions.get('zip')),
162+
processHashing(payloads[1].city || '', 'sha256', 'hex', normalizationFunctions.get('city')),
163+
processHashing(payloads[1].state || '', 'sha256', 'hex', normalizationFunctions.get('state')),
164+
processHashing(payloads[1].zip || '', 'sha256', 'hex', normalizationFunctions.get('zip')),
165165
EMPTY, // mobile_advertiser_id,
166-
processHashingV2(payloads[1].country || '', 'sha256', 'hex', normalizationFunctions.get('country'))
166+
processHashing(payloads[1].country || '', 'sha256', 'hex', normalizationFunctions.get('country'))
167167
]
168168
])
169169
})

packages/destination-actions/src/destinations/facebook-custom-audiences/fbca-operations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DynamicFieldItem, DynamicFieldError, RequestClient, Features } from '@segment/actions-core'
22
import { Payload } from './sync/generated-types'
33
import { segmentSchemaKeyToArrayIndex, SCHEMA_PROPERTIES, normalizationFunctions } from './fbca-properties'
4-
import { processHashingV2 } from '../../lib/hashing-utils'
4+
import { processHashing } from '../../lib/hashing-utils'
55
import { StatsContext } from '@segment/actions-core/destination-kit'
66
import { API_VERSION, BASE_URL, CANARY_API_VERSION, FACEBOOK_CUSTOM_AUDIENCE_FLAGON } from './constants'
77

@@ -76,7 +76,7 @@ const appendToDataRow = (key: string, value: string | number, row: (string | num
7676
return
7777
}
7878

79-
row[index] = processHashingV2(value, 'sha256', 'hex', normalizationFunctions.get(key))
79+
row[index] = processHashing(value, 'sha256', 'hex', normalizationFunctions.get(key))
8080
}
8181

8282
export const getApiVersion = (features?: Features, statsContext?: StatsContext): string => {

packages/destination-actions/src/destinations/facebook-custom-audiences/sync/__tests__/index.test.ts

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import nock from 'nock'
44
import { SCHEMA_PROPERTIES } from '../../fbca-properties'
55
import { normalizationFunctions } from '../../fbca-properties'
66
import { BASE_URL, CANARY_API_VERSION, API_VERSION } from '../../constants'
7-
import { processHashingV2 } from '../../../../lib/hashing-utils'
7+
import { processHashing } from '../../../../lib/hashing-utils'
88

99
const testDestination = createTestIntegration(Destination)
1010
const auth = {
@@ -50,34 +50,24 @@ describe('FacebookCustomAudiences.sync', () => {
5050
[
5151
event.properties?.id, // external_id
5252
'816341caf0c06dbc4c156d3465323f52b3cb62533241d5f9247c008f657e8343', // email
53-
processHashingV2(
54-
event.properties?.phone as string,
55-
'sha256',
56-
'hex',
57-
normalizationFunctions.get('phone')
58-
),
53+
processHashing(event.properties?.phone as string, 'sha256', 'hex', normalizationFunctions.get('phone')),
5954
EMPTY, // gender
6055
EMPTY, // year
6156
EMPTY, // month
6257
EMPTY, // day
6358
EMPTY, // last_name
6459
EMPTY, // first_name
6560
EMPTY, // first_initial
66-
processHashingV2(event.properties?.city as string, 'sha256', 'hex', normalizationFunctions.get('city')),
67-
processHashingV2(
68-
event.properties?.state as string,
69-
'sha256',
70-
'hex',
71-
normalizationFunctions.get('state')
72-
),
73-
processHashingV2(
61+
processHashing(event.properties?.city as string, 'sha256', 'hex', normalizationFunctions.get('city')),
62+
processHashing(event.properties?.state as string, 'sha256', 'hex', normalizationFunctions.get('state')),
63+
processHashing(
7464
(event.properties?.zip_code as string) || '',
7565
'sha256',
7666
'hex',
7767
normalizationFunctions.get('zip')
7868
),
7969
'2024', // mobile_advertiser_id,
80-
processHashingV2('US', 'sha256', 'hex', normalizationFunctions.get('country'))
70+
processHashing('US', 'sha256', 'hex', normalizationFunctions.get('country'))
8171
]
8272
],
8373
app_ids: ['2024']
@@ -141,7 +131,7 @@ describe('FacebookCustomAudiences.sync', () => {
141131
[
142132
event.properties?.id, // external_id
143133
'816341caf0c06dbc4c156d3465323f52b3cb62533241d5f9247c008f657e8343', // email
144-
processHashingV2(
134+
processHashing(
145135
(event.properties?.phone as string) || '',
146136
'sha256',
147137
'hex',
@@ -154,26 +144,26 @@ describe('FacebookCustomAudiences.sync', () => {
154144
EMPTY, // last_name
155145
EMPTY, // first_name
156146
EMPTY, // first_initial
157-
processHashingV2(
147+
processHashing(
158148
(event.properties?.city as string) || '',
159149
'sha256',
160150
'hex',
161151
normalizationFunctions.get('city')
162152
),
163-
processHashingV2(
153+
processHashing(
164154
(event.properties?.state as string) || '',
165155
'sha256',
166156
'hex',
167157
normalizationFunctions.get('state')
168158
),
169-
processHashingV2(
159+
processHashing(
170160
(event.properties?.zip_code as string) || '',
171161
'sha256',
172162
'hex',
173163
normalizationFunctions.get('zip')
174164
),
175165
'2024', // mobile_advertiser_id,
176-
processHashingV2('US', 'sha256', 'hex', normalizationFunctions.get('country')) // country
166+
processHashing('US', 'sha256', 'hex', normalizationFunctions.get('country')) // country
177167
]
178168
],
179169
app_ids: ['2024']

packages/destination-actions/src/destinations/first-party-dv360/functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IntegrationError, RequestClient, StatsContext } from '@segment/actions-core'
22
import { Payload } from './addToAudContactInfo/generated-types'
33
import { Payload as DeviceIdPayload } from './addToAudMobileDeviceId/generated-types'
4-
import { processHashingV2 } from '../../lib/hashing-utils'
4+
import { processHashing } from '../../lib/hashing-utils'
55

66
const DV360API = `https://displayvideo.googleapis.com/v3/firstAndThirdPartyAudiences`
77
const CONSENT_STATUS_GRANTED = 'CONSENT_STATUS_GRANTED' // Define consent status
@@ -179,7 +179,7 @@ function normalizeAndHash(data: string) {
179179
// Normalize the data
180180
const normalizedData = data.toLowerCase().trim() // Example: Convert to lowercase and remove leading/trailing spaces
181181
// Hash the normalized data using SHA-256
182-
return processHashingV2(normalizedData, 'sha256', 'hex')
182+
return processHashing(normalizedData, 'sha256', 'hex')
183183
}
184184

185185
function processPayload(payload: Payload) {

packages/destination-actions/src/destinations/google-campaign-manager-360/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
ConsentType,
1717
EncryptionInfo
1818
} from './types'
19-
import { processHashingV2 } from '../../lib/hashing-utils'
19+
import { processHashing } from '../../lib/hashing-utils'
2020

2121
export async function send(
2222
request: RequestClient,
@@ -154,19 +154,19 @@ export function getJSON(payloads: UploadPayload[] | Adjustayload[], settings: Se
154154
const identifiers: UserIdentifier[] = []
155155
if (email) {
156156
identifiers.push({
157-
hashedEmail: processHashingV2(email, 'sha256', 'hex')
157+
hashedEmail: processHashing(email, 'sha256', 'hex')
158158
})
159159
}
160160
if (phone) {
161161
identifiers.push({
162-
hashedPhoneNumber: processHashingV2(phone, 'sha256', 'hex')
162+
hashedPhoneNumber: processHashing(phone, 'sha256', 'hex')
163163
})
164164
}
165165
if (firstName || lastName || streetAddress || city || state || postalCode || countryCode) {
166166
const addressInfo: AddressInfo = {
167-
hashedFirstName: firstName ? processHashingV2(firstName, 'sha256', 'hex') : undefined,
168-
hashedLastName: lastName ? processHashingV2(lastName, 'sha256', 'hex') : undefined,
169-
hashedStreetAddress: streetAddress ? processHashingV2(streetAddress, 'sha256', 'hex') : undefined,
167+
hashedFirstName: firstName ? processHashing(firstName, 'sha256', 'hex') : undefined,
168+
hashedLastName: lastName ? processHashing(lastName, 'sha256', 'hex') : undefined,
169+
hashedStreetAddress: streetAddress ? processHashing(streetAddress, 'sha256', 'hex') : undefined,
170170
city: city ?? undefined,
171171
state: state ?? undefined,
172172
postalCode: postalCode ?? undefined,
@@ -190,7 +190,7 @@ export function getJSON(payloads: UploadPayload[] | Adjustayload[], settings: Se
190190
encryptedUserIdCandidates
191191
?.split(',')
192192
.map((value) => {
193-
return processHashingV2(value, 'sha256', 'hex')
193+
return processHashing(value, 'sha256', 'hex')
194194
})
195195
.filter((str): str is string => str !== undefined) ?? []
196196
} as Conversion

0 commit comments

Comments
 (0)