insights: add pings for total counts for insights
Created by: coury-clark
Closes #25196 (closed)
** Don't merge until the analytics team has updated the big query schema docs**
Adds insight total counts pings. Since these connect to the codeinsights-db
which is an enterprise only feature, this uses a strategy of emitting a ping to event_logs
in a background routine once per hour, allowing the ping code (which is included in OSS) to pull the data if it exists. This also means we don't have to be concerned with the DISABLE_CODE_INSIGHTS
flag, since that is already handled by the background
package.
I tested this by manually editing in some code to print out the resulting json, and then adding new rows and testing the diff. Example of adding a new insight_series
not attached to a view.
Before:
{
"WeeklyUsageStatisticsByInsight": [],
"WeeklyInsightsPageViews": 0,
"WeeklyInsightsUniquePageViews": 0,
"WeeklyInsightConfigureClick": 0,
"WeeklyInsightAddMoreClick": 0,
"WeekStart": "2021-11-15T00:00:00Z",
"WeeklyInsightCreators": 0,
"WeeklyFirstTimeInsightCreators": 0,
"WeeklyAggregatedUsage": [],
"InsightTimeIntervals": [
{
"IntervalDays": 3,
"TotalCount": 1
},
{
"IntervalDays": 60,
"TotalCount": 4
},
{
"IntervalDays": 30,
"TotalCount": 2
},
{
"IntervalDays": 14,
"TotalCount": 2
},
{
"IntervalDays": 21,
"TotalCount": 1
},
{
"IntervalDays": 730,
"TotalCount": 1
},
{
"IntervalDays": 90,
"TotalCount": 1
}
],
"InsightOrgVisible": [
{
"Type": "search",
"TotalCount": 5
},
{
"Type": "lang-stats",
"TotalCount": 0
}
],
"InsightTotalCounts": {
"ViewCounts": [
{
"ViewType": "PIE",
"TotalCount": 2
},
{
"ViewType": "LINE",
"TotalCount": 37
}
],
"SeriesCounts": [
{
"GenerationType": "search-global",
"TotalCount": 10
},
{
"GenerationType": "language-stats",
"TotalCount": 2
},
{
"GenerationType": "search",
"TotalCount": 29
}
],
"ViewSeriesCounts": [
{
"GenerationType": "search",
"ViewType": "LINE",
"TotalCount": 29
},
{
"GenerationType": "language-stats",
"ViewType": "PIE",
"TotalCount": 2
},
{
"GenerationType": "search-global",
"ViewType": "LINE",
"TotalCount": 11
}
]
}
}
After
{
"WeeklyUsageStatisticsByInsight": [],
"WeeklyInsightsPageViews": 0,
"WeeklyInsightsUniquePageViews": 0,
"WeeklyInsightConfigureClick": 0,
"WeeklyInsightAddMoreClick": 0,
"WeekStart": "2021-11-15T00:00:00Z",
"WeeklyInsightCreators": 0,
"WeeklyFirstTimeInsightCreators": 0,
"WeeklyAggregatedUsage": [],
"InsightTimeIntervals": [
{
"IntervalDays": 60,
"TotalCount": 4
},
{
"IntervalDays": 30,
"TotalCount": 2
},
{
"IntervalDays": 14,
"TotalCount": 2
},
{
"IntervalDays": 21,
"TotalCount": 1
},
{
"IntervalDays": 730,
"TotalCount": 1
},
{
"IntervalDays": 90,
"TotalCount": 1
},
{
"IntervalDays": 3,
"TotalCount": 1
}
],
"InsightOrgVisible": [
{
"Type": "search",
"TotalCount": 5
},
{
"Type": "lang-stats",
"TotalCount": 0
}
],
"InsightTotalCounts": {
"ViewCounts": [
{
"ViewType": "PIE",
"TotalCount": 2
},
{
"ViewType": "LINE",
"TotalCount": 37
}
],
"SeriesCounts": [
{
"GenerationType": "search-global",
"TotalCount": 10
},
{
"GenerationType": "language-stats",
"TotalCount": 3
},
{
"GenerationType": "search",
"TotalCount": 29
}
],
"ViewSeriesCounts": [
{
"GenerationType": "search",
"ViewType": "LINE",
"TotalCount": 29
},
{
"GenerationType": "language-stats",
"ViewType": "PIE",
"TotalCount": 2
},
{
"GenerationType": "search-global",
"ViewType": "LINE",
"TotalCount": 11
}
]
}
}