MM-59954 Community plugins telemetry (#28226)
* add known plugins to the list of possible plugins to be located * improve testing and fix config data collection * Improve testing * remove empty lines * make linter happy * go through all plugins
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
87ad717434
Коммит
343746c4b6
@@ -1448,10 +1448,6 @@ func (ts *TelemetryService) trackPluginConfig(cfg *model.Config, marketplaceURL
|
|||||||
marketplacePlugins, err := ts.GetAllMarketplacePlugins(marketplaceURL)
|
marketplacePlugins, err := ts.GetAllMarketplacePlugins(marketplaceURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mlog.Info("Failed to fetch marketplace plugins for telemetry. Using predefined list.", mlog.Err(err))
|
mlog.Info("Failed to fetch marketplace plugins for telemetry. Using predefined list.", mlog.Err(err))
|
||||||
|
|
||||||
for _, id := range knownPluginIDs {
|
|
||||||
pluginConfigData["enable_"+id] = pluginActivated(cfg.PluginSettings.PluginStates, id)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for _, p := range marketplacePlugins {
|
for _, p := range marketplacePlugins {
|
||||||
id := p.Manifest.Id
|
id := p.Manifest.Id
|
||||||
@@ -1460,26 +1456,31 @@ func (ts *TelemetryService) trackPluginConfig(cfg *model.Config, marketplaceURL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, id := range knownPluginIDs {
|
||||||
|
pluginIdStr := fmt.Sprintf("enable_%s", id)
|
||||||
|
_, exists := pluginConfigData[pluginIdStr]
|
||||||
|
if !exists {
|
||||||
|
pluginConfigData[pluginIdStr] = pluginActivated(cfg.PluginSettings.PluginStates, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
pluginsEnvironment := ts.srv.GetPluginsEnvironment()
|
pluginsEnvironment := ts.srv.GetPluginsEnvironment()
|
||||||
if pluginsEnvironment != nil {
|
if pluginsEnvironment != nil {
|
||||||
if plugins, appErr := pluginsEnvironment.Available(); appErr != nil {
|
if plugins, appErr := pluginsEnvironment.Available(); appErr != nil {
|
||||||
ts.log.Warn("Unable to add plugin versions to telemetry", mlog.Err(appErr))
|
ts.log.Warn("Unable to add plugin versions to telemetry", mlog.Err(appErr))
|
||||||
} else {
|
} else {
|
||||||
// If marketplace request failed, use predefined list
|
for _, p := range marketplacePlugins {
|
||||||
if marketplacePlugins == nil {
|
id := p.Manifest.Id
|
||||||
for _, id := range knownPluginIDs {
|
pluginConfigData["version_"+id] = pluginVersion(plugins, id)
|
||||||
pluginConfigData["version_"+id] = pluginVersion(plugins, id)
|
}
|
||||||
}
|
for _, id := range knownPluginIDs {
|
||||||
} else {
|
pluginVersionStr := fmt.Sprintf("version_%s", id)
|
||||||
for _, p := range marketplacePlugins {
|
_, exists := pluginConfigData[pluginVersionStr]
|
||||||
id := p.Manifest.Id
|
if !exists {
|
||||||
|
pluginConfigData[pluginVersionStr] = pluginVersion(plugins, id)
|
||||||
pluginConfigData["version_"+id] = pluginVersion(plugins, id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.SendTelemetry(TrackConfigPlugin, pluginConfigData)
|
ts.SendTelemetry(TrackConfigPlugin, pluginConfigData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -552,9 +552,12 @@ func TestRudderTelemetry(t *testing.T) {
|
|||||||
assert.Contains(t, b.Properties, "enable_testplugin")
|
assert.Contains(t, b.Properties, "enable_testplugin")
|
||||||
assert.Contains(t, b.Properties, "version_testplugin")
|
assert.Contains(t, b.Properties, "version_testplugin")
|
||||||
|
|
||||||
// Confirm known plugins are not present
|
// Confirm known plugins are present
|
||||||
assert.NotContains(t, b.Properties, "enable_jira")
|
assert.Contains(t, b.Properties, "enable_jira")
|
||||||
assert.NotContains(t, b.Properties, "version_jira")
|
assert.Contains(t, b.Properties, "version_jira")
|
||||||
|
|
||||||
|
// Confirm it doesn't contain unknown plugins
|
||||||
|
assert.NotContains(t, b.Properties, "enable_something")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user