diff --git a/package.json b/package.json index 2900de90..e7bc8423 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build": "yarn build-libs && yarn build-samples", "build-libs": "yarn workspaces foreach --from '@openshift/*' run build", "build-samples": "yarn workspaces foreach --from '@monorepo/sample-*' run build", + "copy-api-reports": "cp ./**/**/dist/api/*.api.md ./reports/", "run-samples": "yarn workspaces foreach -pvi --from '@monorepo/sample-*' run http-server", "lint": "yarn eslint packages", "test": "yarn jest", diff --git a/packages/sample-app/src/components/PageHeader.tsx b/packages/sample-app/src/components/PageHeader.tsx index 64c9a65f..2bb432e2 100644 --- a/packages/sample-app/src/components/PageHeader.tsx +++ b/packages/sample-app/src/components/PageHeader.tsx @@ -1,3 +1,4 @@ +import { usePluginStore } from '@openshift/dynamic-plugin-sdk'; import { Brand, Button, @@ -20,11 +21,32 @@ import type { LoadPluginModalRefProps } from './LoadPluginModal'; const PageHeader: React.FC = () => { const loadPluginModalRef = React.useRef(null); + const pluginStore = usePluginStore(); const openLoadPluginModal = () => { loadPluginModalRef.current?.open(); }; + const manuallyLoadPlugin = () => { + pluginStore.loadPlugin({ + name: 'manual-plugin', + version: '0.0.0', + local: true, + extensions: [ + { + type: 'core.telemetry/listener', + properties: { + listener: () => import('./manualPlugin').then((m) => m.default), + }, + flags: { + required: ['TELEMETRY_FLAG'], + disallowed: [], + }, + }, + ], + }); + }; + return ( @@ -53,6 +75,15 @@ const PageHeader: React.FC = () => { Load plugin + + + diff --git a/packages/sample-app/src/components/manualPlugin.ts b/packages/sample-app/src/components/manualPlugin.ts new file mode 100644 index 00000000..7d6ca5d8 --- /dev/null +++ b/packages/sample-app/src/components/manualPlugin.ts @@ -0,0 +1,8 @@ +import type { TelemetryEventListener } from '@openshift/dynamic-plugin-sdk-extensions'; + +const telemetryListener: TelemetryEventListener = (eventType, properties) => { + // eslint-disable-next-line no-console + console.info('Telemetry listener', eventType, properties); +}; + +export default telemetryListener;