Skip to content

Commit b701620

Browse files
committed
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 (cherry picked from commit 0793a4b)
1 parent 0703fc6 commit b701620

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
@@ -450,6 +450,7 @@ func New(options *Options) *API {
450450
WorkspaceProxy: false,
451451
UpgradeMessage: api.DeploymentValues.CLIUpgradeMessage.String(),
452452
DeploymentID: api.DeploymentID,
453+
Telemetry: api.Telemetry.Enabled(),
453454
}
454455
api.SiteHandler = site.New(&site.Options{
455456
BinFS: binFS,

coderd/telemetry/telemetry.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ type Reporter interface {
100100
// database. For example, if a new user is added, a snapshot can
101101
// contain just that user entry.
102102
Report(snapshot *Snapshot)
103+
Enabled() bool
103104
Close()
104105
}
105106

@@ -116,6 +117,10 @@ type remoteReporter struct {
116117
shutdownAt *time.Time
117118
}
118119

120+
func (*remoteReporter) Enabled() bool {
121+
return true
122+
}
123+
119124
func (r *remoteReporter) Report(snapshot *Snapshot) {
120125
go r.reportSync(snapshot)
121126
}
@@ -992,4 +997,5 @@ type Experiment struct {
992997
type noopReporter struct{}
993998

994999
func (*noopReporter) Report(_ *Snapshot) {}
1000+
func (*noopReporter) Enabled() bool { return false }
9951001
func (*noopReporter) Close() {}

codersdk/deployment.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2162,11 +2162,12 @@ type BuildInfoResponse struct {
21622162
ExternalURL string `json:"external_url"`
21632163
// Version returns the semantic version of the build.
21642164
Version string `json:"version"`
2165-
21662165
// DashboardURL is the URL to hit the deployment's dashboard.
21672166
// For external workspace proxies, this is the coderd they are connected
21682167
// to.
21692168
DashboardURL string `json:"dashboard_url"`
2169+
// Telemetry is a boolean that indicates whether telemetry is enabled.
2170+
Telemetry bool `json:"telemetry"`
21702171

21712172
WorkspaceProxy bool `json:"workspace_proxy"`
21722173

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy