@goliapkg/sentori-react-native 0.8.0 → 0.8.1

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.
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ type Trigger = 'fab' | 'manual' | 'shake';
3
+ export type FeedbackButtonHandle = {
4
+ /** Open the feedback modal. Returns immediately. */
5
+ open: (defaults?: {
6
+ body?: string;
7
+ eventId?: string;
8
+ title?: string;
9
+ }) => void;
10
+ /** Close the modal if open. */
11
+ close: () => void;
12
+ };
13
+ export type FeedbackButtonProps = {
14
+ /** When to surface the prompt. Default `'fab'`. */
15
+ trigger?: Trigger;
16
+ /** Pass the eventId from the last `captureException` to tie the
17
+ * report to that crash. Optional. */
18
+ eventId?: string;
19
+ /** Localized strings. Defaults are English. */
20
+ labels?: {
21
+ title?: string;
22
+ bodyPlaceholder?: string;
23
+ emailPlaceholder?: string;
24
+ submit?: string;
25
+ cancel?: string;
26
+ sent?: string;
27
+ };
28
+ /** Shake sensitivity in m/s² above gravity. Default 18 (≈ a normal
29
+ * intentional shake; lower triggers more easily). Only used when
30
+ * `trigger="shake"`. */
31
+ shakeThreshold?: number;
32
+ };
33
+ export declare const FeedbackButton: React.ForwardRefExoticComponent<FeedbackButtonProps & React.RefAttributes<FeedbackButtonHandle>>;
34
+ export {};
35
+ //# sourceMappingURL=feedback-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback-widget.d.ts","sourceRoot":"","sources":["../src/feedback-widget.tsx"],"names":[],"mappings":"AAYA,OAAO,KAON,MAAM,OAAO,CAAC;AAYf,KAAK,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1C,MAAM,MAAM,oBAAoB,GAAG;IACjC,oDAAoD;IACpD,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/E,+BAA+B;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,mDAAmD;IACnD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;0CACsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF;;6BAEyB;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,cAAc,kGAgK1B,CAAC"}
@@ -0,0 +1,186 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // v0.9.1 #9 — Feedback Widget.
3
+ //
4
+ // `<FeedbackButton trigger="shake|manual|fab" />` — drop into the
5
+ // app root, opens a modal prompt that submits via the existing
6
+ // `sentori.sendUserFeedback` API. Shake detection is opt-in and
7
+ // requires `expo-sensors` (Accelerometer) — falls back to manual
8
+ // trigger if not installed. The button can also be controlled
9
+ // programmatically via a ref: `feedbackRef.current.open()`.
10
+ //
11
+ // Aesthetic: very plain Modal + Text + TextInput so it adopts the
12
+ // host app's color scheme without forcing a sentori theme on it.
13
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState, } from 'react';
14
+ import { Modal, Pressable, StyleSheet, Text, TextInput, View, } from 'react-native';
15
+ import { sendUserFeedback } from './capture';
16
+ export const FeedbackButton = forwardRef(function FeedbackButton(props, ref) {
17
+ const trigger = props.trigger ?? 'fab';
18
+ const [open, setOpen] = useState(false);
19
+ const [title, setTitle] = useState('');
20
+ const [body, setBody] = useState('');
21
+ const [email, setEmail] = useState('');
22
+ const [submitting, setSubmitting] = useState(false);
23
+ const [sent, setSent] = useState(false);
24
+ const eventIdRef = useRef(props.eventId);
25
+ useImperativeHandle(ref, () => ({
26
+ open: (defaults) => {
27
+ setTitle(defaults?.title ?? '');
28
+ setBody(defaults?.body ?? '');
29
+ eventIdRef.current = defaults?.eventId ?? props.eventId;
30
+ setSent(false);
31
+ setOpen(true);
32
+ },
33
+ close: () => setOpen(false),
34
+ }), [props.eventId]);
35
+ // Shake detection — opt-in. We load expo-sensors lazily so apps
36
+ // that don't install it never pay the bundle cost.
37
+ useEffect(() => {
38
+ if (trigger !== 'shake')
39
+ return;
40
+ let sub = null;
41
+ try {
42
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
43
+ const mod = require('expo-sensors');
44
+ const A = mod.Accelerometer;
45
+ if (!A)
46
+ return;
47
+ A.setUpdateInterval(100);
48
+ const thr = props.shakeThreshold ?? 18;
49
+ let lastTriggerAt = 0;
50
+ sub = A.addListener(({ x, y, z }) => {
51
+ const mag = Math.sqrt(x * x + y * y + z * z) * 9.81; // g → m/s²
52
+ const now = Date.now();
53
+ if (mag > thr && now - lastTriggerAt > 1500) {
54
+ lastTriggerAt = now;
55
+ setSent(false);
56
+ setOpen(true);
57
+ }
58
+ });
59
+ }
60
+ catch {
61
+ // expo-sensors not installed → silently fall back to manual
62
+ }
63
+ return () => {
64
+ if (sub)
65
+ sub.remove();
66
+ };
67
+ }, [trigger, props.shakeThreshold]);
68
+ const onSubmit = useCallback(async () => {
69
+ if (!title.trim() || !body.trim())
70
+ return;
71
+ setSubmitting(true);
72
+ try {
73
+ await sendUserFeedback({
74
+ title: title.trim().slice(0, 200),
75
+ body: body.trim().slice(0, 8000),
76
+ email: email.trim() || undefined,
77
+ eventId: eventIdRef.current,
78
+ });
79
+ setSent(true);
80
+ setTimeout(() => setOpen(false), 1200);
81
+ }
82
+ finally {
83
+ setSubmitting(false);
84
+ }
85
+ }, [title, body, email]);
86
+ const L = {
87
+ bodyPlaceholder: 'What happened?',
88
+ cancel: 'Cancel',
89
+ emailPlaceholder: 'email (optional)',
90
+ sent: 'Thanks — report sent.',
91
+ submit: 'Send',
92
+ title: 'Report a problem',
93
+ ...props.labels,
94
+ };
95
+ return (_jsxs(_Fragment, { children: [trigger === 'fab' && (_jsx(Pressable, { accessibilityLabel: "Open feedback", onPress: () => {
96
+ setSent(false);
97
+ setOpen(true);
98
+ }, style: styles.fab, children: _jsx(Text, { style: styles.fabText, children: "?" }) })), _jsx(Modal, { animationType: "fade", transparent: true, visible: open, onRequestClose: () => setOpen(false), children: _jsx(View, { style: styles.backdrop, children: _jsx(View, { style: styles.card, children: sent ? (_jsx(Text, { style: styles.sentMessage, children: L.sent })) : (_jsxs(_Fragment, { children: [_jsx(Text, { style: styles.heading, children: L.title }), _jsx(TextInput, { autoCapitalize: "sentences", onChangeText: setTitle, placeholder: "Subject", placeholderTextColor: "#888", style: styles.titleInput, value: title }), _jsx(TextInput, { multiline: true, onChangeText: setBody, placeholder: L.bodyPlaceholder, placeholderTextColor: "#888", style: styles.bodyInput, textAlignVertical: "top", value: body }), _jsx(TextInput, { autoCapitalize: "none", keyboardType: "email-address", onChangeText: setEmail, placeholder: L.emailPlaceholder, placeholderTextColor: "#888", style: styles.emailInput, value: email }), _jsxs(View, { style: styles.actions, children: [_jsx(Pressable, { onPress: () => setOpen(false), style: styles.cancelBtn, children: _jsx(Text, { style: styles.cancelText, children: L.cancel }) }), _jsx(Pressable, { disabled: submitting || !title.trim() || !body.trim(), onPress: onSubmit, style: [styles.submitBtn, submitting && styles.submitBtnDisabled], children: _jsx(Text, { style: styles.submitText, children: submitting ? '…' : L.submit }) })] })] })) }) }) })] }));
99
+ });
100
+ const styles = StyleSheet.create({
101
+ actions: {
102
+ flexDirection: 'row',
103
+ gap: 8,
104
+ justifyContent: 'flex-end',
105
+ },
106
+ backdrop: {
107
+ alignItems: 'center',
108
+ backgroundColor: 'rgba(0,0,0,0.5)',
109
+ flex: 1,
110
+ justifyContent: 'center',
111
+ paddingHorizontal: 24,
112
+ },
113
+ bodyInput: {
114
+ backgroundColor: '#f7f7f8',
115
+ borderColor: '#e5e5e8',
116
+ borderRadius: 6,
117
+ borderWidth: 1,
118
+ color: '#111',
119
+ fontSize: 14,
120
+ marginBottom: 8,
121
+ minHeight: 100,
122
+ paddingHorizontal: 12,
123
+ paddingVertical: 10,
124
+ },
125
+ cancelBtn: {
126
+ paddingHorizontal: 14,
127
+ paddingVertical: 8,
128
+ },
129
+ cancelText: { color: '#666', fontSize: 14 },
130
+ card: {
131
+ backgroundColor: '#fff',
132
+ borderRadius: 10,
133
+ padding: 16,
134
+ width: '100%',
135
+ },
136
+ emailInput: {
137
+ backgroundColor: '#f7f7f8',
138
+ borderColor: '#e5e5e8',
139
+ borderRadius: 6,
140
+ borderWidth: 1,
141
+ color: '#111',
142
+ fontSize: 14,
143
+ marginBottom: 14,
144
+ paddingHorizontal: 12,
145
+ paddingVertical: 8,
146
+ },
147
+ fab: {
148
+ alignItems: 'center',
149
+ backgroundColor: '#111',
150
+ borderRadius: 24,
151
+ bottom: 28,
152
+ elevation: 4,
153
+ height: 48,
154
+ justifyContent: 'center',
155
+ position: 'absolute',
156
+ right: 18,
157
+ shadowColor: '#000',
158
+ shadowOffset: { height: 2, width: 0 },
159
+ shadowOpacity: 0.18,
160
+ shadowRadius: 4,
161
+ width: 48,
162
+ },
163
+ fabText: { color: '#fff', fontSize: 22, fontWeight: '500' },
164
+ heading: { color: '#111', fontSize: 18, fontWeight: '500', marginBottom: 12 },
165
+ sentMessage: { color: '#111', fontSize: 14, paddingVertical: 18, textAlign: 'center' },
166
+ submitBtn: {
167
+ backgroundColor: '#111',
168
+ borderRadius: 6,
169
+ paddingHorizontal: 16,
170
+ paddingVertical: 8,
171
+ },
172
+ submitBtnDisabled: { opacity: 0.5 },
173
+ submitText: { color: '#fff', fontSize: 14, fontWeight: '500' },
174
+ titleInput: {
175
+ backgroundColor: '#f7f7f8',
176
+ borderColor: '#e5e5e8',
177
+ borderRadius: 6,
178
+ borderWidth: 1,
179
+ color: '#111',
180
+ fontSize: 14,
181
+ marginBottom: 8,
182
+ paddingHorizontal: 12,
183
+ paddingVertical: 8,
184
+ },
185
+ });
186
+ //# sourceMappingURL=feedback-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback-widget.js","sourceRoot":"","sources":["../src/feedback-widget.tsx"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B,EAAE;AACF,kEAAkE;AAClE,+DAA+D;AAC/D,gEAAgE;AAChE,iEAAiE;AACjE,8DAA8D;AAC9D,4DAA4D;AAC5D,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AAEjE,OAAc,EACZ,UAAU,EACV,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,KAAK,EACL,SAAS,EACT,UAAU,EACV,IAAI,EACJ,SAAS,EACT,IAAI,GACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAgC7C,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CACtC,SAAS,cAAc,CAAC,KAAK,EAAE,GAAG;IAChC,MAAM,OAAO,GAAY,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC;IAChD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,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@
1
1
  import { ErrorBoundary } from './error-boundary';
