@bbearai/core 0.9.8 → 0.9.9

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/index.d.mts CHANGED
@@ -1292,7 +1292,8 @@ declare class BugBearClient {
1292
1292
  }>;
1293
1293
  /**
1294
1294
  * Submit feedback about the BugBear widget itself.
1295
- * Sends to BugBear's own internal project via a dedicated API endpoint.
1295
+ * When an API key is configured, sends via the dashboard API endpoint.
1296
+ * Otherwise, inserts directly via the Supabase connection.
1296
1297
  */
1297
1298
  submitWidgetFeedback(feedback: {
1298
1299
  description: string;
package/dist/index.d.ts CHANGED
@@ -1292,7 +1292,8 @@ declare class BugBearClient {
1292
1292
  }>;
1293
1293
  /**
1294
1294
  * Submit feedback about the BugBear widget itself.
1295
- * Sends to BugBear's own internal project via a dedicated API endpoint.
1295
+ * When an API key is configured, sends via the dashboard API endpoint.
1296
+ * Otherwise, inserts directly via the Supabase connection.
1296
1297
  */
1297
1298
  submitWidgetFeedback(feedback: {
1298
1299
  description: string;
package/dist/index.js CHANGED
@@ -1419,34 +1419,55 @@ var BugBearClient = class {
1419
1419
  }
1420
1420
  /**
1421
1421
  * Submit feedback about the BugBear widget itself.
1422
- * Sends to BugBear's own internal project via a dedicated API endpoint.
1422
+ * When an API key is configured, sends via the dashboard API endpoint.
1423
+ * Otherwise, inserts directly via the Supabase connection.
1423
1424
  */
1424
1425
  async submitWidgetFeedback(feedback) {
1425
1426
  try {
1426
1427
  await this.ready();
1427
- const baseUrl = (this.config.apiBaseUrl || DEFAULT_API_BASE_URL).replace(/\/$/, "");
1428
1428
  const testerInfo = await this.getTesterInfo();
1429
- const response = await fetch(`${baseUrl}/api/v1/widget-feedback`, {
1430
- method: "POST",
1431
- headers: {
1432
- "Content-Type": "application/json",
1433
- ...this.config.apiKey ? { "Authorization": `Bearer ${this.config.apiKey}` } : {}
1434
- },
1435
- body: JSON.stringify({
1436
- description: feedback.description,
1437
- type: feedback.type,
1438
- severity: feedback.severity,
1439
- title: feedback.title,
1440
- screenshots: feedback.screenshots,
1441
- deviceInfo: this.getDeviceInfo(),
1442
- appContext: this.getAppContext(),
1443
- reporterName: testerInfo?.name || null,
1444
- reporterEmail: testerInfo?.email || null
1445
- })
1429
+ if (this.config.apiKey) {
1430
+ const baseUrl = (this.config.apiBaseUrl || DEFAULT_API_BASE_URL).replace(/\/$/, "");
1431
+ const response = await fetch(`${baseUrl}/api/v1/widget-feedback`, {
1432
+ method: "POST",
1433
+ headers: {
1434
+ "Content-Type": "application/json",
1435
+ "Authorization": `Bearer ${this.config.apiKey}`
1436
+ },
1437
+ body: JSON.stringify({
1438
+ description: feedback.description,
1439
+ type: feedback.type,
1440
+ severity: feedback.severity,
1441
+ title: feedback.title,
1442
+ screenshots: feedback.screenshots,
1443
+ deviceInfo: this.getDeviceInfo(),
1444
+ appContext: this.getAppContext(),
1445
+ reporterName: testerInfo?.name || null,
1446
+ reporterEmail: testerInfo?.email || null
1447
+ })
1448
+ });
1449
+ if (!response.ok) {
1450
+ const body = await response.json().catch(() => ({}));
1451
+ return { success: false, error: body.error || `HTTP ${response.status}` };
1452
+ }
1453
+ return { success: true };
1454
+ }
1455
+ const { error } = await this.supabase.from("reports").insert({
1456
+ project_id: this.config.projectId,
1457
+ report_type: feedback.type,
1458
+ description: feedback.description.trim().slice(0, 1e4),
1459
+ title: feedback.title?.slice(0, 500) || null,
1460
+ severity: feedback.severity || null,
1461
+ screenshot_urls: feedback.screenshots || [],
1462
+ device_info: this.getDeviceInfo(),
1463
+ app_context: this.getAppContext(),
1464
+ report_source: "widget_feedback",
1465
+ reporter_name: testerInfo?.name || null,
1466
+ reporter_email: testerInfo?.email || null
1446
1467
  });
1447
- if (!response.ok) {
1448
- const body = await response.json().catch(() => ({}));
1449
- return { success: false, error: body.error || `HTTP ${response.status}` };
1468
+ if (error) {
1469
+ console.error("BugBear: Failed to submit widget feedback", formatPgError(error));
1470
+ return { success: false, error: error.message || "Failed to save feedback" };
1450
1471
  }
1451
1472
  return { success: true };
1452
1473
  } catch (err) {
package/dist/index.mjs CHANGED
@@ -1373,34 +1373,55 @@ var BugBearClient = class {
1373
1373
  }
1374
1374
  /**
1375
1375
  * Submit feedback about the BugBear widget itself.
1376
- * Sends to BugBear's own internal project via a dedicated API endpoint.
1376
+ * When an API key is configured, sends via the dashboard API endpoint.
1377
+ * Otherwise, inserts directly via the Supabase connection.
1377
1378
  */
1378
1379
  async submitWidgetFeedback(feedback) {
1379
1380
  try {
1380
1381
  await this.ready();
1381
- const baseUrl = (this.config.apiBaseUrl || DEFAULT_API_BASE_URL).replace(/\/$/, "");
1382
1382
  const testerInfo = await this.getTesterInfo();
1383
- const response = await fetch(`${baseUrl}/api/v1/widget-feedback`, {
1384
- method: "POST",
1385
- headers: {
1386
- "Content-Type": "application/json",
1387
- ...this.config.apiKey ? { "Authorization": `Bearer ${this.config.apiKey}` } : {}
1388
- },
1389
- body: JSON.stringify({
1390
- description: feedback.description,
1391
- type: feedback.type,
1392
- severity: feedback.severity,
1393
- title: feedback.title,
1394
- screenshots: feedback.screenshots,
1395
- deviceInfo: this.getDeviceInfo(),
1396
- appContext: this.getAppContext(),
1397
- reporterName: testerInfo?.name || null,
1398
- reporterEmail: testerInfo?.email || null
1399
- })
1383
+ if (this.config.apiKey) {
1384
+ const baseUrl = (this.config.apiBaseUrl || DEFAULT_API_BASE_URL).replace(/\/$/, "");
1385
+ const response = await fetch(`${baseUrl}/api/v1/widget-feedback`, {
1386
+ method: "POST",
1387
+ headers: {
1388
+ "Content-Type": "application/json",
1389
+ "Authorization": `Bearer ${this.config.apiKey}`
1390
+ },
1391
+ body: JSON.stringify({
1392
+ description: feedback.description,
1393
+ type: feedback.type,
1394
+ severity: feedback.severity,
1395
+ title: feedback.title,
1396
+ screenshots: feedback.screenshots,
1397
+ deviceInfo: this.getDeviceInfo(),
1398
+ appContext: this.getAppContext(),
1399
+ reporterName: testerInfo?.name || null,
1400
+ reporterEmail: testerInfo?.email || null
1401
+ })
1402
+ });
1403
+ if (!response.ok) {
1404
+ const body = await response.json().catch(() => ({}));
1405
+ return { success: false, error: body.error || `HTTP ${response.status}` };
1406
+ }
1407
+ return { success: true };
1408
+ }
1409
+ const { error } = await this.supabase.from("reports").insert({
1410
+ project_id: this.config.projectId,
1411
+ report_type: feedback.type,
1412
+ description: feedback.description.trim().slice(0, 1e4),
1413
+ title: feedback.title?.slice(0, 500) || null,
1414
+ severity: feedback.severity || null,
1415
+ screenshot_urls: feedback.screenshots || [],
1416
+ device_info: this.getDeviceInfo(),
1417
+ app_context: this.getAppContext(),
1418
+ report_source: "widget_feedback",
1419
+ reporter_name: testerInfo?.name || null,
1420
+ reporter_email: testerInfo?.email || null
1400
1421
  });
1401
- if (!response.ok) {
1402
- const body = await response.json().catch(() => ({}));
1403
- return { success: false, error: body.error || `HTTP ${response.status}` };
1422
+ if (error) {
1423
+ console.error("BugBear: Failed to submit widget feedback", formatPgError(error));
1424
+ return { success: false, error: error.message || "Failed to save feedback" };
1404
1425
  }
1405
1426
  return { success: true };
1406
1427
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbearai/core",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "description": "Core utilities and types for BugBear QA platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",