@bbearai/core 0.9.8 → 0.9.10

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
- })
1446
- });
1447
- if (!response.ok) {
1448
- const body = await response.json().catch(() => ({}));
1449
- return { success: false, error: body.error || `HTTP ${response.status}` };
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
1467
+ }).select("id").single();
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) {
@@ -1736,8 +1757,9 @@ var BugBearClient = class {
1736
1757
  )
1737
1758
  `).eq("id", assignmentId).single();
1738
1759
  if (error || !data) return null;
1739
- const testCase = data.test_case;
1740
- const rpt = data.original_report;
1760
+ const row = data;
1761
+ const testCase = row.test_case;
1762
+ const rpt = row.original_report;
1741
1763
  const originalReport = rpt ? {
1742
1764
  id: rpt.id,
1743
1765
  title: rpt.title,
@@ -1747,7 +1769,7 @@ var BugBearClient = class {
1747
1769
  resolutionNotes: rpt.resolution_notes || void 0,
1748
1770
  route: rpt.app_context?.currentRoute || void 0
1749
1771
  } : void 0;
1750
- if (!testCase && !data.is_verification) {
1772
+ if (!testCase && !row.is_verification) {
1751
1773
  console.error("BugBear: Assignment returned without test_case");
1752
1774
  return null;
1753
1775
  }
@@ -1757,8 +1779,8 @@ var BugBearClient = class {
1757
1779
  status: data.status,
1758
1780
  startedAt: data.started_at,
1759
1781
  durationSeconds: data.duration_seconds,
1760
- isVerification: data.is_verification || false,
1761
- originalReportId: data.original_report_id,
1782
+ isVerification: row.is_verification || false,
1783
+ originalReportId: row.original_report_id ?? void 0,
1762
1784
  originalReport,
1763
1785
  testCase: testCase ? {
1764
1786
  id: testCase.id,
@@ -1779,8 +1801,8 @@ var BugBearClient = class {
1779
1801
  description: track.description
1780
1802
  } : void 0
1781
1803
  } : {
1782
- id: data.original_report_id || data.id,
1783
- title: rpt?.title || (data.notes?.replace(/^Verification:\s*/i, "") || "Bug Verification"),
1804
+ id: row.original_report_id || data.id,
1805
+ title: rpt?.title || (row.notes?.replace(/^Verification:\s*/i, "") || "Bug Verification"),
1784
1806
  testKey: "VERIFY",
1785
1807
  description: rpt?.description || "Verify that the reported bug has been fixed",
1786
1808
  steps: [],
@@ -2230,6 +2252,7 @@ var BugBearClient = class {
2230
2252
  originalBugId: row.original_bug_id || void 0,
2231
2253
  originalBugTitle: row.original_bug_title || void 0,
2232
2254
  resolutionNotes: row.resolution_notes || void 0,
2255
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Supabase JSON column
2233
2256
  fixCommitSha: row.code_context?.fix?.commit_sha || void 0,
2234
2257
  fixCommitMessage: row.code_context?.fix?.commit_message || void 0,
2235
2258
  fixFilesChanged: row.code_context?.fix?.files_changed || void 0
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
- })
1400
- });
1401
- if (!response.ok) {
1402
- const body = await response.json().catch(() => ({}));
1403
- return { success: false, error: body.error || `HTTP ${response.status}` };
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
1421
+ }).select("id").single();
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) {
@@ -1690,8 +1711,9 @@ var BugBearClient = class {
1690
1711
  )
1691
1712
  `).eq("id", assignmentId).single();
1692
1713
  if (error || !data) return null;
1693
- const testCase = data.test_case;
1694
- const rpt = data.original_report;
1714
+ const row = data;
1715
+ const testCase = row.test_case;
1716
+ const rpt = row.original_report;
1695
1717
  const originalReport = rpt ? {
1696
1718
  id: rpt.id,
1697
1719
  title: rpt.title,
@@ -1701,7 +1723,7 @@ var BugBearClient = class {
1701
1723
  resolutionNotes: rpt.resolution_notes || void 0,
1702
1724
  route: rpt.app_context?.currentRoute || void 0
1703
1725
  } : void 0;
1704
- if (!testCase && !data.is_verification) {
1726
+ if (!testCase && !row.is_verification) {
1705
1727
  console.error("BugBear: Assignment returned without test_case");
1706
1728
  return null;
1707
1729
  }
@@ -1711,8 +1733,8 @@ var BugBearClient = class {
1711
1733
  status: data.status,
1712
1734
  startedAt: data.started_at,
1713
1735
  durationSeconds: data.duration_seconds,
1714
- isVerification: data.is_verification || false,
1715
- originalReportId: data.original_report_id,
1736
+ isVerification: row.is_verification || false,
1737
+ originalReportId: row.original_report_id ?? void 0,
1716
1738
  originalReport,
1717
1739
  testCase: testCase ? {
1718
1740
  id: testCase.id,
@@ -1733,8 +1755,8 @@ var BugBearClient = class {
1733
1755
  description: track.description
1734
1756
  } : void 0
1735
1757
  } : {
1736
- id: data.original_report_id || data.id,
1737
- title: rpt?.title || (data.notes?.replace(/^Verification:\s*/i, "") || "Bug Verification"),
1758
+ id: row.original_report_id || data.id,
1759
+ title: rpt?.title || (row.notes?.replace(/^Verification:\s*/i, "") || "Bug Verification"),
1738
1760
  testKey: "VERIFY",
1739
1761
  description: rpt?.description || "Verify that the reported bug has been fixed",
1740
1762
  steps: [],
@@ -2184,6 +2206,7 @@ var BugBearClient = class {
2184
2206
  originalBugId: row.original_bug_id || void 0,
2185
2207
  originalBugTitle: row.original_bug_title || void 0,
2186
2208
  resolutionNotes: row.resolution_notes || void 0,
2209
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Supabase JSON column
2187
2210
  fixCommitSha: row.code_context?.fix?.commit_sha || void 0,
2188
2211
  fixCommitMessage: row.code_context?.fix?.commit_message || void 0,
2189
2212
  fixFilesChanged: row.code_context?.fix?.files_changed || void 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbearai/core",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "description": "Core utilities and types for BugBear QA platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",