Differentiate enabled and disabled selected plugins in analytics
Summary: As we now allow selection of disabled plugins we need to track plugin usage a bit smarter. We'll add a new field "pluginEnabled" to the logged messages to indicate whether selected plugin is enabled or not. Reviewed By: cekkaewnumchai Differential Revision: D29455248 fbshipit-source-id: 32c79e0961653edc8f4cc89adecc2662b37cbd7b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
142859f0ed
commit
4ad7a70ee3
@@ -15,6 +15,7 @@ const layoutSelection: SelectionInfo = {
|
|||||||
plugin: 'Layout',
|
plugin: 'Layout',
|
||||||
pluginName: 'flipper-plugin-layout',
|
pluginName: 'flipper-plugin-layout',
|
||||||
pluginVersion: '0.0.0',
|
pluginVersion: '0.0.0',
|
||||||
|
pluginEnabled: true,
|
||||||
app: 'Facebook',
|
app: 'Facebook',
|
||||||
device: 'test device',
|
device: 'test device',
|
||||||
deviceName: 'test device',
|
deviceName: 'test device',
|
||||||
|
|||||||
@@ -84,15 +84,8 @@ export default (store: Store, logger: Logger) => {
|
|||||||
noTimeBudgetWarns: true,
|
noTimeBudgetWarns: true,
|
||||||
runSynchronously: true,
|
runSynchronously: true,
|
||||||
},
|
},
|
||||||
(state) => ({
|
getSelectionInfo,
|
||||||
connections: state.connections,
|
(selection, store) => {
|
||||||
loadedPlugins: state.plugins.loadedPlugins,
|
|
||||||
}),
|
|
||||||
(state, store) => {
|
|
||||||
const selection = getSelectionInfo(
|
|
||||||
state.connections,
|
|
||||||
state.loadedPlugins,
|
|
||||||
);
|
|
||||||
const time = Date.now();
|
const time = Date.now();
|
||||||
store.dispatch(selectionChanged({selection, time}));
|
store.dispatch(selectionChanged({selection, time}));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ describe('info', () => {
|
|||||||
"deviceType": "physical",
|
"deviceType": "physical",
|
||||||
"os": "Android",
|
"os": "Android",
|
||||||
"plugin": "Network",
|
"plugin": "Network",
|
||||||
|
"pluginEnabled": true,
|
||||||
"pluginName": "flipper-plugin-network",
|
"pluginName": "flipper-plugin-network",
|
||||||
"pluginVersion": "0.78.0",
|
"pluginVersion": "0.78.0",
|
||||||
}
|
}
|
||||||
@@ -102,6 +103,7 @@ describe('info', () => {
|
|||||||
"deviceType": "physical",
|
"deviceType": "physical",
|
||||||
"os": "Android",
|
"os": "Android",
|
||||||
"plugin": "Inspector",
|
"plugin": "Inspector",
|
||||||
|
"pluginEnabled": true,
|
||||||
"pluginName": "flipper-plugin-inspector",
|
"pluginName": "flipper-plugin-inspector",
|
||||||
"pluginVersion": "0.59.0",
|
"pluginVersion": "0.59.0",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export type SelectionInfo = {
|
|||||||
plugin: string | null;
|
plugin: string | null;
|
||||||
pluginName: string | null;
|
pluginName: string | null;
|
||||||
pluginVersion: string | null;
|
pluginVersion: string | null;
|
||||||
|
pluginEnabled: boolean | null;
|
||||||
app: string | null;
|
app: string | null;
|
||||||
os: string | null;
|
os: string | null;
|
||||||
device: string | null;
|
device: string | null;
|
||||||
@@ -47,6 +48,7 @@ let selection: SelectionInfo = {
|
|||||||
plugin: null,
|
plugin: null,
|
||||||
pluginName: null,
|
pluginName: null,
|
||||||
pluginVersion: null,
|
pluginVersion: null,
|
||||||
|
pluginEnabled: null,
|
||||||
app: null,
|
app: null,
|
||||||
os: null,
|
os: null,
|
||||||
device: null,
|
device: null,
|
||||||
@@ -66,12 +68,9 @@ export default (store: Store, _logger: Logger) => {
|
|||||||
runSynchronously: true,
|
runSynchronously: true,
|
||||||
fireImmediately: true,
|
fireImmediately: true,
|
||||||
},
|
},
|
||||||
(state) => ({
|
getSelectionInfo,
|
||||||
connections: state.connections,
|
(newSelection, _store) => {
|
||||||
loadedPlugins: state.plugins.loadedPlugins,
|
selection = newSelection;
|
||||||
}),
|
|
||||||
(state, _store) => {
|
|
||||||
selection = getSelectionInfo(state.connections, state.loadedPlugins);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -127,25 +126,38 @@ export function stringifyInfo(info: Info): string {
|
|||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSelectionInfo(
|
export function getSelectionInfo({
|
||||||
connections: State['connections'],
|
plugins: {clientPlugins, devicePlugins, loadedPlugins},
|
||||||
loadedPlugins: State['plugins']['loadedPlugins'],
|
connections: {
|
||||||
): SelectionInfo {
|
selectedApp,
|
||||||
const selectedApp = connections.selectedApp;
|
selectedPlugin,
|
||||||
|
enabledDevicePlugins,
|
||||||
|
enabledPlugins,
|
||||||
|
selectedDevice,
|
||||||
|
},
|
||||||
|
}: State): SelectionInfo {
|
||||||
const clientIdParts = selectedApp ? deconstructClientId(selectedApp) : null;
|
const clientIdParts = selectedApp ? deconstructClientId(selectedApp) : null;
|
||||||
const loadedPlugin = connections.selectedPlugin
|
const loadedPlugin = selectedPlugin
|
||||||
? loadedPlugins.get(connections.selectedPlugin)
|
? loadedPlugins.get(selectedPlugin)
|
||||||
: null;
|
: null;
|
||||||
|
const pluginEnabled =
|
||||||
|
!!selectedPlugin &&
|
||||||
|
((enabledDevicePlugins.has(selectedPlugin) &&
|
||||||
|
devicePlugins.has(selectedPlugin)) ||
|
||||||
|
(clientIdParts &&
|
||||||
|
enabledPlugins[clientIdParts.app]?.includes(selectedPlugin) &&
|
||||||
|
clientPlugins.has(selectedPlugin)));
|
||||||
return {
|
return {
|
||||||
plugin: connections.selectedPlugin || null,
|
plugin: selectedPlugin || null,
|
||||||
pluginName: loadedPlugin?.name || null,
|
pluginName: loadedPlugin?.name || null,
|
||||||
pluginVersion: loadedPlugin?.version || null,
|
pluginVersion: loadedPlugin?.version || null,
|
||||||
|
pluginEnabled,
|
||||||
app: clientIdParts?.app || null,
|
app: clientIdParts?.app || null,
|
||||||
device: connections.selectedDevice?.title || null,
|
device: selectedDevice?.title || null,
|
||||||
deviceName: clientIdParts?.device || null,
|
deviceName: clientIdParts?.device || null,
|
||||||
deviceSerial: connections.selectedDevice?.serial || null,
|
deviceSerial: selectedDevice?.serial || null,
|
||||||
deviceType: connections.selectedDevice?.deviceType || null,
|
deviceType: selectedDevice?.deviceType || null,
|
||||||
os: connections.selectedDevice?.os || null,
|
os: selectedDevice?.os || null,
|
||||||
archived: connections.selectedDevice?.isArchived || false,
|
archived: selectedDevice?.isArchived || false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user