react-native-bug-reporter 1.0.0
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/LICENSE +21 -0
- package/README.md +217 -0
- package/android/build.gradle +49 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/java/com/bugreporter/ScreenshotDetectorModule.kt +227 -0
- package/android/src/main/java/com/bugreporter/ScreenshotDetectorPackage.kt +20 -0
- package/ios/RNBugReporterScreenshot.m +11 -0
- package/ios/RNBugReporterScreenshot.swift +113 -0
- package/lib/commonjs/BugReporterProvider.js +139 -0
- package/lib/commonjs/BugReporterProvider.js.map +1 -0
- package/lib/commonjs/collectors/appInfo.js +21 -0
- package/lib/commonjs/collectors/appInfo.js.map +1 -0
- package/lib/commonjs/collectors/collectContext.js +45 -0
- package/lib/commonjs/collectors/collectContext.js.map +1 -0
- package/lib/commonjs/collectors/deviceInfo.js +41 -0
- package/lib/commonjs/collectors/deviceInfo.js.map +1 -0
- package/lib/commonjs/collectors/networkInfo.js +33 -0
- package/lib/commonjs/collectors/networkInfo.js.map +1 -0
- package/lib/commonjs/components/BugReportAdminScreen.js +225 -0
- package/lib/commonjs/components/BugReportAdminScreen.js.map +1 -0
- package/lib/commonjs/components/BugReportModal.js +341 -0
- package/lib/commonjs/components/BugReportModal.js.map +1 -0
- package/lib/commonjs/components/ScreenshotEditor.js +466 -0
- package/lib/commonjs/components/ScreenshotEditor.js.map +1 -0
- package/lib/commonjs/components/ScreenshotPreview.js +134 -0
- package/lib/commonjs/components/ScreenshotPreview.js.map +1 -0
- package/lib/commonjs/components/SeveritySelector.js +65 -0
- package/lib/commonjs/components/SeveritySelector.js.map +1 -0
- package/lib/commonjs/context/BugReporterContext.js +24 -0
- package/lib/commonjs/context/BugReporterContext.js.map +1 -0
- package/lib/commonjs/hooks/useScreenshotDetector.js +22 -0
- package/lib/commonjs/hooks/useScreenshotDetector.js.map +1 -0
- package/lib/commonjs/index.js +87 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/native/ScreenshotDetector.js +72 -0
- package/lib/commonjs/native/ScreenshotDetector.js.map +1 -0
- package/lib/commonjs/navigation/screenTracker.js +47 -0
- package/lib/commonjs/navigation/screenTracker.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/services/bugReportService.js +61 -0
- package/lib/commonjs/services/bugReportService.js.map +1 -0
- package/lib/commonjs/services/supabaseService.js +166 -0
- package/lib/commonjs/services/supabaseService.js.map +1 -0
- package/lib/commonjs/theme.js +28 -0
- package/lib/commonjs/theme.js.map +1 -0
- package/lib/commonjs/types.js +35 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils/logger.js +29 -0
- package/lib/commonjs/utils/logger.js.map +1 -0
- package/lib/module/BugReporterProvider.js +134 -0
- package/lib/module/BugReporterProvider.js.map +1 -0
- package/lib/module/collectors/appInfo.js +16 -0
- package/lib/module/collectors/appInfo.js.map +1 -0
- package/lib/module/collectors/collectContext.js +41 -0
- package/lib/module/collectors/collectContext.js.map +1 -0
- package/lib/module/collectors/deviceInfo.js +37 -0
- package/lib/module/collectors/deviceInfo.js.map +1 -0
- package/lib/module/collectors/networkInfo.js +29 -0
- package/lib/module/collectors/networkInfo.js.map +1 -0
- package/lib/module/components/BugReportAdminScreen.js +221 -0
- package/lib/module/components/BugReportAdminScreen.js.map +1 -0
- package/lib/module/components/BugReportModal.js +337 -0
- package/lib/module/components/BugReportModal.js.map +1 -0
- package/lib/module/components/ScreenshotEditor.js +461 -0
- package/lib/module/components/ScreenshotEditor.js.map +1 -0
- package/lib/module/components/ScreenshotPreview.js +130 -0
- package/lib/module/components/ScreenshotPreview.js.map +1 -0
- package/lib/module/components/SeveritySelector.js +61 -0
- package/lib/module/components/SeveritySelector.js.map +1 -0
- package/lib/module/context/BugReporterContext.js +19 -0
- package/lib/module/context/BugReporterContext.js.map +1 -0
- package/lib/module/hooks/useScreenshotDetector.js +18 -0
- package/lib/module/hooks/useScreenshotDetector.js.map +1 -0
- package/lib/module/index.js +32 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native/ScreenshotDetector.js +68 -0
- package/lib/module/native/ScreenshotDetector.js.map +1 -0
- package/lib/module/navigation/screenTracker.js +41 -0
- package/lib/module/navigation/screenTracker.js.map +1 -0
- package/lib/module/services/bugReportService.js +57 -0
- package/lib/module/services/bugReportService.js.map +1 -0
- package/lib/module/services/supabaseService.js +159 -0
- package/lib/module/services/supabaseService.js.map +1 -0
- package/lib/module/theme.js +23 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/types.js +31 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/logger.js +25 -0
- package/lib/module/utils/logger.js.map +1 -0
- package/lib/typescript/src/BugReporterProvider.d.ts +18 -0
- package/lib/typescript/src/BugReporterProvider.d.ts.map +1 -0
- package/lib/typescript/src/collectors/appInfo.d.ts +6 -0
- package/lib/typescript/src/collectors/appInfo.d.ts.map +1 -0
- package/lib/typescript/src/collectors/collectContext.d.ts +7 -0
- package/lib/typescript/src/collectors/collectContext.d.ts.map +1 -0
- package/lib/typescript/src/collectors/deviceInfo.d.ts +7 -0
- package/lib/typescript/src/collectors/deviceInfo.d.ts.map +1 -0
- package/lib/typescript/src/collectors/networkInfo.d.ts +6 -0
- package/lib/typescript/src/collectors/networkInfo.d.ts.map +1 -0
- package/lib/typescript/src/components/BugReportAdminScreen.d.ts +11 -0
- package/lib/typescript/src/components/BugReportAdminScreen.d.ts.map +1 -0
- package/lib/typescript/src/components/BugReportModal.d.ts +20 -0
- package/lib/typescript/src/components/BugReportModal.d.ts.map +1 -0
- package/lib/typescript/src/components/ScreenshotEditor.d.ts +16 -0
- package/lib/typescript/src/components/ScreenshotEditor.d.ts.map +1 -0
- package/lib/typescript/src/components/ScreenshotPreview.d.ts +11 -0
- package/lib/typescript/src/components/ScreenshotPreview.d.ts.map +1 -0
- package/lib/typescript/src/components/SeveritySelector.d.ts +10 -0
- package/lib/typescript/src/components/SeveritySelector.d.ts.map +1 -0
- package/lib/typescript/src/context/BugReporterContext.d.ts +20 -0
- package/lib/typescript/src/context/BugReporterContext.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useScreenshotDetector.d.ts +7 -0
- package/lib/typescript/src/hooks/useScreenshotDetector.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +26 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/native/ScreenshotDetector.d.ts +15 -0
- package/lib/typescript/src/native/ScreenshotDetector.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screenTracker.d.ts +7 -0
- package/lib/typescript/src/navigation/screenTracker.d.ts.map +1 -0
- package/lib/typescript/src/services/bugReportService.d.ts +17 -0
- package/lib/typescript/src/services/bugReportService.d.ts.map +1 -0
- package/lib/typescript/src/services/supabaseService.d.ts +38 -0
- package/lib/typescript/src/services/supabaseService.d.ts.map +1 -0
- package/lib/typescript/src/theme.d.ts +7 -0
- package/lib/typescript/src/theme.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +144 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/logger.d.ts +7 -0
- package/lib/typescript/src/utils/logger.d.ts.map +1 -0
- package/package.json +100 -0
- package/react-native-bug-reporter.podspec +22 -0
- package/react-native.config.js +18 -0
- package/src/BugReporterProvider.tsx +178 -0
- package/src/collectors/appInfo.ts +15 -0
- package/src/collectors/collectContext.ts +47 -0
- package/src/collectors/deviceInfo.ts +51 -0
- package/src/collectors/networkInfo.ts +31 -0
- package/src/components/BugReportAdminScreen.tsx +160 -0
- package/src/components/BugReportModal.tsx +315 -0
- package/src/components/ScreenshotEditor.tsx +410 -0
- package/src/components/ScreenshotPreview.tsx +98 -0
- package/src/components/SeveritySelector.tsx +59 -0
- package/src/context/BugReporterContext.ts +29 -0
- package/src/hooks/useScreenshotDetector.ts +20 -0
- package/src/index.ts +51 -0
- package/src/native/ScreenshotDetector.ts +87 -0
- package/src/navigation/screenTracker.ts +40 -0
- package/src/services/bugReportService.ts +81 -0
- package/src/services/supabaseService.ts +195 -0
- package/src/theme.ts +23 -0
- package/src/types.ts +156 -0
- package/src/utils/logger.ts +24 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SeveritySelector = SeveritySelector;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _types = require("../types");
|
|
9
|
+
var _theme = require("../theme");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
const LABELS = {
|
|
12
|
+
low: 'Low',
|
|
13
|
+
medium: 'Medium',
|
|
14
|
+
high: 'High',
|
|
15
|
+
critical: 'Critical'
|
|
16
|
+
};
|
|
17
|
+
function SeveritySelector({
|
|
18
|
+
value,
|
|
19
|
+
onChange,
|
|
20
|
+
theme
|
|
21
|
+
}) {
|
|
22
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
23
|
+
style: styles.row,
|
|
24
|
+
children: _types.SEVERITIES.map(sev => {
|
|
25
|
+
const selected = sev === value;
|
|
26
|
+
const color = _theme.SEVERITY_COLORS[sev];
|
|
27
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
28
|
+
accessibilityRole: "button",
|
|
29
|
+
accessibilityState: {
|
|
30
|
+
selected
|
|
31
|
+
},
|
|
32
|
+
onPress: () => onChange(sev),
|
|
33
|
+
style: [styles.chip, {
|
|
34
|
+
borderColor: selected ? color : theme.borderColor
|
|
35
|
+
}, selected && {
|
|
36
|
+
backgroundColor: color
|
|
37
|
+
}],
|
|
38
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
39
|
+
style: [styles.label, {
|
|
40
|
+
color: selected ? '#fff' : theme.mutedColor
|
|
41
|
+
}],
|
|
42
|
+
children: LABELS[sev]
|
|
43
|
+
})
|
|
44
|
+
}, sev);
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const styles = _reactNative.StyleSheet.create({
|
|
49
|
+
row: {
|
|
50
|
+
flexDirection: 'row',
|
|
51
|
+
gap: 8
|
|
52
|
+
},
|
|
53
|
+
chip: {
|
|
54
|
+
flex: 1,
|
|
55
|
+
paddingVertical: 10,
|
|
56
|
+
borderRadius: 10,
|
|
57
|
+
borderWidth: 1.5,
|
|
58
|
+
alignItems: 'center'
|
|
59
|
+
},
|
|
60
|
+
label: {
|
|
61
|
+
fontSize: 13,
|
|
62
|
+
fontWeight: '600'
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=SeveritySelector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_types","_theme","_jsxRuntime","LABELS","low","medium","high","critical","SeveritySelector","value","onChange","theme","jsx","View","style","styles","row","children","SEVERITIES","map","sev","selected","color","SEVERITY_COLORS","TouchableOpacity","accessibilityRole","accessibilityState","onPress","chip","borderColor","backgroundColor","Text","label","mutedColor","StyleSheet","create","flexDirection","gap","flex","paddingVertical","borderRadius","borderWidth","alignItems","fontSize","fontWeight"],"sourceRoot":"../../../src","sources":["components/SeveritySelector.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAA+D,IAAAG,WAAA,GAAAH,OAAA;AAQ/D,MAAMI,MAAmC,GAAG;EAC1CC,GAAG,EAAE,KAAK;EACVC,MAAM,EAAE,QAAQ;EAChBC,IAAI,EAAE,MAAM;EACZC,QAAQ,EAAE;AACZ,CAAC;AAEM,SAASC,gBAAgBA,CAAC;EAAEC,KAAK;EAAEC,QAAQ;EAAEC;AAAa,CAAC,EAAE;EAClE,oBACE,IAAAT,WAAA,CAAAU,GAA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AAE;IAAEC,UAAU,EAAE;EAAM;AAC3C,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BugReporterContext = void 0;
|
|
7
|
+
exports.useBugReporter = useBugReporter;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
const BugReporterContext = exports.BugReporterContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Access the bug reporter imperatively, e.g. to wire a "Report a bug" button:
|
|
13
|
+
*
|
|
14
|
+
* const { openReporter } = useBugReporter();
|
|
15
|
+
* <Button title="Report a bug" onPress={() => openReporter()} />
|
|
16
|
+
*/
|
|
17
|
+
function useBugReporter() {
|
|
18
|
+
const ctx = (0, _react.useContext)(BugReporterContext);
|
|
19
|
+
if (!ctx) {
|
|
20
|
+
throw new Error('useBugReporter must be used within a <BugReporterProvider>');
|
|
21
|
+
}
|
|
22
|
+
return ctx;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=BugReporterContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","BugReporterContext","exports","createContext","useBugReporter","ctx","useContext","Error"],"sourceRoot":"../../../src","sources":["context/BugReporterContext.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAcO,MAAMC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,gBAAG,IAAAE,oBAAa,EAAiC,IAAI,CAAC;;AAErF;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAA,EAA4B;EACxD,MAAMC,GAAG,GAAG,IAAAC,iBAAU,EAACL,kBAAkB,CAAC;EAC1C,IAAI,CAACI,GAAG,EAAE;IACR,MAAM,IAAIE,KAAK,CAAC,4DAA4D,CAAC;EAC/E;EACA,OAAOF,GAAG;AACZ","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useScreenshotDetector = useScreenshotDetector;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _ScreenshotDetector = require("../native/ScreenshotDetector");
|
|
9
|
+
/**
|
|
10
|
+
* Subscribes to native screenshot detection while `enabled` is true.
|
|
11
|
+
* Calls `onScreenshot` with the captured image whenever the user takes one.
|
|
12
|
+
*/
|
|
13
|
+
function useScreenshotDetector(enabled, onScreenshot) {
|
|
14
|
+
(0, _react.useEffect)(() => {
|
|
15
|
+
if (!enabled) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const unsubscribe = _ScreenshotDetector.screenshotDetector.subscribe(onScreenshot);
|
|
19
|
+
return unsubscribe;
|
|
20
|
+
}, [enabled, onScreenshot]);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=useScreenshotDetector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_ScreenshotDetector","useScreenshotDetector","enabled","onScreenshot","useEffect","unsubscribe","screenshotDetector","subscribe"],"sourceRoot":"../../../src","sources":["hooks/useScreenshotDetector.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAGA;AACA;AACA;AACA;AACO,SAASE,qBAAqBA,CACnCC,OAAgB,EAChBC,YAAkD,EAClD;EACA,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAI,CAACF,OAAO,EAAE;MACZ;IACF;IACA,MAAMG,WAAW,GAAGC,sCAAkB,CAACC,SAAS,CAACJ,YAAY,CAAC;IAC9D,OAAOE,WAAW;EACpB,CAAC,EAAE,CAACH,OAAO,EAAEC,YAAY,CAAC,CAAC;AAC7B","ignoreList":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BugReportAdminScreen", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _BugReportAdminScreen.BugReportAdminScreen;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "BugReporterProvider", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _BugReporterProvider.BugReporterProvider;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "SEVERITIES", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _types.SEVERITIES;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "collectContext", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _collectContext.collectContext;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "getActiveRouteName", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _screenTracker.getActiveRouteName;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "getCurrentScreen", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _screenTracker.getCurrentScreen;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "screenshotDetector", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _ScreenshotDetector.screenshotDetector;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "setCurrentScreen", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _screenTracker.setCurrentScreen;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "submitBugReport", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _bugReportService.submitBugReport;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "subscribeToReports", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _supabaseService.subscribeToReports;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "updateReportStatus", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _supabaseService.updateReportStatus;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "useBugReporter", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _BugReporterContext.useBugReporter;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
var _BugReporterProvider = require("./BugReporterProvider");
|
|
79
|
+
var _BugReporterContext = require("./context/BugReporterContext");
|
|
80
|
+
var _BugReportAdminScreen = require("./components/BugReportAdminScreen");
|
|
81
|
+
var _screenTracker = require("./navigation/screenTracker");
|
|
82
|
+
var _collectContext = require("./collectors/collectContext");
|
|
83
|
+
var _bugReportService = require("./services/bugReportService");
|
|
84
|
+
var _supabaseService = require("./services/supabaseService");
|
|
85
|
+
var _ScreenshotDetector = require("./native/ScreenshotDetector");
|
|
86
|
+
var _types = require("./types");
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_BugReporterProvider","require","_BugReporterContext","_BugReportAdminScreen","_screenTracker","_collectContext","_bugReportService","_supabaseService","_ScreenshotDetector","_types"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAGA,IAAAG,cAAA,GAAAH,OAAA;AAOA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AAIA,IAAAO,mBAAA,GAAAP,OAAA;AAgBA,IAAAQ,MAAA,GAAAR,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.screenshotDetector = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _logger = require("../utils/logger");
|
|
9
|
+
const LINKING_ERROR = `The native module 'RNBugReporterScreenshot' from 'react-native-bug-reporter' is not linked.\n` + _reactNative.Platform.select({
|
|
10
|
+
ios: '- Run `cd ios && pod install`, then rebuild the app.\n',
|
|
11
|
+
android: '- Rebuild the Android app (autolinking registers the module automatically).\n',
|
|
12
|
+
default: ''
|
|
13
|
+
}) + '- A native rebuild is required after install — Fast Refresh is not enough.\n';
|
|
14
|
+
const NativeScreenshot = _reactNative.NativeModules.RNBugReporterScreenshot;
|
|
15
|
+
/**
|
|
16
|
+
* Thin wrapper around the native screenshot detector. Exposes a single
|
|
17
|
+
* `subscribe` method that starts detection and returns an unsubscribe fn.
|
|
18
|
+
*/
|
|
19
|
+
class ScreenshotDetector {
|
|
20
|
+
emitter = null;
|
|
21
|
+
listenerCount = 0;
|
|
22
|
+
isAvailable() {
|
|
23
|
+
return !!NativeScreenshot;
|
|
24
|
+
}
|
|
25
|
+
subscribe(listener) {
|
|
26
|
+
if (!NativeScreenshot) {
|
|
27
|
+
_logger.logger.warn(LINKING_ERROR);
|
|
28
|
+
return () => {};
|
|
29
|
+
}
|
|
30
|
+
if (!this.emitter) {
|
|
31
|
+
this.emitter = new _reactNative.NativeEventEmitter(NativeScreenshot);
|
|
32
|
+
}
|
|
33
|
+
const subscription = this.emitter.addListener('BugReporterScreenshotTaken', payload => {
|
|
34
|
+
if (!payload || !payload.uri) {
|
|
35
|
+
// Detection fired but capture failed — still notify with no image so
|
|
36
|
+
// the user can file a report manually.
|
|
37
|
+
listener({
|
|
38
|
+
uri: '',
|
|
39
|
+
width: 0,
|
|
40
|
+
height: 0
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
listener({
|
|
45
|
+
uri: payload.uri,
|
|
46
|
+
width: payload.width,
|
|
47
|
+
height: payload.height
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
if (this.listenerCount === 0) {
|
|
51
|
+
try {
|
|
52
|
+
NativeScreenshot.start();
|
|
53
|
+
} catch (e) {
|
|
54
|
+
_logger.logger.warn('failed to start native detector', e);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this.listenerCount += 1;
|
|
58
|
+
return () => {
|
|
59
|
+
subscription.remove();
|
|
60
|
+
this.listenerCount = Math.max(0, this.listenerCount - 1);
|
|
61
|
+
if (this.listenerCount === 0) {
|
|
62
|
+
try {
|
|
63
|
+
NativeScreenshot.stop();
|
|
64
|
+
} catch (e) {
|
|
65
|
+
_logger.logger.warn('failed to stop native detector', e);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const screenshotDetector = exports.screenshotDetector = new ScreenshotDetector();
|
|
72
|
+
//# sourceMappingURL=ScreenshotDetector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_logger","LINKING_ERROR","Platform","select","ios","android","default","NativeScreenshot","NativeModules","RNBugReporterScreenshot","ScreenshotDetector","emitter","listenerCount","isAvailable","subscribe","listener","logger","warn","NativeEventEmitter","subscription","addListener","payload","uri","width","height","start","e","remove","Math","max","stop","screenshotDetector","exports"],"sourceRoot":"../../../src","sources":["native/ScreenshotDetector.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,aAAa,GACjB,+FAA+F,GAC/FC,qBAAQ,CAACC,MAAM,CAAC;EACdC,GAAG,EAAE,wDAAwD;EAC7DC,OAAO,EAAE,+EAA+E;EACxFC,OAAO,EAAE;AACX,CAAC,CAAC,GACF,8EAA8E;AAEhF,MAAMC,gBAAgB,GAAGC,0BAAa,CAACC,uBAO1B;AAIb;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,CAAC;EACfC,OAAO,GAA8B,IAAI;EACzCC,aAAa,GAAG,CAAC;EAEzBC,WAAWA,CAAA,EAAY;IACrB,OAAO,CAAC,CAACN,gBAAgB;EAC3B;EAEAO,SAASA,CAACC,QAA4B,EAAc;IAClD,IAAI,CAACR,gBAAgB,EAAE;MACrBS,cAAM,CAACC,IAAI,CAAChB,aAAa,CAAC;MAC1B,OAAO,MAAM,CAAC,CAAC;IACjB;IAEA,IAAI,CAAC,IAAI,CAACU,OAAO,EAAE;MACjB,IAAI,CAACA,OAAO,GAAG,IAAIO,+BAAkB,CAACX,gBAAuB,CAAC;IAChE;IAEA,MAAMY,YAAY,GAAG,IAAI,CAACR,OAAO,CAACS,WAAW,CAC3C,4BAA4B,EAC3BC,OAAiE,IAAK;MACrE,IAAI,CAACA,OAAO,IAAI,CAACA,OAAO,CAACC,GAAG,EAAE;QAC5B;QACA;QACAP,QAAQ,CAAC;UAAEO,GAAG,EAAE,EAAE;UAAEC,KAAK,EAAE,CAAC;UAAEC,MAAM,EAAE;QAAE,CAAC,CAAC;QAC1C;MACF;MACAT,QAAQ,CAAC;QACPO,GAAG,EAAED,OAAO,CAACC,GAAG;QAChBC,KAAK,EAAEF,OAAO,CAACE,KAAK;QACpBC,MAAM,EAAEH,OAAO,CAACG;MAClB,CAAC,CAAC;IACJ,CACF,CAAC;IAED,IAAI,IAAI,CAACZ,aAAa,KAAK,CAAC,EAAE;MAC5B,IAAI;QACFL,gBAAgB,CAACkB,KAAK,CAAC,CAAC;MAC1B,CAAC,CAAC,OAAOC,CAAC,EAAE;QACVV,cAAM,CAACC,IAAI,CAAC,iCAAiC,EAAES,CAAC,CAAC;MACnD;IACF;IACA,IAAI,CAACd,aAAa,IAAI,CAAC;IAEvB,OAAO,MAAM;MACXO,YAAY,CAACQ,MAAM,CAAC,CAAC;MACrB,IAAI,CAACf,aAAa,GAAGgB,IAAI,CAACC,GAAG,CAAC,CAAC,EAAE,IAAI,CAACjB,aAAa,GAAG,CAAC,CAAC;MACxD,IAAI,IAAI,CAACA,aAAa,KAAK,CAAC,EAAE;QAC5B,IAAI;UACFL,gBAAgB,CAACuB,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC,OAAOJ,CAAC,EAAE;UACVV,cAAM,CAACC,IAAI,CAAC,gCAAgC,EAAES,CAAC,CAAC;QAClD;MACF;IACF,CAAC;EACH;AACF;AAEO,MAAMK,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,IAAIrB,kBAAkB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getActiveRouteName = getActiveRouteName;
|
|
7
|
+
exports.getCurrentScreen = getCurrentScreen;
|
|
8
|
+
exports.setCurrentScreen = setCurrentScreen;
|
|
9
|
+
/**
|
|
10
|
+
* Lightweight current-screen tracker.
|
|
11
|
+
*
|
|
12
|
+
* The SDK is navigation-library agnostic. The host app reports its active
|
|
13
|
+
* route name here, and the SDK reads it when collecting context.
|
|
14
|
+
*
|
|
15
|
+
* Usage with React Navigation:
|
|
16
|
+
*
|
|
17
|
+
* <NavigationContainer
|
|
18
|
+
* onStateChange={(state) => {
|
|
19
|
+
* const route = getActiveRouteName(state);
|
|
20
|
+
* if (route) setCurrentScreen(route);
|
|
21
|
+
* }}
|
|
22
|
+
* />
|
|
23
|
+
*
|
|
24
|
+
* Or call `setCurrentScreen('Home')` manually from any screen's effect.
|
|
25
|
+
*/
|
|
26
|
+
let currentScreen = null;
|
|
27
|
+
function setCurrentScreen(name) {
|
|
28
|
+
currentScreen = name;
|
|
29
|
+
}
|
|
30
|
+
function getCurrentScreen() {
|
|
31
|
+
return currentScreen;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Walks a React Navigation state object to find the deepest active route name.
|
|
36
|
+
*/
|
|
37
|
+
function getActiveRouteName(state) {
|
|
38
|
+
if (!state || typeof state.index !== 'number' || !Array.isArray(state.routes)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const route = state.routes[state.index];
|
|
42
|
+
if (route?.state) {
|
|
43
|
+
return getActiveRouteName(route.state);
|
|
44
|
+
}
|
|
45
|
+
return route?.name ?? null;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=screenTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["currentScreen","setCurrentScreen","name","getCurrentScreen","getActiveRouteName","state","index","Array","isArray","routes","route"],"sourceRoot":"../../../src","sources":["navigation/screenTracker.ts"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,aAA4B,GAAG,IAAI;AAEhC,SAASC,gBAAgBA,CAACC,IAAmB,EAAQ;EAC1DF,aAAa,GAAGE,IAAI;AACtB;AAEO,SAASC,gBAAgBA,CAAA,EAAkB;EAChD,OAAOH,aAAa;AACtB;;AAEA;AACA;AACA;AACO,SAASI,kBAAkBA,CAACC,KAAU,EAAiB;EAC5D,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,CAACC,KAAK,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,KAAK,CAACI,MAAM,CAAC,EAAE;IAC7E,OAAO,IAAI;EACb;EACA,MAAMC,KAAK,GAAGL,KAAK,CAACI,MAAM,CAACJ,KAAK,CAACC,KAAK,CAAC;EACvC,IAAII,KAAK,EAAEL,KAAK,EAAE;IAChB,OAAOD,kBAAkB,CAACM,KAAK,CAACL,KAAK,CAAC;EACxC;EACA,OAAOK,KAAK,EAAER,IAAI,IAAI,IAAI;AAC5B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.submitBugReport = submitBugReport;
|
|
7
|
+
var _supabaseService = require("./supabaseService");
|
|
8
|
+
var _logger = require("../utils/logger");
|
|
9
|
+
/**
|
|
10
|
+
* End-to-end submission pipeline (Supabase):
|
|
11
|
+
* 1. upload the screenshot to Supabase Storage (if present)
|
|
12
|
+
* 2. insert the report row into Postgres
|
|
13
|
+
*
|
|
14
|
+
* A Database Webhook → Edge Function then sends the notification email.
|
|
15
|
+
*/
|
|
16
|
+
async function submitBugReport({
|
|
17
|
+
input,
|
|
18
|
+
context,
|
|
19
|
+
screenshot,
|
|
20
|
+
config,
|
|
21
|
+
onState
|
|
22
|
+
}) {
|
|
23
|
+
const target = (0, _supabaseService.targetFromConfig)(config);
|
|
24
|
+
|
|
25
|
+
// Normalize configured recipient(s).
|
|
26
|
+
const notifyEmails = (Array.isArray(config.notifyEmails) ? config.notifyEmails : config.notifyEmails ? [config.notifyEmails] : []).map(e => e.trim()).filter(Boolean);
|
|
27
|
+
let screenshotUrl = null;
|
|
28
|
+
let screenshotPath = null;
|
|
29
|
+
try {
|
|
30
|
+
if (screenshot?.uri) {
|
|
31
|
+
onState?.('uploading');
|
|
32
|
+
const result = await (0, _supabaseService.uploadScreenshot)(target, screenshot.uri);
|
|
33
|
+
screenshotUrl = result.publicUrl;
|
|
34
|
+
screenshotPath = result.storagePath;
|
|
35
|
+
}
|
|
36
|
+
onState?.('saving');
|
|
37
|
+
const report = {
|
|
38
|
+
title: input.title.trim(),
|
|
39
|
+
description: input.description.trim(),
|
|
40
|
+
severity: input.severity,
|
|
41
|
+
screenshotUrl,
|
|
42
|
+
screenshotPath,
|
|
43
|
+
context,
|
|
44
|
+
status: 'open',
|
|
45
|
+
createdAt: context.timestamp,
|
|
46
|
+
...(notifyEmails.length ? {
|
|
47
|
+
notifyEmails
|
|
48
|
+
} : {})
|
|
49
|
+
};
|
|
50
|
+
const saved = await (0, _supabaseService.insertReport)(target, report);
|
|
51
|
+
onState?.('done');
|
|
52
|
+
config.onSubmitted?.(saved);
|
|
53
|
+
return saved;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
_logger.logger.error('submit failed', error);
|
|
56
|
+
onState?.('error');
|
|
57
|
+
config.onError?.(error);
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=bugReportService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_supabaseService","require","_logger","submitBugReport","input","context","screenshot","config","onState","target","targetFromConfig","notifyEmails","Array","isArray","map","e","trim","filter","Boolean","screenshotUrl","screenshotPath","uri","result","uploadScreenshot","publicUrl","storagePath","report","title","description","severity","status","createdAt","timestamp","length","saved","insertReport","onSubmitted","error","logger","onError"],"sourceRoot":"../../../src","sources":["services/bugReportService.ts"],"mappings":";;;;;;AAQA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeE,eAAeA,CAAC;EACpCC,KAAK;EACLC,OAAO;EACPC,UAAU;EACVC,MAAM;EACNC;AACU,CAAC,EAAsB;EACjC,MAAMC,MA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KAAK,CAAC;IAC3B,OAAOA,KAAK;EACd,CAAC,CAAC,OAAOG,KAAK,EAAE;IACdC,cAAM,CAACD,KAAK,CAAC,eAAe,EAAEA,KAAK,CAAC;IACpC7B,OAAO,GAAG,OAAO,CAAC;IAClBD,MAAM,CAACgC,OAAO,GAAGF,KAAK,CAAC;IACvB,MAAMA,KAAK;EACb;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.insertReport = insertReport;
|
|
7
|
+
exports.subscribeToReports = subscribeToReports;
|
|
8
|
+
exports.targetFromConfig = targetFromConfig;
|
|
9
|
+
exports.updateReportStatus = updateReportStatus;
|
|
10
|
+
exports.uploadScreenshot = uploadScreenshot;
|
|
11
|
+
require("react-native-url-polyfill/auto");
|
|
12
|
+
var _supabaseJs = require("@supabase/supabase-js");
|
|
13
|
+
var _logger = require("../utils/logger");
|
|
14
|
+
/**
|
|
15
|
+
* Supabase backend for the SDK.
|
|
16
|
+
*
|
|
17
|
+
* - Screenshots upload to a Supabase Storage bucket.
|
|
18
|
+
* - Reports are inserted into a Postgres table.
|
|
19
|
+
* - A Database Webhook → Edge Function (see supabase/) emails each new report.
|
|
20
|
+
*
|
|
21
|
+
* The client is pure JS — no native config files. You only need the project URL
|
|
22
|
+
* and anon key (passed via BugReporterConfig).
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
let client = null;
|
|
26
|
+
let clientKey = '';
|
|
27
|
+
function getClient(url, anonKey) {
|
|
28
|
+
const key = `${url}::${anonKey}`;
|
|
29
|
+
if (!client || clientKey !== key) {
|
|
30
|
+
client = (0, _supabaseJs.createClient)(url, anonKey, {
|
|
31
|
+
auth: {
|
|
32
|
+
persistSession: false,
|
|
33
|
+
autoRefreshToken: false
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
clientKey = key;
|
|
37
|
+
}
|
|
38
|
+
return client;
|
|
39
|
+
}
|
|
40
|
+
/** DB row (snake_case) → SDK BugReport (camelCase). */
|
|
41
|
+
function mapRow(row) {
|
|
42
|
+
return {
|
|
43
|
+
id: row.id,
|
|
44
|
+
title: row.title ?? '',
|
|
45
|
+
description: row.description ?? '',
|
|
46
|
+
severity: row.severity ?? 'medium',
|
|
47
|
+
screenshotUrl: row.screenshot_url ?? null,
|
|
48
|
+
screenshotPath: row.screenshot_path ?? null,
|
|
49
|
+
context: row.context ?? {},
|
|
50
|
+
status: row.status ?? 'open',
|
|
51
|
+
createdAt: row.created_at ?? '',
|
|
52
|
+
notifyEmails: row.notify_emails ?? undefined
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Uploads a local screenshot file to Supabase Storage; returns its public URL.
|
|
57
|
+
*
|
|
58
|
+
* Uses a multipart FormData POST to the Storage REST endpoint. React Native's
|
|
59
|
+
* networking streams `file://` / `content://` uris natively this way, which is
|
|
60
|
+
* reliable on real devices — unlike `fetch(fileUri).arrayBuffer()`, which throws
|
|
61
|
+
* "Network request failed" on Android.
|
|
62
|
+
*/
|
|
63
|
+
async function uploadScreenshot(target, localUri) {
|
|
64
|
+
const storagePath = `${Date.now()}_${Math.floor(Math.random() * 1e6)}.png`;
|
|
65
|
+
const endpoint = `${target.supabaseUrl.replace(/\/+$/, '')}/storage/v1/object/${target.storageBucket}/${storagePath}`;
|
|
66
|
+
const form = new FormData();
|
|
67
|
+
form.append('file', {
|
|
68
|
+
uri: localUri,
|
|
69
|
+
name: storagePath,
|
|
70
|
+
type: 'image/png'
|
|
71
|
+
});
|
|
72
|
+
const res = await fetch(endpoint, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
apikey: target.supabaseAnonKey,
|
|
76
|
+
Authorization: `Bearer ${target.supabaseAnonKey}`,
|
|
77
|
+
'x-upsert': 'true'
|
|
78
|
+
},
|
|
79
|
+
body: form
|
|
80
|
+
});
|
|
81
|
+
if (!res.ok) {
|
|
82
|
+
const text = await res.text().catch(() => '');
|
|
83
|
+
throw new Error(`Storage upload failed (${res.status}): ${text}`);
|
|
84
|
+
}
|
|
85
|
+
const publicUrl = `${target.supabaseUrl.replace(/\/+$/, '')}/storage/v1/object/public/${target.storageBucket}/${storagePath}`;
|
|
86
|
+
_logger.logger.log('screenshot uploaded', storagePath);
|
|
87
|
+
return {
|
|
88
|
+
publicUrl,
|
|
89
|
+
storagePath
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Inserts a bug report row and returns the saved report. */
|
|
94
|
+
async function insertReport(target, report) {
|
|
95
|
+
const supabase = getClient(target.supabaseUrl, target.supabaseAnonKey);
|
|
96
|
+
const {
|
|
97
|
+
data,
|
|
98
|
+
error
|
|
99
|
+
} = await supabase.from(target.tableName).insert({
|
|
100
|
+
title: report.title,
|
|
101
|
+
description: report.description,
|
|
102
|
+
severity: report.severity,
|
|
103
|
+
screenshot_url: report.screenshotUrl,
|
|
104
|
+
screenshot_path: report.screenshotPath,
|
|
105
|
+
context: report.context,
|
|
106
|
+
status: report.status,
|
|
107
|
+
created_at: report.createdAt,
|
|
108
|
+
notify_emails: report.notifyEmails ?? null
|
|
109
|
+
}).select().single();
|
|
110
|
+
if (error) throw error;
|
|
111
|
+
_logger.logger.log('report inserted', data.id);
|
|
112
|
+
return mapRow(data);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Subscribes to the reports table (newest first). Does an initial fetch, then
|
|
117
|
+
* refetches on any realtime change. Returns an unsubscribe function.
|
|
118
|
+
*/
|
|
119
|
+
function subscribeToReports(target, onData, onError) {
|
|
120
|
+
const supabase = getClient(target.supabaseUrl, target.supabaseAnonKey);
|
|
121
|
+
const fetchAll = async () => {
|
|
122
|
+
const {
|
|
123
|
+
data,
|
|
124
|
+
error
|
|
125
|
+
} = await supabase.from(target.tableName).select('*').order('created_at', {
|
|
126
|
+
ascending: false
|
|
127
|
+
}).limit(200);
|
|
128
|
+
if (error) {
|
|
129
|
+
_logger.logger.error('reports fetch error', error);
|
|
130
|
+
onError?.(error);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
onData((data ?? []).map(mapRow));
|
|
134
|
+
};
|
|
135
|
+
fetchAll();
|
|
136
|
+
const channel = supabase.channel(`bugreporter:${target.tableName}`).on('postgres_changes', {
|
|
137
|
+
event: '*',
|
|
138
|
+
schema: 'public',
|
|
139
|
+
table: target.tableName
|
|
140
|
+
}, () => fetchAll()).subscribe();
|
|
141
|
+
return () => {
|
|
142
|
+
supabase.removeChannel(channel);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Updates a report's status (admin). */
|
|
147
|
+
async function updateReportStatus(target, reportId, status) {
|
|
148
|
+
const supabase = getClient(target.supabaseUrl, target.supabaseAnonKey);
|
|
149
|
+
const {
|
|
150
|
+
error
|
|
151
|
+
} = await supabase.from(target.tableName).update({
|
|
152
|
+
status
|
|
153
|
+
}).eq('id', reportId);
|
|
154
|
+
if (error) throw error;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Builds a SupabaseTarget from the SDK config (with defaults). */
|
|
158
|
+
function targetFromConfig(config) {
|
|
159
|
+
return {
|
|
160
|
+
supabaseUrl: config.supabaseUrl,
|
|
161
|
+
supabaseAnonKey: config.supabaseAnonKey,
|
|
162
|
+
tableName: config.tableName ?? 'bug_reports',
|
|
163
|
+
storageBucket: config.storageBucket ?? 'bug-reports'
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=supabaseService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["require","_supabaseJs","_logger","client","clientKey","getClient","url","anonKey","key","createClient","auth","persistSession","autoRefreshToken","mapRow","row","id","title","description","severity","screenshotUrl","screenshot_url","screenshotPath","screenshot_path","context","status","createdAt","created_at","notifyEmails","notify_emails","undefined","uploadScreenshot","target","localUri","storagePath","Date","now","Math","floor","random","endpoint","supabaseUrl","replace","storageBucket","form","FormData","append","uri","name","type","res","fetch","method","headers","apikey","supabaseAnonKey","Authorization","body","ok","text","catch","Error","publicUrl","logger","log","insertReport","report","supabase","data","error","from","tableName","insert","select","single","subscribeToReports","onData","onError","fetchAll","order","ascending","limit","map","channel","on","event","schema","table","subscribe","removeChannel","updateReportStatus","reportId","update","eq","targetFromConfig","config"],"sourceRoot":"../../../src","sources":["services/supabaseService.ts"],"mappings":";;;;;;;;;;AAAAA,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAIG,MAA6B,GAAG,IAAI;AACxC,IAAIC,SAAS,GAAG,EAAE;AAElB,SAASC,SAASA,CAACC,GAAW,EAAEC,OAAe,EAAkB;EAC/D,MAAMC,GAAG,GAAG,GAAGF,GAAG,KAAKC,OAAO,EAAE;EAChC,IAAI,CAACJ,MAAM,IAAIC,SAAS,KAAKI,GAAG,EAAE;IAChCL,MAAM,GAAG,IAAAM,wBAAY,EAACH,GAAG,EAAEC,OAAO,EAAE;MAClCG,IAAI,EAAE;QAAEC,cAAc,EAAE,KAAK;QAAEC,gBAAgB,EAAE;MAAM;IACzD,CAAC,CAAC;IACFR,SAAS,GAAGI,GAAG;EACjB;EACA,OAAOL,MAAM;AACf;AASA;AACA,SAASU,MAAMA,CAACC,GAA4B,EAAa;EACvD,OAAO;IACLC,EAAE,EAAED,GAAG,CAACC,EAAY;IACpBC,KAAK,EAAGF,GAAG,CAACE,KAAK,IAAe,EAAE;IAClCC,WAAW,EAAGH,GAAG,CAACG,WAAW,IAAe,EAAE;IAC9CC,QAAQ,EAAGJ,GAAG,CAACI,QAAQ,IAA8B,QAAQ;IAC7DC,aAAa,EAAGL,GAAG,CAACM,cAAc,IAAe,IAAI;IACrDC,cAAc,EAAGP,GAAG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,CAACS,WAAW,EAAET,MAAM,CAACuB,eAAe,CAAC;EACtE,MAAM;IAAEc;EAAM,CAAC,GAAG,MAAMF,QAAQ,CAC7BG,IAAI,CAACtC,MAAM,CAACuC,SAAS,CAAC,CACtBqB,MAAM,CAAC;IAAEnE;EAAO,CAAC,CAAC,CAClBoE,EAAE,CAAC,IAAI,EAAEF,QAAQ,CAAC;EACrB,IAAItB,KAAK,EAAE,MAAMA,KAAK;AACxB;;AAEA;AACO,SAASyB,gBAAgBA,CAACC,MAKhC,EAAkB;EACjB,OAAO;IACLtD,WAAW,EAAEsD,MAAM,CAACtD,WAAW;IAC/Bc,eAAe,EAAEwC,MAAM,CAACxC,eAAe;IACvCgB,SAAS,EAAEwB,MAAM,CAACxB,SAAS,IAAI,aAAa;IAC5C5B,aAAa,EAAEoD,MAAM,CAACpD,aAAa,IAAI;EACzC,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultTheme = exports.SEVERITY_COLORS = void 0;
|
|
7
|
+
exports.resolveTheme = resolveTheme;
|
|
8
|
+
const defaultTheme = exports.defaultTheme = {
|
|
9
|
+
primaryColor: '#2563eb',
|
|
10
|
+
backgroundColor: '#ffffff',
|
|
11
|
+
textColor: '#111827',
|
|
12
|
+
mutedColor: '#6b7280',
|
|
13
|
+
borderColor: '#e5e7eb',
|
|
14
|
+
errorColor: '#ef4444'
|
|
15
|
+
};
|
|
16
|
+
function resolveTheme(theme) {
|
|
17
|
+
return {
|
|
18
|
+
...defaultTheme,
|
|
19
|
+
...(theme || {})
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const SEVERITY_COLORS = exports.SEVERITY_COLORS = {
|
|
23
|
+
low: '#3b82f6',
|
|
24
|
+
medium: '#f59e0b',
|
|
25
|
+
high: '#ef4444',
|
|
26
|
+
critical: '#991b1b'
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultTheme","exports","primaryColor","backgroundColor","textColor","mutedColor","borderColor","errorColor","resolveTheme","theme","SEVERITY_COLORS","low","medium","high","critical"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":";;;;;;;AAIO,MAAMA,YAA2B,GAAAC,OAAA,CAAAD,YAAA,GAAG;EACzCE,YAAY,EAAE,SAAS;EACvBC,eAAe,EAAE,SAAS;EAC1BC,SAAS,EAAE,SAAS;EACpBC,UAAU,EAAE,SAAS;EACrBC,WAAW,EAAE,SAAS;EACtBC,UAAU,EAAE;AACd,CAAC;AAEM,SAASC,YAAYA,CAACC,KAAwB,EAAiB;EACpE,OAAO;IAAE,GAAGT,YAAY;IAAE,IAAIS,KAAK,IAAI,CAAC,CAAC;EAAE,CAAC;AAC9C;AAEO,MAAMC,eAAuC,GAAAT,OAAA,CAAAS,eAAA,GAAG;EACrDC,GAAG,EAAE,SAAS;EACdC,MAAM,EAAE,SAAS;EACjBC,IAAI,EAAE,SAAS;EACfC,QAAQ,EAAE;AACZ,CAAC","ignoreList":[]}
|