From 98ed93ee5bd9da1bd937e5c1c714f76f74a144bf Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 15 Jun 2018 16:59:42 +0100 Subject: [PATCH] Don't hash the eventId (it's uneccessary) --- src/DecryptionFailureTracker.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/DecryptionFailureTracker.js b/src/DecryptionFailureTracker.js index e668884f64..2a7f2a4e26 100644 --- a/src/DecryptionFailureTracker.js +++ b/src/DecryptionFailureTracker.js @@ -21,10 +21,6 @@ class DecryptionFailure { } } -function eventIdHash(eventId) { - return crypto.subtle.digest('SHA-256', eventId); -} - export default class DecryptionFailureTracker { // Array of items of type DecryptionFailure. Every `CHECK_INTERVAL_MS`, this list // is checked for failures that happened > `GRACE_PERIOD_MS` ago. Those that did @@ -37,7 +33,7 @@ export default class DecryptionFailureTracker { // Event IDs of failures that were tracked previously trackedEventHashMap = { - // [eventIdHash(eventId)]: true + // [eventId]: true }; // Spread the load on `Analytics` by sending at most 1 event per @@ -130,7 +126,7 @@ export default class DecryptionFailureTracker { // Only track one failure per event const dedupedFailuresMap = failuresGivenGrace.reduce( (map, failure) => { - if (!this.trackedEventHashMap[eventIdHash(failure.failedEventId)]) { + if (!this.trackedEventHashMap[failure.failedEventId]) { return map.set(failure.failedEventId, failure); } else { return map; @@ -143,7 +139,7 @@ export default class DecryptionFailureTracker { const trackedEventIds = [...dedupedFailuresMap.keys()]; this.trackedEventHashMap = trackedEventIds.reduce( - (result, eventId) => ({...result, [eventIdHash(eventId)]: true}), + (result, eventId) => ({...result, [eventId]: true}), this.trackedEventHashMap, );