* Fetch install counts from GitHub stats repository
()
| 182 | * Fetch install counts from GitHub stats repository |
| 183 | */ |
| 184 | async function fetchInstallCountsFromGitHub(): Promise< |
| 185 | Array<{ plugin: string; unique_installs: number }> |
| 186 | > { |
| 187 | logForDebugging(`Fetching install counts from ${INSTALL_COUNTS_URL}`) |
| 188 | |
| 189 | const started = performance.now() |
| 190 | try { |
| 191 | const response = await axios.get<GitHubStatsResponse>(INSTALL_COUNTS_URL, { |
| 192 | timeout: 10000, |
| 193 | }) |
| 194 | |
| 195 | if (!response.data?.plugins || !Array.isArray(response.data.plugins)) { |
| 196 | throw new Error('Invalid response format from install counts API') |
| 197 | } |
| 198 | |
| 199 | logPluginFetch( |
| 200 | 'install_counts', |
| 201 | INSTALL_COUNTS_URL, |
| 202 | 'success', |
| 203 | performance.now() - started, |
| 204 | ) |
| 205 | return response.data.plugins |
| 206 | } catch (error) { |
| 207 | logPluginFetch( |
| 208 | 'install_counts', |
| 209 | INSTALL_COUNTS_URL, |
| 210 | 'failure', |
| 211 | performance.now() - started, |
| 212 | classifyFetchError(error), |
| 213 | ) |
| 214 | throw error |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Get plugin install counts as a Map. |
no test coverage detected