Skip to content

Commit 0793a4b

Browse files
authored
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
1 parent a1db6d8 commit 0793a4b

File tree

15 files changed

+131
-5
lines changed

15 files changed

+131
-5
lines changed

coderd/apidoc/docs.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ func New(options *Options) *API {
447447
WorkspaceProxy: false,
448448
UpgradeMessage: api.DeploymentValues.CLIUpgradeMessage.String(),
449449
DeploymentID: api.DeploymentID,
450+
Telemetry: api.Telemetry.Enabled(),
450451
}
451452
api.SiteHandler = site.New(&site.Options{
452453
BinFS: binFS,

coderd/telemetry/telemetry.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ type Reporter interface {
9393
// database. For example, if a new user is added, a snapshot can
9494
// contain just that user entry.
9595
Report(snapshot *Snapshot)
96+
Enabled() bool
9697
Close()
9798
}
9899

@@ -109,6 +110,10 @@ type remoteReporter struct {
109110
shutdownAt *time.Time
110111
}
111112

113+
func (*remoteReporter) Enabled() bool {
114+
return true
115+
}
116+
112117
func (r *remoteReporter) Report(snapshot *Snapshot) {
113118
go r.reportSync(snapshot)
114119
}
@@ -948,4 +953,5 @@ type ExternalProvisioner struct {
948953
type noopReporter struct{}
949954

950955
func (*noopReporter) Report(_ *Snapshot) {}
956+
func (*noopReporter) Enabled() bool { return false }
951957
func (*noopReporter) Close() {}

codersdk/deployment.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,11 +2173,12 @@ type BuildInfoResponse struct {
21732173
ExternalURL string `json:"external_url"`
21742174
// Version returns the semantic version of the build.
21752175
Version string `json:"version"`
2176-
21772176
// DashboardURL is the URL to hit the deployment's dashboard.
21782177
// For external workspace proxies, this is the coderd they are connected
21792178
// to.
21802179
DashboardURL string `json:"dashboard_url"`
2180+
// Telemetry is a boolean that indicates whether telemetry is enabled.
2181+
Telemetry bool `json:"telemetry"`
21812182

21822183
WorkspaceProxy bool `json:"workspace_proxy"`
21832184

docs/api/general.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/schemas.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/wsproxy/wsproxysdk/wsproxysdk_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func TestDialCoordinator(t *testing.T) {
216216
Node: &proto.Node{
217217
Id: 55,
218218
AsOf: timestamppb.New(time.Unix(1689653252, 0)),
219-
Key: peerNodeKey[:],
219+
Key: peerNodeKey,
220220
Disco: string(peerDiscoKey),
221221
PreferredDerp: 0,
222222
DerpLatency: map[string]float64{

site/jest.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ global.scrollTo = jest.fn();
4141

4242
window.HTMLElement.prototype.scrollIntoView = jest.fn();
4343
window.open = jest.fn();
44+
navigator.sendBeacon = jest.fn();
4445

4546
// Polyfill the getRandomValues that is used on utils/random.ts
4647
Object.defineProperty(global.self, "crypto", {

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)