mcp-ga4 2.0.11 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +1 -1
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"sha":"
|
|
1
|
+
{"sha":"365ccaf","builtAt":"2026-04-09T23:19:20.109Z"}
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,13 @@ catch {
|
|
|
25
25
|
}
|
|
26
26
|
// Version safety: warn if running a deprecated or dangerously old version
|
|
27
27
|
const __minimumSafeVersion = "2.0.1"; // minimum version with input sanitization
|
|
28
|
-
|
|
28
|
+
const __semverLt = (a, b) => { const pa = a.split(".").map(Number), pb = b.split(".").map(Number); for (let i = 0; i < 3; i++) {
|
|
29
|
+
if ((pa[i] || 0) < (pb[i] || 0))
|
|
30
|
+
return true;
|
|
31
|
+
if ((pa[i] || 0) > (pb[i] || 0))
|
|
32
|
+
return false;
|
|
33
|
+
} return false; };
|
|
34
|
+
if (__semverLt(__cliPkg.version, __minimumSafeVersion)) {
|
|
29
35
|
console.error(`[WARNING] Running deprecated version ${__cliPkg.version}. Minimum safe version is ${__minimumSafeVersion}. Please upgrade.`);
|
|
30
36
|
}
|
|
31
37
|
// CLI flags
|
|
@@ -184,12 +190,19 @@ class Ga4Manager {
|
|
|
184
190
|
const mets = (options.metrics || "eventCount").split(",").map(m => ({ name: m.trim() })).filter(m => m.name);
|
|
185
191
|
const startDate = options.startDate || "7daysAgo";
|
|
186
192
|
const endDate = options.endDate || "today";
|
|
193
|
+
// Future date validation (skip relative dates like "7daysAgo")
|
|
194
|
+
const today_ga4 = new Date().toISOString().slice(0, 10);
|
|
195
|
+
if (startDate && !startDate.includes("daysAgo") && !startDate.includes("yesterday") && !startDate.includes("today") && startDate > today_ga4) {
|
|
196
|
+
return { rows: [], row_count: 0, error: `start_date "${startDate}" is in the future. Reports only cover historical data.` };
|
|
197
|
+
}
|
|
198
|
+
// Cap limit at 10,000 for sanity (GA4 API max is 100,000)
|
|
199
|
+
const limit = Math.min(options.limit || 100, 10000);
|
|
187
200
|
const request = {
|
|
188
201
|
property: `properties/${propertyId}`,
|
|
189
202
|
dimensions: dims,
|
|
190
203
|
metrics: mets,
|
|
191
204
|
dateRanges: [{ startDate, endDate }],
|
|
192
|
-
limit
|
|
205
|
+
limit,
|
|
193
206
|
};
|
|
194
207
|
if (options.dimensionFilter && options.dimensionFilter.includes("==")) {
|
|
195
208
|
const [field, value] = options.dimensionFilter.split("==", 2);
|
package/package.json
CHANGED