-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move generateHash methods into utility class (#531)
- Loading branch information
1 parent
2d3d575
commit 029f51e
Showing
10 changed files
with
528 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,7 @@ | |
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.6.0", | ||
"jest-environment-jsdom": "^29.5.0", | ||
"slugify": "^1.3.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { generateHash } from "./utils"; | ||
// TODO: https://mparticle-eng.atlassian.net/browse/SQDSDKS-5381 | ||
import { EventTypeEnum, IdentityType } from "./types.interfaces"; | ||
import Constants from './constants'; | ||
|
||
export default class KitFilterHelper { | ||
static hashEventType(eventType: EventTypeEnum): number { | ||
return generateHash(eventType as unknown as string); | ||
}; | ||
|
||
static hashEventName(eventName: string, eventType: EventTypeEnum): number { | ||
return generateHash(eventType + eventName); | ||
}; | ||
|
||
static hashEventAttributeKey(eventType: EventTypeEnum, eventName: string, customAttributeName: string): number { | ||
return generateHash(eventType + eventName + customAttributeName); | ||
} | ||
|
||
static hashUserAttribute(userAttributeKey: string): number { | ||
return generateHash(userAttributeKey); | ||
} | ||
|
||
// User Identities are not actually hashed, this method is named this way to | ||
// be consistent with the filter class. UserIdentityType is also a number | ||
static hashUserIdentity(userIdentity: IdentityType): IdentityType { | ||
return userIdentity; | ||
} | ||
|
||
static hashConsentPurpose(prefix: string, purpose: string){ | ||
return generateHash(prefix + purpose) | ||
|
||
} | ||
|
||
// The methods below are for conditional forwarding, a type of filter | ||
// hashAttributeCondiitonalForwarding is used for both User and Event | ||
// attribute keys and attribute values | ||
// The backend returns the hashes as strings for conditional forwarding | ||
// but returns "regular" filters as arrays of numbers | ||
// See IFilteringEventAttributeValue in configApiClient.ts as an example | ||
static hashAttributeConditionalForwarding(attribute: string): string { | ||
return generateHash(attribute).toString(); | ||
} | ||
|
||
static hashConsentPurposeConditionalForwarding(prefix: string, purpose: string): string { | ||
return this.hashConsentPurpose(prefix, purpose).toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export enum EventTypeEnum { | ||
Unknown, | ||
Navigation, | ||
Location, | ||
Search, | ||
Transaction, | ||
UserContent, | ||
UserPreference, | ||
Social, | ||
Other, | ||
Media, | ||
} | ||
|
||
export enum IdentityType { | ||
Other = 0, | ||
CustomerId = 1, | ||
Facebook = 2, | ||
Twitter = 3, | ||
Google = 4, | ||
Microsoft = 5, | ||
Yahoo = 6, | ||
Email = 7, | ||
FacebookCustomAudienceId = 9, | ||
Other2 = 10, | ||
Other3 = 11, | ||
Other4 = 12, | ||
Other5 = 13, | ||
Other6 = 14, | ||
Other7 = 15, | ||
Other8 = 16, | ||
Other9 = 17, | ||
Other10 = 18, | ||
MobileNumber = 19, | ||
PhoneNumber2 = 20, | ||
PhoneNumber3 = 21, | ||
} |
Oops, something went wrong.