Move AnalyticsImplementationBlueprint to @backstage/plugin-app-react
Migrated the AnalyticsImplementationBlueprint and AnalyticsImplementationFactory from @backstage/frontend-plugin-api to @backstage/plugin-app-react. The original exports are deprecated with pointers to the new location. Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2025 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AnalyticsImplementationBlueprint } from './AnalyticsImplementationBlueprint';
|
||||
|
||||
describe('AnalyticsBlueprint', () => {
|
||||
it('should create an extension with sensible defaults', () => {
|
||||
const factory = {
|
||||
deps: {},
|
||||
factory: () => ({ captureEvent: () => {} }),
|
||||
};
|
||||
|
||||
const extension = AnalyticsImplementationBlueprint.make({
|
||||
params: define => define(factory),
|
||||
name: 'test',
|
||||
});
|
||||
|
||||
expect(extension).toMatchInlineSnapshot(`
|
||||
{
|
||||
"$$type": "@backstage/ExtensionDefinition",
|
||||
"T": undefined,
|
||||
"attachTo": {
|
||||
"id": "api:app/analytics",
|
||||
"input": "implementations",
|
||||
},
|
||||
"configSchema": undefined,
|
||||
"disabled": false,
|
||||
"factory": [Function],
|
||||
"inputs": {},
|
||||
"kind": "analytics",
|
||||
"name": "test",
|
||||
"output": [
|
||||
[Function],
|
||||
],
|
||||
"override": [Function],
|
||||
"toString": [Function],
|
||||
"version": "v2",
|
||||
}
|
||||
`);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2025 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
AnalyticsImplementation,
|
||||
TypesToApiRefs,
|
||||
createExtensionBlueprint,
|
||||
createExtensionBlueprintParams,
|
||||
createExtensionDataRef,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
|
||||
/** @public */
|
||||
export type AnalyticsImplementationFactory<
|
||||
Deps extends { [name in string]: unknown } = {},
|
||||
> = {
|
||||
deps: TypesToApiRefs<Deps>;
|
||||
factory(deps: Deps): AnalyticsImplementation;
|
||||
};
|
||||
|
||||
const factoryDataRef =
|
||||
createExtensionDataRef<AnalyticsImplementationFactory>().with({
|
||||
id: 'core.analytics.factory',
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates analytics implementations.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const AnalyticsImplementationBlueprint = createExtensionBlueprint({
|
||||
kind: 'analytics',
|
||||
attachTo: { id: 'api:app/analytics', input: 'implementations' },
|
||||
output: [factoryDataRef],
|
||||
dataRefs: {
|
||||
factory: factoryDataRef,
|
||||
},
|
||||
defineParams: <TDeps extends { [name in string]: unknown }>(
|
||||
params: AnalyticsImplementationFactory<TDeps>,
|
||||
) => createExtensionBlueprintParams(params as AnalyticsImplementationFactory),
|
||||
*factory(params) {
|
||||
yield factoryDataRef(params);
|
||||
},
|
||||
});
|
||||
@@ -14,6 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export {
|
||||
AnalyticsImplementationBlueprint,
|
||||
type AnalyticsImplementationFactory,
|
||||
} from './AnalyticsImplementationBlueprint';
|
||||
export { AppRootWrapperBlueprint } from './AppRootWrapperBlueprint';
|
||||
export { IconBundleBlueprint } from './IconBundleBlueprint';
|
||||
export { NavContentBlueprint } from './NavContentBlueprint';
|
||||
|
||||
Reference in New Issue
Block a user