Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ANALYTICS] Improve SRP reveal metrics #4798

Merged
merged 11 commits into from
Aug 16, 2022
2 changes: 2 additions & 0 deletions app/components/UI/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export function getNavigationOptionsTitle(
navigation,
isFullScreenModal,
themeColors,
navigationPopEvent,
) {
const innerStyles = StyleSheet.create({
headerTitleStyle: {
Expand All @@ -188,6 +189,7 @@ export function getNavigationOptionsTitle(
},
});
function navigationPop() {
if (navigationPopEvent) trackEvent(navigationPopEvent);
navigation.pop();
}
return {
Expand Down
33 changes: 32 additions & 1 deletion app/components/Views/RevealPrivateCredential/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,17 @@ class RevealPrivateCredential extends PureComponent {
navigation,
false,
colors,
AnalyticsV2.ANALYTICS_EVENTS.GO_BACK_SRP_SCREEN,
),
);
};

async componentDidMount() {
this.updateNavBar();
// Track SRP Reveal screen rendered
if (!this.isPrivateKey()) {
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.REVEAL_SRP_SCREEN);
}
// Try to use biometrics to unloc
// (if available)
const biometryType = await SecureKeychain.getSupportedBiometryType();
Expand Down Expand Up @@ -289,6 +294,10 @@ class RevealPrivateCredential extends PureComponent {
{ view: 'Enter password' },
);

if (!this.isPrivateKey())
AnalyticsV2.trackEvent(
AnalyticsV2.ANALYTICS_EVENTS.CANCEL_REVEAL_SRP_CTA,
);
if (this.props.cancel) return this.props.cancel();
this.navigateBack();
};
Expand All @@ -298,6 +307,12 @@ class RevealPrivateCredential extends PureComponent {
navigation.pop();
};

done = () => {
if (!this.isPrivateKey())
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SRP_DONE_CTA);
this.navigateBack();
};

async tryUnlockWithPassword(password, privateCredentialName) {
const { KeyringController } = Engine.context;
const { selectedAddress } = this.props;
Expand Down Expand Up @@ -345,6 +360,8 @@ class RevealPrivateCredential extends PureComponent {
}

tryUnlock = () => {
if (!this.isPrivateKey())
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.NEXT_REVEAL_SRP_CTA);
this.setState({ isModalVisible: true });
};

Expand All @@ -360,6 +377,9 @@ class RevealPrivateCredential extends PureComponent {
{ action: 'copied to clipboard' },
);

if (!this.isPrivateKey())
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.COPY_SRP);

const { clipboardPrivateCredential } = this.state;
await ClipboardManager.setStringExpire(clipboardPrivateCredential);

Expand Down Expand Up @@ -423,13 +443,19 @@ class RevealPrivateCredential extends PureComponent {
: AnalyticsV2.ANALYTICS_EVENTS.REVEAL_SRP_COMPLETED,
{ action: 'viewed SRP' },
);

if (!this.isPrivateKey())
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.VIEW_SRP);
} else if (event.i === 1) {
AnalyticsV2.trackEvent(
this.isPrivateKey()
? AnalyticsV2.ANALYTICS_EVENTS.REVEAL_PRIVATE_KEY_COMPLETED
: AnalyticsV2.ANALYTICS_EVENTS.REVEAL_SRP_COMPLETED,
{ action: 'viewed QR code' },
);

if (!this.isPrivateKey())
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.VIEW_SRP_QR);
}
};

Expand Down Expand Up @@ -535,6 +561,11 @@ class RevealPrivateCredential extends PureComponent {
{ view: 'Hold to reveal' },
);

if (!this.isPrivateKey())
AnalyticsV2.trackEvent(
AnalyticsV2.ANALYTICS_EVENTS.SRP_DISMISS_HOLD_TO_REVEAL_DIALOG,
);

this.setState({
isModalVisible: false,
});
Expand Down Expand Up @@ -669,7 +700,7 @@ class RevealPrivateCredential extends PureComponent {
: strings('reveal_credential.cancel')
}
confirmText={strings('reveal_credential.confirm')}
onCancelPress={unlocked ? this.navigateBack : this.cancel}
onCancelPress={unlocked ? this.done : this.cancel}
testID={`next-button`}
onConfirmPress={() => this.tryUnlock()}
showConfirmButton={!unlocked}
Expand Down
2 changes: 2 additions & 0 deletions app/components/Views/Settings/SecuritySettings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ class Settings extends PureComponent {

componentDidMount = async () => {
this.updateNavBar();
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.VIEW_SECURITY_SETTINGS);
const biometryType = await SecureKeychain.getSupportedBiometryType();
const analyticsEnabled = Analytics.checkEnabled();
const currentSeedphraseHints = await AsyncStorage.getItem(
Expand Down Expand Up @@ -590,6 +591,7 @@ class Settings extends PureComponent {

goToRevealPrivateCredential = () => {
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.REVEAL_SRP_INITIATED);
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.REVEAL_SRP_CTA);
this.props.navigation.navigate('RevealPrivateCredentialView', {
privateCredentialName: 'seed_phrase',
});
Expand Down
20 changes: 18 additions & 2 deletions app/util/analyticsV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,27 @@ export const ANALYTICS_EVENTS_V2 = {
BROWSER_SHARE_SITE: generateOpt('Shared A Site'),
BROWSER_RELOAD: generateOpt('Reload Browser'),
BROWSER_ADD_FAVORITES: generateOpt('Added Site To Favorites'),
// Settings
// Reveal Credentials
// Security & Privacy Settings
VIEW_SECURITY_SETTINGS: generateOpt('Views Security & Privacy'),
// Reveal SRP
REVEAL_SRP_CTA: generateOpt('Clicks Reveal Secret Recovery Phrase'),
REVEAL_SRP_SCREEN: generateOpt('Views Reveal Secret Recovery Phrase'),
GO_BACK_SRP_SCREEN: generateOpt('Clicked Back on Reveal SRP Password Page'),
CANCEL_REVEAL_SRP_CTA: generateOpt(
'Clicks Cancel on Reveal Secret Recovery Phrase Page',
),
NEXT_REVEAL_SRP_CTA: generateOpt(
'Clicks Next on Reveal Secret Recovery Phrase',
),
VIEW_SRP: generateOpt('Views SRP'),
SRP_DISMISS_HOLD_TO_REVEAL_DIALOG: generateOpt('Closes Hold To Reveal SRP'),
VIEW_SRP_QR: generateOpt('Views SRP QR code'),
COPY_SRP: generateOpt('Copies SRP to clipboard'),
SRP_DONE_CTA: generateOpt('Clicks Done with SRP'),
REVEAL_SRP_INITIATED: generateOpt('Reveal SRP Initiated'),
REVEAL_SRP_CANCELLED: generateOpt('Reveal SRP Cancelled'),
REVEAL_SRP_COMPLETED: generateOpt('Reveal SRP Completed'),
// Reveal Private Key
REVEAL_PRIVATE_KEY_INITIATED: generateOpt('Reveal Private Key Initiated'),
REVEAL_PRIVATE_KEY_CANCELLED: generateOpt('Reveal Private Key Cancelled'),
REVEAL_PRIVATE_KEY_COMPLETED: generateOpt('Reveal Private Key Completed'),
Expand Down