Skip to content

Commit fa03a20

Browse files
committed
update logger warning and error message to exclude user attributes
1 parent ccc9f30 commit fa03a20

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/roktManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export default class RoktManager {
295295

296296
} catch (error) {
297297
const errorMessage = error instanceof Error ? error.message : String(error);
298-
this.logger.error(`Failed to hash "${attributes}", selectPlacements will continue: ${errorMessage}`);
298+
this.logger.error(`Failed to hashAttributes, returning an empty object: ${errorMessage}`);
299299
return {};
300300
}
301301
}
@@ -335,7 +335,7 @@ export default class RoktManager {
335335
*/
336336
public async hashSha256(attribute: string | number | boolean | undefined | null): Promise<string | undefined | null> {
337337
if (attribute === null || attribute === undefined) {
338-
this.logger.warning(`hashSha256 received ${attribute} as input`);
338+
this.logger.warning(`hashSha256 received null/undefined as input`);
339339
return attribute as null | undefined;
340340
}
341341

@@ -344,7 +344,7 @@ export default class RoktManager {
344344
return await this.sha256Hex(normalizedValue);
345345
} catch (error) {
346346
const errorMessage = error instanceof Error ? error.message : String(error);
347-
this.logger.error(`Failed to hash "${attribute}" and returning undefined: ${errorMessage}`);
347+
this.logger.error(`Failed to hashSha256 and returning undefined: ${errorMessage}`);
348348
return undefined;
349349
}
350350
}

test/jest/roktManager.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ describe('RoktManager', () => {
157157

158158
expect(result).toEqual({});
159159
expect(mockMPInstance.Logger.error).toHaveBeenCalledWith(
160-
expect.stringContaining('Failed to hash "')
160+
expect.stringContaining('Failed to hashAttributes, returning an empty object: Hashing failed')
161161
);
162162
});
163163
});
@@ -207,14 +207,14 @@ describe('RoktManager', () => {
207207
const result = await roktManager.hashSha256(null);
208208

209209
expect(result).toBeNull();
210-
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith('hashSha256 received null as input');
210+
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith('hashSha256 received null/undefined as input');
211211
});
212212

213213
it('should return undefined and log warning when value is undefined', async () => {
214214
const result = await roktManager.hashSha256(undefined);
215215

216216
expect(result).toBeUndefined();
217-
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith('hashSha256 received undefined as input');
217+
expect(mockMPInstance.Logger.warning).toHaveBeenCalledWith('hashSha256 received null/undefined as input');
218218
});
219219

220220
it('should return undefined and log error when hashing fails', async () => {
@@ -224,7 +224,7 @@ describe('RoktManager', () => {
224224

225225
expect(result).toBeUndefined();
226226
expect(mockMPInstance.Logger.error).toHaveBeenCalledWith(
227-
expect.stringContaining('Failed to hash "[email protected]" and returning undefined')
227+
expect.stringContaining('Failed to hashSha256 and returning undefined: Hash failed')
228228
);
229229
});
230230

0 commit comments

Comments
 (0)