whyusersleave 1.1.0 → 1.2.0
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/index.js +39 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -317,6 +317,45 @@ server.tool(
|
|
|
317
317
|
}
|
|
318
318
|
);
|
|
319
319
|
|
|
320
|
+
// Tool 5: ask_question
|
|
321
|
+
server.tool(
|
|
322
|
+
"ask_question",
|
|
323
|
+
"Ask a question about user behavior on your site. Returns a data-grounded answer from your real analytics. Use this to understand WHY users behave a certain way, not just WHAT they do. Examples: 'Why are users bouncing from /pricing?', 'What form fields cause the most abandonment?', 'What are users searching for with Ctrl+F?'",
|
|
324
|
+
{
|
|
325
|
+
question: {
|
|
326
|
+
type: "string",
|
|
327
|
+
description:
|
|
328
|
+
"Natural language question about user behavior, e.g. 'Why are users bouncing from /pricing?'",
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
async ({ question }) => {
|
|
332
|
+
const sites = await getSites();
|
|
333
|
+
trackToolCall("ask_question");
|
|
334
|
+
const allLines = [];
|
|
335
|
+
|
|
336
|
+
for (const site of sites) {
|
|
337
|
+
if (sites.length > 1) {
|
|
338
|
+
allLines.push(`# ${site.name || site.domain}\n`);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const res = await apiCall(`/api/ask${qs(siteParam(site.id))}`, {
|
|
342
|
+
method: "POST",
|
|
343
|
+
body: JSON.stringify({ question }),
|
|
344
|
+
});
|
|
345
|
+
const data = await res.json();
|
|
346
|
+
allLines.push(data.answer || "No answer generated.");
|
|
347
|
+
|
|
348
|
+
if (data.sources?.length > 0) {
|
|
349
|
+
allLines.push(`\n*Based on: ${data.sources.join(", ")}*`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
content: [{ type: "text", text: allLines.join("\n\n") }],
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
|
|
320
359
|
// Start server
|
|
321
360
|
const transport = new StdioServerTransport();
|
|
322
361
|
await server.connect(transport);
|
package/package.json
CHANGED