@diegotsi/flint-react 1.0.1 → 1.2.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/dist/index.cjs +66 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -120
- package/dist/index.d.ts +5 -120
- package/dist/index.js +57 -33
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -30,9 +30,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
Flint: () => import_flint_core9.Flint,
|
|
33
34
|
FlintModal: () => FlintModal,
|
|
34
35
|
FlintWidget: () => FlintWidget,
|
|
35
|
-
flint: () =>
|
|
36
|
+
flint: () => import_flint_core9.flint
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
38
39
|
|
|
@@ -41,7 +42,7 @@ var import_react2 = require("react");
|
|
|
41
42
|
var import_react_i18next = require("react-i18next");
|
|
42
43
|
|
|
43
44
|
// src/api.ts
|
|
44
|
-
var
|
|
45
|
+
var import_flint_core = require("@diegotsi/flint-core");
|
|
45
46
|
|
|
46
47
|
// src/ScreenAnnotator.tsx
|
|
47
48
|
var import_modern_screenshot = require("modern-screenshot");
|
|
@@ -186,7 +187,7 @@ function ScreenAnnotator({ zIndex, onCapture, onCancel }) {
|
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
// src/theme.ts
|
|
189
|
-
var
|
|
190
|
+
var import_flint_core2 = require("@diegotsi/flint-core");
|
|
190
191
|
|
|
191
192
|
// src/FlintModal.tsx
|
|
192
193
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -244,6 +245,7 @@ function FlintModal({
|
|
|
244
245
|
getEnvironment,
|
|
245
246
|
getConsoleLogs,
|
|
246
247
|
getNetworkErrors,
|
|
248
|
+
getFormErrors,
|
|
247
249
|
getReplayEvents,
|
|
248
250
|
getExternalReplayUrl,
|
|
249
251
|
initialSelection = "",
|
|
@@ -254,7 +256,7 @@ function FlintModal({
|
|
|
254
256
|
onError
|
|
255
257
|
}) {
|
|
256
258
|
const { t } = (0, import_react_i18next.useTranslation)();
|
|
257
|
-
const colors = (0,
|
|
259
|
+
const colors = (0, import_flint_core2.resolveTheme)(theme);
|
|
258
260
|
const isDark = theme === "dark";
|
|
259
261
|
const [severity, setSeverity] = (0, import_react2.useState)("P2");
|
|
260
262
|
const [description, setDescription] = (0, import_react2.useState)("");
|
|
@@ -302,7 +304,8 @@ function FlintModal({
|
|
|
302
304
|
...meta,
|
|
303
305
|
environment: getEnvironment(),
|
|
304
306
|
consoleLogs: getConsoleLogs(),
|
|
305
|
-
networkErrors: getNetworkErrors()
|
|
307
|
+
networkErrors: getNetworkErrors(),
|
|
308
|
+
formErrors: getFormErrors()
|
|
306
309
|
};
|
|
307
310
|
if (isText) {
|
|
308
311
|
collectedMeta.textIssue = {
|
|
@@ -331,13 +334,13 @@ function FlintModal({
|
|
|
331
334
|
}
|
|
332
335
|
}
|
|
333
336
|
try {
|
|
334
|
-
const res = await (0,
|
|
337
|
+
const res = await (0, import_flint_core.submitReport)(serverUrl, projectKey, payload, !isText ? screenshot ?? void 0 : void 0);
|
|
335
338
|
setResult(res);
|
|
336
339
|
setStatus("success");
|
|
337
340
|
onSuccess?.(res);
|
|
338
341
|
const events = getReplayEvents();
|
|
339
342
|
if (events.length > 0) {
|
|
340
|
-
(0,
|
|
343
|
+
(0, import_flint_core.submitReplay)(serverUrl, projectKey, res.id, events).catch(() => {
|
|
341
344
|
});
|
|
342
345
|
}
|
|
343
346
|
} catch (err) {
|
|
@@ -1177,20 +1180,24 @@ function CheckIcon({ size = 20 }) {
|
|
|
1177
1180
|
}
|
|
1178
1181
|
|
|
1179
1182
|
// src/FlintWidget.tsx
|
|
1183
|
+
var import_flint_core10 = require("@diegotsi/flint-core");
|
|
1180
1184
|
var import_react4 = require("react");
|
|
1181
1185
|
var import_react_i18next3 = require("react-i18next");
|
|
1182
1186
|
|
|
1183
1187
|
// src/collectors/console.ts
|
|
1184
|
-
var
|
|
1188
|
+
var import_flint_core3 = require("@diegotsi/flint-core");
|
|
1185
1189
|
|
|
1186
1190
|
// src/collectors/environment.ts
|
|
1187
|
-
var
|
|
1191
|
+
var import_flint_core4 = require("@diegotsi/flint-core");
|
|
1192
|
+
|
|
1193
|
+
// src/collectors/formErrors.ts
|
|
1194
|
+
var import_flint_core5 = require("@diegotsi/flint-core");
|
|
1188
1195
|
|
|
1189
1196
|
// src/collectors/frustration.ts
|
|
1190
|
-
var
|
|
1197
|
+
var import_flint_core6 = require("@diegotsi/flint-core");
|
|
1191
1198
|
|
|
1192
1199
|
// src/collectors/network.ts
|
|
1193
|
-
var
|
|
1200
|
+
var import_flint_core7 = require("@diegotsi/flint-core");
|
|
1194
1201
|
|
|
1195
1202
|
// src/i18n/index.ts
|
|
1196
1203
|
var import_i18next = require("i18next");
|
|
@@ -1242,11 +1249,11 @@ widgetI18n.use(import_react_i18next2.initReactI18next).init({
|
|
|
1242
1249
|
var i18n_default = widgetI18n;
|
|
1243
1250
|
|
|
1244
1251
|
// src/store.ts
|
|
1245
|
-
var
|
|
1252
|
+
var import_flint_core8 = require("@diegotsi/flint-core");
|
|
1246
1253
|
var import_react3 = require("react");
|
|
1247
|
-
var
|
|
1254
|
+
var import_flint_core9 = require("@diegotsi/flint-core");
|
|
1248
1255
|
function useFlintStore() {
|
|
1249
|
-
return (0, import_react3.useSyncExternalStore)(
|
|
1256
|
+
return (0, import_react3.useSyncExternalStore)(import_flint_core8.subscribe, import_flint_core8.getSnapshot);
|
|
1250
1257
|
}
|
|
1251
1258
|
|
|
1252
1259
|
// src/FlintWidget.tsx
|
|
@@ -1274,6 +1281,7 @@ function WidgetContent({
|
|
|
1274
1281
|
enableScreenshot = true,
|
|
1275
1282
|
enableConsole = true,
|
|
1276
1283
|
enableNetwork = true,
|
|
1284
|
+
enableFormErrors = true,
|
|
1277
1285
|
enableFrustration = false,
|
|
1278
1286
|
autoReportFrustration = false,
|
|
1279
1287
|
onBeforeSubmit,
|
|
@@ -1308,7 +1316,7 @@ function WidgetContent({
|
|
|
1308
1316
|
const [open, setOpen] = (0, import_react4.useState)(false);
|
|
1309
1317
|
const [hovered, setHovered] = (0, import_react4.useState)(false);
|
|
1310
1318
|
const pendingSelection = (0, import_react4.useRef)("");
|
|
1311
|
-
const colors = (0,
|
|
1319
|
+
const colors = (0, import_flint_core2.resolveTheme)(theme);
|
|
1312
1320
|
const [selectionTooltip, setSelectionTooltip] = (0, import_react4.useState)(null);
|
|
1313
1321
|
const tooltipRef = (0, import_react4.useRef)(null);
|
|
1314
1322
|
const triggerRef = (0, import_react4.useRef)(null);
|
|
@@ -1351,31 +1359,42 @@ function WidgetContent({
|
|
|
1351
1359
|
setOpen(true);
|
|
1352
1360
|
onOpen?.();
|
|
1353
1361
|
};
|
|
1362
|
+
const globalInit = import_flint_core10.Flint.isInitialized();
|
|
1363
|
+
const global = import_flint_core10.Flint.getInstance();
|
|
1354
1364
|
const consoleCollector = (0, import_react4.useRef)(null);
|
|
1355
1365
|
const networkCollector = (0, import_react4.useRef)(null);
|
|
1356
1366
|
const replayEvents = (0, import_react4.useRef)([]);
|
|
1357
1367
|
const stopReplay = (0, import_react4.useRef)(null);
|
|
1358
|
-
|
|
1359
|
-
consoleCollector.current = (0, import_core3.createConsoleCollector)();
|
|
1360
|
-
consoleCollector.current.start();
|
|
1361
|
-
}
|
|
1362
|
-
if (enableNetwork && !networkCollector.current) {
|
|
1363
|
-
const flintHost = (() => {
|
|
1364
|
-
try {
|
|
1365
|
-
return new URL(serverUrl).hostname;
|
|
1366
|
-
} catch {
|
|
1367
|
-
return "";
|
|
1368
|
-
}
|
|
1369
|
-
})();
|
|
1370
|
-
networkCollector.current = (0, import_core6.createNetworkCollector)(flintHost ? [flintHost] : []);
|
|
1371
|
-
networkCollector.current.start();
|
|
1372
|
-
}
|
|
1368
|
+
const formErrorCollector = (0, import_react4.useRef)(null);
|
|
1373
1369
|
const frustrationCollector = (0, import_react4.useRef)(null);
|
|
1374
|
-
if (
|
|
1375
|
-
|
|
1376
|
-
|
|
1370
|
+
if (!globalInit) {
|
|
1371
|
+
if (enableConsole && !consoleCollector.current) {
|
|
1372
|
+
consoleCollector.current = (0, import_flint_core3.createConsoleCollector)();
|
|
1373
|
+
consoleCollector.current.start();
|
|
1374
|
+
}
|
|
1375
|
+
if (enableNetwork && !networkCollector.current) {
|
|
1376
|
+
const flintHost = (() => {
|
|
1377
|
+
try {
|
|
1378
|
+
return new URL(serverUrl).hostname;
|
|
1379
|
+
} catch {
|
|
1380
|
+
return "";
|
|
1381
|
+
}
|
|
1382
|
+
})();
|
|
1383
|
+
networkCollector.current = (0, import_flint_core7.createNetworkCollector)(flintHost ? [flintHost] : []);
|
|
1384
|
+
networkCollector.current.start();
|
|
1385
|
+
}
|
|
1386
|
+
if (enableFormErrors && !formErrorCollector.current) {
|
|
1387
|
+
formErrorCollector.current = (0, import_flint_core5.createFormErrorCollector)();
|
|
1388
|
+
formErrorCollector.current.start();
|
|
1389
|
+
(0, import_flint_core9._setFormErrorCollector)(formErrorCollector.current);
|
|
1390
|
+
}
|
|
1391
|
+
if (enableFrustration && !frustrationCollector.current) {
|
|
1392
|
+
frustrationCollector.current = (0, import_flint_core6.createFrustrationCollector)();
|
|
1393
|
+
frustrationCollector.current.start();
|
|
1394
|
+
}
|
|
1377
1395
|
}
|
|
1378
1396
|
(0, import_react4.useEffect)(() => {
|
|
1397
|
+
if (globalInit) return;
|
|
1379
1398
|
let cancelled = false;
|
|
1380
1399
|
if (enableReplay) {
|
|
1381
1400
|
import("rrweb").then(({ record }) => {
|
|
@@ -1396,15 +1415,18 @@ function WidgetContent({
|
|
|
1396
1415
|
cancelled = true;
|
|
1397
1416
|
consoleCollector.current?.stop();
|
|
1398
1417
|
networkCollector.current?.stop();
|
|
1418
|
+
formErrorCollector.current?.stop();
|
|
1419
|
+
(0, import_flint_core9._setFormErrorCollector)(null);
|
|
1399
1420
|
frustrationCollector.current?.stop();
|
|
1400
1421
|
stopReplay.current?.();
|
|
1401
1422
|
};
|
|
1402
|
-
}, [enableReplay]);
|
|
1423
|
+
}, [enableReplay, globalInit]);
|
|
1403
1424
|
(0, import_react4.useEffect)(() => {
|
|
1425
|
+
if (globalInit) return;
|
|
1404
1426
|
if (!enableFrustration || !autoReportFrustration || !frustrationCollector.current) return;
|
|
1405
1427
|
const unsubscribe = frustrationCollector.current.onFrustration(async (event) => {
|
|
1406
1428
|
const user2 = resolvedUser;
|
|
1407
|
-
await (0,
|
|
1429
|
+
await (0, import_flint_core.submitReport)(serverUrl, projectKey, {
|
|
1408
1430
|
reporterId: user2?.id ?? "anonymous",
|
|
1409
1431
|
reporterName: user2?.name ?? "Anonymous",
|
|
1410
1432
|
reporterEmail: user2?.email,
|
|
@@ -1412,16 +1434,17 @@ function WidgetContent({
|
|
|
1412
1434
|
severity: event.type === "error_loop" ? "P1" : event.type === "rage_click" ? "P2" : "P3",
|
|
1413
1435
|
url: event.url,
|
|
1414
1436
|
meta: {
|
|
1415
|
-
environment: (0,
|
|
1437
|
+
environment: (0, import_flint_core4.collectEnvironment)(),
|
|
1416
1438
|
consoleLogs: consoleCollector.current?.getEntries() ?? [],
|
|
1417
1439
|
networkErrors: networkCollector.current?.getEntries() ?? [],
|
|
1440
|
+
formErrors: formErrorCollector.current?.getEntries() ?? [],
|
|
1418
1441
|
frustrationEvent: event
|
|
1419
1442
|
}
|
|
1420
1443
|
}).catch(() => {
|
|
1421
1444
|
});
|
|
1422
1445
|
});
|
|
1423
1446
|
return unsubscribe;
|
|
1424
|
-
}, [enableFrustration, autoReportFrustration]);
|
|
1447
|
+
}, [enableFrustration, autoReportFrustration, globalInit]);
|
|
1425
1448
|
const label = buttonLabel ?? t("buttonLabel");
|
|
1426
1449
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1427
1450
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
@@ -1518,10 +1541,11 @@ function WidgetContent({
|
|
|
1518
1541
|
onClose?.();
|
|
1519
1542
|
pendingSelection.current = "";
|
|
1520
1543
|
},
|
|
1521
|
-
getEnvironment:
|
|
1522
|
-
getConsoleLogs: () => consoleCollector.current?.getEntries() ?? [],
|
|
1523
|
-
getNetworkErrors: () => networkCollector.current?.getEntries() ?? [],
|
|
1524
|
-
|
|
1544
|
+
getEnvironment: import_flint_core4.collectEnvironment,
|
|
1545
|
+
getConsoleLogs: () => globalInit ? global?.console?.getEntries() ?? [] : consoleCollector.current?.getEntries() ?? [],
|
|
1546
|
+
getNetworkErrors: () => globalInit ? global?.network?.getEntries() ?? [] : networkCollector.current?.getEntries() ?? [],
|
|
1547
|
+
getFormErrors: () => globalInit ? global?.formErrors?.getEntries() ?? [] : formErrorCollector.current?.getEntries() ?? [],
|
|
1548
|
+
getReplayEvents: () => globalInit ? import_flint_core10.Flint.getReplayEvents() : [...replayEvents.current],
|
|
1525
1549
|
getExternalReplayUrl,
|
|
1526
1550
|
initialSelection: pendingSelection.current,
|
|
1527
1551
|
enableScreenshot,
|
|
@@ -1574,6 +1598,7 @@ function SparkIcon2() {
|
|
|
1574
1598
|
}
|
|
1575
1599
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1576
1600
|
0 && (module.exports = {
|
|
1601
|
+
Flint,
|
|
1577
1602
|
FlintModal,
|
|
1578
1603
|
FlintWidget,
|
|
1579
1604
|
flint
|