* Build a map of {sanitizedPluginName: hookCount} from matched hooks. * Only logs actual names for official marketplace plugins; others become 'third-party'.
( hooks: MatchedHook[], )
| 1459 | * Only logs actual names for official marketplace plugins; others become 'third-party'. |
| 1460 | */ |
| 1461 | function getPluginHookCounts( |
| 1462 | hooks: MatchedHook[], |
| 1463 | ): Record<string, number> | undefined { |
| 1464 | const pluginHooks = hooks.filter(h => h.pluginId) |
| 1465 | if (pluginHooks.length === 0) { |
| 1466 | return undefined |
| 1467 | } |
| 1468 | const counts: Record<string, number> = {} |
| 1469 | for (const h of pluginHooks) { |
| 1470 | const atIndex = h.pluginId!.lastIndexOf('@') |
| 1471 | const isOfficial = |
| 1472 | atIndex > 0 && |
| 1473 | ALLOWED_OFFICIAL_MARKETPLACE_NAMES.has(h.pluginId!.slice(atIndex + 1)) |
| 1474 | const key = isOfficial ? h.pluginId! : 'third-party' |
| 1475 | counts[key] = (counts[key] || 0) + 1 |
| 1476 | } |
| 1477 | return counts |
| 1478 | } |
| 1479 | |
| 1480 | |
| 1481 | /** |
no test coverage detected