strapi-plugin-magic-sessionmanager 4.11.0 → 4.13.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/CHANGELOG.md +84 -1
- package/README.md +75 -24
- package/dist/admin/{Analytics-CBHeWeGn.js → Analytics-BikQQx_J.js} +45 -75
- package/dist/admin/{Analytics-D56O8Q6e.mjs → Analytics-DIY51RI_.mjs} +45 -75
- package/dist/admin/{App-EDIkLJdb.mjs → App-B3vaybSO.mjs} +584 -120
- package/dist/admin/{App-D4cBPwB_.js → App-BV1LM9Bp.js} +584 -120
- package/dist/admin/{OnlineUsersWidget-MwUutkKQ.mjs → OnlineUsersWidget-T-2upsDd.mjs} +18 -26
- package/dist/admin/{OnlineUsersWidget-BF2R2YIy.js → OnlineUsersWidget-fJogM1xl.js} +18 -26
- package/dist/admin/{Settings-CMzEF8EH.js → Settings-AyYka8wn.js} +1 -1
- package/dist/admin/{Settings-bLMyi0BN.mjs → Settings-BpBlXyMY.mjs} +1 -1
- package/dist/admin/{de-CxfuTF6C.mjs → de-BSCDuq1i.mjs} +41 -6
- package/dist/admin/{de-DVNTHmSo.js → de-z0aHRwdw.js} +41 -6
- package/dist/admin/{en-BcPIlQYL.mjs → en-B4Cuq9JN.mjs} +41 -6
- package/dist/admin/{en-BuVXIcHA.js → en-BWPOiiMt.js} +41 -6
- package/dist/admin/{es-CEteHmBO.js → es-CMskkUh-.js} +41 -6
- package/dist/admin/{es-DxHpaNA1.mjs → es-DBAmysKi.mjs} +41 -6
- package/dist/admin/{fr-Dw43lHg7.mjs → fr-BNGdtjEl.mjs} +41 -6
- package/dist/admin/{fr-BMd2-wW7.js → fr-ClJ2BkrE.js} +41 -6
- package/dist/admin/{index-DvNfekoR.js → index-DyE1rLW0.js} +22 -56
- package/dist/admin/{index-qa6Qnfkc.mjs → index-mCVi1j7e.mjs} +48 -82
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/{pt-BvO63p01.js → pt-CRh_J7JS.js} +41 -6
- package/dist/admin/{pt-7jnxDSX-.mjs → pt-Cl7TWsOV.mjs} +41 -6
- package/dist/server/index.js +1495 -51
- package/dist/server/index.mjs +1495 -51
- package/package.json +10 -2
- package/pics/untracked-confirm-dialog.webp +0 -0
- package/pics/untracked-disclosure-warning-dark.webp +0 -0
- package/pics/untracked-disclosure-warning.webp +0 -0
- package/pics/untracked-mobile-notice-warning.webp +0 -0
- package/pics/untracked-notice-neutral.webp +0 -0
|
@@ -9,7 +9,7 @@ const designSystem = require("@strapi/design-system");
|
|
|
9
9
|
const icons = require("@strapi/icons");
|
|
10
10
|
const symbols = require("@strapi/icons/symbols");
|
|
11
11
|
const styled = require("styled-components");
|
|
12
|
-
const index = require("./index-
|
|
12
|
+
const index = require("./index-DyE1rLW0.js");
|
|
13
13
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
14
14
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
15
15
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
@@ -23,27 +23,76 @@ const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800
|
|
|
23
23
|
});
|
|
24
24
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant, textColor, "data-end-reason": presentation.reason, children: translate(presentation) });
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
const MAX_EXPORT_ROWS = 5e4;
|
|
27
|
+
const EXPORT_BATCH_SIZE = 1e3;
|
|
28
|
+
const EMPTY_SESSION_STATS = Object.freeze({
|
|
29
|
+
total: 0,
|
|
30
|
+
open: 0,
|
|
31
|
+
active: 0,
|
|
32
|
+
idle: 0,
|
|
33
|
+
ended: 0,
|
|
34
|
+
loggedOut: 0,
|
|
35
|
+
timedOut: 0,
|
|
36
|
+
otherReasons: 0,
|
|
37
|
+
usersOnline: 0,
|
|
38
|
+
nativeOnly: 0,
|
|
39
|
+
nativeOnlyAfterTracking: null
|
|
40
|
+
});
|
|
41
|
+
const COUNT_KEYS = Object.freeze(
|
|
42
|
+
Object.keys(EMPTY_SESSION_STATS).filter((key) => key !== "nativeOnlyAfterTracking")
|
|
43
|
+
);
|
|
44
|
+
function filterParams(query) {
|
|
45
|
+
const params = {};
|
|
46
|
+
if (query.status && query.status !== "all") params.status = query.status;
|
|
47
|
+
if (query.status === "ended" && query.reason && query.reason !== "all") {
|
|
48
|
+
params.reason = query.reason;
|
|
49
|
+
}
|
|
50
|
+
const search = typeof query.search === "string" ? query.search.trim().slice(0, 100) : "";
|
|
51
|
+
if (search) params.search = search;
|
|
52
|
+
return params;
|
|
53
|
+
}
|
|
54
|
+
function buildListParams(query) {
|
|
55
|
+
return {
|
|
56
|
+
page: String(Math.max(1, Number(query.page) || 1)),
|
|
57
|
+
pageSize: String(query.pageSize),
|
|
58
|
+
...filterParams(query)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function buildExportParams(query, cursor) {
|
|
62
|
+
return {
|
|
63
|
+
limit: String(EXPORT_BATCH_SIZE),
|
|
64
|
+
...filterParams(query),
|
|
65
|
+
...cursor ? { cursor } : {}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const isCount$1 = (value) => Number.isInteger(value) && value >= 0;
|
|
69
|
+
function readSessionPage(payload) {
|
|
70
|
+
const body = (
|
|
71
|
+
/** @type {any} */
|
|
72
|
+
payload
|
|
36
73
|
);
|
|
37
|
-
const
|
|
74
|
+
const pagination = body?.meta?.pagination;
|
|
75
|
+
if (!Array.isArray(body?.data) || !isCount$1(pagination?.total) || !isCount$1(pagination?.pageCount)) {
|
|
76
|
+
throw new Error("Invalid session page response");
|
|
77
|
+
}
|
|
38
78
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
pageCount,
|
|
42
|
-
startIndex: total === 0 ? 0 : offset + 1,
|
|
43
|
-
endIndex: Math.min(total, offset + normalizedSize),
|
|
44
|
-
total
|
|
79
|
+
rows: body.data,
|
|
80
|
+
pagination: { total: pagination.total, pageCount: Math.max(1, pagination.pageCount) }
|
|
45
81
|
};
|
|
46
82
|
}
|
|
83
|
+
function readSessionStats(payload) {
|
|
84
|
+
const data = (
|
|
85
|
+
/** @type {any} */
|
|
86
|
+
payload?.data
|
|
87
|
+
);
|
|
88
|
+
const stats = { ...EMPTY_SESSION_STATS };
|
|
89
|
+
for (const key of COUNT_KEYS) {
|
|
90
|
+
if (!isCount$1(data?.[key])) throw new Error("Invalid session statistics response");
|
|
91
|
+
stats[key] = data[key];
|
|
92
|
+
}
|
|
93
|
+
stats.nativeOnlyAfterTracking = isCount$1(data?.nativeOnlyAfterTracking) ? data.nativeOnlyAfterTracking : null;
|
|
94
|
+
return stats;
|
|
95
|
+
}
|
|
47
96
|
const CSV_HEADERS = Object.freeze([
|
|
48
97
|
"ID",
|
|
49
98
|
"Status",
|
|
@@ -59,7 +108,12 @@ const CSV_HEADERS = Object.freeze([
|
|
|
59
108
|
"Minutes Idle",
|
|
60
109
|
"End Reason"
|
|
61
110
|
]);
|
|
62
|
-
const
|
|
111
|
+
const FORMULA_START = /^[=+\-@\t\r]/;
|
|
112
|
+
const escapeCsvValue = (value) => {
|
|
113
|
+
const text = String(value ?? "");
|
|
114
|
+
const safe = typeof value === "string" && FORMULA_START.test(text) ? `'${text}` : text;
|
|
115
|
+
return `"${safe.replace(/"/g, '""')}"`;
|
|
116
|
+
};
|
|
63
117
|
function toIsoTimestamp(value) {
|
|
64
118
|
if (value === null || value === void 0 || value === "") return "";
|
|
65
119
|
const date = value instanceof Date ? value : new Date(
|
|
@@ -330,39 +384,6 @@ function hasActiveFilters(state) {
|
|
|
330
384
|
if (!state) return false;
|
|
331
385
|
return state.status !== index.DEFAULT_SESSION_FILTER || Boolean(state.reason) && state.reason !== index.DEFAULT_END_REASON_FILTER || Boolean(state.search);
|
|
332
386
|
}
|
|
333
|
-
const getUserKey = (session) => {
|
|
334
|
-
const user = session?.user;
|
|
335
|
-
return index.presentText(user?.documentId) || index.presentText(user?.id) || index.presentText(user?.email);
|
|
336
|
-
};
|
|
337
|
-
function getSessionStats(sessions) {
|
|
338
|
-
const rows = Array.isArray(sessions) ? sessions : [];
|
|
339
|
-
const stats = {
|
|
340
|
-
active: 0,
|
|
341
|
-
idle: 0,
|
|
342
|
-
ended: 0,
|
|
343
|
-
total: rows.length,
|
|
344
|
-
usersOnline: 0,
|
|
345
|
-
loggedOut: 0,
|
|
346
|
-
timedOut: 0,
|
|
347
|
-
otherReasons: 0
|
|
348
|
-
};
|
|
349
|
-
const onlineUsers = /* @__PURE__ */ new Set();
|
|
350
|
-
for (const session of rows) {
|
|
351
|
-
const state = index.getSessionState(session);
|
|
352
|
-
stats[state] += 1;
|
|
353
|
-
if (state === "active") {
|
|
354
|
-
const key = getUserKey(session);
|
|
355
|
-
if (key) onlineUsers.add(key);
|
|
356
|
-
} else if (state === "ended") {
|
|
357
|
-
const reason = index.getSessionEndReason(session);
|
|
358
|
-
if (reason === "logout") stats.loggedOut += 1;
|
|
359
|
-
else if (reason === "idle") stats.timedOut += 1;
|
|
360
|
-
else stats.otherReasons += 1;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
stats.usersOnline = onlineUsers.size;
|
|
364
|
-
return stats;
|
|
365
|
-
}
|
|
366
387
|
function getSessionUserLabels(session) {
|
|
367
388
|
const username = index.presentText(session?.user?.username);
|
|
368
389
|
const email = index.presentText(session?.user?.email);
|
|
@@ -1211,7 +1232,7 @@ const SessionSearch = ({ value, onSearch }) => {
|
|
|
1211
1232
|
}
|
|
1212
1233
|
) });
|
|
1213
1234
|
};
|
|
1214
|
-
const Caret = styled__default.default(icons.CaretDown)`
|
|
1235
|
+
const Caret$1 = styled__default.default(icons.CaretDown)`
|
|
1215
1236
|
transform: rotate(${({ $open }) => $open ? "0deg" : "-90deg"});
|
|
1216
1237
|
`;
|
|
1217
1238
|
const Legend = styled__default.default.ul`
|
|
@@ -1250,7 +1271,7 @@ const HowSessionsWork = () => {
|
|
|
1250
1271
|
designSystem.TextButton,
|
|
1251
1272
|
{
|
|
1252
1273
|
minHeight: "3.2rem",
|
|
1253
|
-
startIcon: /* @__PURE__ */ jsxRuntime.jsx(Caret, { $open: open, "aria-hidden": true, focusable: false }),
|
|
1274
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(Caret$1, { $open: open, "aria-hidden": true, focusable: false }),
|
|
1254
1275
|
"aria-expanded": open,
|
|
1255
1276
|
"aria-controls": contentId,
|
|
1256
1277
|
onClick: toggle,
|
|
@@ -1292,13 +1313,424 @@ const HowSessionsWork = () => {
|
|
|
1292
1313
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
1293
1314
|
"homepage.howItWorks.history",
|
|
1294
1315
|
"Ended sessions stay in the history until they are deleted."
|
|
1316
|
+
) }),
|
|
1317
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
1318
|
+
"homepage.howItWorks.untracked",
|
|
1319
|
+
"Strapi also keeps its own list of sign-ins (refresh tokens). A sign-in that has no session details here, for example one from before this plugin tracked sessions, is not in this list and is never counted as active or online. A notice above the cards shows how many there are and why."
|
|
1295
1320
|
) })
|
|
1296
1321
|
] }) : null
|
|
1297
1322
|
}
|
|
1298
1323
|
)
|
|
1299
1324
|
] });
|
|
1300
1325
|
};
|
|
1301
|
-
const
|
|
1326
|
+
const UNTRACKED_SUMMARY_PATH = "/magic-sessionmanager/sessions/native-only/summary";
|
|
1327
|
+
const UNTRACKED_END_PATH = "/magic-sessionmanager/sessions/native-only/end";
|
|
1328
|
+
const isCount = (value) => Number.isInteger(value) && value >= 0;
|
|
1329
|
+
function untrackedTone(stats) {
|
|
1330
|
+
return isCount(stats?.nativeOnlyAfterTracking) && stats.nativeOnlyAfterTracking > 0 ? "warning" : "neutral";
|
|
1331
|
+
}
|
|
1332
|
+
function readUntrackedSummary(payload) {
|
|
1333
|
+
const data = (
|
|
1334
|
+
/** @type {any} */
|
|
1335
|
+
payload?.data
|
|
1336
|
+
);
|
|
1337
|
+
const fail = () => {
|
|
1338
|
+
throw new Error("Invalid untracked session summary");
|
|
1339
|
+
};
|
|
1340
|
+
if (!data || typeof data !== "object") fail();
|
|
1341
|
+
const counts = [
|
|
1342
|
+
data.total,
|
|
1343
|
+
data.beforeTracking,
|
|
1344
|
+
data.afterTracking,
|
|
1345
|
+
data.earlier,
|
|
1346
|
+
data.bySource?.signIn,
|
|
1347
|
+
data.bySource?.passwordChange,
|
|
1348
|
+
data.bySource?.tokenOnly,
|
|
1349
|
+
data.byDevice?.desktop,
|
|
1350
|
+
data.byDevice?.mobile,
|
|
1351
|
+
data.byDevice?.unknown,
|
|
1352
|
+
data.deviceSample?.scanned,
|
|
1353
|
+
data.deviceSample?.limit,
|
|
1354
|
+
data.expiring?.within7Days,
|
|
1355
|
+
data.expiring?.within30Days
|
|
1356
|
+
];
|
|
1357
|
+
if (!counts.every(isCount)) fail();
|
|
1358
|
+
if (!Array.isArray(data.byMonth)) fail();
|
|
1359
|
+
const byMonth = data.byMonth.filter(
|
|
1360
|
+
(entry) => typeof entry?.month === "string" && /^\d{4}-\d{2}$/.test(entry.month)
|
|
1361
|
+
);
|
|
1362
|
+
if (!byMonth.every((entry) => isCount(entry.count))) fail();
|
|
1363
|
+
const since = typeof data.trackingSince === "string" ? new Date(data.trackingSince) : null;
|
|
1364
|
+
return {
|
|
1365
|
+
total: data.total,
|
|
1366
|
+
trackingSince: since && Number.isFinite(since.getTime()) ? since : null,
|
|
1367
|
+
beforeTracking: data.beforeTracking,
|
|
1368
|
+
afterTracking: data.afterTracking,
|
|
1369
|
+
byMonth,
|
|
1370
|
+
earlier: data.earlier,
|
|
1371
|
+
bySource: { ...data.bySource },
|
|
1372
|
+
byDevice: { ...data.byDevice },
|
|
1373
|
+
deviceSample: { ...data.deviceSample, complete: data.deviceSample.complete === true },
|
|
1374
|
+
expiring: { ...data.expiring }
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
function shareOf(part, total) {
|
|
1378
|
+
if (!isCount(part) || !isCount(total) || total === 0) return 0;
|
|
1379
|
+
return Math.min(1, part / total);
|
|
1380
|
+
}
|
|
1381
|
+
function monthToDate(month) {
|
|
1382
|
+
const match = /^(\d{4})-(\d{2})$/.exec(month || "");
|
|
1383
|
+
if (!match) return null;
|
|
1384
|
+
return new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, 1));
|
|
1385
|
+
}
|
|
1386
|
+
function readEndResult(payload) {
|
|
1387
|
+
const data = (
|
|
1388
|
+
/** @type {any} */
|
|
1389
|
+
payload?.data
|
|
1390
|
+
);
|
|
1391
|
+
if (!isCount(data?.ended) || !isCount(data?.remaining) || !isCount(data?.limit)) {
|
|
1392
|
+
throw new Error("Invalid end response");
|
|
1393
|
+
}
|
|
1394
|
+
return { ended: data.ended, remaining: data.remaining, limit: data.limit };
|
|
1395
|
+
}
|
|
1396
|
+
const Caret = styled__default.default(icons.CaretDown)`
|
|
1397
|
+
transform: rotate(${({ $open }) => $open ? "0deg" : "-90deg"});
|
|
1398
|
+
`;
|
|
1399
|
+
const Groups = styled__default.default.div`
|
|
1400
|
+
display: grid;
|
|
1401
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1402
|
+
gap: ${({ theme }) => theme.spaces[6]};
|
|
1403
|
+
|
|
1404
|
+
${({ theme }) => theme.breakpoints.medium} {
|
|
1405
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
${({ theme }) => theme.breakpoints.large} {
|
|
1409
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
1410
|
+
}
|
|
1411
|
+
`;
|
|
1412
|
+
const Rows = styled__default.default.ul`
|
|
1413
|
+
list-style: none;
|
|
1414
|
+
margin: 0;
|
|
1415
|
+
padding: 0;
|
|
1416
|
+
display: flex;
|
|
1417
|
+
flex-direction: column;
|
|
1418
|
+
gap: ${({ theme }) => theme.spaces[2]};
|
|
1419
|
+
|
|
1420
|
+
&& > li {
|
|
1421
|
+
margin: 0;
|
|
1422
|
+
max-width: none;
|
|
1423
|
+
}
|
|
1424
|
+
`;
|
|
1425
|
+
const Row = ({ label, value }) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "li", justifyContent: "space-between", alignItems: "baseline", gap: 4, minWidth: 0, children: [
|
|
1426
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral700", minWidth: 0, children: label }),
|
|
1427
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: value })
|
|
1428
|
+
] });
|
|
1429
|
+
const Group = ({ title, children, hint }) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, minWidth: 0, children: [
|
|
1430
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", tag: "h3", textColor: "neutral800", children: title }),
|
|
1431
|
+
/* @__PURE__ */ jsxRuntime.jsx(Rows, { children }),
|
|
1432
|
+
hint ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: hint }) : null
|
|
1433
|
+
] });
|
|
1434
|
+
const UntrackedSessionsNotice = ({ stats, onChanged, fallbackFocusRef }) => {
|
|
1435
|
+
const { formatMessage, formatNumber, formatDate } = reactIntl.useIntl();
|
|
1436
|
+
const { get, post } = StrapiAdmin.useFetchClient();
|
|
1437
|
+
const { toggleNotification } = StrapiAdmin.useNotification();
|
|
1438
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1439
|
+
const [open, setOpen] = react.useState(false);
|
|
1440
|
+
const [summary, setSummary] = react.useState(null);
|
|
1441
|
+
const [summaryState, setSummaryState] = react.useState("idle");
|
|
1442
|
+
const requestRef = react.useRef(0);
|
|
1443
|
+
const panelId = `untracked-sessions-${react.useId().replace(/:/g, "")}`;
|
|
1444
|
+
const count = stats?.nativeOnly || 0;
|
|
1445
|
+
const after = stats?.nativeOnlyAfterTracking;
|
|
1446
|
+
const tone = untrackedTone(stats);
|
|
1447
|
+
const loadSummary = async () => {
|
|
1448
|
+
const request = ++requestRef.current;
|
|
1449
|
+
setSummaryState("loading");
|
|
1450
|
+
try {
|
|
1451
|
+
const response = await get(UNTRACKED_SUMMARY_PATH);
|
|
1452
|
+
const next = readUntrackedSummary(response.data);
|
|
1453
|
+
if (request !== requestRef.current) return;
|
|
1454
|
+
setSummary(next);
|
|
1455
|
+
setSummaryState("ready");
|
|
1456
|
+
} catch (err) {
|
|
1457
|
+
if (request !== requestRef.current) return;
|
|
1458
|
+
index.logSafeAdminError("dashboard.untrackedSummary", err);
|
|
1459
|
+
setSummaryState("error");
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
const toggle = () => {
|
|
1463
|
+
const next = !open;
|
|
1464
|
+
setOpen(next);
|
|
1465
|
+
if (next && summaryState !== "ready" && summaryState !== "loading") loadSummary();
|
|
1466
|
+
};
|
|
1467
|
+
const endSessions = async () => {
|
|
1468
|
+
try {
|
|
1469
|
+
const response = await post(UNTRACKED_END_PATH, {});
|
|
1470
|
+
const result = readEndResult(response.data);
|
|
1471
|
+
setSummary(null);
|
|
1472
|
+
setSummaryState("idle");
|
|
1473
|
+
if (open) loadSummary();
|
|
1474
|
+
await onChanged?.();
|
|
1475
|
+
toggleNotification({
|
|
1476
|
+
type: "success",
|
|
1477
|
+
message: result.remaining > 0 ? t(
|
|
1478
|
+
"homepage.untracked.end.partial",
|
|
1479
|
+
"{ended, plural, one {# untracked session ended.} other {# untracked sessions ended.}} {remaining, plural, one {# is left; run the action again to end it.} other {# are left; run the action again to end them.}}",
|
|
1480
|
+
{ ended: result.ended, remaining: result.remaining }
|
|
1481
|
+
) : t(
|
|
1482
|
+
"homepage.untracked.end.success",
|
|
1483
|
+
"{ended, plural, one {# untracked session ended.} other {# untracked sessions ended.}}",
|
|
1484
|
+
{ ended: result.ended }
|
|
1485
|
+
)
|
|
1486
|
+
});
|
|
1487
|
+
} catch (err) {
|
|
1488
|
+
index.logSafeAdminError("dashboard.untrackedEnd", err);
|
|
1489
|
+
toggleNotification({
|
|
1490
|
+
type: "danger",
|
|
1491
|
+
message: t(
|
|
1492
|
+
"homepage.untracked.end.error",
|
|
1493
|
+
"The untracked sessions could not be ended. Please try again."
|
|
1494
|
+
)
|
|
1495
|
+
});
|
|
1496
|
+
throw err;
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
if (count <= 0) return null;
|
|
1500
|
+
const title = tone === "warning" ? t(
|
|
1501
|
+
"homepage.untracked.title.gap",
|
|
1502
|
+
"Possible tracking gap: {count, plural, one {# Strapi sign-in is} other {# Strapi sign-ins are}} not tracked",
|
|
1503
|
+
{ count }
|
|
1504
|
+
) : t(
|
|
1505
|
+
"homepage.untracked.title.legacy",
|
|
1506
|
+
"{count, plural, one {# older Strapi sign-in is} other {# older Strapi sign-ins are}} not tracked",
|
|
1507
|
+
{ count }
|
|
1508
|
+
);
|
|
1509
|
+
const body = tone === "warning" ? t(
|
|
1510
|
+
"homepage.untracked.body.gap",
|
|
1511
|
+
"Strapi still accepts these sign-ins (refresh tokens), but they are not in this list and are not active or online sessions. {after, plural, one {# was} other {# were}} created after this plugin started tracking, so one sign-in path may not be tracked. Select “Why?” for details.",
|
|
1512
|
+
{ after }
|
|
1513
|
+
) : t(
|
|
1514
|
+
"homepage.untracked.body.legacy",
|
|
1515
|
+
"Strapi still accepts these sign-ins (refresh tokens) until they expire, but they are not in this list and are not active or online sessions. They were created before this plugin tracked sessions."
|
|
1516
|
+
);
|
|
1517
|
+
const pct = (part, total) => formatNumber(shareOf(part, total), { style: "percent", maximumFractionDigits: 0 });
|
|
1518
|
+
const num = (value) => formatNumber(value);
|
|
1519
|
+
const actions = /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
|
|
1520
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1521
|
+
designSystem.Button,
|
|
1522
|
+
{
|
|
1523
|
+
size: "S",
|
|
1524
|
+
variant: "tertiary",
|
|
1525
|
+
startIcon: /* @__PURE__ */ jsxRuntime.jsx(Caret, { $open: open, "aria-hidden": true, focusable: false }),
|
|
1526
|
+
"aria-expanded": open,
|
|
1527
|
+
"aria-controls": panelId,
|
|
1528
|
+
onClick: toggle,
|
|
1529
|
+
children: t("homepage.untracked.why", "Why?")
|
|
1530
|
+
}
|
|
1531
|
+
),
|
|
1532
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1533
|
+
index.ConfirmAction,
|
|
1534
|
+
{
|
|
1535
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "danger-light", children: t("homepage.untracked.end.action", "End these sessions") }),
|
|
1536
|
+
title: t(
|
|
1537
|
+
"homepage.untracked.end.title",
|
|
1538
|
+
"End {count, plural, one {# untracked Strapi sign-in} other {# untracked Strapi sign-ins}}?",
|
|
1539
|
+
{ count }
|
|
1540
|
+
),
|
|
1541
|
+
body: t(
|
|
1542
|
+
"homepage.untracked.end.body",
|
|
1543
|
+
"Strapi deletes these sign-ins now, so their refresh tokens stop working. Users on those devices must sign in again once their current access token expires, within minutes. Sessions listed here and Strapi administrator sessions are not affected. This cannot be undone."
|
|
1544
|
+
),
|
|
1545
|
+
confirmLabel: t("homepage.untracked.end.confirm", "End sessions"),
|
|
1546
|
+
onConfirm: endSessions,
|
|
1547
|
+
fallbackFocusRef
|
|
1548
|
+
}
|
|
1549
|
+
)
|
|
1550
|
+
] });
|
|
1551
|
+
let panel = null;
|
|
1552
|
+
if (summaryState === "loading" && !summary) {
|
|
1553
|
+
panel = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("homepage.untracked.summary.loading", "Loading details") }) });
|
|
1554
|
+
} else if (summaryState === "error") {
|
|
1555
|
+
panel = /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 3, children: [
|
|
1556
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "danger600", role: "alert", children: t("homepage.untracked.summary.error", "The details could not be loaded.") }),
|
|
1557
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "S", variant: "secondary", onClick: loadSummary, children: t("common.tryAgain", "Try again") })
|
|
1558
|
+
] });
|
|
1559
|
+
} else if (summary) {
|
|
1560
|
+
const since = summary.trackingSince ? formatDate(summary.trackingSince, { dateStyle: "medium" }) : null;
|
|
1561
|
+
panel = /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
1562
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Groups, { children: [
|
|
1563
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1564
|
+
Group,
|
|
1565
|
+
{
|
|
1566
|
+
title: t("homepage.untracked.summary.tracking", "Created before or after tracking"),
|
|
1567
|
+
hint: since ? t(
|
|
1568
|
+
"homepage.untracked.summary.trackingSince",
|
|
1569
|
+
"This plugin has linked new sign-ins since {date}.",
|
|
1570
|
+
{ date: since }
|
|
1571
|
+
) : t(
|
|
1572
|
+
"homepage.untracked.summary.trackingUnknown",
|
|
1573
|
+
"The tracking start date is not known yet."
|
|
1574
|
+
),
|
|
1575
|
+
children: [
|
|
1576
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1577
|
+
Row,
|
|
1578
|
+
{
|
|
1579
|
+
label: t(
|
|
1580
|
+
"homepage.untracked.summary.before",
|
|
1581
|
+
"Before tracking (expire on their own)"
|
|
1582
|
+
),
|
|
1583
|
+
value: num(summary.beforeTracking)
|
|
1584
|
+
}
|
|
1585
|
+
),
|
|
1586
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1587
|
+
Row,
|
|
1588
|
+
{
|
|
1589
|
+
label: t("homepage.untracked.summary.after", "After tracking (possible gap)"),
|
|
1590
|
+
value: num(summary.afterTracking)
|
|
1591
|
+
}
|
|
1592
|
+
)
|
|
1593
|
+
]
|
|
1594
|
+
}
|
|
1595
|
+
),
|
|
1596
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1597
|
+
Group,
|
|
1598
|
+
{
|
|
1599
|
+
title: t("homepage.untracked.summary.source", "How Strapi created them"),
|
|
1600
|
+
hint: t(
|
|
1601
|
+
"homepage.untracked.summary.sourceHint",
|
|
1602
|
+
"“Token only” comes from code that issues a token without Strapi’s sign-in details: GraphQL email confirmation, custom login routes or other plugins."
|
|
1603
|
+
),
|
|
1604
|
+
children: [
|
|
1605
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1606
|
+
Row,
|
|
1607
|
+
{
|
|
1608
|
+
label: t("homepage.untracked.summary.signIn", "Sign-in with device details"),
|
|
1609
|
+
value: num(summary.bySource.signIn)
|
|
1610
|
+
}
|
|
1611
|
+
),
|
|
1612
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1613
|
+
Row,
|
|
1614
|
+
{
|
|
1615
|
+
label: t("homepage.untracked.summary.passwordChange", "Password change or reset"),
|
|
1616
|
+
value: num(summary.bySource.passwordChange)
|
|
1617
|
+
}
|
|
1618
|
+
),
|
|
1619
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1620
|
+
Row,
|
|
1621
|
+
{
|
|
1622
|
+
label: t("homepage.untracked.summary.tokenOnly", "Token only"),
|
|
1623
|
+
value: num(summary.bySource.tokenOnly)
|
|
1624
|
+
}
|
|
1625
|
+
)
|
|
1626
|
+
]
|
|
1627
|
+
}
|
|
1628
|
+
),
|
|
1629
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Group, { title: t("homepage.untracked.summary.expiring", "Expiry"), children: [
|
|
1630
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1631
|
+
Row,
|
|
1632
|
+
{
|
|
1633
|
+
label: t("homepage.untracked.summary.within7", "Expire within 7 days"),
|
|
1634
|
+
value: t("homepage.untracked.summary.share", "{count} ({share})", {
|
|
1635
|
+
count: num(summary.expiring.within7Days),
|
|
1636
|
+
share: pct(summary.expiring.within7Days, summary.total)
|
|
1637
|
+
})
|
|
1638
|
+
}
|
|
1639
|
+
),
|
|
1640
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1641
|
+
Row,
|
|
1642
|
+
{
|
|
1643
|
+
label: t("homepage.untracked.summary.within30", "Expire within 30 days"),
|
|
1644
|
+
value: t("homepage.untracked.summary.share", "{count} ({share})", {
|
|
1645
|
+
count: num(summary.expiring.within30Days),
|
|
1646
|
+
share: pct(summary.expiring.within30Days, summary.total)
|
|
1647
|
+
})
|
|
1648
|
+
}
|
|
1649
|
+
)
|
|
1650
|
+
] }),
|
|
1651
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Group, { title: t("homepage.untracked.summary.months", "Created per month"), children: [
|
|
1652
|
+
summary.byMonth.map((entry) => {
|
|
1653
|
+
const date = monthToDate(entry.month);
|
|
1654
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1655
|
+
Row,
|
|
1656
|
+
{
|
|
1657
|
+
label: date ? formatDate(date, { month: "long", year: "numeric", timeZone: "UTC" }) : entry.month,
|
|
1658
|
+
value: num(entry.count)
|
|
1659
|
+
},
|
|
1660
|
+
entry.month
|
|
1661
|
+
);
|
|
1662
|
+
}),
|
|
1663
|
+
summary.earlier > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1664
|
+
Row,
|
|
1665
|
+
{
|
|
1666
|
+
label: t("homepage.untracked.summary.earlier", "Earlier"),
|
|
1667
|
+
value: num(summary.earlier)
|
|
1668
|
+
}
|
|
1669
|
+
) : null
|
|
1670
|
+
] }),
|
|
1671
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1672
|
+
Group,
|
|
1673
|
+
{
|
|
1674
|
+
title: t("homepage.untracked.summary.devices", "Devices"),
|
|
1675
|
+
hint: summary.deviceSample.complete ? t(
|
|
1676
|
+
"homepage.untracked.summary.devicesHint",
|
|
1677
|
+
"From the device label Strapi stores; Strapi stores no device type."
|
|
1678
|
+
) : t(
|
|
1679
|
+
"homepage.untracked.summary.devicesSample",
|
|
1680
|
+
"From the device label Strapi stores, for the first {limit, number} sign-ins.",
|
|
1681
|
+
{ limit: summary.deviceSample.limit }
|
|
1682
|
+
),
|
|
1683
|
+
children: [
|
|
1684
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1685
|
+
Row,
|
|
1686
|
+
{
|
|
1687
|
+
label: t("homepage.untracked.summary.desktop", "Desktop"),
|
|
1688
|
+
value: num(summary.byDevice.desktop)
|
|
1689
|
+
}
|
|
1690
|
+
),
|
|
1691
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1692
|
+
Row,
|
|
1693
|
+
{
|
|
1694
|
+
label: t("homepage.untracked.summary.mobile", "Mobile"),
|
|
1695
|
+
value: num(summary.byDevice.mobile)
|
|
1696
|
+
}
|
|
1697
|
+
),
|
|
1698
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1699
|
+
Row,
|
|
1700
|
+
{
|
|
1701
|
+
label: t("homepage.untracked.summary.unknownDevice", "Unknown device"),
|
|
1702
|
+
value: num(summary.byDevice.unknown)
|
|
1703
|
+
}
|
|
1704
|
+
)
|
|
1705
|
+
]
|
|
1706
|
+
}
|
|
1707
|
+
)
|
|
1708
|
+
] }),
|
|
1709
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
1710
|
+
"homepage.untracked.summary.next",
|
|
1711
|
+
"Sessions created after tracking started point to a sign-in path this plugin does not see: a custom login route, GraphQL sign-ins or a plugin that issues tokens. The plugin documentation explains each case. Older sessions need no action."
|
|
1712
|
+
) })
|
|
1713
|
+
] });
|
|
1714
|
+
}
|
|
1715
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-untracked-sessions": tone, children: [
|
|
1716
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.PersistentAlert, { variant: tone, title, titleAs: "h2", stacked: true, action: actions, children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: body }) }),
|
|
1717
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1718
|
+
designSystem.Box,
|
|
1719
|
+
{
|
|
1720
|
+
id: panelId,
|
|
1721
|
+
hidden: !open,
|
|
1722
|
+
width: "100%",
|
|
1723
|
+
background: "neutral0",
|
|
1724
|
+
hasRadius: true,
|
|
1725
|
+
shadow: "tableShadow",
|
|
1726
|
+
padding: { initial: 4, medium: 6 },
|
|
1727
|
+
"aria-live": "polite",
|
|
1728
|
+
"aria-busy": summaryState === "loading",
|
|
1729
|
+
children: open ? panel : null
|
|
1730
|
+
}
|
|
1731
|
+
)
|
|
1732
|
+
] });
|
|
1733
|
+
};
|
|
1302
1734
|
const CLOCK_TICK_MS = 30 * 1e3;
|
|
1303
1735
|
const ANALYTICS_PATH = `/settings/${index.pluginId}/analytics`;
|
|
1304
1736
|
const CONFIGURATION_PATH = `/settings/${index.pluginId}/general`;
|
|
@@ -1336,7 +1768,9 @@ const HomePage = () => {
|
|
|
1336
1768
|
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
1337
1769
|
const dashboard = parseDashboardQuery(query);
|
|
1338
1770
|
const [sessions, setSessions] = react.useState([]);
|
|
1339
|
-
const [
|
|
1771
|
+
const [pagination, setPagination] = react.useState({ total: 0, pageCount: 1 });
|
|
1772
|
+
const [stats, setStats] = react.useState(EMPTY_SESSION_STATS);
|
|
1773
|
+
const [exporting, setExporting] = react.useState(false);
|
|
1340
1774
|
const [loading, setLoading] = react.useState(true);
|
|
1341
1775
|
const [refreshing, setRefreshing] = react.useState(false);
|
|
1342
1776
|
const [loadError, setLoadError] = react.useState(false);
|
|
@@ -1356,6 +1790,16 @@ const HomePage = () => {
|
|
|
1356
1790
|
const mutationSnapshotRef = react.useRef([]);
|
|
1357
1791
|
const listHeadingId = `session-list-caption-${react.useId().replace(/:/g, "")}`;
|
|
1358
1792
|
const mutationPending = Boolean(terminatingSessionId || deletingSessionId);
|
|
1793
|
+
const listQuery = react.useMemo(
|
|
1794
|
+
() => ({
|
|
1795
|
+
page: dashboard.page,
|
|
1796
|
+
pageSize: dashboard.pageSize,
|
|
1797
|
+
status: dashboard.status,
|
|
1798
|
+
reason: dashboard.reason,
|
|
1799
|
+
search: dashboard.search
|
|
1800
|
+
}),
|
|
1801
|
+
[dashboard.page, dashboard.pageSize, dashboard.status, dashboard.reason, dashboard.search]
|
|
1802
|
+
);
|
|
1359
1803
|
react.useEffect(() => {
|
|
1360
1804
|
const timer = setInterval(() => setNow(Date.now()), CLOCK_TICK_MS);
|
|
1361
1805
|
return () => clearInterval(timer);
|
|
@@ -1366,11 +1810,16 @@ const HomePage = () => {
|
|
|
1366
1810
|
if (hasLoadedRef.current) setRefreshing(true);
|
|
1367
1811
|
else setLoading(true);
|
|
1368
1812
|
try {
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1813
|
+
const [listResponse, statsResponse] = await Promise.all([
|
|
1814
|
+
get(`/${index.pluginId}/sessions`, { params: buildListParams(listQuery) }),
|
|
1815
|
+
get(`/${index.pluginId}/sessions/stats`)
|
|
1816
|
+
]);
|
|
1817
|
+
const page = readSessionPage(listResponse.data);
|
|
1818
|
+
const nextStats = readSessionStats(statsResponse.data);
|
|
1371
1819
|
if (requestId !== requestIdRef.current) return;
|
|
1372
|
-
setSessions(
|
|
1373
|
-
|
|
1820
|
+
setSessions(page.rows);
|
|
1821
|
+
setPagination(page.pagination);
|
|
1822
|
+
setStats(nextStats);
|
|
1374
1823
|
setLoadError(false);
|
|
1375
1824
|
setHasData(true);
|
|
1376
1825
|
setLastUpdated(Date.now());
|
|
@@ -1386,7 +1835,7 @@ const HomePage = () => {
|
|
|
1386
1835
|
setRefreshing(false);
|
|
1387
1836
|
}
|
|
1388
1837
|
}
|
|
1389
|
-
}, [get]);
|
|
1838
|
+
}, [get, listQuery]);
|
|
1390
1839
|
react.useEffect(() => {
|
|
1391
1840
|
fetchSessions();
|
|
1392
1841
|
}, [fetchSessions]);
|
|
@@ -1474,53 +1923,74 @@ const HomePage = () => {
|
|
|
1474
1923
|
setDeletingSessionId(null);
|
|
1475
1924
|
}
|
|
1476
1925
|
};
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
),
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
const pageResult = paginateSessions(filteredSessions, dashboard.page, dashboard.pageSize);
|
|
1926
|
+
const pageSize = Number(dashboard.pageSize);
|
|
1927
|
+
const pageResult = {
|
|
1928
|
+
items: sessions,
|
|
1929
|
+
total: pagination.total,
|
|
1930
|
+
pageCount: pagination.pageCount,
|
|
1931
|
+
startIndex: pagination.total > 0 ? (dashboard.page - 1) * pageSize + 1 : 0,
|
|
1932
|
+
endIndex: pagination.total > 0 ? (dashboard.page - 1) * pageSize + sessions.length : 0
|
|
1933
|
+
};
|
|
1486
1934
|
const visibleIds = pageResult.items.map((session) => String(session.id));
|
|
1487
1935
|
react.useLayoutEffect(() => {
|
|
1488
1936
|
visibleIdsRef.current = visibleIds;
|
|
1489
1937
|
});
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
});
|
|
1497
|
-
downloadFile(csvContent, "text/csv;charset=utf-8;", "csv");
|
|
1498
|
-
} catch (err) {
|
|
1499
|
-
index.logSafeAdminError("dashboard.exportCsv", err);
|
|
1500
|
-
toggleNotification({
|
|
1501
|
-
type: "danger",
|
|
1502
|
-
message: t("notifications.error.exportFailed", "The export could not be created.")
|
|
1938
|
+
const fetchExportRows = async () => {
|
|
1939
|
+
const rows = [];
|
|
1940
|
+
let cursor = null;
|
|
1941
|
+
do {
|
|
1942
|
+
const { data } = await get(`/${index.pluginId}/sessions/export`, {
|
|
1943
|
+
params: buildExportParams(listQuery, cursor)
|
|
1503
1944
|
});
|
|
1504
|
-
|
|
1945
|
+
rows.push(...index.requireSessionList(data));
|
|
1946
|
+
cursor = typeof data?.meta?.nextCursor === "string" ? data.meta.nextCursor : null;
|
|
1947
|
+
} while (cursor && rows.length < MAX_EXPORT_ROWS);
|
|
1948
|
+
const capped = rows.length > MAX_EXPORT_ROWS || Boolean(cursor) && rows.length >= MAX_EXPORT_ROWS;
|
|
1949
|
+
return { rows: rows.slice(0, MAX_EXPORT_ROWS), capped };
|
|
1505
1950
|
};
|
|
1506
|
-
const
|
|
1951
|
+
const handleExport = async (format) => {
|
|
1952
|
+
if (exporting) return;
|
|
1953
|
+
setExporting(true);
|
|
1507
1954
|
try {
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1955
|
+
const { rows, capped } = await fetchExportRows();
|
|
1956
|
+
if (format === "csv") {
|
|
1957
|
+
const csvContent = buildSessionCsv(rows, {
|
|
1958
|
+
unavailableValue: "",
|
|
1959
|
+
getDeviceInfo: getExportDeviceInfo,
|
|
1960
|
+
getSessionStatus: index.getSessionStatus
|
|
1961
|
+
});
|
|
1962
|
+
downloadFile(csvContent, "text/csv;charset=utf-8;", "csv");
|
|
1963
|
+
} else {
|
|
1964
|
+
const jsonContent = buildSessionJson(rows, {
|
|
1965
|
+
filterStatus: dashboard.status,
|
|
1966
|
+
totalSessions: stats.total,
|
|
1967
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1968
|
+
unavailableValue: "",
|
|
1969
|
+
getDeviceInfo: getExportDeviceInfo,
|
|
1970
|
+
getSessionStatus: index.getSessionStatus,
|
|
1971
|
+
truncated: capped
|
|
1972
|
+
});
|
|
1973
|
+
downloadFile(jsonContent, "application/json", "json");
|
|
1974
|
+
}
|
|
1975
|
+
if (capped) {
|
|
1976
|
+
toggleNotification({
|
|
1977
|
+
type: "warning",
|
|
1978
|
+
message: t(
|
|
1979
|
+
"homepage.export.capped",
|
|
1980
|
+
"The export contains the newest {limit, number} sessions. Narrow the filter to export the rest.",
|
|
1981
|
+
{ limit: MAX_EXPORT_ROWS }
|
|
1982
|
+
)
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1518
1985
|
} catch (err) {
|
|
1519
|
-
index.
|
|
1986
|
+
if (index.isCancelledRequest(err)) return;
|
|
1987
|
+
index.logSafeAdminError(format === "csv" ? "dashboard.exportCsv" : "dashboard.exportJson", err);
|
|
1520
1988
|
toggleNotification({
|
|
1521
1989
|
type: "danger",
|
|
1522
1990
|
message: t("notifications.error.exportFailed", "The export could not be created.")
|
|
1523
1991
|
});
|
|
1992
|
+
} finally {
|
|
1993
|
+
setExporting(false);
|
|
1524
1994
|
}
|
|
1525
1995
|
};
|
|
1526
1996
|
const handleSessionClick = (session, opener) => {
|
|
@@ -1555,10 +2025,10 @@ const HomePage = () => {
|
|
|
1555
2025
|
[]
|
|
1556
2026
|
);
|
|
1557
2027
|
react.useEffect(() => {
|
|
1558
|
-
if (!loading && dashboard.page > pageResult.pageCount) {
|
|
2028
|
+
if (!loading && !refreshing && dashboard.page > pageResult.pageCount) {
|
|
1559
2029
|
setQuery({ page: String(pageResult.pageCount) }, "push", true);
|
|
1560
2030
|
}
|
|
1561
|
-
}, [loading, dashboard.page, pageResult.pageCount, setQuery]);
|
|
2031
|
+
}, [loading, refreshing, dashboard.page, pageResult.pageCount, setQuery]);
|
|
1562
2032
|
const handleStatusChange = (value) => {
|
|
1563
2033
|
const status = String(value);
|
|
1564
2034
|
setQuery({ status: status === "all" ? void 0 : status, reason: void 0, page: "1" });
|
|
@@ -1577,12 +2047,11 @@ const HomePage = () => {
|
|
|
1577
2047
|
setQuery({ search: void 0, _q: void 0, status: void 0, reason: void 0, page: "1" });
|
|
1578
2048
|
listHeadingRef.current?.focus();
|
|
1579
2049
|
};
|
|
1580
|
-
const stats = getSessionStats(sessions);
|
|
1581
2050
|
const showSessionData = !loading && hasData;
|
|
1582
|
-
const showToolbar = showSessionData &&
|
|
1583
|
-
const canExport = showSessionData &&
|
|
2051
|
+
const showToolbar = showSessionData && stats.total > 0;
|
|
2052
|
+
const canExport = showSessionData && pageResult.total > 0 && !exporting;
|
|
1584
2053
|
const filtersActive = hasActiveFilters(dashboard);
|
|
1585
|
-
const exportValues = { count:
|
|
2054
|
+
const exportValues = { count: Math.min(pageResult.total, MAX_EXPORT_ROWS) };
|
|
1586
2055
|
const exportMenu = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1587
2056
|
designSystem.SimpleMenu,
|
|
1588
2057
|
{
|
|
@@ -1591,20 +2060,12 @@ const HomePage = () => {
|
|
|
1591
2060
|
startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
|
|
1592
2061
|
disabled: !canExport,
|
|
1593
2062
|
children: [
|
|
1594
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect:
|
|
1595
|
-
"homepage.export.csvTruncated",
|
|
1596
|
-
"{count, plural, one {Export # session as CSV} other {Export # sessions as CSV}} (latest {limit, number} sessions only)",
|
|
1597
|
-
exportValues
|
|
1598
|
-
) : t(
|
|
2063
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => void handleExport("csv"), children: t(
|
|
1599
2064
|
"homepage.export.csv",
|
|
1600
2065
|
"{count, plural, one {Export # session as CSV} other {Export # sessions as CSV}}",
|
|
1601
2066
|
exportValues
|
|
1602
2067
|
) }),
|
|
1603
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect:
|
|
1604
|
-
"homepage.export.jsonTruncated",
|
|
1605
|
-
"{count, plural, one {Export # session as JSON} other {Export # sessions as JSON}} (latest {limit, number} sessions only)",
|
|
1606
|
-
exportValues
|
|
1607
|
-
) : t(
|
|
2068
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => void handleExport("json"), children: t(
|
|
1608
2069
|
"homepage.export.json",
|
|
1609
2070
|
"{count, plural, one {Export # session as JSON} other {Export # sessions as JSON}}",
|
|
1610
2071
|
exportValues
|
|
@@ -1736,13 +2197,16 @@ const HomePage = () => {
|
|
|
1736
2197
|
children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: t("homepage.error.load", "Sessions could not be loaded.") })
|
|
1737
2198
|
}
|
|
1738
2199
|
) : null,
|
|
1739
|
-
showSessionData &&
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
2200
|
+
showSessionData && stats.nativeOnly > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2201
|
+
UntrackedSessionsNotice,
|
|
2202
|
+
{
|
|
2203
|
+
stats,
|
|
2204
|
+
onChanged: fetchSessions,
|
|
2205
|
+
fallbackFocusRef: dashboardRef
|
|
2206
|
+
}
|
|
2207
|
+
) : null,
|
|
1744
2208
|
loading ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: t("homepage.loading", "Loading sessions") }) }) : null,
|
|
1745
|
-
showSessionData &&
|
|
2209
|
+
showSessionData && stats.total > 0 ? /* @__PURE__ */ jsxRuntime.jsx(HowSessionsWork, {}) : null,
|
|
1746
2210
|
showSessionData && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|
|
1747
2211
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", children: t("homepage.stats.label", "Session statistics") }) }),
|
|
1748
2212
|
/* @__PURE__ */ jsxRuntime.jsxs(index.StatGrid, { label: t("homepage.stats.label", "Session statistics"), children: [
|
|
@@ -1831,7 +2295,7 @@ const HomePage = () => {
|
|
|
1831
2295
|
),
|
|
1832
2296
|
lastUpdatedLine
|
|
1833
2297
|
] }),
|
|
1834
|
-
|
|
2298
|
+
pageResult.total > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1835
2299
|
isBelowMedium ? /* @__PURE__ */ jsxRuntime.jsx(SessionCardList, { ...listProps }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1836
2300
|
SessionTable,
|
|
1837
2301
|
{
|
|
@@ -1863,7 +2327,7 @@ const HomePage = () => {
|
|
|
1863
2327
|
}
|
|
1864
2328
|
)
|
|
1865
2329
|
] }),
|
|
1866
|
-
showSessionData &&
|
|
2330
|
+
showSessionData && stats.total === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1867
2331
|
designSystem.EmptyStateLayout,
|
|
1868
2332
|
{
|
|
1869
2333
|
icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "16rem", height: "8.8rem", "aria-hidden": "true" }),
|