mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add cross-origin reporting for telemetry in the dashboard (#13612)
* feat: add cross-origin reporting for telemetry in the dashboard * Respect the telemetry flag * Fix embedded metadata * Fix compilation error * Fix linting
This commit is contained in:
Generated
+4
@@ -8351,6 +8351,10 @@ const docTemplate = `{
|
||||
"description": "ExternalURL references the current Coder version.\nFor production builds, this will link directly to a release. For development builds, this will link to a commit.",
|
||||
"type": "string"
|
||||
},
|
||||
"telemetry": {
|
||||
"description": "Telemetry is a boolean that indicates whether telemetry is enabled.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"upgrade_message": {
|
||||
"description": "UpgradeMessage is the message displayed to users when an outdated client\nis detected.",
|
||||
"type": "string"
|
||||
|
||||
Generated
+4
@@ -7430,6 +7430,10 @@
|
||||
"description": "ExternalURL references the current Coder version.\nFor production builds, this will link directly to a release. For development builds, this will link to a commit.",
|
||||
"type": "string"
|
||||
},
|
||||
"telemetry": {
|
||||
"description": "Telemetry is a boolean that indicates whether telemetry is enabled.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"upgrade_message": {
|
||||
"description": "UpgradeMessage is the message displayed to users when an outdated client\nis detected.",
|
||||
"type": "string"
|
||||
|
||||
@@ -447,6 +447,7 @@ func New(options *Options) *API {
|
||||
WorkspaceProxy: false,
|
||||
UpgradeMessage: api.DeploymentValues.CLIUpgradeMessage.String(),
|
||||
DeploymentID: api.DeploymentID,
|
||||
Telemetry: api.Telemetry.Enabled(),
|
||||
}
|
||||
api.SiteHandler = site.New(&site.Options{
|
||||
BinFS: binFS,
|
||||
|
||||
@@ -93,6 +93,7 @@ type Reporter interface {
|
||||
// database. For example, if a new user is added, a snapshot can
|
||||
// contain just that user entry.
|
||||
Report(snapshot *Snapshot)
|
||||
Enabled() bool
|
||||
Close()
|
||||
}
|
||||
|
||||
@@ -109,6 +110,10 @@ type remoteReporter struct {
|
||||
shutdownAt *time.Time
|
||||
}
|
||||
|
||||
func (*remoteReporter) Enabled() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (r *remoteReporter) Report(snapshot *Snapshot) {
|
||||
go r.reportSync(snapshot)
|
||||
}
|
||||
@@ -948,4 +953,5 @@ type ExternalProvisioner struct {
|
||||
type noopReporter struct{}
|
||||
|
||||
func (*noopReporter) Report(_ *Snapshot) {}
|
||||
func (*noopReporter) Enabled() bool { return false }
|
||||
func (*noopReporter) Close() {}
|
||||
|
||||
Reference in New Issue
Block a user