Skip to content

Commit

Permalink
fix: standardize hashing for all CAPI integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
anantjain45823 committed May 16, 2024
1 parent a06ddce commit 8955511
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/cdk/v2/destinations/reddit/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ steps:
const os = (.message.context.os.name)? .message.context.os.name.toLowerCase(): null;
const hashData = .destination.Config.hashData;
let user = .message.().({
"email": hashData ? $.SHA256({{{{$.getGenericPaths("email")}}}}) : ({{{{$.getGenericPaths("email")}}}}),
"external_id": hashData ? $.SHA256({{{{$.getGenericPaths("userId")}}}}) : ({{{{$.getGenericPaths("userId")}}}}),
"ip_address": hashData? $.SHA256(.context.ip || .request_ip) : (.context.ip || .request_ip),
"email": hashData ? $.SHA256({{{{$.getGenericPaths("email")}}}}.trim()) : ({{{{$.getGenericPaths("email")}}}}),
"external_id": hashData ? $.SHA256({{{{$.getGenericPaths("userId")}}}}.trim()) : ({{{{$.getGenericPaths("userId")}}}}),
"ip_address": hashData? $.SHA256(.context.ip.trim() || .request_ip.trim()) : (.context.ip || .request_ip),
"uuid": .properties.uuid,
"user_agent": .context.userAgent,
"idfa": $.isAppleFamily(os)? (hashData? $.SHA256(.context.device.advertisingId): .context.device.advertisingId): null,
"aaid": os === "android" && .context.device ? (hashData? $.SHA256(.context.device.advertisingId): .context.device.advertisingId): null,
"idfa": $.isAppleFamily(os)? (hashData? $.SHA256(.context.device.advertisingId.trim()): .context.device.advertisingId): null,
"aaid": os === "android" && .context.device ? (hashData? $.SHA256(.context.device.advertisingId.trim()): .context.device.advertisingId): null,
"opt_out": .properties.optOut,
"screen_dimensions": {"width": .context.screen.width, "height": .context.screen.height},
});
Expand Down
6 changes: 3 additions & 3 deletions src/v0/destinations/pinterest_tag/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const getHashedValue = (key, value) => {
case 'fn':
case 'ge':
value = Array.isArray(value)
? value.map((val) => val.toString().toLowerCase())
: value.toString().toLowerCase();
? value.map((val) => val.toString().trim().toLowerCase())
: value.toString().trim().toLowerCase();
break;
case 'ph':
// phone numbers should only contain digits & should not contain leading zeros
Expand All @@ -53,7 +53,7 @@ const getHashedValue = (key, value) => {
case 'zp':
// zip fields should only contain digits
value = Array.isArray(value)
? value.map((val) => val.toString().replace(/\D/g, ''))
? value.map((val) => val.toString().trim().replace(/\D/g, ''))
: value.toString().replace(/\D/g, '');
break;
case 'hashed_maids':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const data = [
userAgent: 'chrome',
traits: {
anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1',
email: '[email protected]',
phone: '+1234589947',
email: ' [email protected]',
phone: '+1234589947 ',
gender: 'non-binary',
db: '19950715',
lastname: 'Rudderlabs',
Expand Down
8 changes: 4 additions & 4 deletions test/integrations/destinations/reddit/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ export const data = [
message: {
context: {
traits: {
email: '[email protected]',
email: '[email protected] ',
},
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
ip: '54.100.200.255',
ip: ' 54.100.200.255',
device: {
advertisingId: 'asfds7fdsihf734b34j43f',
advertisingId: ' asfds7fdsihf734b34j43f',
},
os: {
name: 'android',
Expand All @@ -29,7 +29,7 @@ export const data = [
originalTimestamp: '2019-10-14T09:03:17.562Z',
anonymousId: '123456',
event: 'Order Completed',
userId: 'testuserId1',
userId: ' testuserId1',
properties: {
checkout_id: '12345',
order_id: '1234',
Expand Down

0 comments on commit 8955511

Please sign in to comment.