[cloud] Add org_stats table to hold business stats for organizations
Created by: kopancek
Description
We need this data to understand if organizations connect most of their repositories to sourcegraph.com or if they cherry pick only a few. This is a signal towards customers trust to Sourcegraph with their organization’s code
We have created a team RFC to look at possible solutions and even though storing business metrics in DB seems like a bad practice, it was the least bad option from the lot.
The data are stored in a new table called org_stats
. The table will be created for on-prem instances as well, but should be empty there, as we only collect the data on cloud instances. We also only collect the data for organization owned repositories only, so this should not affect private repositories for individuals.
Related items
https://sourcegraph.atlassian.net/browse/CLOUD-156 https://docs.google.com/document/d/1FceX9003yDdF5c34hLqZOrTi_tgDxsARBvkyplegy3U/edit#
Testing locally
- Run sg in dotcom mode
sg start dotcom
- Create an organization
- Add a feature flag override for the organization to see the code host connections and repositories screens
- Add code host connection
- Go to Manage repositories screen
- In Postgres, the
org_stats
table should now contain a new row with the number of repositories returned fromAffilatedRepositories
graphQL query.