2
+ import { type FeedbackButtonHandle, type FeedbackButtonProps } from './feedback-widget';
2
3
  import { clearMaskQuery, registerMaskQuery } from './mask';
3
4
  import { measureFn } from './measure';
4
5
  import { startMoment } from '@goliapkg/sentori-core';
@@ -31,6 +32,7 @@ export declare const sentori: {
31
32
  clearAllFeatureFlags: () => void;
32
33
  getFeatureFlags: () => Record<string, string>;
33
34
  ErrorBoundary: typeof ErrorBoundary;
35
+ FeedbackButton: import("react").ForwardRefExoticComponent<FeedbackButtonProps & import("react").RefAttributes<FeedbackButtonHandle>>;
34
36
  RageTapCapture: typeof RageTapCapture;
35
37
  registerMaskQuery: typeof registerMaskQuery;
36
38
  clearMaskQuery: typeof clearMaskQuery;
@@ -43,6 +45,7 @@ export { init, init as initSentori } from './init';
43
45
  export { addBreadcrumb } from './breadcrumbs';
44
46
  export { captureError, captureException, captureStep, getUser, sendUserFeedback, setUser, } from './capture';
45
47
  export { ErrorBoundary } from './error-boundary';
48
+ export { FeedbackButton, type FeedbackButtonHandle, type FeedbackButtonProps } from './feedback-widget';
46
49
  export { clearAllFeatureFlags, clearFeatureFlag, getFeatureFlags, setFeatureFlag, } from './feature-flags';
47
50
  export { clearMaskQuery, registerMaskQuery } from './mask';
48
51
  export { flushMetrics, recordMetric } from './metrics';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOjD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAO5C,eA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,YAAY,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAE1E,YAAY,EACV,KAAK,EACL,YAAY,EACZ,KAAK,EACL,UAAU,EACV,cAAc,EACd,MAAM,EACN,QAAQ,EACR,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,QAAQ,GACT,MAAM,SAAS,CAAC"}
package/lib/index.js CHANGED
@@ -2,6 +2,7 @@ import { init } from './init';
2
2
  import { addBreadcrumb } from './breadcrumbs';
3
3
  import { captureError, captureException, captureStep, getUser, sendUserFeedback, setUser, } from './capture';
4
4
  import { ErrorBoundary } from './error-boundary';
5
+ import { FeedbackButton } from './feedback-widget';
5
6
  import { clearAllFeatureFlags, clearFeatureFlag, getFeatureFlags, setFeatureFlag, } from './feature-flags';
6
7
  import { clearMaskQuery, registerMaskQuery } from './mask';
7
8
  import { measureFn } from './measure';
@@ -27,6 +28,7 @@ export const sentori = {
27
28
  clearAllFeatureFlags,
28
29
  getFeatureFlags,
29
30
  ErrorBoundary,
31
+ FeedbackButton,
30
32
  RageTapCapture,
31
33
  registerMaskQuery,
32
34
  clearMaskQuery,
@@ -39,6 +41,7 @@ export { init, init as initSentori } from './init';
39
41
  export { addBreadcrumb } from './breadcrumbs';
40
42
  export { captureError, captureException, captureStep, getUser, sendUserFeedback, setUser, } from './capture';
41
43
  export { ErrorBoundary } from './error-boundary';
44
+ export { FeedbackButton } from './feedback-widget';
42
45
  export { clearAllFeatureFlags, clearFeatureFlag, getFeatureFlags, setFeatureFlag, } from './feature-flags';
43
46
  export { clearMaskQuery, registerMaskQuery } from './mask';
44
47
  export { flushMetrics, recordMetric } from './metrics';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,OAAO,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI;IACJ,aAAa;IACb,OAAO;IACP,OAAO;IACP,YAAY;IACZ,gBAAgB;IAChB,WAAW;IACX,gBAAgB;IAChB,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,WAAW;IACX,cAAc;IACd,gBAAgB;IAChB,oBAAoB;IACpB,eAAe;IACf,aAAa;IACb,cAAc;IACd,iBAAiB;IACjB,cAAc;IACd,YAAY;IACZ,UAAU;IACV,kBAAkB;CACnB,CAAC;AAEF,eAAe,OAAO,CAAC;AAEvB,OAAO,EAAE,I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AiB,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAyB,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA0B,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goliapkg/sentori-react-native",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Sentori SDK for React Native \u2014 JS-layer error capture, native crash handlers (iOS / Android), batched transport, fetch + react-navigation tracing.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://sentori.golia.jp",
@@ -53,6 +53,9 @@
53
53
  "expo-modules-core": {
54
54
  "optional": true
55
55
  },
56
+ "expo-sensors": {
57
+ "optional": true
58
+ },
56
59
  "expo-updates": {
57
60
  "optional": true
58
61
  },
@@ -64,6 +67,7 @@
64
67
  "@react-native-async-storage/async-storage": ">=1.23",
65
68
  "@react-native-community/netinfo": ">=11.0",
66
69
  "expo-modules-core": ">=2.0",
70
+ "expo-sensors": ">=14.0",
67
71
  "expo-updates": ">=0.27",
68
72
  "react-native-code-push": ">=8.0"
69
73
  },
@@ -0,0 +1,309 @@
1
+ // v0.9.1 #9 — Feedback Widget.
2
+ //
3
+ // `<FeedbackButton trigger="shake|manual|fab" />` — drop into the
4
+ // app root, opens a modal prompt that submits via the existing
5
+ // `sentori.sendUserFeedback` API. Shake detection is opt-in and
6
+ // requires `expo-sensors` (Accelerometer) — falls back to manual
7
+ // trigger if not installed. The button can also be controlled
8
+ // programmatically via a ref: `feedbackRef.current.open()`.
9
+ //
10
+ // Aesthetic: very plain Modal + Text + TextInput so it adopts the
11
+ // host app's color scheme without forcing a sentori theme on it.
12
+
13
+ import React, {
14
+ forwardRef,
15
+ useCallback,
16
+ useEffect,
17
+ useImperativeHandle,
18
+ useRef,
19
+ useState,
20
+ } from 'react';
21
+ import {
22
+ Modal,
23
+ Pressable,
24
+ StyleSheet,
25
+ Text,
26
+ TextInput,
27
+ View,
28
+ } from 'react-native';
29
+
30
+ import { sendUserFeedback } from './capture';
31
+
32
+ type Trigger = 'fab' | 'manual' | 'shake';
33
+
34
+ export type FeedbackButtonHandle = {
35
+ /** Open the feedback modal. Returns immediately. */
36
+ open: (defaults?: { body?: string; eventId?: string; title?: string }) => void;
37
+ /** Close the modal if open. */
38
+ close: () => void;
39
+ };
40
+
41
+ export type FeedbackButtonProps = {
42
+ /** When to surface the prompt. Default `'fab'`. */
43
+ trigger?: Trigger;
44
+ /** Pass the eventId from the last `captureException` to tie the
45
+ * report to that crash. Optional. */
46
+ eventId?: string;
47
+ /** Localized strings. Defaults are English. */
48
+ labels?: {
49
+ title?: string;
50
+ bodyPlaceholder?: string;
51
+ emailPlaceholder?: string;
52
+ submit?: string;
53
+ cancel?: string;
54
+ sent?: string;
55
+ };
56
+ /** Shake sensitivity in m/s² above gravity. Default 18 (≈ a normal
57
+ * intentional shake; lower triggers more easily). Only used when
58
+ * `trigger="shake"`. */
59
+ shakeThreshold?: number;
60
+ };
61
+
62
+ export const FeedbackButton = forwardRef<FeedbackButtonHandle, FeedbackButtonProps>(
63
+ function FeedbackButton(props, ref) {
64
+ const trigger: Trigger = props.trigger ?? 'fab';
65
+ const [open, setOpen] = useState(false);
66
+ const [title, setTitle] = useState('');
67
+ const [body, setBody] = useState('');
68
+ const [email, setEmail] = useState('');
69
+ const [submitting, setSubmitting] = useState(false);
70
+ const [sent, setSent] = useState(false);
71
+ const eventIdRef = useRef<string | undefined>(props.eventId);
72
+
73
+ useImperativeHandle(
74
+ ref,
75
+ () => ({
76
+ open: (defaults) => {
77
+ setTitle(defaults?.title ?? '');
78
+ setBody(defaults?.body ?? '');
79
+ eventIdRef.current = defaults?.eventId ?? props.eventId;
80
+ setSent(false);
81
+ setOpen(true);
82
+ },
83
+ close: () => setOpen(false),
84
+ }),
85
+ [props.eventId],
86
+ );
87
+
88
+ // Shake detection — opt-in. We load expo-sensors lazily so apps
89
+ // that don't install it never pay the bundle cost.
90
+ useEffect(() => {
91
+ if (trigger !== 'shake') return;
92
+ let sub: { remove: () => void } | null = null;
93
+ try {
94
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
95
+ const mod = require('expo-sensors') as {
96
+ Accelerometer?: {
97
+ addListener: (cb: (d: { x: number; y: number; z: number }) => void) => {
98
+ remove: () => void;
99
+ };
100
+ setUpdateInterval: (ms: number) => void;
101
+ };
102
+ };
103
+ const A = mod.Accelerometer;
104
+ if (!A) return;
105
+ A.setUpdateInterval(100);
106
+ const thr = props.shakeThreshold ?? 18;
107
+ let lastTriggerAt = 0;
108
+ sub = A.addListener(({ x, y, z }) => {
109
+ const mag = Math.sqrt(x * x + y * y + z * z) * 9.81; // g → m/s²
110
+ const now = Date.now();
111
+ if (mag > thr && now - lastTriggerAt > 1500) {
112
+ lastTriggerAt = now;
113
+ setSent(false);
114
+ setOpen(true);
115
+ }
116
+ });
117
+ } catch {
118
+ // expo-sensors not installed → silently fall back to manual
119
+ }
120
+ return () => {
121
+ if (sub) sub.remove();
122
+ };
123
+ }, [trigger, props.shakeThreshold]);
124
+
125
+ const onSubmit = useCallback(async () => {
126
+ if (!title.trim() || !body.trim()) return;
127
+ setSubmitting(true);
128
+ try {
129
+ await sendUserFeedback({
130
+ title: title.trim().slice(0, 200),
131
+ body: body.trim().slice(0, 8000),
132
+ email: email.trim() || undefined,
133
+ eventId: eventIdRef.current,
134
+ });
135
+ setSent(true);
136
+ setTimeout(() => setOpen(false), 1200);
137
+ } finally {
138
+ setSubmitting(false);
139
+ }
140
+ }, [title, body, email]);
141
+
142
+ const L = {
143
+ bodyPlaceholder: 'What happened?',
144
+ cancel: 'Cancel',
145
+ emailPlaceholder: 'email (optional)',
146
+ sent: 'Thanks — report sent.',
147
+ submit: 'Send',
148
+ title: 'Report a problem',
149
+ ...props.labels,
150
+ };
151
+
152
+ return (
153
+ <>
154
+ {trigger === 'fab' && (
155
+ <Pressable
156
+ accessibilityLabel="Open feedback"
157
+ onPress={() => {
158
+ setSent(false);
159
+ setOpen(true);
160
+ }}
161
+ style={styles.fab}
162
+ >
163
+ <Text style={styles.fabText}>?</Text>
164
+ </Pressable>
165
+ )}
166
+ <Modal animationType="fade" transparent visible={open} onRequestClose={() => setOpen(false)}>
167
+ <View style={styles.backdrop}>
168
+ <View style={styles.card}>
169
+ {sent ? (
170
+ <Text style={styles.sentMessage}>{L.sent}</Text>
171
+ ) : (
172
+ <>
173
+ <Text style={styles.heading}>{L.title}</Text>
174
+ <TextInput
175
+ autoCapitalize="sentences"
176
+ onChangeText={setTitle}
177
+ placeholder="Subject"
178
+ placeholderTextColor="#888"
179
+ style={styles.titleInput}
180
+ value={title}
181
+ />
182
+ <TextInput
183
+ multiline
184
+ onChangeText={setBody}
185
+ placeholder={L.bodyPlaceholder}
186
+ placeholderTextColor="#888"
187
+ style={styles.bodyInput}
188
+ textAlignVertical="top"
189
+ value={body}
190
+ />
191
+ <TextInput
192
+ autoCapitalize="none"
193
+ keyboardType="email-address"
194
+ onChangeText={setEmail}
195
+ placeholder={L.emailPlaceholder}
196
+ placeholderTextColor="#888"
197
+ style={styles.emailInput}
198
+ value={email}
199
+ />
200
+ <View style={styles.actions}>
201
+ <Pressable onPress={() => setOpen(false)} style={styles.cancelBtn}>
202
+ <Text style={styles.cancelText}>{L.cancel}</Text>
203
+ </Pressable>
204
+ <Pressable
205
+ disabled={submitting || !title.trim() || !body.trim()}
206
+ onPress={onSubmit}
207
+ style={[styles.submitBtn, submitting && styles.submitBtnDisabled]}
208
+ >
209
+ <Text style={styles.submitText}>
210
+ {submitting ? '…' : L.submit}
211
+ </Text>
212
+ </Pressable>
213
+ </View>
214
+ </>
215
+ )}
216
+ </View>
217
+ </View>
218
+ </Modal>
219
+ </>
220
+ );
221
+ },
222
+ );
223
+
224
+ const styles = StyleSheet.create({
225
+ actions: {
226
+ flexDirection: 'row',
227
+ gap: 8,
228
+ justifyContent: 'flex-end',
229
+ },
230
+ backdrop: {
231
+ alignItems: 'center',
232
+ backgroundColor: 'rgba(0,0,0,0.5)',
233
+ flex: 1,
234
+ justifyContent: 'center',
235
+ paddingHorizontal: 24,
236
+ },
237
+ bodyInput: {
238
+ backgroundColor: '#f7f7f8',
239
+ borderColor: '#e5e5e8',
240
+ borderRadius: 6,
241
+ borderWidth: 1,
242
+ color: '#111',
243
+ fontSize: 14,
244
+ marginBottom: 8,
245
+ minHeight: 100,
246
+ paddingHorizontal: 12,
247
+ paddingVertical: 10,
248
+ },
249
+ cancelBtn: {
250
+ paddingHorizontal: 14,
251
+ paddingVertical: 8,
252
+ },
253
+ cancelText: { color: '#666', fontSize: 14 },
254
+ card: {
255
+ backgroundColor: '#fff',
256
+ borderRadius: 10,
257
+ padding: 16,
258
+ width: '100%',
259
+ },
260
+ emailInput: {
261
+ backgroundColor: '#f7f7f8',
262
+ borderColor: '#e5e5e8',
263
+ borderRadius: 6,
264
+ borderWidth: 1,
265
+ color: '#111',
266
+ fontSize: 14,
267
+ marginBottom: 14,
268
+ paddingHorizontal: 12,
269
+ paddingVertical: 8,
270
+ },
271
+ fab: {
272
+ alignItems: 'center',
273
+ backgroundColor: '#111',
274
+ borderRadius: 24,
275
+ bottom: 28,
276
+ elevation: 4,
277
+ height: 48,
278
+ justifyContent: 'center',
279
+ position: 'absolute',
280
+ right: 18,
281
+ shadowColor: '#000',
282
+ shadowOffset: { height: 2, width: 0 },
283
+ shadowOpacity: 0.18,
284
+ shadowRadius: 4,
285
+ width: 48,
286
+ },
287
+ fabText: { color: '#fff', fontSize: 22, fontWeight: '500' },
288
+ heading: { color: '#111', fontSize: 18, fontWeight: '500', marginBottom: 12 },
289
+ sentMessage: { color: '#111', fontSize: 14, paddingVertical: 18, textAlign: 'center' },
290
+ submitBtn: {
291
+ backgroundColor: '#111',
292
+ borderRadius: 6,
293
+ paddingHorizontal: 16,
294
+ paddingVertical: 8,
295
+ },
296
+ submitBtnDisabled: { opacity: 0.5 },
297
+ submitText: { color: '#fff', fontSize: 14, fontWeight: '500' },
298
+ titleInput: {
299
+ backgroundColor: '#f7f7f8',
300
+ borderColor: '#e5e5e8',
301
+ borderRadius: 6,
302
+ borderWidth: 1,
303
+ color: '#111',
304
+ fontSize: 14,
305
+ marginBottom: 8,
306
+ paddingHorizontal: 12,
307
+ paddingVertical: 8,
308
+ },
309
+ });
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  setUser,
10
10
  } from './capture';
11
11
  import { ErrorBoundary } from './error-boundary';
12
+ import { FeedbackButton, type FeedbackButtonHandle, type FeedbackButtonProps } from './feedback-widget';
12
13
  import {
13
14
  clearAllFeatureFlags,
14
15
  clearFeatureFlag,
@@ -44,6 +45,7 @@ export const sentori = {
44
45
  clearAllFeatureFlags,
45
46
  getFeatureFlags,
46
47
  ErrorBoundary,
48
+ FeedbackButton,
47
49
  RageTapCapture,
48
50
  registerMaskQuery,
49
51
  clearMaskQuery,
@@ -65,6 +67,7 @@ export {
65
67
  setUser,
66
68
  } from './capture';
67
69
  export { ErrorBoundary } from './error-boundary';
70
+ export { FeedbackButton, type FeedbackButtonHandle, type FeedbackButtonProps } from './feedback-widget';
68
71
  export {
69
72
  clearAllFeatureFlags,
70
73
  clearFeatureFlag,