Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: track the first time html is served in telemetry #16334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jan 31, 2025

Conversation

hugodutka
Copy link
Contributor

@hugodutka hugodutka commented Jan 29, 2025

Addresses https://github.com/coder/nexus/issues/175.

Changes

  • Adds the telemetry_items database table. It's a key value store for telemetry events that don't fit any other database tables.
  • Adds a telemetry report when HTML is served for the first time in site.go.

@hugodutka hugodutka force-pushed the hugodutka/telemetry-html-first-served branch from 24b1f2a to 63246e8 Compare January 29, 2025 19:01
@hugodutka hugodutka changed the title chorte: track the first time html is served in telemetry chore: track the first time html is served in telemetry Jan 29, 2025
@hugodutka hugodutka marked this pull request as ready for review January 30, 2025 16:27
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM
Nothing major that needs fixing


accessURL := waitAccessURL(t, cfg)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
ctx := testutil.Context(t, testutil.WaitMedium)

@@ -1536,6 +1557,20 @@ type Organization struct {
CreatedAt time.Time `json:"created_at"`
}

//revive:disable:exported
type TelemetryItemKey string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this has to be exported; can you elaborate pls?

Copy link
Contributor Author

@hugodutka hugodutka Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a habit that when I export enum values, I export their type too. It's not strictly necessary here.

// The purpose is to track the first time the first user opens the site.
func (h *Handler) reportHTMLFirstServedAt() {
// nolint:gocritic // Manipulating telemetry items is system-restricted.
ctx := dbauthz.AsSystemRestricted(context.Background())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a TODO to add a telemetry context in RBAC at some point.

site/site.go Outdated
@@ -183,6 +187,8 @@ type Handler struct {

Entitlements *entitlements.Set
Experiments atomic.Pointer[codersdk.Experiments]

TelemetryHTMLServedOnce sync.Once
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this exported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to be - thanks for catching it.

@hugodutka hugodutka merged commit 2ace044 into main Jan 31, 2025
33 of 35 checks passed
@hugodutka hugodutka deleted the hugodutka/telemetry-html-first-served branch January 31, 2025 12:55
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants