@diegotsi/flint-react 2.1.2 → 2.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 +38 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -108
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -286,7 +286,8 @@ function FlintModal({
|
|
|
286
286
|
severity: isText ? "P3" : severity,
|
|
287
287
|
url: window.location.href,
|
|
288
288
|
meta: collectedMeta,
|
|
289
|
-
label: isText ? "TEXT" : void 0
|
|
289
|
+
label: isText ? "TEXT" : void 0,
|
|
290
|
+
source: isText ? "text_issue" : "widget"
|
|
290
291
|
};
|
|
291
292
|
if (onBeforeSubmit) {
|
|
292
293
|
const proceed = await onBeforeSubmit(payload);
|
|
@@ -1146,21 +1147,9 @@ import { Flint as Flint2 } from "@diegotsi/flint-core";
|
|
|
1146
1147
|
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
1147
1148
|
import { I18nextProvider, useTranslation as useTranslation2 } from "react-i18next";
|
|
1148
1149
|
|
|
1149
|
-
// src/collectors/console.ts
|
|
1150
|
-
import { createConsoleCollector } from "@diegotsi/flint-core";
|
|
1151
|
-
|
|
1152
1150
|
// src/collectors/environment.ts
|
|
1153
1151
|
import { collectEnvironment } from "@diegotsi/flint-core";
|
|
1154
1152
|
|
|
1155
|
-
// src/collectors/formErrors.ts
|
|
1156
|
-
import { createFormErrorCollector } from "@diegotsi/flint-core";
|
|
1157
|
-
|
|
1158
|
-
// src/collectors/frustration.ts
|
|
1159
|
-
import { createFrustrationCollector } from "@diegotsi/flint-core";
|
|
1160
|
-
|
|
1161
|
-
// src/collectors/network.ts
|
|
1162
|
-
import { createNetworkCollector } from "@diegotsi/flint-core";
|
|
1163
|
-
|
|
1164
1153
|
// src/i18n/index.ts
|
|
1165
1154
|
import { createInstance } from "i18next";
|
|
1166
1155
|
import { initReactI18next } from "react-i18next";
|
|
@@ -1220,7 +1209,6 @@ function useFlintStore() {
|
|
|
1220
1209
|
|
|
1221
1210
|
// src/FlintWidget.tsx
|
|
1222
1211
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1223
|
-
var REPLAY_WINDOW_MS = 6e4;
|
|
1224
1212
|
function FlintWidget(props) {
|
|
1225
1213
|
const { locale = "en-US" } = props;
|
|
1226
1214
|
useEffect3(() => {
|
|
@@ -1265,9 +1253,9 @@ function WidgetContent({
|
|
|
1265
1253
|
const ddRum = window.DD_RUM;
|
|
1266
1254
|
const ctx = ddRum?.getInternalContext?.();
|
|
1267
1255
|
if (ctx?.session_id) {
|
|
1268
|
-
const ts = bugTimestamp.current ||
|
|
1269
|
-
const fromTs = ts -
|
|
1270
|
-
const toTs = ts +
|
|
1256
|
+
const ts = bugTimestamp.current || Date.now();
|
|
1257
|
+
const fromTs = ts - 3e4;
|
|
1258
|
+
const toTs = ts + 5e3;
|
|
1271
1259
|
return `https://${datadogSite}/rum/replay/sessions/${ctx.session_id}?from_ts=${fromTs}&to_ts=${toTs}&tab=replay&live=false`;
|
|
1272
1260
|
}
|
|
1273
1261
|
} catch {
|
|
@@ -1320,96 +1308,30 @@ function WidgetContent({
|
|
|
1320
1308
|
const openWithSelection = (text) => {
|
|
1321
1309
|
pendingSelection.current = text;
|
|
1322
1310
|
setSelectionTooltip(null);
|
|
1323
|
-
bugTimestamp.current =
|
|
1311
|
+
bugTimestamp.current = Date.now();
|
|
1324
1312
|
setOpen(true);
|
|
1325
1313
|
onOpen?.();
|
|
1326
1314
|
};
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
return new URL(serverUrl).hostname;
|
|
1344
|
-
} catch {
|
|
1345
|
-
return "";
|
|
1346
|
-
}
|
|
1347
|
-
})();
|
|
1348
|
-
networkCollector.current = createNetworkCollector(flintHost ? [flintHost] : []);
|
|
1349
|
-
networkCollector.current.start();
|
|
1350
|
-
}
|
|
1351
|
-
if (enableFormErrors && !formErrorCollector.current) {
|
|
1352
|
-
formErrorCollector.current = createFormErrorCollector();
|
|
1353
|
-
formErrorCollector.current.start();
|
|
1354
|
-
_setFormErrorCollector(formErrorCollector.current);
|
|
1355
|
-
}
|
|
1356
|
-
if (enableFrustration && !frustrationCollector.current) {
|
|
1357
|
-
frustrationCollector.current = createFrustrationCollector();
|
|
1358
|
-
frustrationCollector.current.start();
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
useEffect3(() => {
|
|
1362
|
-
if (globalInit) return;
|
|
1363
|
-
let cancelled = false;
|
|
1364
|
-
if (enableReplay) {
|
|
1365
|
-
import("rrweb").then(({ record }) => {
|
|
1366
|
-
if (cancelled) return;
|
|
1367
|
-
const stopFn = record({
|
|
1368
|
-
emit(event) {
|
|
1369
|
-
replayEvents.current.push(event);
|
|
1370
|
-
const cutoff = Date.now() - REPLAY_WINDOW_MS;
|
|
1371
|
-
while (replayEvents.current.length > 0 && replayEvents.current[0].timestamp < cutoff) {
|
|
1372
|
-
replayEvents.current.shift();
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
});
|
|
1376
|
-
stopReplay.current = stopFn ?? null;
|
|
1377
|
-
});
|
|
1378
|
-
}
|
|
1379
|
-
return () => {
|
|
1380
|
-
cancelled = true;
|
|
1381
|
-
consoleCollector.current?.stop();
|
|
1382
|
-
networkCollector.current?.stop();
|
|
1383
|
-
formErrorCollector.current?.stop();
|
|
1384
|
-
_setFormErrorCollector(null);
|
|
1385
|
-
frustrationCollector.current?.stop();
|
|
1386
|
-
stopReplay.current?.();
|
|
1387
|
-
};
|
|
1388
|
-
}, [enableReplay, globalInit]);
|
|
1389
|
-
useEffect3(() => {
|
|
1390
|
-
if (globalInit) return;
|
|
1391
|
-
if (!enableFrustration || !autoReportFrustration || !frustrationCollector.current) return;
|
|
1392
|
-
const unsubscribe = frustrationCollector.current.onFrustration(async (event) => {
|
|
1393
|
-
const user2 = resolvedUser;
|
|
1394
|
-
await submitReport(serverUrl, projectKey, {
|
|
1395
|
-
reporterId: user2?.id ?? "anonymous",
|
|
1396
|
-
reporterName: user2?.name ?? "Anonymous",
|
|
1397
|
-
reporterEmail: user2?.email,
|
|
1398
|
-
description: `[Auto-detected] ${event.type.replace(/_/g, " ")}: ${event.details}`,
|
|
1399
|
-
severity: event.type === "error_loop" ? "P1" : event.type === "rage_click" ? "P2" : "P3",
|
|
1400
|
-
url: event.url,
|
|
1401
|
-
meta: {
|
|
1402
|
-
environment: collectEnvironment(),
|
|
1403
|
-
consoleLogs: consoleCollector.current?.getEntries() ?? [],
|
|
1404
|
-
networkErrors: networkCollector.current?.getEntries() ?? [],
|
|
1405
|
-
formErrors: formErrorCollector.current?.getEntries() ?? [],
|
|
1406
|
-
frustrationEvent: event
|
|
1407
|
-
}
|
|
1408
|
-
}).catch(() => {
|
|
1409
|
-
});
|
|
1315
|
+
const didAutoInit = useRef3(false);
|
|
1316
|
+
if (!Flint2.isInitialized() && !didAutoInit.current) {
|
|
1317
|
+
Flint2.init({
|
|
1318
|
+
serverUrl,
|
|
1319
|
+
projectKey,
|
|
1320
|
+
user,
|
|
1321
|
+
enableConsole,
|
|
1322
|
+
enableNetwork,
|
|
1323
|
+
enableFormErrors,
|
|
1324
|
+
enableFrustration,
|
|
1325
|
+
autoReportFrustration,
|
|
1326
|
+
enableReplay,
|
|
1327
|
+
_replayRecorder: enableReplay ? (emit) => import("rrweb").then(({ record }) => {
|
|
1328
|
+
const stop = record({ emit });
|
|
1329
|
+
return stop ?? void 0;
|
|
1330
|
+
}) : void 0
|
|
1410
1331
|
});
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1332
|
+
didAutoInit.current = true;
|
|
1333
|
+
}
|
|
1334
|
+
const global = Flint2.getInstance();
|
|
1413
1335
|
const label = buttonLabel ?? t("buttonLabel");
|
|
1414
1336
|
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1415
1337
|
/* @__PURE__ */ jsxs3(
|
|
@@ -1420,7 +1342,7 @@ function WidgetContent({
|
|
|
1420
1342
|
pendingSelection.current = window.getSelection()?.toString().trim() ?? "";
|
|
1421
1343
|
},
|
|
1422
1344
|
onClick: () => {
|
|
1423
|
-
bugTimestamp.current =
|
|
1345
|
+
bugTimestamp.current = Date.now();
|
|
1424
1346
|
setOpen(true);
|
|
1425
1347
|
onOpen?.();
|
|
1426
1348
|
},
|
|
@@ -1508,10 +1430,10 @@ function WidgetContent({
|
|
|
1508
1430
|
pendingSelection.current = "";
|
|
1509
1431
|
},
|
|
1510
1432
|
getEnvironment: collectEnvironment,
|
|
1511
|
-
getConsoleLogs: () =>
|
|
1512
|
-
getNetworkErrors: () =>
|
|
1513
|
-
getFormErrors: () =>
|
|
1514
|
-
getReplayEvents: () =>
|
|
1433
|
+
getConsoleLogs: () => global?.console?.getEntries() ?? [],
|
|
1434
|
+
getNetworkErrors: () => global?.network?.getEntries() ?? [],
|
|
1435
|
+
getFormErrors: () => global?.formErrors?.getEntries() ?? [],
|
|
1436
|
+
getReplayEvents: () => Flint2.getReplayEvents(),
|
|
1515
1437
|
getExternalReplayUrl,
|
|
1516
1438
|
initialSelection: pendingSelection.current,
|
|
1517
1439
|
enableScreenshot,
|