diff --git a/x-pack/plugins/maps/public/licensed_features.ts b/x-pack/plugins/maps/public/licensed_features.ts index f709dd529e375..f16fcac900683 100644 --- a/x-pack/plugins/maps/public/licensed_features.ts +++ b/x-pack/plugins/maps/public/licensed_features.ts @@ -54,17 +54,23 @@ export function registerLicensedFeatures(licensingPlugin: LicensingPluginSetup) } let licensingPluginStart: LicensingPluginStart; -export function setLicensingPluginStart(licensingPlugin: LicensingPluginStart) { - licensingPluginStart = licensingPlugin; - licensingPluginStart.license$.subscribe((license: ILicense) => { - const gold = license.check(APP_ID, 'gold'); - isGoldPlus = gold.state === 'valid'; - const enterprise = license.check(APP_ID, 'enterprise'); - isEnterprisePlus = enterprise.state === 'valid'; +function updateLicenseState(license: ILicense) { + const gold = license.check(APP_ID, 'gold'); + isGoldPlus = gold.state === 'valid'; + + const enterprise = license.check(APP_ID, 'enterprise'); + isEnterprisePlus = enterprise.state === 'valid'; + + licenseId = license.uid; +} + +export async function setLicensingPluginStart(licensingPlugin: LicensingPluginStart) { + const license = await licensingPlugin.refresh(); + updateLicenseState(license); - licenseId = license.uid; - }); + licensingPluginStart = licensingPlugin; + licensingPluginStart.license$.subscribe(updateLicenseState); } export function notifyLicensedFeatureUsage(licensedFeature: LICENSED_FEATURES) { diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts index 8bffea3ce5a87..b5340f4e31068 100644 --- a/x-pack/plugins/maps/public/plugin.ts +++ b/x-pack/plugins/maps/public/plugin.ts @@ -158,8 +158,8 @@ export class MapsPlugin }); } - public start(core: CoreStart, plugins: MapsPluginStartDependencies): MapsStartApi { - setLicensingPluginStart(plugins.licensing); + public async start(core: CoreStart, plugins: MapsPluginStartDependencies): Promise { + await setLicensingPluginStart(plugins.licensing); plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction); setStartServices(core, plugins); // unregisters the OSS alias