Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/api/utils/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Badge utilities for GitMCP documentation tracking
*/

const badgeCountAllowedRepos = ["mcp-ui", "git-mcp"];

/**
* Gets a Durable Object stub for the view counter
* @param env Cloudflare environment
Expand Down Expand Up @@ -163,7 +165,12 @@ export function withViewTracking<T, R>(
): (args: T) => Promise<R> {
return async (args: T) => {
// Only track if we have both owner and repo and counter binding available
if (repoData.owner && repoData.repo && env?.VIEW_COUNTER) {
if (
repoData.owner &&
repoData.repo &&
badgeCountAllowedRepos.includes(repoData.repo) &&
env?.VIEW_COUNTER
) {
// Handle the view count tracking
try {
const incrementPromise = incrementRepoViewCount(
Expand Down
4 changes: 2 additions & 2 deletions src/test/badge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe("Badge utilities", () => {
const originalCallback = vi.fn().mockResolvedValue("result");

// Create the wrapped callback
const repoData = { owner: "owner", repo: "repo" };
const repoData = { owner: "idosal", repo: "git-mcp" };
const wrappedCallback = withViewTracking(
mockEnv,
mockCtx,
Expand Down Expand Up @@ -171,7 +171,7 @@ describe("Badge utilities", () => {
const originalCallback = vi.fn().mockResolvedValue("result");

// Create the wrapped callback
const repoData = { owner: "owner", repo: "repo" };
const repoData = { owner: "idosal", repo: "git-mcp" };
const wrappedCallback = withViewTracking(
mockEnv,
{},
Expand Down
Loading