submitRequest()
Programmatically submit a bug report or feature request. This is the method the widget calls internally, but you can also use it directly for custom UIs.
const result = await maestrio.submitRequest({
title: "Button doesn't work on mobile",
description: "The submit button is unresponsive on iOS Safari.",
type: "bug",
});
if (result.isOk()) {
console.log("Request created:", result.value.id);
} else {
console.error("Failed:", result.error.message);
}Signature
submitRequest(
params: SubmitRequestParams
): Promise<Result<SubmitRequestResponse, SdkError>>Parameters
| Property | Type | Required | Description |
|---|---|---|---|
title | string | Yes | A short summary of the bug or feature request. |
description | string | Yes | Detailed description of the issue or suggestion. |
type | "bug" | "feature" | Yes | The type of request. |
pointedElements | PointedElement[] | No | DOM elements the user highlighted as relevant. |
PointedElement
When using the widget’s element picker, users can select page regions related to their feedback. Each selected element is captured as:
| Property | Type | Description |
|---|---|---|
selector | string | CSS selector for the element |
tagName | string | HTML tag name (e.g. "button", "div") |
text | string | Text content of the element |
html | string | Outer HTML of the element |
Return value
Returns a Result from the better-result library. This is a discriminated union that is either a success or an error.
On success
interface SubmitRequestResponse {
id: string; // Unique request ID
status: string; // Initial status (usually "received")
queued: boolean; // Whether the request was queued for AI processing
}On error
Returns one of the following error types:
| Error | When |
|---|---|
NotIdentifiedError | identify() was not called before submitting |
ValidationError | Missing or invalid parameters |
ApiError | The API returned a non-2xx response |
NetworkError | The request failed to reach the server |
Working with Result
const result = await maestrio.submitRequest({
title: "Add dark mode",
description: "It would be great to have a dark mode option.",
type: "feature",
});
if (result.isOk()) {
const { id, status, queued } = result.value;
console.log(`Request ${id} created (status: ${status}, queued: ${queued})`);
} else {
const error = result.error;
switch (error._tag) {
case "NotIdentifiedError":
console.error("User not identified");
break;
case "ValidationError":
console.error(`Invalid field: ${error.field}`);
break;
case "ApiError":
console.error(`API error (${error.status}): ${error.message}`);
break;
case "NetworkError":
console.error("Network error:", error.message);
break;
}
}Prerequisite
You must call identify() before submitRequest(). If the user is not identified, the method returns a NotIdentifiedError result.