@metrone-io/mcp 1.0.2 → 1.0.3
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/README.md +1 -1
- package/dist/index.js +21 -2
- package/dist/tools.js +21 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ Optionally set `METRONE_ENDPOINT` to override the default API base URL (`https:/
|
|
|
37
37
|
| `metrone_get_pages` | Top pages by views |
|
|
38
38
|
| `metrone_get_sources` | Traffic sources breakdown |
|
|
39
39
|
| `metrone_get_live` | Current live visitors |
|
|
40
|
-
| `metrone_track_event` | Track a custom event |
|
|
40
|
+
| `metrone_track_event` | Track a custom event (query strings and `mailto:` local-parts are stripped) |
|
|
41
41
|
| `metrone_track_ai_call` | Track an AI call or chat session |
|
|
42
42
|
|
|
43
43
|
## Example
|
package/dist/index.js
CHANGED
|
@@ -123,8 +123,13 @@ var TOOLS = [
|
|
|
123
123
|
source: str(args.source) ?? "assistant"
|
|
124
124
|
};
|
|
125
125
|
if (str(args.event_name)) body.event_name = args.event_name;
|
|
126
|
-
|
|
127
|
-
if (
|
|
126
|
+
const pageUrl = str(args.page_url);
|
|
127
|
+
if (pageUrl) body.page_url = sanitizePublicUrl(pageUrl);
|
|
128
|
+
if (args.properties && typeof args.properties === "object") {
|
|
129
|
+
const props = { ...args.properties };
|
|
130
|
+
if (typeof props.url === "string") props.url = sanitizePublicUrl(props.url);
|
|
131
|
+
body.properties = props;
|
|
132
|
+
}
|
|
128
133
|
return { method: "POST", path: "/v1/api/events", body };
|
|
129
134
|
}
|
|
130
135
|
},
|
|
@@ -192,6 +197,20 @@ async function dispatch(toolName, args, executor) {
|
|
|
192
197
|
validateArgs(tool, args);
|
|
193
198
|
return executor(tool.buildRequest(args));
|
|
194
199
|
}
|
|
200
|
+
function sanitizePublicUrl(url) {
|
|
201
|
+
if (!url) return url;
|
|
202
|
+
if (url.startsWith("mailto:")) {
|
|
203
|
+
const rest = url.slice(7).split("?")[0].split("#")[0];
|
|
204
|
+
const at = rest.lastIndexOf("@");
|
|
205
|
+
return at >= 0 ? `mailto:@${rest.slice(at + 1)}` : "mailto:";
|
|
206
|
+
}
|
|
207
|
+
const q = url.indexOf("?");
|
|
208
|
+
const h = url.indexOf("#");
|
|
209
|
+
let cut = url.length;
|
|
210
|
+
if (q >= 0) cut = q;
|
|
211
|
+
if (h >= 0 && h < cut) cut = h;
|
|
212
|
+
return url.slice(0, cut);
|
|
213
|
+
}
|
|
195
214
|
|
|
196
215
|
// src/index.ts
|
|
197
216
|
var API_KEY = process.env.METRONE_API_KEY;
|
package/dist/tools.js
CHANGED
|
@@ -116,8 +116,13 @@ var TOOLS = [
|
|
|
116
116
|
source: str(args.source) ?? "assistant"
|
|
117
117
|
};
|
|
118
118
|
if (str(args.event_name)) body.event_name = args.event_name;
|
|
119
|
-
|
|
120
|
-
if (
|
|
119
|
+
const pageUrl = str(args.page_url);
|
|
120
|
+
if (pageUrl) body.page_url = sanitizePublicUrl(pageUrl);
|
|
121
|
+
if (args.properties && typeof args.properties === "object") {
|
|
122
|
+
const props = { ...args.properties };
|
|
123
|
+
if (typeof props.url === "string") props.url = sanitizePublicUrl(props.url);
|
|
124
|
+
body.properties = props;
|
|
125
|
+
}
|
|
121
126
|
return { method: "POST", path: "/v1/api/events", body };
|
|
122
127
|
}
|
|
123
128
|
},
|
|
@@ -185,6 +190,20 @@ async function dispatch(toolName, args, executor) {
|
|
|
185
190
|
validateArgs(tool, args);
|
|
186
191
|
return executor(tool.buildRequest(args));
|
|
187
192
|
}
|
|
193
|
+
function sanitizePublicUrl(url) {
|
|
194
|
+
if (!url) return url;
|
|
195
|
+
if (url.startsWith("mailto:")) {
|
|
196
|
+
const rest = url.slice(7).split("?")[0].split("#")[0];
|
|
197
|
+
const at = rest.lastIndexOf("@");
|
|
198
|
+
return at >= 0 ? `mailto:@${rest.slice(at + 1)}` : "mailto:";
|
|
199
|
+
}
|
|
200
|
+
const q = url.indexOf("?");
|
|
201
|
+
const h = url.indexOf("#");
|
|
202
|
+
let cut = url.length;
|
|
203
|
+
if (q >= 0) cut = q;
|
|
204
|
+
if (h >= 0 && h < cut) cut = h;
|
|
205
|
+
return url.slice(0, cut);
|
|
206
|
+
}
|
|
188
207
|
export {
|
|
189
208
|
TOOLS,
|
|
190
209
|
ToolValidationError,
|