@bbearai/react-native 0.3.10 → 0.3.11

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.js CHANGED
@@ -11534,7 +11534,7 @@ var ContextCaptureManager = class {
11534
11534
  });
11535
11535
  }
11536
11536
  captureFetch() {
11537
- if (typeof window === "undefined" || typeof fetch === "undefined") return;
11537
+ if (typeof window === "undefined" || typeof fetch === "undefined" || typeof document === "undefined") return;
11538
11538
  this.originalFetch = window.fetch;
11539
11539
  const self2 = this;
11540
11540
  window.fetch = async function(input, init) {
@@ -14435,32 +14435,46 @@ function ReportScreen({ nav, prefill }) {
14435
14435
  const [description, setDescription] = (0, import_react10.useState)("");
14436
14436
  const [affectedScreen, setAffectedScreen] = (0, import_react10.useState)("");
14437
14437
  const [submitting, setSubmitting] = (0, import_react10.useState)(false);
14438
+ const [error, setError] = (0, import_react10.useState)(null);
14438
14439
  const images = useImageAttachments(uploadImage, 5, "screenshots");
14439
14440
  const isBugType = reportType === "bug" || reportType === "test_fail";
14440
14441
  const handleSubmit = async () => {
14441
14442
  if (!client || !description.trim()) return;
14442
14443
  setSubmitting(true);
14443
- const baseContext = client.getAppContext();
14444
- const appContext = {
14445
- ...baseContext,
14446
- currentRoute: affectedScreen.trim() || baseContext.currentRoute
14447
- };
14448
- const screenshotUrls = images.getScreenshotUrls();
14449
- await client.submitReport({
14450
- type: reportType,
14451
- description: description.trim(),
14452
- severity: isBugType ? severity : void 0,
14453
- assignmentId: prefill?.assignmentId,
14454
- testCaseId: prefill?.testCaseId,
14455
- appContext,
14456
- deviceInfo: getDeviceInfo(),
14457
- screenshots: screenshotUrls.length > 0 ? screenshotUrls : void 0
14458
- });
14459
- if (prefill?.assignmentId) {
14460
- await refreshAssignments();
14444
+ setError(null);
14445
+ try {
14446
+ const baseContext = client.getAppContext();
14447
+ const appContext = {
14448
+ ...baseContext,
14449
+ currentRoute: affectedScreen.trim() || baseContext.currentRoute
14450
+ };
14451
+ const screenshotUrls = images.getScreenshotUrls();
14452
+ const result = await client.submitReport({
14453
+ type: reportType,
14454
+ description: description.trim(),
14455
+ severity: isBugType ? severity : void 0,
14456
+ assignmentId: prefill?.assignmentId,
14457
+ testCaseId: prefill?.testCaseId,
14458
+ appContext,
14459
+ deviceInfo: getDeviceInfo(),
14460
+ screenshots: screenshotUrls.length > 0 ? screenshotUrls : void 0
14461
+ });
14462
+ if (!result.success) {
14463
+ console.error("BugBear: Report submission failed", result.error);
14464
+ setError(result.error || "Failed to submit report. Please try again.");
14465
+ setSubmitting(false);
14466
+ return;
14467
+ }
14468
+ if (prefill?.assignmentId) {
14469
+ await refreshAssignments();
14470
+ }
14471
+ setSubmitting(false);
14472
+ nav.replace({ name: "REPORT_SUCCESS" });
14473
+ } catch (err) {
14474
+ console.error("BugBear: Report submission error", err);
14475
+ setError(err instanceof Error ? err.message : "An unexpected error occurred. Please try again.");
14476
+ setSubmitting(false);
14461
14477
  }
14462
- setSubmitting(false);
14463
- nav.replace({ name: "REPORT_SUCCESS" });
14464
14478
  };
14465
14479
  return /* @__PURE__ */ import_react10.default.createElement(import_react_native9.View, null, /* @__PURE__ */ import_react10.default.createElement(import_react_native9.Text, { style: shared.label }, "What are you reporting?"), /* @__PURE__ */ import_react10.default.createElement(import_react_native9.View, { style: styles7.typeRow }, [
14466
14480
  { type: "bug", label: "Bug", icon: "\u{1F41B}" },
@@ -14519,14 +14533,14 @@ function ReportScreen({ nav, prefill }) {
14519
14533
  onRemove: images.removeImage,
14520
14534
  label: "Screenshots (optional)"
14521
14535
  }
14522
- ), /* @__PURE__ */ import_react10.default.createElement(
14536
+ ), error && /* @__PURE__ */ import_react10.default.createElement(import_react_native9.View, { style: styles7.errorBanner }, /* @__PURE__ */ import_react10.default.createElement(import_react_native9.Text, { style: styles7.errorText }, error)), /* @__PURE__ */ import_react10.default.createElement(
14523
14537
  import_react_native9.TouchableOpacity,
14524
14538
  {
14525
14539
  style: [shared.primaryButton, (!description.trim() || submitting || images.isUploading) && shared.primaryButtonDisabled, { marginTop: 20 }],
14526
14540
  onPress: handleSubmit,
14527
14541
  disabled: !description.trim() || submitting || images.isUploading
14528
14542
  },
14529
- /* @__PURE__ */ import_react10.default.createElement(import_react_native9.Text, { style: shared.primaryButtonText }, images.isUploading ? "Uploading images..." : submitting ? "Submitting..." : "Submit Report")
14543
+ /* @__PURE__ */ import_react10.default.createElement(import_react_native9.Text, { style: shared.primaryButtonText }, images.isUploading ? "Uploading images..." : submitting ? "Submitting..." : error ? "Retry" : "Submit Report")
14530
14544
  ));
14531
14545
  }
14532
14546
  var styles7 = import_react_native9.StyleSheet.create({
@@ -14542,7 +14556,9 @@ var styles7 = import_react_native9.StyleSheet.create({
14542
14556
  sevText: { fontSize: 12, fontWeight: "500", color: colors.textSecondary, textTransform: "capitalize" },
14543
14557
  descInput: { backgroundColor: colors.card, borderWidth: 1, borderColor: colors.border, borderRadius: 12, paddingHorizontal: 14, paddingVertical: 12, fontSize: 14, color: colors.textPrimary, minHeight: 100 },
14544
14558
  screenInput: { backgroundColor: colors.card, borderWidth: 1, borderColor: colors.border, borderRadius: 8, paddingHorizontal: 12, paddingVertical: 8, fontSize: 13, color: colors.textPrimary },
14545
- screenHint: { fontSize: 11, color: colors.textMuted, marginTop: 4 }
14559
+ screenHint: { fontSize: 11, color: colors.textMuted, marginTop: 4 },
14560
+ errorBanner: { backgroundColor: "#7f1d1d", borderWidth: 1, borderColor: "#991b1b", borderRadius: 8, padding: 12, marginTop: 16 },
14561
+ errorText: { fontSize: 13, color: "#fca5a5", lineHeight: 18 }
14546
14562
  });
14547
14563
 
14548
14564
  // src/widget/screens/ReportSuccessScreen.tsx
package/dist/index.mjs CHANGED
@@ -11503,7 +11503,7 @@ var ContextCaptureManager = class {
11503
11503
  });
11504
11504
  }
11505
11505
  captureFetch() {
11506
- if (typeof window === "undefined" || typeof fetch === "undefined") return;
11506
+ if (typeof window === "undefined" || typeof fetch === "undefined" || typeof document === "undefined") return;
11507
11507
  this.originalFetch = window.fetch;
11508
11508
  const self2 = this;
11509
11509
  window.fetch = async function(input, init) {
@@ -14419,32 +14419,46 @@ function ReportScreen({ nav, prefill }) {
14419
14419
  const [description, setDescription] = useState6("");
14420
14420
  const [affectedScreen, setAffectedScreen] = useState6("");
14421
14421
  const [submitting, setSubmitting] = useState6(false);
14422
+ const [error, setError] = useState6(null);
14422
14423
  const images = useImageAttachments(uploadImage, 5, "screenshots");
14423
14424
  const isBugType = reportType === "bug" || reportType === "test_fail";
14424
14425
  const handleSubmit = async () => {
14425
14426
  if (!client || !description.trim()) return;
14426
14427
  setSubmitting(true);
14427
- const baseContext = client.getAppContext();
14428
- const appContext = {
14429
- ...baseContext,
14430
- currentRoute: affectedScreen.trim() || baseContext.currentRoute
14431
- };
14432
- const screenshotUrls = images.getScreenshotUrls();
14433
- await client.submitReport({
14434
- type: reportType,
14435
- description: description.trim(),
14436
- severity: isBugType ? severity : void 0,
14437
- assignmentId: prefill?.assignmentId,
14438
- testCaseId: prefill?.testCaseId,
14439
- appContext,
14440
- deviceInfo: getDeviceInfo(),
14441
- screenshots: screenshotUrls.length > 0 ? screenshotUrls : void 0
14442
- });
14443
- if (prefill?.assignmentId) {
14444
- await refreshAssignments();
14428
+ setError(null);
14429
+ try {
14430
+ const baseContext = client.getAppContext();
14431
+ const appContext = {
14432
+ ...baseContext,
14433
+ currentRoute: affectedScreen.trim() || baseContext.currentRoute
14434
+ };
14435
+ const screenshotUrls = images.getScreenshotUrls();
14436
+ const result = await client.submitReport({
14437
+ type: reportType,
14438
+ description: description.trim(),
14439
+ severity: isBugType ? severity : void 0,
14440
+ assignmentId: prefill?.assignmentId,
14441
+ testCaseId: prefill?.testCaseId,
14442
+ appContext,
14443
+ deviceInfo: getDeviceInfo(),
14444
+ screenshots: screenshotUrls.length > 0 ? screenshotUrls : void 0
14445
+ });
14446
+ if (!result.success) {
14447
+ console.error("BugBear: Report submission failed", result.error);
14448
+ setError(result.error || "Failed to submit report. Please try again.");
14449
+ setSubmitting(false);
14450
+ return;
14451
+ }
14452
+ if (prefill?.assignmentId) {
14453
+ await refreshAssignments();
14454
+ }
14455
+ setSubmitting(false);
14456
+ nav.replace({ name: "REPORT_SUCCESS" });
14457
+ } catch (err) {
14458
+ console.error("BugBear: Report submission error", err);
14459
+ setError(err instanceof Error ? err.message : "An unexpected error occurred. Please try again.");
14460
+ setSubmitting(false);
14445
14461
  }
14446
- setSubmitting(false);
14447
- nav.replace({ name: "REPORT_SUCCESS" });
14448
14462
  };
14449
14463
  return /* @__PURE__ */ React8.createElement(View7, null, /* @__PURE__ */ React8.createElement(Text7, { style: shared.label }, "What are you reporting?"), /* @__PURE__ */ React8.createElement(View7, { style: styles7.typeRow }, [
14450
14464
  { type: "bug", label: "Bug", icon: "\u{1F41B}" },
@@ -14503,14 +14517,14 @@ function ReportScreen({ nav, prefill }) {
14503
14517
  onRemove: images.removeImage,
14504
14518
  label: "Screenshots (optional)"
14505
14519
  }
14506
- ), /* @__PURE__ */ React8.createElement(
14520
+ ), error && /* @__PURE__ */ React8.createElement(View7, { style: styles7.errorBanner }, /* @__PURE__ */ React8.createElement(Text7, { style: styles7.errorText }, error)), /* @__PURE__ */ React8.createElement(
14507
14521
  TouchableOpacity7,
14508
14522
  {
14509
14523
  style: [shared.primaryButton, (!description.trim() || submitting || images.isUploading) && shared.primaryButtonDisabled, { marginTop: 20 }],
14510
14524
  onPress: handleSubmit,
14511
14525
  disabled: !description.trim() || submitting || images.isUploading
14512
14526
  },
14513
- /* @__PURE__ */ React8.createElement(Text7, { style: shared.primaryButtonText }, images.isUploading ? "Uploading images..." : submitting ? "Submitting..." : "Submit Report")
14527
+ /* @__PURE__ */ React8.createElement(Text7, { style: shared.primaryButtonText }, images.isUploading ? "Uploading images..." : submitting ? "Submitting..." : error ? "Retry" : "Submit Report")
14514
14528
  ));
14515
14529
  }
14516
14530
  var styles7 = StyleSheet8.create({
@@ -14526,7 +14540,9 @@ var styles7 = StyleSheet8.create({
14526
14540
  sevText: { fontSize: 12, fontWeight: "500", color: colors.textSecondary, textTransform: "capitalize" },
14527
14541
  descInput: { backgroundColor: colors.card, borderWidth: 1, borderColor: colors.border, borderRadius: 12, paddingHorizontal: 14, paddingVertical: 12, fontSize: 14, color: colors.textPrimary, minHeight: 100 },
14528
14542
  screenInput: { backgroundColor: colors.card, borderWidth: 1, borderColor: colors.border, borderRadius: 8, paddingHorizontal: 12, paddingVertical: 8, fontSize: 13, color: colors.textPrimary },
14529
- screenHint: { fontSize: 11, color: colors.textMuted, marginTop: 4 }
14543
+ screenHint: { fontSize: 11, color: colors.textMuted, marginTop: 4 },
14544
+ errorBanner: { backgroundColor: "#7f1d1d", borderWidth: 1, borderColor: "#991b1b", borderRadius: 8, padding: 12, marginTop: 16 },
14545
+ errorText: { fontSize: 13, color: "#fca5a5", lineHeight: 18 }
14530
14546
  });
14531
14547
 
14532
14548
  // src/widget/screens/ReportSuccessScreen.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbearai/react-native",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "BugBear React Native components for mobile apps",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",