diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 884873f4535cc..2859d764ef26f 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -10,7 +10,6 @@ import { Adapters as Adapters_2 } from 'src/plugins/inspector/common'; import { ApiResponse } from '@elastic/elasticsearch'; import { ApiResponse as ApiResponse_2 } from '@elastic/elasticsearch/lib/Transport'; import { ApplicationStart } from 'kibana/public'; -import { ApplicationUsageTracker } from '@kbn/analytics'; import { Assign } from '@kbn/utility-types'; import { BehaviorSubject } from 'rxjs'; import { BfetchPublicSetup } from 'src/plugins/bfetch/public'; diff --git a/src/plugins/kibana_usage_collection/server/collectors/application_usage/README.md b/src/plugins/kibana_usage_collection/server/collectors/application_usage/README.md index 3e3afe88c596a..c66074b792bd0 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/application_usage/README.md +++ b/src/plugins/kibana_usage_collection/server/collectors/application_usage/README.md @@ -70,17 +70,6 @@ Application Usage will automatically track the active minutes on screen and clic The prop `viewId` is used as a unique identifier for your plugin. The Application Id is automatically attached to the tracked usage, based on the ID used when registering your app via `core.application.register`. -#### Advanced Usage - -If you have a custom use case not provided by the Application Usage helpers you can use the `usageCollection.applicationUsageTracker` public api directly. - -To start tracking a view: `applicationUsageTracker.trackApplicationViewUsage(viewId)` -Calling this method will marks the specified `viewId` as active. applicationUsageTracker will start tracking clicks and screen minutes for the view. - -To stop tracking a view: `applicationUsageTracker.flushTrackedView(viewId)` -Calling this method will stop tracking the clicks and screen minutes for that view. Usually once the view is no longer active. - - ## Application Usage Telemetry Data This collector reports the number of general clicks and minutes on screen for each registered application in Kibana. diff --git a/src/plugins/usage_collection/public/mocks.tsx b/src/plugins/usage_collection/public/mocks.tsx index 268ed3316542e..369d8009b2759 100644 --- a/src/plugins/usage_collection/public/mocks.tsx +++ b/src/plugins/usage_collection/public/mocks.tsx @@ -13,11 +13,20 @@ import { ApplicationUsageContext } from './components/track_application_view'; export type Setup = jest.Mocked; -export const createApplicationUsageTrackerMock = (): ApplicationUsageTracker => { - const applicationUsageTrackerMock: jest.Mocked = { - setCurrentAppId: jest.fn(), +// This is to avoid having to mock every private property of the class +type ApplicationUsageTrackerPublic = Pick; + +export const createApplicationUsageTrackerMock = (): ApplicationUsageTrackerPublic => { + const applicationUsageTrackerMock: jest.Mocked = { trackApplicationViewUsage: jest.fn(), - } as any; + flushTrackedView: jest.fn(), + updateViewClickCounter: jest.fn(), + setCurrentAppId: jest.fn(), + start: jest.fn(), + stop: jest.fn(), + pauseTrackingAll: jest.fn(), + resumeTrackingAll: jest.fn(), + }; return applicationUsageTrackerMock; }; @@ -32,7 +41,6 @@ const createSetupContract = (): Setup => { ), }, - applicationUsageTracker: applicationUsageTrackerMock, reportUiCounter: jest.fn(), }; diff --git a/src/plugins/usage_collection/public/plugin.tsx b/src/plugins/usage_collection/public/plugin.tsx index 79260b17e0c82..f50919eb8f622 100644 --- a/src/plugins/usage_collection/public/plugin.tsx +++ b/src/plugins/usage_collection/public/plugin.tsx @@ -35,16 +35,11 @@ export interface UsageCollectionSetup { components: { ApplicationUsageTrackingProvider: React.FC; }; - applicationUsageTracker: IApplicationUsageTracker; reportUiCounter: Reporter['reportUiCounter']; } export interface UsageCollectionStart { reportUiCounter: Reporter['reportUiCounter']; - applicationUsageTracker: Pick< - ApplicationUsageTracker, - 'trackApplicationViewUsage' | 'flushTrackedView' | 'updateViewClickCounter' - >; } export function isUnauthenticated(http: HttpSetup) { @@ -83,7 +78,6 @@ export class UsageCollectionPlugin implements Plugin ), }, - applicationUsageTracker, reportUiCounter: this.reporter.reportUiCounter, }; } @@ -105,7 +99,6 @@ export class UsageCollectionPlugin implements Plugin, - applicationUsageTracker: ApplicationUsageTracker + applicationUsageTracker: Pick< + ApplicationUsageTracker, + 'updateViewClickCounter' | 'setCurrentAppId' | 'trackApplicationViewUsage' + > ) { const windowClickSubscrition = fromEvent(window, 'click').subscribe(() => { applicationUsageTracker.updateViewClickCounter(MAIN_APP_DEFAULT_VIEW_ID);