Plugins: adds plugin version to log output (#109845)

This commit is contained in:
Hugo Häggmark
2025-08-20 13:18:59 +02:00
committed by GitHub
parent 38672c7936
commit 71fd156eda
3 changed files with 10 additions and 4 deletions
@@ -34,7 +34,11 @@ export class DataSourcePluginSettings extends PureComponent<Props> {
<div>
{plugin.components.ConfigEditor &&
createElement(plugin.components.ConfigEditor, {
options: writableProxy(dataSource, { source: 'datasource', pluginId: plugin.meta?.id }),
options: writableProxy(dataSource, {
source: 'datasource',
pluginId: plugin.meta?.id,
pluginVersion: plugin.meta?.info?.version,
}),
onOptionsChange: this.onModelChanged,
})}
</div>
@@ -903,7 +903,7 @@ describe('Plugin Extensions / Utils', () => {
// Logs a warning
expect(log.error).toHaveBeenCalledTimes(1);
expect(log.error).toHaveBeenCalledWith(
`Attempted to mutate object property "c" from extension with id grafana-worldmap-panel and version unknown`,
`Attempted to mutate object property "c" from extension with id grafana-worldmap-panel and version 1.0.0`,
{
stack: expect.any(String),
}
@@ -931,7 +931,7 @@ describe('Plugin Extensions / Utils', () => {
// Logs a warning
expect(log.warning).toHaveBeenCalledTimes(1);
expect(log.warning).toHaveBeenCalledWith(
`Attempted to mutate object property "c" from extension with id grafana-worldmap-panel and version unknown`,
`Attempted to mutate object property "c" from extension with id grafana-worldmap-panel and version 1.0.0`,
{
stack: expect.any(String),
}
@@ -98,7 +98,9 @@ export const wrapWithPluginContext = <T,>({
return (
<PluginContextProvider meta={pluginMeta}>
<ExtensionErrorBoundary pluginId={pluginId} extensionTitle={extensionTitle} log={log}>
<Component {...writableProxy(props, { log, source: 'extension', pluginId })} />
<Component
{...writableProxy(props, { log, source: 'extension', pluginId, pluginVersion: pluginMeta.info?.version })}
/>
</ExtensionErrorBoundary>
</PluginContextProvider>
);