diff --git a/.changeset/eleven-tigers-drop.md b/.changeset/eleven-tigers-drop.md new file mode 100644 index 0000000000..7abfe51744 --- /dev/null +++ b/.changeset/eleven-tigers-drop.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-home': patch +--- + +Add the missing Vists API to the alpha plugin, fixing a crash due to the API not being installed. diff --git a/plugins/home/report-alpha.api.md b/plugins/home/report-alpha.api.md index 98a8cab823..c7fcf8ab67 100644 --- a/plugins/home/report-alpha.api.md +++ b/plugins/home/report-alpha.api.md @@ -3,6 +3,7 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { AnyApiFactory } from '@backstage/frontend-plugin-api'; import { AnyRouteRefParams } from '@backstage/frontend-plugin-api'; import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api'; import { ExtensionDefinition } from '@backstage/frontend-plugin-api'; @@ -19,6 +20,21 @@ const _default: FrontendPlugin< }, {}, { + 'api:home/visits': ExtensionDefinition<{ + kind: 'api'; + name: 'visits'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + params: { + factory: AnyApiFactory; + }; + }>; 'app-root-element:home/visit-listener': ExtensionDefinition<{ kind: 'app-root-element'; name: 'visit-listener'; diff --git a/plugins/home/src/alpha.tsx b/plugins/home/src/alpha.tsx index 880b53af40..0d5b0fb94c 100644 --- a/plugins/home/src/alpha.tsx +++ b/plugins/home/src/alpha.tsx @@ -22,9 +22,14 @@ import { createFrontendPlugin, createRouteRef, AppRootElementBlueprint, + identityApiRef, + storageApiRef, + createApiFactory, + ApiBlueprint, } from '@backstage/frontend-plugin-api'; import { compatWrapper } from '@backstage/core-compat-api'; import { VisitListener } from './components/'; +import { visitsApiRef, VisitsStorageApi } from './api'; const rootRouteRef = createRouteRef(); @@ -72,13 +77,28 @@ const visitListenerAppRootElement = AppRootElementBlueprint.make({ }, }); +const visitsApi = ApiBlueprint.make({ + name: 'visits', + params: { + factory: createApiFactory({ + api: visitsApiRef, + deps: { + storageApi: storageApiRef, + identityApi: identityApiRef, + }, + factory: ({ storageApi, identityApi }) => + VisitsStorageApi.create({ storageApi, identityApi }), + }), + }, +}); + /** * @alpha */ export default createFrontendPlugin({ pluginId: 'home', info: { packageJson: () => import('../package.json') }, - extensions: [homePage, visitListenerAppRootElement], + extensions: [homePage, visitsApi, visitListenerAppRootElement], routes: { root: rootRouteRef, },