From 76bf84cb20291b402b5f8f9b420a3da50c0cffd1 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 4 Feb 2020 06:23:27 -0800 Subject: [PATCH] More analytics and added analytics for groups Summary: Adds analytics for the selected group, failure cases and distinguishing between user clicks for the support form vs deeplink. Reviewed By: passy Differential Revision: D19697856 fbshipit-source-id: 62d5afa998d2096252570387c9a3df1c7c134e67 --- .../mainsidebar/MainSidebarUtilsSection.tsx | 15 ++++++-- src/reducers/supportForm.tsx | 35 ++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/chrome/mainsidebar/MainSidebarUtilsSection.tsx b/src/chrome/mainsidebar/MainSidebarUtilsSection.tsx index 15b72abb9..33dadddc7 100644 --- a/src/chrome/mainsidebar/MainSidebarUtilsSection.tsx +++ b/src/chrome/mainsidebar/MainSidebarUtilsSection.tsx @@ -28,11 +28,14 @@ import { PluginName, ListItem, } from './sidebarUtils'; +import {Group} from '../../reducers/supportForm'; +import {getInstance} from '../../fb-stubs/Logger'; type OwnProps = {}; type StateFromProps = { staticView: StaticView; + selectedGroup: Group; }; type DispatchFromProps = { @@ -44,6 +47,7 @@ type Props = OwnProps & StateFromProps & DispatchFromProps; function MainSidebarUtilsSection({ staticView, + selectedGroup, setActiveSheet, setStaticView, }: Props) { @@ -86,7 +90,13 @@ function MainSidebarUtilsSection({ return ( setStaticView(SupportRequestFormV2)}> + onClick={() => { + getInstance().track('usage', 'support-form-source', { + source: 'sidebar', + group: selectedGroup.name, + }); + setStaticView(SupportRequestFormV2); + }}> ( - ({connections: {staticView}}) => ({ + ({connections: {staticView}, supportForm: {supportFormV2}}) => ({ staticView, + selectedGroup: supportFormV2.selectedGroup, }), { setStaticView, diff --git a/src/reducers/supportForm.tsx b/src/reducers/supportForm.tsx index 3fe9a8d80..04dbfa764 100644 --- a/src/reducers/supportForm.tsx +++ b/src/reducers/supportForm.tsx @@ -17,6 +17,11 @@ import {selectedPlugins as setSelectedPlugins} from './plugins'; import {getEnabledOrExportPersistedStatePlugins} from '../utils/pluginUtils'; import {addStatusMessage, removeStatusMessage} from './application'; import constants from '../fb-stubs/constants'; +import {getInstance} from '../fb-stubs/Logger'; +import {logPlatformSuccessRate} from '../utils/metrics'; + +export const SUPPORT_FORM_PREFIX = 'support-form-v2'; + const { GRAPHQL_IOS_SUPPORT_GROUP_ID, GRAPHQL_ANDROID_SUPPORT_GROUP_ID, @@ -68,12 +73,16 @@ export class Group { } handleSupportFormDeeplinks(store: Store) { - // TODO: Incorporate grp info in analytics. + getInstance().track('usage', 'support-form-source', { + source: 'deeplink', + group: this.name, + }); store.dispatch(setStaticView(SupportRequestFormV2)); const selectedApp = store.getState().connections.selectedApp; const selectedClient = store.getState().connections.clients.find(o => { return o.id === store.getState().connections.selectedApp; }); + let errorMessage: string | undefined = undefined; if (selectedApp) { const {app} = deconstructClientId(selectedApp); const enabledPlugins: Array | null = store.getState().connections @@ -101,10 +110,16 @@ export class Group { } } if (unsupportedPlugins.length > 0) { + errorMessage = `The current client does not support ${unsupportedPlugins.join( + ', ', + )}. Please change the app from the dropdown in the support form.`; + logPlatformSuccessRate(`${SUPPORT_FORM_PREFIX}-deeplink`, { + kind: 'failure', + supportedOperation: true, + error: errorMessage, + }); showStatusUpdatesForDuration( - `The current client does not support ${unsupportedPlugins.join( - ', ', - )}. Please change the app from the dropdown in the support form.`, + errorMessage, 'Deeplink', 10000, payload => { @@ -116,6 +131,8 @@ export class Group { ); } } else { + errorMessage = + 'Selected app is null, thus the deeplink failed to enable required plugin.'; showStatusUpdatesForDuration( 'Please select an app and the device from the dropdown.', 'Deeplink', @@ -149,6 +166,16 @@ export class Group { }), ), ); + logPlatformSuccessRate( + `${SUPPORT_FORM_PREFIX}-deeplink`, + errorMessage + ? { + kind: 'failure', + supportedOperation: true, + error: errorMessage, + } + : {kind: 'success'}, + ); } }