-
-
Notifications
You must be signed in to change notification settings - Fork 397
Added call_tool #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added call_tool #153
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -10,12 +10,6 @@ try { | |||||||||||||||||||||||||||||||||||||||||
} catch { | ||||||||||||||||||||||||||||||||||||||||||
// Continue without version info if not available | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
// Configuration | ||||||||||||||||||||||||||||||||||||||||||
const GA_MEASUREMENT_ID = 'G-NGGDNL0K4L'; // Replace with your GA4 Measurement ID | ||||||||||||||||||||||||||||||||||||||||||
const GA_API_SECRET = '5M0mC--2S_6t94m8WrI60A'; // Replace with your GA4 API Secret | ||||||||||||||||||||||||||||||||||||||||||
const GA_BASE_URL = `https://www.google-analytics.com/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`; | ||||||||||||||||||||||||||||||||||||||||||
const GA_DEBUG_BASE_URL = `https://www.google-analytics.com/debug/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// Will be initialized when needed | ||||||||||||||||||||||||||||||||||||||||||
let uniqueUserId = 'unknown'; | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -81,13 +75,13 @@ export function sanitizeError(error: any): { message: string, code?: string } { | |||||||||||||||||||||||||||||||||||||||||
* @param event Event name | ||||||||||||||||||||||||||||||||||||||||||
* @param properties Optional event properties | ||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||
export const capture = async (event: string, properties?: any) => { | ||||||||||||||||||||||||||||||||||||||||||
export const captureBase = async (captureURL: string, event: string, properties?: any) => { | ||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||
// Check if telemetry is enabled in config (defaults to true if not set) | ||||||||||||||||||||||||||||||||||||||||||
const telemetryEnabled = await configManager.getValue('telemetryEnabled'); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// If telemetry is explicitly disabled or GA credentials are missing, don't send | ||||||||||||||||||||||||||||||||||||||||||
if (telemetryEnabled === false || !GA_MEASUREMENT_ID || !GA_API_SECRET) { | ||||||||||||||||||||||||||||||||||||||||||
if (telemetryEnabled === false || !captureURL) { | ||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
@@ -165,7 +159,7 @@ export const capture = async (event: string, properties?: any) => { | |||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
const req = https.request(GA_BASE_URL, options, (res) => { | ||||||||||||||||||||||||||||||||||||||||||
const req = https.request(captureURL, options, (res) => { | ||||||||||||||||||||||||||||||||||||||||||
// Response handling (optional) | ||||||||||||||||||||||||||||||||||||||||||
let data = ''; | ||||||||||||||||||||||||||||||||||||||||||
res.on('data', (chunk) => { | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -197,3 +191,20 @@ export const capture = async (event: string, properties?: any) => { | |||||||||||||||||||||||||||||||||||||||||
// Silently fail - we don't want analytics issues to break functionality | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
export const capture_call_tool = async (event: string, properties?:any) => { | ||||||||||||||||||||||||||||||||||||||||||
const GA_MEASUREMENT_ID = 'G-35YKFM782B'; // Replace with your GA4 Measurement ID | ||||||||||||||||||||||||||||||||||||||||||
const GA_API_SECRET = 'qM5VNk6aQy6NN5s-tCppZw'; // Replace with your GA4 API Secret | ||||||||||||||||||||||||||||||||||||||||||
const GA_BASE_URL = `https://www.google-analytics.com/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`; | ||||||||||||||||||||||||||||||||||||||||||
const GA_DEBUG_BASE_URL = `https://www.google-analytics.com/debug/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`; | ||||||||||||||||||||||||||||||||||||||||||
return await captureBase(GA_BASE_URL, event, properties); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
export const capture = async (event: string, properties?: any) => { | ||||||||||||||||||||||||||||||||||||||||||
const GA_MEASUREMENT_ID = 'G-NGGDNL0K4L'; // Replace with your GA4 Measurement ID | ||||||||||||||||||||||||||||||||||||||||||
const GA_API_SECRET = '5M0mC--2S_6t94m8WrI60A'; // Replace with your GA4 API Secret | ||||||||||||||||||||||||||||||||||||||||||
const GA_BASE_URL = `https://www.google-analytics.com/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`; | ||||||||||||||||||||||||||||||||||||||||||
const GA_DEBUG_BASE_URL = `https://www.google-analytics.com/debug/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
return await captureBase(GA_BASE_URL, event, properties); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+203
to
+210
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical security issue: Hardcoded API credentials exposed in source code. Similar to the -export const capture = async (event: string, properties?: any) => {
- const GA_MEASUREMENT_ID = 'G-NGGDNL0K4L'; // Replace with your GA4 Measurement ID
- const GA_API_SECRET = '5M0mC--2S_6t94m8WrI60A'; // Replace with your GA4 API Secret
- const GA_BASE_URL = `https://www.google-analytics.com/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`;
- const GA_DEBUG_BASE_URL = `https://www.google-analytics.com/debug/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`;
-
- return await captureBase(GA_BASE_URL, event, properties);
-}
+export const capture = async (event: string, properties?: any) => {
+ const GA_MEASUREMENT_ID = process.env.GA_MEASUREMENT_ID || '';
+ const GA_API_SECRET = process.env.GA_API_SECRET || '';
+
+ if (!GA_MEASUREMENT_ID || !GA_API_SECRET) {
+ console.warn('GA credentials not configured for capture');
+ return;
+ }
+
+ const GA_BASE_URL = `https://www.google-analytics.com/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`;
+ return await captureBase(GA_BASE_URL, event, properties);
+} 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Gitleaks (8.26.0)205-205: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) 🤖 Prompt for AI Agents
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical security issue: Hardcoded API credentials exposed in source code.
The Google Analytics API secret and measurement ID are hardcoded in the source code, which poses a significant security risk. These credentials should be stored in environment variables or a secure configuration system.
🧰 Tools
🪛 Gitleaks (8.26.0)
197-197: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🤖 Prompt for AI Agents