Skip to content

Commit

Permalink
[FEATURE] Add analytics for android keystore (#3292)
Browse files Browse the repository at this point in the history
* added keystore tracking event and assocaited text

* removed console logs for testing

* added optional check

* added try catch on setItem
  • Loading branch information
sethkfman authored Oct 18, 2021
1 parent d513283 commit b2eb1bd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/core/SecureKeychain.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
PASSCODE_DISABLED,
TRUE,
} from '../constants/storage';
import Device from '../util/device';
import AnalyticsV2 from '../util/analyticsV2';

const privates = new WeakMap();
const encryptor = new Encryptor();
Expand Down Expand Up @@ -37,6 +39,7 @@ class SecureKeychain {
privates.set(this, { code });
SecureKeychain.instance = this;
}

return SecureKeychain.instance;
}

Expand All @@ -53,6 +56,10 @@ let instance;
export default {
init(salt) {
instance = new SecureKeychain(salt);

if (Device.isAndroid && Keychain.SECURITY_LEVEL?.SECURE_HARDWARE)
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.ANDROID_HARDWARE_KEYSTORE);

Object.freeze(instance);
return instance;
},
Expand Down
6 changes: 5 additions & 1 deletion app/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const MigratedStorage = {
}
},
async setItem(key, value) {
return await FilesystemStorage.setItem(key, value);
try {
return await FilesystemStorage.setItem(key, value);
} catch (error) {
Logger.error(error, { message: 'Failed to set item' });
}
},
async removeItem(key) {
try {
Expand Down
2 changes: 2 additions & 0 deletions app/util/analyticsV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export const ANALYTICS_EVENTS_V2 = {
// SETTINGS
SETTINGS_TOKEN_DETECTION_ON: generateOpt(`Token detection turned ON`),
SETTINGS_TOKEN_DETECTION_OFF: generateOpt(`Token detection turned OFF`),
// KEY MANAGMENT INVESTIGATION
ANDROID_HARDWARE_KEYSTORE: generateOpt('Android Hardware Keystore'),
};

/**
Expand Down

0 comments on commit b2eb1bd

Please sign in to comment.