Skip to content

Commit 80e7f52

Browse files
committed
rename mappedEmailShaIdentityType for conciseness
1 parent 79918e0 commit 80e7f52

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/roktManager.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default class RoktManager {
9999
private launcherOptions?: IRoktLauncherOptions;
100100
private logger: SDKLoggerApi;
101101
private domain?: string;
102-
private normalizedHashedEmailUserIdentityType?: string | null;
102+
private mappedEmailShaIdentityType?: string | null;
103103
/**
104104
* Initializes the RoktManager with configuration settings and user data.
105105
*
@@ -121,7 +121,7 @@ export default class RoktManager {
121121
): void {
122122
const { userAttributeFilters, settings } = roktConfig || {};
123123
const { placementAttributesMapping, hashedEmailUserIdentityType } = settings || {};
124-
this.normalizedHashedEmailUserIdentityType = hashedEmailUserIdentityType?.toLowerCase() ?? null;
124+
this.mappedEmailShaIdentityType = hashedEmailUserIdentityType?.toLowerCase() ?? null;
125125

126126
this.identityService = identityService;
127127
this.store = store;
@@ -190,15 +190,14 @@ export default class RoktManager {
190190

191191
const currentEmail = currentUserIdentities.email;
192192
const newEmail = mappedAttributes.email as string;
193-
const mappedEmailShaIdentityType = this.normalizedHashedEmailUserIdentityType;
194193

195194
let currentHashedEmail: string | undefined;
196195
let newHashedEmail: string | undefined;
197196

198197
// Hashed email identity is valid if it is set to Other-Other10
199198

200-
if(mappedEmailShaIdentityType && IdentityType.getIdentityType(mappedEmailShaIdentityType) !== false) {
201-
currentHashedEmail = currentUserIdentities[mappedEmailShaIdentityType];
199+
if(this.mappedEmailShaIdentityType && IdentityType.getIdentityType(this.mappedEmailShaIdentityType) !== false) {
200+
currentHashedEmail = currentUserIdentities[this.mappedEmailShaIdentityType];
202201
newHashedEmail = mappedAttributes['emailsha256'] as string || undefined;
203202
}
204203

@@ -214,8 +213,8 @@ export default class RoktManager {
214213
}
215214

216215
if (hashedEmailChanged) {
217-
newIdentities[mappedEmailShaIdentityType] = newHashedEmail;
218-
this.logger.warning(`emailsha256 mismatch detected. Current mParticle ${mappedEmailShaIdentityType} identity, ${currentHashedEmail}, differs from 'emailsha256' passed to selectPlacements call, ${newHashedEmail}. Proceeding to call identify with ${mappedEmailShaIdentityType} set to ${newHashedEmail}. Please verify your implementation`);
216+
newIdentities[this.mappedEmailShaIdentityType] = newHashedEmail;
217+
this.logger.warning(`emailsha256 mismatch detected. Current mParticle ${this.mappedEmailShaIdentityType} identity, ${currentHashedEmail}, differs from 'emailsha256' passed to selectPlacements call, ${newHashedEmail}. Proceeding to call identify with ${this.mappedEmailShaIdentityType} set to ${newHashedEmail}. Please verify your implementation`);
219218
}
220219

221220
if (!isEmpty(newIdentities)) {

test/jest/roktManager.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,15 @@ describe('RoktManager', () => {
365365
expect(roktManager['domain']).toBe(domain);
366366
});
367367

368-
it('should set normalizedHashedEmailUserIdentityType as a lowercase hashedEmailUserIdentityType when passed as a setting', () => {
368+
it('should set mappedEmailShaIdentityType as a lowercase hashedEmailUserIdentityType when passed as a setting', () => {
369369
roktManager.init(
370370
{settings: {hashedEmailUserIdentityType: 'Other5'}} as unknown as IKitConfigs,
371371
undefined,
372372
mockMPInstance.Identity,
373373
mockMPInstance._Store,
374374
mockMPInstance.Logger,
375375
);
376-
expect(roktManager['normalizedHashedEmailUserIdentityType']).toBe('other5');
376+
expect(roktManager['mappedEmailShaIdentityType']).toBe('other5');
377377
});
378378
});
379379

@@ -1054,7 +1054,7 @@ describe('RoktManager', () => {
10541054
};
10551055

10561056
roktManager.kit = kit as IRoktKit;
1057-
roktManager['normalizedHashedEmailUserIdentityType'] ='other5';
1057+
roktManager['mappedEmailShaIdentityType'] ='other5';
10581058

10591059
// Set up fresh mocks for this test
10601060
const mockIdentity = {
@@ -1108,7 +1108,7 @@ describe('RoktManager', () => {
11081108
};
11091109

11101110
roktManager.kit = kit as IRoktKit;
1111-
roktManager['normalizedHashedEmailUserIdentityType'] = 'other5';
1111+
roktManager['mappedEmailShaIdentityType'] = 'other5';
11121112

11131113
// Set up fresh mocks for this test
11141114
const mockIdentity = {
@@ -1150,7 +1150,7 @@ describe('RoktManager', () => {
11501150
};
11511151

11521152
roktManager.kit = kit as IRoktKit;
1153-
roktManager['normalizedHashedEmailUserIdentityType'] = 'other';
1153+
roktManager['mappedEmailShaIdentityType'] = 'other';
11541154

11551155
const mockIdentity = {
11561156
getCurrentUser: jest.fn().mockReturnValue({

0 commit comments

Comments
 (0)