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
This commit is contained in:
Pritesh Nandgaonkar
2020-02-04 06:23:27 -08:00
committed by Facebook Github Bot
parent e48966f529
commit 76bf84cb20
2 changed files with 44 additions and 6 deletions

View File

@@ -28,11 +28,14 @@ import {
PluginName, PluginName,
ListItem, ListItem,
} from './sidebarUtils'; } from './sidebarUtils';
import {Group} from '../../reducers/supportForm';
import {getInstance} from '../../fb-stubs/Logger';
type OwnProps = {}; type OwnProps = {};
type StateFromProps = { type StateFromProps = {
staticView: StaticView; staticView: StaticView;
selectedGroup: Group;
}; };
type DispatchFromProps = { type DispatchFromProps = {
@@ -44,6 +47,7 @@ type Props = OwnProps & StateFromProps & DispatchFromProps;
function MainSidebarUtilsSection({ function MainSidebarUtilsSection({
staticView, staticView,
selectedGroup,
setActiveSheet, setActiveSheet,
setStaticView, setStaticView,
}: Props) { }: Props) {
@@ -86,7 +90,13 @@ function MainSidebarUtilsSection({
return ( return (
<ListItem <ListItem
active={active} active={active}
onClick={() => setStaticView(SupportRequestFormV2)}> onClick={() => {
getInstance().track('usage', 'support-form-source', {
source: 'sidebar',
group: selectedGroup.name,
});
setStaticView(SupportRequestFormV2);
}}>
<PluginIcon <PluginIcon
color={colors.light50} color={colors.light50}
name={'app-dailies'} name={'app-dailies'}
@@ -112,8 +122,9 @@ function MainSidebarUtilsSection({
} }
export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>( export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
({connections: {staticView}}) => ({ ({connections: {staticView}, supportForm: {supportFormV2}}) => ({
staticView, staticView,
selectedGroup: supportFormV2.selectedGroup,
}), }),
{ {
setStaticView, setStaticView,

View File

@@ -17,6 +17,11 @@ import {selectedPlugins as setSelectedPlugins} from './plugins';
import {getEnabledOrExportPersistedStatePlugins} from '../utils/pluginUtils'; import {getEnabledOrExportPersistedStatePlugins} from '../utils/pluginUtils';
import {addStatusMessage, removeStatusMessage} from './application'; import {addStatusMessage, removeStatusMessage} from './application';
import constants from '../fb-stubs/constants'; 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 { const {
GRAPHQL_IOS_SUPPORT_GROUP_ID, GRAPHQL_IOS_SUPPORT_GROUP_ID,
GRAPHQL_ANDROID_SUPPORT_GROUP_ID, GRAPHQL_ANDROID_SUPPORT_GROUP_ID,
@@ -68,12 +73,16 @@ export class Group {
} }
handleSupportFormDeeplinks(store: Store) { handleSupportFormDeeplinks(store: Store) {
// TODO: Incorporate grp info in analytics. getInstance().track('usage', 'support-form-source', {
source: 'deeplink',
group: this.name,
});
store.dispatch(setStaticView(SupportRequestFormV2)); store.dispatch(setStaticView(SupportRequestFormV2));
const selectedApp = store.getState().connections.selectedApp; const selectedApp = store.getState().connections.selectedApp;
const selectedClient = store.getState().connections.clients.find(o => { const selectedClient = store.getState().connections.clients.find(o => {
return o.id === store.getState().connections.selectedApp; return o.id === store.getState().connections.selectedApp;
}); });
let errorMessage: string | undefined = undefined;
if (selectedApp) { if (selectedApp) {
const {app} = deconstructClientId(selectedApp); const {app} = deconstructClientId(selectedApp);
const enabledPlugins: Array<string> | null = store.getState().connections const enabledPlugins: Array<string> | null = store.getState().connections
@@ -101,10 +110,16 @@ export class Group {
} }
} }
if (unsupportedPlugins.length > 0) { 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( showStatusUpdatesForDuration(
`The current client does not support ${unsupportedPlugins.join( errorMessage,
', ',
)}. Please change the app from the dropdown in the support form.`,
'Deeplink', 'Deeplink',
10000, 10000,
payload => { payload => {
@@ -116,6 +131,8 @@ export class Group {
); );
} }
} else { } else {
errorMessage =
'Selected app is null, thus the deeplink failed to enable required plugin.';
showStatusUpdatesForDuration( showStatusUpdatesForDuration(
'Please select an app and the device from the dropdown.', 'Please select an app and the device from the dropdown.',
'Deeplink', 'Deeplink',
@@ -149,6 +166,16 @@ export class Group {
}), }),
), ),
); );
logPlatformSuccessRate(
`${SUPPORT_FORM_PREFIX}-deeplink`,
errorMessage
? {
kind: 'failure',
supportedOperation: true,
error: errorMessage,
}
: {kind: 'success'},
);
} }
} }