Skip to content

Commit 0a84320

Browse files
committed
chore(google-tag-manager): remove debug logs
- Remove all console.log statements from gtm-client.ts - Remove all console.log statements from accounts.ts - Clean code ready for production deployment
1 parent d05cd58 commit 0a84320

2 files changed

Lines changed: 10 additions & 59 deletions

File tree

google-tag-manager/server/lib/gtm-client.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ export class GTMClient {
4242
* Make a request to the GTM API
4343
*/
4444
private async request<T>(url: string, options: RequestInit = {}): Promise<T> {
45-
console.log(`[GTM API Request] ${options.method || "GET"} ${url}`);
46-
4745
const response = await fetch(url, {
4846
...options,
4947
headers: {
@@ -53,33 +51,19 @@ export class GTMClient {
5351
},
5452
});
5553

56-
console.log(
57-
`[GTM API Response] Status: ${response.status} ${response.statusText}`,
58-
);
59-
6054
if (!response.ok) {
6155
const error = await response.text();
62-
console.error(`[GTM API Error] ${response.status} - ${error}`);
6356
throw new Error(
6457
`Google Tag Manager API error: ${response.status} - ${error}`,
6558
);
6659
}
6760

6861
// Handle 204 No Content
6962
if (response.status === 204) {
70-
console.log(`[GTM API] 204 No Content - returning empty object`);
7163
return {} as T;
7264
}
7365

74-
const data = await response.json();
75-
console.log(
76-
`[GTM API Data] Response type: ${Array.isArray(data) ? "Array" : typeof data}`,
77-
);
78-
if (typeof data === "object" && data !== null) {
79-
console.log(`[GTM API Data] Keys:`, Object.keys(data));
80-
}
81-
82-
return data as T;
66+
return (await response.json()) as T;
8367
}
8468

8569
// ==================== Account Methods ====================

google-tag-manager/server/tools/accounts.ts

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,54 +44,21 @@ export const createListAccountsTool = (env: Env) =>
4444
nextPageToken: z.string().optional(),
4545
}),
4646
execute: async ({ context }) => {
47-
console.log(
48-
"[list_accounts] Starting with pageToken:",
49-
context.pageToken,
50-
);
51-
5247
const client = new GTMClient({
5348
accessToken: getAccessToken(env),
5449
});
5550

5651
const response = await client.listAccounts(context.pageToken);
5752

58-
console.log("[list_accounts] Raw response structure:");
59-
console.log("- Type:", typeof response);
60-
console.log("- Keys:", Object.keys(response));
61-
console.log("- Has 'account' property:", "account" in response);
62-
console.log(
63-
"- 'account' type:",
64-
Array.isArray(response.account) ? "Array" : typeof response.account,
65-
);
66-
console.log("- 'account' length:", response.account?.length);
67-
68-
if (response.account && response.account.length > 0) {
69-
console.log("[list_accounts] First account structure:");
70-
console.log(JSON.stringify(response.account[0], null, 2));
71-
}
72-
73-
const accounts = (response.account || []).map((acc) => {
74-
console.log(
75-
"[list_accounts] Processing account:",
76-
acc.accountId,
77-
acc.name,
78-
);
79-
return {
80-
path: acc.path,
81-
accountId: acc.accountId,
82-
name: acc.name,
83-
...(acc.shareData !== undefined && { shareData: acc.shareData }),
84-
...(acc.fingerprint && { fingerprint: acc.fingerprint }),
85-
...(acc.tagManagerUrl && { tagManagerUrl: acc.tagManagerUrl }),
86-
...(acc.features && { features: acc.features }),
87-
};
88-
});
89-
90-
console.log(
91-
"[list_accounts] Returning result with",
92-
accounts.length,
93-
"accounts",
94-
);
53+
const accounts = (response.account || []).map((acc) => ({
54+
path: acc.path,
55+
accountId: acc.accountId,
56+
name: acc.name,
57+
...(acc.shareData !== undefined && { shareData: acc.shareData }),
58+
...(acc.fingerprint && { fingerprint: acc.fingerprint }),
59+
...(acc.tagManagerUrl && { tagManagerUrl: acc.tagManagerUrl }),
60+
...(acc.features && { features: acc.features }),
61+
}));
9562

9663
return {
9764
accounts,

0 commit comments

Comments
 (0)