[MM-21703] Send telemetry for all Marketplace plugins (#14846)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
93dc68873a
Коммит
8f42177870
@@ -73,17 +73,19 @@ func TestRudderDiagnostics(t *testing.T) {
|
||||
})
|
||||
defer th.TearDown()
|
||||
|
||||
type batch struct {
|
||||
MessageId string
|
||||
UserId string
|
||||
Event string
|
||||
Timestamp time.Time
|
||||
Properties map[string]interface{}
|
||||
}
|
||||
|
||||
type payload struct {
|
||||
MessageId string
|
||||
SentAt time.Time
|
||||
Batch []struct {
|
||||
MessageId string
|
||||
UserId string
|
||||
Event string
|
||||
Timestamp time.Time
|
||||
Properties map[string]interface{}
|
||||
}
|
||||
Context struct {
|
||||
Batch []batch
|
||||
Context struct {
|
||||
Library struct {
|
||||
Name string
|
||||
Version string
|
||||
@@ -104,6 +106,21 @@ func TestRudderDiagnostics(t *testing.T) {
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
marketplaceServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
res.WriteHeader(http.StatusOK)
|
||||
json, err := json.Marshal([]*model.MarketplacePlugin{{
|
||||
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
|
||||
Manifest: &model.Manifest{
|
||||
Id: "testplugin",
|
||||
},
|
||||
},
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
res.Write(json)
|
||||
}))
|
||||
|
||||
defer func() { marketplaceServer.Close() }()
|
||||
|
||||
diagnosticID := "test-diagnostic-id-12345"
|
||||
th.App.SetDiagnosticId(diagnosticID)
|
||||
th.Server.initDiagnostics(server.URL)
|
||||
@@ -140,6 +157,19 @@ func TestRudderDiagnostics(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
collectBatches := func(info *[]batch) {
|
||||
t.Helper()
|
||||
for {
|
||||
select {
|
||||
case result := <-data:
|
||||
assertPayload(t, result, "", nil)
|
||||
*info = append(*info, result.Batch[0])
|
||||
case <-time.After(time.Second * 1):
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Should send a client identify message
|
||||
select {
|
||||
case identifyMessage := <-data:
|
||||
@@ -245,6 +275,42 @@ func TestRudderDiagnostics(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Diagnostics for Marketplace plugins is returned", func(t *testing.T) {
|
||||
th.App.Srv().trackPluginConfig(th.App.Srv().Config(), marketplaceServer.URL)
|
||||
|
||||
var batches []batch
|
||||
collectBatches(&batches)
|
||||
|
||||
for _, b := range batches {
|
||||
if b.Event == TRACK_CONFIG_PLUGIN {
|
||||
assert.Contains(t, b.Properties, "enable_testplugin")
|
||||
assert.Contains(t, b.Properties, "version_testplugin")
|
||||
|
||||
// Confirm known plugins are not present
|
||||
assert.NotContains(t, b.Properties, "enable_jira")
|
||||
assert.NotContains(t, b.Properties, "version_jira")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Diagnostics for known plugins is returned, if request to Marketplace fails", func(t *testing.T) {
|
||||
th.App.Srv().trackPluginConfig(th.App.Srv().Config(), "http://some.random.invalid.url")
|
||||
|
||||
var batches []batch
|
||||
collectBatches(&batches)
|
||||
|
||||
for _, b := range batches {
|
||||
if b.Event == TRACK_CONFIG_PLUGIN {
|
||||
assert.NotContains(t, b.Properties, "enable_testplugin")
|
||||
assert.NotContains(t, b.Properties, "version_testplugin")
|
||||
|
||||
// Confirm known plugins are present
|
||||
assert.Contains(t, b.Properties, "enable_jira")
|
||||
assert.Contains(t, b.Properties, "version_jira")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("SendDailyDiagnosticsNoRudderKey", func(t *testing.T) {
|
||||
th.App.Srv().SendDailyDiagnostics()
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user