File tree Expand file tree Collapse file tree 4 files changed +22
-3
lines changed
x-pack/plugins/graph/server Expand file tree Collapse file tree 4 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 77import Boom from 'boom' ;
88import { map } from 'rxjs/operators' ;
99import { Observable , Subscription } from 'rxjs' ;
10+ import { LicensingPluginStart } from '../../../licensing/server' ;
1011import { ILicense } from '../../../licensing/common/types' ;
1112import { checkLicense , GraphLicenseInformation } from '../../common/check_license' ;
1213
1314export class LicenseState {
1415 private licenseInformation : GraphLicenseInformation = checkLicense ( undefined ) ;
1516 private subscription : Subscription | null = null ;
1617 private observable : Observable < GraphLicenseInformation > | null = null ;
18+ private _notifyUsage : LicensingPluginStart [ 'featureUsage' ] [ 'notifyUsage' ] | null = null ;
1719
1820 private updateInformation ( licenseInformation : GraphLicenseInformation ) {
1921 this . licenseInformation = licenseInformation ;
@@ -24,6 +26,17 @@ export class LicenseState {
2426 this . subscription = this . observable . subscribe ( this . updateInformation . bind ( this ) ) ;
2527 }
2628
29+ public setNotifyUsage ( notifyUsage : LicensingPluginStart [ 'featureUsage' ] [ 'notifyUsage' ] ) {
30+ this . _notifyUsage = notifyUsage ;
31+ }
32+
33+ // 'Graph' is the only allowed feature here at the moment, if this gets extended in the future, add to the union type
34+ public notifyUsage ( featureName : 'Graph' ) {
35+ if ( this . _notifyUsage ) {
36+ this . _notifyUsage ( featureName ) ;
37+ }
38+ }
39+
2740 public stop ( ) {
2841 if ( this . subscription ) {
2942 this . subscription . unsubscribe ( ) ;
Original file line number Diff line number Diff line change 55 */
66
77import { i18n } from '@kbn/i18n' ;
8- import { Plugin , CoreSetup } from 'src/core/server' ;
9- import { LicensingPluginSetup } from '../../licensing/server' ;
8+ import { Plugin , CoreSetup , CoreStart } from 'src/core/server' ;
9+ import { LicensingPluginSetup , LicensingPluginStart } from '../../licensing/server' ;
1010import { LicenseState } from './lib/license_state' ;
1111import { registerSearchRoute } from './routes/search' ;
1212import { registerExploreRoute } from './routes/explore' ;
@@ -34,6 +34,7 @@ export class GraphPlugin implements Plugin {
3434 licenseState . start ( licensing . license$ ) ;
3535 this . licenseState = licenseState ;
3636 core . savedObjects . registerType ( graphWorkspace ) ;
37+ licensing . featureUsage . register ( 'Graph' , 'platinum' ) ;
3738
3839 if ( home ) {
3940 registerSampleData ( home . sampleData , licenseState ) ;
@@ -79,7 +80,10 @@ export class GraphPlugin implements Plugin {
7980 registerExploreRoute ( { licenseState, router } ) ;
8081 }
8182
82- public start ( ) { }
83+ public start ( core : CoreStart , { licensing } : { licensing : LicensingPluginStart } ) {
84+ this . licenseState ! . setNotifyUsage ( licensing . featureUsage . notifyUsage ) ;
85+ }
86+
8387 public stop ( ) {
8488 if ( this . licenseState ) {
8589 this . licenseState . stop ( ) ;
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ export function registerExploreRoute({
4242 response
4343 ) => {
4444 verifyApiAccess ( licenseState ) ;
45+ licenseState . notifyUsage ( 'Graph' ) ;
4546 try {
4647 return response . ok ( {
4748 body : {
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ export function registerSearchRoute({
4242 response
4343 ) => {
4444 verifyApiAccess ( licenseState ) ;
45+ licenseState . notifyUsage ( 'Graph' ) ;
4546 const includeFrozen = await uiSettings . get < boolean > ( UI_SETTINGS . SEARCH_INCLUDE_FROZEN ) ;
4647 try {
4748 return response . ok ( {
You can’t perform that action at this time.
0 commit comments