Skip to content

Commit

Permalink
[Application Usage] Remove deprecated & unused legacy.appChanged API
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Feb 16, 2021
1 parent 52cd0d9 commit 9c69d03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
3 changes: 0 additions & 3 deletions src/plugins/usage_collection/public/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ const createSetupContract = (): Setup => {
allowTrackUserAgent: jest.fn(),
reportUiCounter: jest.fn(),
METRIC_TYPE,
__LEGACY: {
appChanged: jest.fn(),
},
};

return setupContract;
Expand Down
25 changes: 6 additions & 19 deletions src/plugins/usage_collection/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
*/

import { Reporter, METRIC_TYPE, ApplicationUsageTracker } from '@kbn/analytics';
import { Subject, merge, Subscription } from 'rxjs';
import type { Subscription } from 'rxjs';
import React from 'react';
import { Storage } from '../../kibana_utils/public';
import { createReporter, trackApplicationUsageChange } from './services';
import {
import type {
PluginInitializerContext,
Plugin,
CoreSetup,
CoreStart,
HttpSetup,
} from '../../../core/public';
} from 'src/core/public';
import { Storage } from '../../kibana_utils/public';
import { createReporter, trackApplicationUsageChange } from './services';
import { ApplicationUsageContext } from './components/track_application_view';

export interface PublicConfigType {
Expand All @@ -39,15 +39,6 @@ export interface UsageCollectionSetup {
applicationUsageTracker: IApplicationUsageTracker;
reportUiCounter: Reporter['reportUiCounter'];
METRIC_TYPE: typeof METRIC_TYPE;
__LEGACY: {
/**
* Legacy handler so we can report the actual app being used inside "kibana#/{appId}".
* To be removed when we get rid of the legacy world
*
* @deprecated
*/
appChanged: (appId: string) => void;
};
}

export interface UsageCollectionStart {
Expand All @@ -65,7 +56,6 @@ export function isUnauthenticated(http: HttpSetup) {
}

export class UsageCollectionPlugin implements Plugin<UsageCollectionSetup, UsageCollectionStart> {
private readonly legacyAppId$ = new Subject<string>();
private applicationUsageTracker?: ApplicationUsageTracker;
private trackUserAgent: boolean = true;
private subscriptions: Subscription[] = [];
Expand Down Expand Up @@ -103,9 +93,6 @@ export class UsageCollectionPlugin implements Plugin<UsageCollectionSetup, Usage
},
reportUiCounter: this.reporter.reportUiCounter,
METRIC_TYPE,
__LEGACY: {
appChanged: (appId) => this.legacyAppId$.next(appId),
},
};
}

Expand All @@ -118,7 +105,7 @@ export class UsageCollectionPlugin implements Plugin<UsageCollectionSetup, Usage
this.reporter.start();
this.applicationUsageTracker.start();
this.subscriptions = trackApplicationUsageChange(
merge(application.currentAppId$, this.legacyAppId$),
application.currentAppId$,
this.applicationUsageTracker
);
}
Expand Down

0 comments on commit 9c69d03

Please sign in to comment.