-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(usage-report): Add decide usage report (#15956)
- Loading branch information
1 parent
0cb194b
commit 9fb1aa7
Showing
4 changed files
with
471 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
298 changes: 298 additions & 0 deletions
298
posthog/tasks/test/__snapshots__/test_usage_report.ambr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,298 @@ | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests | ||
' | ||
|
||
SELECT team_id, | ||
count(1) as count | ||
FROM events | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.1 | ||
' | ||
|
||
SELECT team_id, | ||
count(1) as count | ||
FROM events | ||
WHERE timestamp between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.10 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(query_duration_ms) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['hogql_query', 'HogQLQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = '' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.11 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(read_bytes) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['hogql_query', 'HogQLQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = 'personal_api_key' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.12 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(read_rows) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['hogql_query', 'HogQLQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = 'personal_api_key' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.13 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(query_duration_ms) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['hogql_query', 'HogQLQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = 'personal_api_key' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.14 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(read_bytes) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['EventsQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = '' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.15 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(read_rows) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['EventsQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = '' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.16 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(query_duration_ms) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['EventsQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = '' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.17 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(read_bytes) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['EventsQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = 'personal_api_key' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.18 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(read_rows) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['EventsQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = 'personal_api_key' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.19 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(query_duration_ms) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['EventsQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = 'personal_api_key' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.2 | ||
' | ||
|
||
SELECT team_id, | ||
count(1) as count | ||
FROM events | ||
WHERE timestamp between '2022-01-01 00:00:00' AND '2022-01-10 23:59:59' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.3 | ||
' | ||
|
||
SELECT team_id, | ||
count(1) as count | ||
FROM events | ||
WHERE timestamp between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND ($group_0 != '' | ||
OR $group_1 != '' | ||
OR $group_2 != '' | ||
OR $group_3 != '' | ||
OR $group_4 != '') | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.4 | ||
' | ||
|
||
SELECT team_id, | ||
count(distinct session_id) as count | ||
FROM session_recording_events | ||
WHERE first_event_timestamp BETWEEN '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND session_id NOT IN | ||
(SELECT DISTINCT session_id | ||
FROM session_recording_events | ||
WHERE toDate(first_event_timestamp) = toDate('2022-01-10 00:00:00') - INTERVAL 1 DAY | ||
GROUP BY session_id) | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.5 | ||
' | ||
|
||
SELECT team_id, | ||
count(distinct session_id) as count | ||
FROM session_recording_events | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.6 | ||
' | ||
|
||
SELECT distinct_id as team, | ||
sum(JSONExtractInt(properties, 'count')) as sum | ||
FROM events | ||
WHERE team_id = 2 | ||
AND event='decide usage' | ||
AND timestamp between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND has(['correct'], replaceRegexpAll(JSONExtractRaw(properties, 'token'), '^"|"$', '')) | ||
GROUP BY team | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.7 | ||
' | ||
|
||
SELECT distinct_id as team, | ||
sum(JSONExtractInt(properties, 'count')) as sum | ||
FROM events | ||
WHERE team_id = 2 | ||
AND event='decide usage' | ||
AND timestamp between '2022-01-01 00:00:00' AND '2022-01-10 23:59:59' | ||
AND has(['correct'], replaceRegexpAll(JSONExtractRaw(properties, 'token'), '^"|"$', '')) | ||
GROUP BY team | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.8 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(read_bytes) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['hogql_query', 'HogQLQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = '' | ||
GROUP BY team_id | ||
' | ||
--- | ||
# name: TestFeatureFlagsUsageReport.test_usage_report_decide_requests.9 | ||
' | ||
WITH JSONExtractInt(log_comment, 'team_id') as team_id, | ||
JSONExtractString(log_comment, 'query_type') as query_type, | ||
JSONExtractString(log_comment, 'access_method') as access_method | ||
SELECT team_id, | ||
sum(read_rows) as count | ||
FROM clusterAllReplicas(posthog, system.query_log) | ||
WHERE (type = 'QueryFinish' | ||
OR type = 'ExceptionWhileProcessing') | ||
AND is_initial_query = 1 | ||
AND query_type IN (['hogql_query', 'HogQLQuery']) | ||
AND query_start_time between '2022-01-10 00:00:00' AND '2022-01-10 23:59:59' | ||
AND access_method = '' | ||
GROUP BY team_id | ||
' | ||
--- |
Oops, something went wrong.