mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Add anonymized telemetry to report product usage (#2273)
* feat: Add anonymized telemetry to report product usage This adds a background service to report telemetry to a Coder server for usage data. There will be realtime event data sent in the future, but for now usage will report on a CRON. * Fix flake and requested changes * Add reporting options for setup * Add reporting for workspaces * Add resources as they are reported * Track API key usage * Ensure telemetry is tracked prior to exit
This commit is contained in:
@@ -8,6 +8,9 @@ WHERE
|
||||
LIMIT
|
||||
1;
|
||||
|
||||
-- name: GetAPIKeysLastUsedAfter :many
|
||||
SELECT * FROM api_keys WHERE last_used > $1;
|
||||
|
||||
-- name: InsertAPIKey :one
|
||||
INSERT INTO
|
||||
api_keys (
|
||||
|
||||
@@ -6,6 +6,9 @@ FROM
|
||||
WHERE
|
||||
job_id = $1;
|
||||
|
||||
-- name: GetParameterSchemasCreatedAfter :many
|
||||
SELECT * FROM parameter_schemas WHERE created_at > $1;
|
||||
|
||||
-- name: InsertParameterSchema :one
|
||||
INSERT INTO
|
||||
parameter_schemas (
|
||||
|
||||
@@ -46,6 +46,9 @@ FROM
|
||||
WHERE
|
||||
id = ANY(@ids :: uuid [ ]);
|
||||
|
||||
-- name: GetProvisionerJobsCreatedAfter :many
|
||||
SELECT * FROM provisioner_jobs WHERE created_at > $1;
|
||||
|
||||
-- name: InsertProvisionerJob :one
|
||||
INSERT INTO
|
||||
provisioner_jobs (
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
-- name: InsertDeploymentID :exec
|
||||
INSERT INTO site_configs (key, value) VALUES ('deployment_id', $1);
|
||||
|
||||
-- name: GetDeploymentID :one
|
||||
SELECT value FROM site_configs WHERE key = 'deployment_id';
|
||||
@@ -48,6 +48,9 @@ WHERE
|
||||
LIMIT
|
||||
1;
|
||||
|
||||
-- name: GetTemplates :many
|
||||
SELECT * FROM templates;
|
||||
|
||||
-- name: InsertTemplate :one
|
||||
INSERT INTO
|
||||
templates (
|
||||
|
||||
@@ -40,6 +40,9 @@ FROM
|
||||
WHERE
|
||||
job_id = $1;
|
||||
|
||||
-- name: GetTemplateVersionsCreatedAfter :many
|
||||
SELECT * FROM template_versions WHERE created_at > $1;
|
||||
|
||||
-- name: GetTemplateVersionByTemplateIDAndName :one
|
||||
SELECT
|
||||
*
|
||||
|
||||
@@ -34,6 +34,9 @@ FROM
|
||||
WHERE
|
||||
resource_id = ANY(@ids :: uuid [ ]);
|
||||
|
||||
-- name: GetWorkspaceAgentsCreatedAfter :many
|
||||
SELECT * FROM workspace_agents WHERE created_at > $1;
|
||||
|
||||
-- name: InsertWorkspaceAgent :one
|
||||
INSERT INTO
|
||||
workspace_agents (
|
||||
|
||||
@@ -7,6 +7,9 @@ SELECT * FROM workspace_apps WHERE agent_id = ANY(@ids :: uuid [ ]);
|
||||
-- name: GetWorkspaceAppByAgentIDAndName :one
|
||||
SELECT * FROM workspace_apps WHERE agent_id = $1 AND name = $2;
|
||||
|
||||
-- name: GetWorkspaceAppsCreatedAfter :many
|
||||
SELECT * FROM workspace_apps WHERE created_at > $1;
|
||||
|
||||
-- name: InsertWorkspaceApp :one
|
||||
INSERT INTO
|
||||
workspace_apps (
|
||||
|
||||
@@ -18,6 +18,9 @@ WHERE
|
||||
LIMIT
|
||||
1;
|
||||
|
||||
-- name: GetWorkspaceBuildsCreatedAfter :many
|
||||
SELECT * FROM workspace_builds WHERE created_at > $1;
|
||||
|
||||
-- name: GetWorkspaceBuildByWorkspaceIDAndName :one
|
||||
SELECT
|
||||
*
|
||||
|
||||
@@ -14,6 +14,9 @@ FROM
|
||||
WHERE
|
||||
job_id = $1;
|
||||
|
||||
-- name: GetWorkspaceResourcesCreatedAfter :many
|
||||
SELECT * FROM workspace_resources WHERE created_at > $1;
|
||||
|
||||
-- name: InsertWorkspaceResource :one
|
||||
INSERT INTO
|
||||
workspace_resources (id, created_at, job_id, transition, type, name)
|
||||
|
||||
@@ -8,7 +8,7 @@ WHERE
|
||||
LIMIT
|
||||
1;
|
||||
|
||||
-- name: GetWorkspacesWithFilter :many
|
||||
-- name: GetWorkspaces :many
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
|
||||
Reference in New Issue
Block a user