insights: add GraphQL API to push data into TimescaleDB/insights store directly ("webhooks")
Created by: slimsag
(See #17218 (closed) for general plan / explanation of the work being done on code insights.)
This issue:
Add a GraphQL API which allows someone to push data (e.g. a repo-level or global-level insight) directly into TimescaleDB / the insights store. Basic outline of how to approach this:
- Add an
extend
GraphQL mutation for insights, similar to what we have for campaigns with a new method that will be called to add a series data point. - Call the insights
store.RecordSeriesPoint
method in the GraphQL resolver to record the actual data point.
Two challenges here are:
- Does the person need to create an insight first through the user settings in order to add data for it? Presumably yes. This means, however, that in order to add data they will need to first query the ID of the insight (or we need some nicer way for them to find the ID of the insight they want to record data for. We could display this in the UI somewhere easily.)
- Who has permission to add insights data? An obvious choice would be admins only, or only the owner of the settings the insight is defined in. It may be worth chatting with code intel team, since they have thought a lot about how to allow arbitrary users to upload LSIF data - maybe we could use something similar here like "if you know the secret ID of the insight, you can upload data for it" (this would also prevent "I need an admin's access token to upload data" which is a bit of a security nightmare)