@bbearai/core 0.9.7 → 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;
@@ -1304,6 +1305,16 @@ declare class BugBearClient {
1304
1305
  success: boolean;
1305
1306
  error?: string;
1306
1307
  }>;
1308
+ /**
1309
+ * Get a pre-authenticated dashboard URL for the given tester email.
1310
+ * Uses a server-generated magic link that bypasses the login page.
1311
+ * Falls back to raw dashboardUrl when no API key is configured.
1312
+ */
1313
+ getDashboardLoginUrl(email: string): Promise<{
1314
+ success: boolean;
1315
+ loginUrl?: string;
1316
+ error?: string;
1317
+ }>;
1307
1318
  /**
1308
1319
  * Capture an email for QA testing.
1309
1320
  * Called by the email interceptor — not typically called directly.
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;
@@ -1304,6 +1305,16 @@ declare class BugBearClient {
1304
1305
  success: boolean;
1305
1306
  error?: string;
1306
1307
  }>;
1308
+ /**
1309
+ * Get a pre-authenticated dashboard URL for the given tester email.
1310
+ * Uses a server-generated magic link that bypasses the login page.
1311
+ * Falls back to raw dashboardUrl when no API key is configured.
1312
+ */
1313
+ getDashboardLoginUrl(email: string): Promise<{
1314
+ success: boolean;
1315
+ loginUrl?: string;
1316
+ error?: string;
1317
+ }>;
1307
1318
  /**
1308
1319
  * Capture an email for QA testing.
1309
1320
  * Called by the email interceptor — not typically called directly.
package/dist/index.js CHANGED
@@ -1419,38 +1419,96 @@ 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`, {
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
+ });
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" };
1471
+ }
1472
+ return { success: true };
1473
+ } catch (err) {
1474
+ const message = err instanceof Error ? err.message : "Widget feedback submission failed";
1475
+ return { success: false, error: message };
1476
+ }
1477
+ }
1478
+ /**
1479
+ * Get a pre-authenticated dashboard URL for the given tester email.
1480
+ * Uses a server-generated magic link that bypasses the login page.
1481
+ * Falls back to raw dashboardUrl when no API key is configured.
1482
+ */
1483
+ async getDashboardLoginUrl(email) {
1484
+ try {
1485
+ if (!this.config.apiKey) {
1486
+ const fallback = this.config.dashboardUrl;
1487
+ if (fallback) return { success: true, loginUrl: fallback };
1488
+ return { success: false, error: "API key required for auto-login" };
1489
+ }
1490
+ await this.ready();
1491
+ const baseUrl = (this.config.apiBaseUrl || DEFAULT_API_BASE_URL).replace(/\/$/, "");
1492
+ const response = await fetch(`${baseUrl}/api/v1/auth/widget-login`, {
1430
1493
  method: "POST",
1431
1494
  headers: {
1432
1495
  "Content-Type": "application/json",
1433
- ...this.config.apiKey ? { "Authorization": `Bearer ${this.config.apiKey}` } : {}
1496
+ "Authorization": `Bearer ${this.config.apiKey}`
1434
1497
  },
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
- })
1498
+ body: JSON.stringify({ email })
1446
1499
  });
1447
1500
  if (!response.ok) {
1448
1501
  const body = await response.json().catch(() => ({}));
1449
1502
  return { success: false, error: body.error || `HTTP ${response.status}` };
1450
1503
  }
1451
- return { success: true };
1504
+ const result = await response.json();
1505
+ const loginUrl = result?.data?.loginUrl;
1506
+ if (!loginUrl) {
1507
+ return { success: false, error: "No login URL in response" };
1508
+ }
1509
+ return { success: true, loginUrl };
1452
1510
  } catch (err) {
1453
- const message = err instanceof Error ? err.message : "Widget feedback submission failed";
1511
+ const message = err instanceof Error ? err.message : "Failed to get dashboard login URL";
1454
1512
  return { success: false, error: message };
1455
1513
  }
1456
1514
  }
package/dist/index.mjs CHANGED
@@ -1373,38 +1373,96 @@ 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`, {
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
+ });
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" };
1425
+ }
1426
+ return { success: true };
1427
+ } catch (err) {
1428
+ const message = err instanceof Error ? err.message : "Widget feedback submission failed";
1429
+ return { success: false, error: message };
1430
+ }
1431
+ }
1432
+ /**
1433
+ * Get a pre-authenticated dashboard URL for the given tester email.
1434
+ * Uses a server-generated magic link that bypasses the login page.
1435
+ * Falls back to raw dashboardUrl when no API key is configured.
1436
+ */
1437
+ async getDashboardLoginUrl(email) {
1438
+ try {
1439
+ if (!this.config.apiKey) {
1440
+ const fallback = this.config.dashboardUrl;
1441
+ if (fallback) return { success: true, loginUrl: fallback };
1442
+ return { success: false, error: "API key required for auto-login" };
1443
+ }
1444
+ await this.ready();
1445
+ const baseUrl = (this.config.apiBaseUrl || DEFAULT_API_BASE_URL).replace(/\/$/, "");
1446
+ const response = await fetch(`${baseUrl}/api/v1/auth/widget-login`, {
1384
1447
  method: "POST",
1385
1448
  headers: {
1386
1449
  "Content-Type": "application/json",
1387
- ...this.config.apiKey ? { "Authorization": `Bearer ${this.config.apiKey}` } : {}
1450
+ "Authorization": `Bearer ${this.config.apiKey}`
1388
1451
  },
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
- })
1452
+ body: JSON.stringify({ email })
1400
1453
  });
1401
1454
  if (!response.ok) {
1402
1455
  const body = await response.json().catch(() => ({}));
1403
1456
  return { success: false, error: body.error || `HTTP ${response.status}` };
1404
1457
  }
1405
- return { success: true };
1458
+ const result = await response.json();
1459
+ const loginUrl = result?.data?.loginUrl;
1460
+ if (!loginUrl) {
1461
+ return { success: false, error: "No login URL in response" };
1462
+ }
1463
+ return { success: true, loginUrl };
1406
1464
  } catch (err) {
1407
- const message = err instanceof Error ? err.message : "Widget feedback submission failed";
1465
+ const message = err instanceof Error ? err.message : "Failed to get dashboard login URL";
1408
1466
  return { success: false, error: message };
1409
1467
  }
1410
1468
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbearai/core",
3
- "version": "0.9.7",
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",