mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
register graph usage (#72041)
This commit is contained in:
parent
39381ca3c8
commit
825c16875e
4 changed files with 22 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
|||
import Boom from 'boom';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { LicensingPluginStart } from '../../../licensing/server';
|
||||
import { ILicense } from '../../../licensing/common/types';
|
||||
import { checkLicense, GraphLicenseInformation } from '../../common/check_license';
|
||||
|
||||
|
@ -14,6 +15,7 @@ export class LicenseState {
|
|||
private licenseInformation: GraphLicenseInformation = checkLicense(undefined);
|
||||
private subscription: Subscription | null = null;
|
||||
private observable: Observable<GraphLicenseInformation> | null = null;
|
||||
private _notifyUsage: LicensingPluginStart['featureUsage']['notifyUsage'] | null = null;
|
||||
|
||||
private updateInformation(licenseInformation: GraphLicenseInformation) {
|
||||
this.licenseInformation = licenseInformation;
|
||||
|
@ -24,6 +26,17 @@ export class LicenseState {
|
|||
this.subscription = this.observable.subscribe(this.updateInformation.bind(this));
|
||||
}
|
||||
|
||||
public setNotifyUsage(notifyUsage: LicensingPluginStart['featureUsage']['notifyUsage']) {
|
||||
this._notifyUsage = notifyUsage;
|
||||
}
|
||||
|
||||
// 'Graph' is the only allowed feature here at the moment, if this gets extended in the future, add to the union type
|
||||
public notifyUsage(featureName: 'Graph') {
|
||||
if (this._notifyUsage) {
|
||||
this._notifyUsage(featureName);
|
||||
}
|
||||
}
|
||||
|
||||
public stop() {
|
||||
if (this.subscription) {
|
||||
this.subscription.unsubscribe();
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { Plugin, CoreSetup } from 'src/core/server';
|
||||
import { LicensingPluginSetup } from '../../licensing/server';
|
||||
import { Plugin, CoreSetup, CoreStart } from 'src/core/server';
|
||||
import { LicensingPluginSetup, LicensingPluginStart } from '../../licensing/server';
|
||||
import { LicenseState } from './lib/license_state';
|
||||
import { registerSearchRoute } from './routes/search';
|
||||
import { registerExploreRoute } from './routes/explore';
|
||||
|
@ -34,6 +34,7 @@ export class GraphPlugin implements Plugin {
|
|||
licenseState.start(licensing.license$);
|
||||
this.licenseState = licenseState;
|
||||
core.savedObjects.registerType(graphWorkspace);
|
||||
licensing.featureUsage.register('Graph', 'platinum');
|
||||
|
||||
if (home) {
|
||||
registerSampleData(home.sampleData, licenseState);
|
||||
|
@ -79,7 +80,10 @@ export class GraphPlugin implements Plugin {
|
|||
registerExploreRoute({ licenseState, router });
|
||||
}
|
||||
|
||||
public start() {}
|
||||
public start(core: CoreStart, { licensing }: { licensing: LicensingPluginStart }) {
|
||||
this.licenseState!.setNotifyUsage(licensing.featureUsage.notifyUsage);
|
||||
}
|
||||
|
||||
public stop() {
|
||||
if (this.licenseState) {
|
||||
this.licenseState.stop();
|
||||
|
|
|
@ -42,6 +42,7 @@ export function registerExploreRoute({
|
|||
response
|
||||
) => {
|
||||
verifyApiAccess(licenseState);
|
||||
licenseState.notifyUsage('Graph');
|
||||
try {
|
||||
return response.ok({
|
||||
body: {
|
||||
|
|
|
@ -42,6 +42,7 @@ export function registerSearchRoute({
|
|||
response
|
||||
) => {
|
||||
verifyApiAccess(licenseState);
|
||||
licenseState.notifyUsage('Graph');
|
||||
const includeFrozen = await uiSettings.get<boolean>(UI_SETTINGS.SEARCH_INCLUDE_FROZEN);
|
||||
try {
|
||||
return response.ok({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue