Ensure content is base64 encoded, add check for telemetry enabled.
Этот коммит содержится в:
@@ -5,6 +5,7 @@ package api4
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
b64 "encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -322,6 +323,8 @@ func getOrCreateTrueUpReviewStatus(c *Context) (*model.TrueUpReviewStatus, bool)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
telemetryService := c.App.Srv().GetTelemetryService()
|
||||||
|
status.TelemetryEnabled = telemetryService.TelemetryEnabled()
|
||||||
return status, true
|
return status, true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,9 +364,10 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do not send true-up review data if the user has already requested one for the quarter.
|
// Do not send true-up review data if the user has already requested one for the quarter.
|
||||||
if !status.Completed {
|
// And only send a true-up review via as a one-time telemetry request if telemetry is disabled.
|
||||||
|
telemetryService := c.App.Srv().GetTelemetryService()
|
||||||
|
if !status.Completed && !telemetryService.TelemetryEnabled() {
|
||||||
// Send telemetry data
|
// Send telemetry data
|
||||||
telemetryService := c.App.Srv().GetTelemetryService()
|
|
||||||
telemetryService.SendTelemetry(model.TrueUpReviewTelemetryName, profileMap)
|
telemetryService.SendTelemetry(model.TrueUpReviewTelemetryName, profileMap)
|
||||||
|
|
||||||
// Update the review status to reflect the completion.
|
// Update the review status to reflect the completion.
|
||||||
@@ -371,7 +375,14 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
c.App.Srv().Store().TrueUpReview().Update(status)
|
c.App.Srv().Store().TrueUpReview().Update(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write(profileMapJson)
|
// Encode to string rather than byte[] otherwise json.Marshal will encode it further.
|
||||||
|
encodedData := b64.StdEncoding.EncodeToString(profileMapJson)
|
||||||
|
responseContent := struct {
|
||||||
|
Content string `json:"content"`
|
||||||
|
}{Content: encodedData}
|
||||||
|
response, _ := json.Marshal(responseContent)
|
||||||
|
|
||||||
|
w.Write(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
func trueUpReviewStatus(c *Context, w http.ResponseWriter, r *http.Request) {
|
func trueUpReviewStatus(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ func (t *TrueUpReviewPlugins) ToMap() map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TrueUpReviewStatus struct {
|
type TrueUpReviewStatus struct {
|
||||||
Completed bool `json:"complete"`
|
Completed bool `json:"complete"`
|
||||||
DueDate int64 `json:"due_date"`
|
DueDate int64 `json:"due_date"`
|
||||||
|
TelemetryEnabled bool `json:"telemetry_enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TrueUpReviewStatus) ToSlice() []interface{} {
|
func (t *TrueUpReviewStatus) ToSlice() []interface{} {
|
||||||
|
|||||||
@@ -149,13 +149,13 @@ func (ts *TelemetryService) getRudderConfig() RudderConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TelemetryService) telemetryEnabled() bool {
|
func (ts *TelemetryService) TelemetryEnabled() bool {
|
||||||
return *ts.srv.Config().LogSettings.EnableDiagnostics && ts.srv.IsLeader()
|
return *ts.srv.Config().LogSettings.EnableDiagnostics && ts.srv.IsLeader()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TelemetryService) sendDailyTelemetry(override bool) {
|
func (ts *TelemetryService) sendDailyTelemetry(override bool) {
|
||||||
config := ts.getRudderConfig()
|
config := ts.getRudderConfig()
|
||||||
if ts.telemetryEnabled() && ((config.DataplaneURL != "" && config.RudderKey != "") || override) {
|
if ts.TelemetryEnabled() && ((config.DataplaneURL != "" && config.RudderKey != "") || override) {
|
||||||
ts.initRudder(config.DataplaneURL, config.RudderKey)
|
ts.initRudder(config.DataplaneURL, config.RudderKey)
|
||||||
ts.trackActivity()
|
ts.trackActivity()
|
||||||
ts.trackConfig()
|
ts.trackConfig()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user