Skip to content

[cloud] Add org_stats table to hold business stats for organizations

Administrator requested to merge CLOUD-156 into main

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

  1. Run sg in dotcom mode sg start dotcom
  2. Create an organization
  3. Add a feature flag override for the organization to see the code host connections and repositories screens
  4. Add code host connection
  5. Go to Manage repositories screen
  6. In Postgres, the org_stats table should now contain a new row with the number of repositories returned from AffilatedRepositories graphQL query.

Merge request reports

Loading