Add segment metrics for plugin data context (#3903)

This commit is contained in:
Opender Singh 2021-08-12 15:04:48 +12:00 committed by GitHub
parent 18e7f49b43
commit 63fd9bc3a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { trackSegmentEvent } from '../../common/analytics';
import { exportWorkspacesData, exportWorkspacesHAR } from '../../common/export';
import type { ImportRawConfig } from '../../common/import';
import { importRaw, importUri } from '../../common/import';
@ -26,11 +27,15 @@ const buildImportRawConfig = (options: PluginImportOptions, activeSpaceId: strin
getSpaceId: () => Promise.resolve(activeSpaceId),
});
// TODO: add metrics here to track how frequently this fallback is being used
const getWorkspaces = (activeSpaceId?: string) =>
activeSpaceId
? models.workspace.findByParentId(activeSpaceId)
: models.workspace.all();
const getWorkspaces = (activeSpaceId?: string) => {
if (activeSpaceId) {
trackSegmentEvent('Plugin export loading workspaces for active space');
return models.workspace.findByParentId(activeSpaceId);
} else {
trackSegmentEvent('Plugin export loading all workspace');
return models.workspace.all();
}
};
// Only in the case of running unit tests from Inso via send-request can activeSpaceId be undefined. This is because the concept of a space doesn't exist in git/insomnia sync or an export file
export const init = (activeSpaceId?: string) => ({