Skip to content
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

feat: feature changes counted in new table #4958

Merged
merged 12 commits into from
Oct 10, 2023
Merged

Conversation

chriswk
Copy link
Contributor

@chriswk chriswk commented Oct 6, 2023

As part of more telemetry on the usage of Unleash.

This PR adds a new stat_ prefixed table as well as a trigger on the events table trigger on each insert to increment a counter per environment per day.

The trigger will trigger on every insert into the events base, but will filter and only increment the counter for events that actually have the environment set. (there are events, like user-created, that does not relate to a specific environment).

Bit wary on this, but since we truncate down to row per (day, environment) combo, finding conflict and incrementing shouldn't take too long here.

@ivarconr was it something like this you were considering?

@chriswk chriswk self-assigned this Oct 6, 2023
@vercel
Copy link

vercel bot commented Oct 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-docs ❌ Failed (Inspect) Oct 10, 2023 10:23am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2023 10:23am

@chriswk chriswk force-pushed the feat/featureUsageStats branch 2 times, most recently from 3443abf to 72467ad Compare October 9, 2023 09:32
Copy link
Contributor

@gastonfournier gastonfournier left a comment

Choose a reason for hiding this comment

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

This looks good, I feel we're probably close to considering CDC, but I don't think that'll help with self-hosted. 👍

enterprise: data.versions.enterprise,
};
this.isLatest = data.latest;
if (this.versionCheckUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this change is unrelated but it's worth having it independently of this PR

@ivarconr
Copy link
Member

ivarconr commented Oct 9, 2023

@ivarconr was it something like this you were considering?

yes, this looks spot on! We might peek at environment type in the future when taking out the counters, but that can be improved later.

"SUM(CASE WHEN day > NOW() - INTERVAL '90 days' THEN updates END)",
),
})
.from('stat_environment_updates');
Copy link
Member

Choose a reason for hiding this comment

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

I would expect a where clause here, to only pick production envs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally agree. thanks for the reminder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also updated it to look at the environment type and sum across all environments of type 'production'.

@chriswk chriswk merged commit 1edd73d into main Oct 10, 2023
8 checks passed
@chriswk chriswk deleted the feat/featureUsageStats branch October 10, 2023 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants