strapi-plugin-magic-sessionmanager 4.12.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 +37 -2
- package/README.md +53 -11
- package/dist/admin/{Analytics-lP0-RsVd.js → Analytics-BikQQx_J.js} +1 -1
- package/dist/admin/{Analytics-C_c24Uzq.mjs → Analytics-DIY51RI_.mjs} +1 -1
- package/dist/admin/{App-DCyNPn1k.mjs → App-B3vaybSO.mjs} +433 -13
- package/dist/admin/{App-miWDdmdX.js → App-BV1LM9Bp.js} +433 -13
- package/dist/admin/{OnlineUsersWidget-C6wlwENC.mjs → OnlineUsersWidget-T-2upsDd.mjs} +1 -1
- package/dist/admin/{OnlineUsersWidget-C6b7e4jb.js → OnlineUsersWidget-fJogM1xl.js} +1 -1
- package/dist/admin/{Settings-D9zyn5xn.js → Settings-AyYka8wn.js} +1 -1
- package/dist/admin/{Settings-DssYw2W4.mjs → Settings-BpBlXyMY.mjs} +1 -1
- package/dist/admin/{de--yNl7MPl.mjs → de-BSCDuq1i.mjs} +38 -1
- package/dist/admin/{de-DjPEATFf.js → de-z0aHRwdw.js} +38 -1
- package/dist/admin/{en-5U7g51cH.mjs → en-B4Cuq9JN.mjs} +38 -1
- package/dist/admin/{en-BoO12UQw.js → en-BWPOiiMt.js} +38 -1
- package/dist/admin/{es-BLpEuycJ.js → es-CMskkUh-.js} +38 -1
- package/dist/admin/{es-BJR-zCXL.mjs → es-DBAmysKi.mjs} +38 -1
- package/dist/admin/{fr-CeeCYQCs.mjs → fr-BNGdtjEl.mjs} +38 -1
- package/dist/admin/{fr-BE828R9Q.js → fr-ClJ2BkrE.js} +38 -1
- package/dist/admin/{index-CfQOMZVX.js → index-DyE1rLW0.js} +22 -19
- package/dist/admin/{index-rbxJZcLv.mjs → index-mCVi1j7e.mjs} +22 -19
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/{pt-BWEFiuvo.js → pt-CRh_J7JS.js} +38 -1
- package/dist/admin/{pt-CorrU3yG.mjs → pt-Cl7TWsOV.mjs} +38 -1
- package/dist/server/index.js +721 -30
- package/dist/server/index.mjs +721 -30
- 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
|
@@ -7,7 +7,7 @@ import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Li
|
|
|
7
7
|
import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowClockwise, Check, Clock, User, ChartBubble, Cog } from "@strapi/icons";
|
|
8
8
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
9
9
|
import styled, { useTheme } from "styled-components";
|
|
10
|
-
import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getDevicePresentation, u as useSessionFormatters, f as getSessionStatus, h as isNativeOnlySession, j as getSessionEndReasonPresentation, k as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, M as MissingValue, V as ValueOrMissing, o as SESSION_STATES, q as SESSION_STATUS_PRESENTATION, r as isCancelledRequest, s as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, v as PageShell, w as StatGrid, x as StatCard, y as restoreDialogFocus, z as requireSessionList, A as pluginPermissions } from "./index-
|
|
10
|
+
import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getDevicePresentation, u as useSessionFormatters, f as getSessionStatus, h as isNativeOnlySession, j as getSessionEndReasonPresentation, k as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, M as MissingValue, V as ValueOrMissing, o as SESSION_STATES, q as SESSION_STATUS_PRESENTATION, r as isCancelledRequest, s as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, v as PageShell, w as StatGrid, x as StatCard, y as restoreDialogFocus, z as requireSessionList, A as pluginPermissions } from "./index-mCVi1j7e.mjs";
|
|
11
11
|
const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
|
|
12
12
|
const { formatMessage } = useIntl();
|
|
13
13
|
const key = reason || getSessionEndReason(session);
|
|
@@ -31,8 +31,12 @@ const EMPTY_SESSION_STATS = Object.freeze({
|
|
|
31
31
|
timedOut: 0,
|
|
32
32
|
otherReasons: 0,
|
|
33
33
|
usersOnline: 0,
|
|
34
|
-
nativeOnly: 0
|
|
34
|
+
nativeOnly: 0,
|
|
35
|
+
nativeOnlyAfterTracking: null
|
|
35
36
|
});
|
|
37
|
+
const COUNT_KEYS = Object.freeze(
|
|
38
|
+
Object.keys(EMPTY_SESSION_STATS).filter((key) => key !== "nativeOnlyAfterTracking")
|
|
39
|
+
);
|
|
36
40
|
function filterParams(query) {
|
|
37
41
|
const params = {};
|
|
38
42
|
if (query.status && query.status !== "all") params.status = query.status;
|
|
@@ -57,14 +61,14 @@ function buildExportParams(query, cursor) {
|
|
|
57
61
|
...cursor ? { cursor } : {}
|
|
58
62
|
};
|
|
59
63
|
}
|
|
60
|
-
const isCount = (value) => Number.isInteger(value) && value >= 0;
|
|
64
|
+
const isCount$1 = (value) => Number.isInteger(value) && value >= 0;
|
|
61
65
|
function readSessionPage(payload) {
|
|
62
66
|
const body = (
|
|
63
67
|
/** @type {any} */
|
|
64
68
|
payload
|
|
65
69
|
);
|
|
66
70
|
const pagination = body?.meta?.pagination;
|
|
67
|
-
if (!Array.isArray(body?.data) || !isCount(pagination?.total) || !isCount(pagination?.pageCount)) {
|
|
71
|
+
if (!Array.isArray(body?.data) || !isCount$1(pagination?.total) || !isCount$1(pagination?.pageCount)) {
|
|
68
72
|
throw new Error("Invalid session page response");
|
|
69
73
|
}
|
|
70
74
|
return {
|
|
@@ -78,10 +82,11 @@ function readSessionStats(payload) {
|
|
|
78
82
|
payload?.data
|
|
79
83
|
);
|
|
80
84
|
const stats = { ...EMPTY_SESSION_STATS };
|
|
81
|
-
for (const key of
|
|
82
|
-
if (!isCount(data?.[key])) throw new Error("Invalid session statistics response");
|
|
85
|
+
for (const key of COUNT_KEYS) {
|
|
86
|
+
if (!isCount$1(data?.[key])) throw new Error("Invalid session statistics response");
|
|
83
87
|
stats[key] = data[key];
|
|
84
88
|
}
|
|
89
|
+
stats.nativeOnlyAfterTracking = isCount$1(data?.nativeOnlyAfterTracking) ? data.nativeOnlyAfterTracking : null;
|
|
85
90
|
return stats;
|
|
86
91
|
}
|
|
87
92
|
const CSV_HEADERS = Object.freeze([
|
|
@@ -1223,7 +1228,7 @@ const SessionSearch = ({ value, onSearch }) => {
|
|
|
1223
1228
|
}
|
|
1224
1229
|
) });
|
|
1225
1230
|
};
|
|
1226
|
-
const Caret = styled(CaretDown)`
|
|
1231
|
+
const Caret$1 = styled(CaretDown)`
|
|
1227
1232
|
transform: rotate(${({ $open }) => $open ? "0deg" : "-90deg"});
|
|
1228
1233
|
`;
|
|
1229
1234
|
const Legend = styled.ul`
|
|
@@ -1262,7 +1267,7 @@ const HowSessionsWork = () => {
|
|
|
1262
1267
|
TextButton,
|
|
1263
1268
|
{
|
|
1264
1269
|
minHeight: "3.2rem",
|
|
1265
|
-
startIcon: /* @__PURE__ */ jsx(Caret, { $open: open, "aria-hidden": true, focusable: false }),
|
|
1270
|
+
startIcon: /* @__PURE__ */ jsx(Caret$1, { $open: open, "aria-hidden": true, focusable: false }),
|
|
1266
1271
|
"aria-expanded": open,
|
|
1267
1272
|
"aria-controls": contentId,
|
|
1268
1273
|
onClick: toggle,
|
|
@@ -1304,12 +1309,424 @@ const HowSessionsWork = () => {
|
|
|
1304
1309
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
1305
1310
|
"homepage.howItWorks.history",
|
|
1306
1311
|
"Ended sessions stay in the history until they are deleted."
|
|
1312
|
+
) }),
|
|
1313
|
+
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
1314
|
+
"homepage.howItWorks.untracked",
|
|
1315
|
+
"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."
|
|
1307
1316
|
) })
|
|
1308
1317
|
] }) : null
|
|
1309
1318
|
}
|
|
1310
1319
|
)
|
|
1311
1320
|
] });
|
|
1312
1321
|
};
|
|
1322
|
+
const UNTRACKED_SUMMARY_PATH = "/magic-sessionmanager/sessions/native-only/summary";
|
|
1323
|
+
const UNTRACKED_END_PATH = "/magic-sessionmanager/sessions/native-only/end";
|
|
1324
|
+
const isCount = (value) => Number.isInteger(value) && value >= 0;
|
|
1325
|
+
function untrackedTone(stats) {
|
|
1326
|
+
return isCount(stats?.nativeOnlyAfterTracking) && stats.nativeOnlyAfterTracking > 0 ? "warning" : "neutral";
|
|
1327
|
+
}
|
|
1328
|
+
function readUntrackedSummary(payload) {
|
|
1329
|
+
const data = (
|
|
1330
|
+
/** @type {any} */
|
|
1331
|
+
payload?.data
|
|
1332
|
+
);
|
|
1333
|
+
const fail = () => {
|
|
1334
|
+
throw new Error("Invalid untracked session summary");
|
|
1335
|
+
};
|
|
1336
|
+
if (!data || typeof data !== "object") fail();
|
|
1337
|
+
const counts = [
|
|
1338
|
+
data.total,
|
|
1339
|
+
data.beforeTracking,
|
|
1340
|
+
data.afterTracking,
|
|
1341
|
+
data.earlier,
|
|
1342
|
+
data.bySource?.signIn,
|
|
1343
|
+
data.bySource?.passwordChange,
|
|
1344
|
+
data.bySource?.tokenOnly,
|
|
1345
|
+
data.byDevice?.desktop,
|
|
1346
|
+
data.byDevice?.mobile,
|
|
1347
|
+
data.byDevice?.unknown,
|
|
1348
|
+
data.deviceSample?.scanned,
|
|
1349
|
+
data.deviceSample?.limit,
|
|
1350
|
+
data.expiring?.within7Days,
|
|
1351
|
+
data.expiring?.within30Days
|
|
1352
|
+
];
|
|
1353
|
+
if (!counts.every(isCount)) fail();
|
|
1354
|
+
if (!Array.isArray(data.byMonth)) fail();
|
|
1355
|
+
const byMonth = data.byMonth.filter(
|
|
1356
|
+
(entry) => typeof entry?.month === "string" && /^\d{4}-\d{2}$/.test(entry.month)
|
|
1357
|
+
);
|
|
1358
|
+
if (!byMonth.every((entry) => isCount(entry.count))) fail();
|
|
1359
|
+
const since = typeof data.trackingSince === "string" ? new Date(data.trackingSince) : null;
|
|
1360
|
+
return {
|
|
1361
|
+
total: data.total,
|
|
1362
|
+
trackingSince: since && Number.isFinite(since.getTime()) ? since : null,
|
|
1363
|
+
beforeTracking: data.beforeTracking,
|
|
1364
|
+
afterTracking: data.afterTracking,
|
|
1365
|
+
byMonth,
|
|
1366
|
+
earlier: data.earlier,
|
|
1367
|
+
bySource: { ...data.bySource },
|
|
1368
|
+
byDevice: { ...data.byDevice },
|
|
1369
|
+
deviceSample: { ...data.deviceSample, complete: data.deviceSample.complete === true },
|
|
1370
|
+
expiring: { ...data.expiring }
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
function shareOf(part, total) {
|
|
1374
|
+
if (!isCount(part) || !isCount(total) || total === 0) return 0;
|
|
1375
|
+
return Math.min(1, part / total);
|
|
1376
|
+
}
|
|
1377
|
+
function monthToDate(month) {
|
|
1378
|
+
const match = /^(\d{4})-(\d{2})$/.exec(month || "");
|
|
1379
|
+
if (!match) return null;
|
|
1380
|
+
return new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, 1));
|
|
1381
|
+
}
|
|
1382
|
+
function readEndResult(payload) {
|
|
1383
|
+
const data = (
|
|
1384
|
+
/** @type {any} */
|
|
1385
|
+
payload?.data
|
|
1386
|
+
);
|
|
1387
|
+
if (!isCount(data?.ended) || !isCount(data?.remaining) || !isCount(data?.limit)) {
|
|
1388
|
+
throw new Error("Invalid end response");
|
|
1389
|
+
}
|
|
1390
|
+
return { ended: data.ended, remaining: data.remaining, limit: data.limit };
|
|
1391
|
+
}
|
|
1392
|
+
const Caret = styled(CaretDown)`
|
|
1393
|
+
transform: rotate(${({ $open }) => $open ? "0deg" : "-90deg"});
|
|
1394
|
+
`;
|
|
1395
|
+
const Groups = styled.div`
|
|
1396
|
+
display: grid;
|
|
1397
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1398
|
+
gap: ${({ theme }) => theme.spaces[6]};
|
|
1399
|
+
|
|
1400
|
+
${({ theme }) => theme.breakpoints.medium} {
|
|
1401
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
${({ theme }) => theme.breakpoints.large} {
|
|
1405
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
1406
|
+
}
|
|
1407
|
+
`;
|
|
1408
|
+
const Rows = styled.ul`
|
|
1409
|
+
list-style: none;
|
|
1410
|
+
margin: 0;
|
|
1411
|
+
padding: 0;
|
|
1412
|
+
display: flex;
|
|
1413
|
+
flex-direction: column;
|
|
1414
|
+
gap: ${({ theme }) => theme.spaces[2]};
|
|
1415
|
+
|
|
1416
|
+
&& > li {
|
|
1417
|
+
margin: 0;
|
|
1418
|
+
max-width: none;
|
|
1419
|
+
}
|
|
1420
|
+
`;
|
|
1421
|
+
const Row = ({ label, value }) => /* @__PURE__ */ jsxs(Flex, { tag: "li", justifyContent: "space-between", alignItems: "baseline", gap: 4, minWidth: 0, children: [
|
|
1422
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral700", minWidth: 0, children: label }),
|
|
1423
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral800", children: value })
|
|
1424
|
+
] });
|
|
1425
|
+
const Group = ({ title, children, hint }) => /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 3, minWidth: 0, children: [
|
|
1426
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", tag: "h3", textColor: "neutral800", children: title }),
|
|
1427
|
+
/* @__PURE__ */ jsx(Rows, { children }),
|
|
1428
|
+
hint ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: hint }) : null
|
|
1429
|
+
] });
|
|
1430
|
+
const UntrackedSessionsNotice = ({ stats, onChanged, fallbackFocusRef }) => {
|
|
1431
|
+
const { formatMessage, formatNumber, formatDate } = useIntl();
|
|
1432
|
+
const { get, post } = useFetchClient();
|
|
1433
|
+
const { toggleNotification } = useNotification();
|
|
1434
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
1435
|
+
const [open, setOpen] = useState(false);
|
|
1436
|
+
const [summary, setSummary] = useState(null);
|
|
1437
|
+
const [summaryState, setSummaryState] = useState("idle");
|
|
1438
|
+
const requestRef = useRef(0);
|
|
1439
|
+
const panelId = `untracked-sessions-${useId().replace(/:/g, "")}`;
|
|
1440
|
+
const count = stats?.nativeOnly || 0;
|
|
1441
|
+
const after = stats?.nativeOnlyAfterTracking;
|
|
1442
|
+
const tone = untrackedTone(stats);
|
|
1443
|
+
const loadSummary = async () => {
|
|
1444
|
+
const request = ++requestRef.current;
|
|
1445
|
+
setSummaryState("loading");
|
|
1446
|
+
try {
|
|
1447
|
+
const response = await get(UNTRACKED_SUMMARY_PATH);
|
|
1448
|
+
const next = readUntrackedSummary(response.data);
|
|
1449
|
+
if (request !== requestRef.current) return;
|
|
1450
|
+
setSummary(next);
|
|
1451
|
+
setSummaryState("ready");
|
|
1452
|
+
} catch (err) {
|
|
1453
|
+
if (request !== requestRef.current) return;
|
|
1454
|
+
logSafeAdminError("dashboard.untrackedSummary", err);
|
|
1455
|
+
setSummaryState("error");
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
const toggle = () => {
|
|
1459
|
+
const next = !open;
|
|
1460
|
+
setOpen(next);
|
|
1461
|
+
if (next && summaryState !== "ready" && summaryState !== "loading") loadSummary();
|
|
1462
|
+
};
|
|
1463
|
+
const endSessions = async () => {
|
|
1464
|
+
try {
|
|
1465
|
+
const response = await post(UNTRACKED_END_PATH, {});
|
|
1466
|
+
const result = readEndResult(response.data);
|
|
1467
|
+
setSummary(null);
|
|
1468
|
+
setSummaryState("idle");
|
|
1469
|
+
if (open) loadSummary();
|
|
1470
|
+
await onChanged?.();
|
|
1471
|
+
toggleNotification({
|
|
1472
|
+
type: "success",
|
|
1473
|
+
message: result.remaining > 0 ? t(
|
|
1474
|
+
"homepage.untracked.end.partial",
|
|
1475
|
+
"{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.}}",
|
|
1476
|
+
{ ended: result.ended, remaining: result.remaining }
|
|
1477
|
+
) : t(
|
|
1478
|
+
"homepage.untracked.end.success",
|
|
1479
|
+
"{ended, plural, one {# untracked session ended.} other {# untracked sessions ended.}}",
|
|
1480
|
+
{ ended: result.ended }
|
|
1481
|
+
)
|
|
1482
|
+
});
|
|
1483
|
+
} catch (err) {
|
|
1484
|
+
logSafeAdminError("dashboard.untrackedEnd", err);
|
|
1485
|
+
toggleNotification({
|
|
1486
|
+
type: "danger",
|
|
1487
|
+
message: t(
|
|
1488
|
+
"homepage.untracked.end.error",
|
|
1489
|
+
"The untracked sessions could not be ended. Please try again."
|
|
1490
|
+
)
|
|
1491
|
+
});
|
|
1492
|
+
throw err;
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
if (count <= 0) return null;
|
|
1496
|
+
const title = tone === "warning" ? t(
|
|
1497
|
+
"homepage.untracked.title.gap",
|
|
1498
|
+
"Possible tracking gap: {count, plural, one {# Strapi sign-in is} other {# Strapi sign-ins are}} not tracked",
|
|
1499
|
+
{ count }
|
|
1500
|
+
) : t(
|
|
1501
|
+
"homepage.untracked.title.legacy",
|
|
1502
|
+
"{count, plural, one {# older Strapi sign-in is} other {# older Strapi sign-ins are}} not tracked",
|
|
1503
|
+
{ count }
|
|
1504
|
+
);
|
|
1505
|
+
const body = tone === "warning" ? t(
|
|
1506
|
+
"homepage.untracked.body.gap",
|
|
1507
|
+
"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.",
|
|
1508
|
+
{ after }
|
|
1509
|
+
) : t(
|
|
1510
|
+
"homepage.untracked.body.legacy",
|
|
1511
|
+
"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."
|
|
1512
|
+
);
|
|
1513
|
+
const pct = (part, total) => formatNumber(shareOf(part, total), { style: "percent", maximumFractionDigits: 0 });
|
|
1514
|
+
const num = (value) => formatNumber(value);
|
|
1515
|
+
const actions = /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", children: [
|
|
1516
|
+
/* @__PURE__ */ jsx(
|
|
1517
|
+
Button,
|
|
1518
|
+
{
|
|
1519
|
+
size: "S",
|
|
1520
|
+
variant: "tertiary",
|
|
1521
|
+
startIcon: /* @__PURE__ */ jsx(Caret, { $open: open, "aria-hidden": true, focusable: false }),
|
|
1522
|
+
"aria-expanded": open,
|
|
1523
|
+
"aria-controls": panelId,
|
|
1524
|
+
onClick: toggle,
|
|
1525
|
+
children: t("homepage.untracked.why", "Why?")
|
|
1526
|
+
}
|
|
1527
|
+
),
|
|
1528
|
+
/* @__PURE__ */ jsx(
|
|
1529
|
+
ConfirmAction,
|
|
1530
|
+
{
|
|
1531
|
+
trigger: /* @__PURE__ */ jsx(Button, { size: "S", variant: "danger-light", children: t("homepage.untracked.end.action", "End these sessions") }),
|
|
1532
|
+
title: t(
|
|
1533
|
+
"homepage.untracked.end.title",
|
|
1534
|
+
"End {count, plural, one {# untracked Strapi sign-in} other {# untracked Strapi sign-ins}}?",
|
|
1535
|
+
{ count }
|
|
1536
|
+
),
|
|
1537
|
+
body: t(
|
|
1538
|
+
"homepage.untracked.end.body",
|
|
1539
|
+
"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."
|
|
1540
|
+
),
|
|
1541
|
+
confirmLabel: t("homepage.untracked.end.confirm", "End sessions"),
|
|
1542
|
+
onConfirm: endSessions,
|
|
1543
|
+
fallbackFocusRef
|
|
1544
|
+
}
|
|
1545
|
+
)
|
|
1546
|
+
] });
|
|
1547
|
+
let panel = null;
|
|
1548
|
+
if (summaryState === "loading" && !summary) {
|
|
1549
|
+
panel = /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 4, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("homepage.untracked.summary.loading", "Loading details") }) });
|
|
1550
|
+
} else if (summaryState === "error") {
|
|
1551
|
+
panel = /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 3, children: [
|
|
1552
|
+
/* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "danger600", role: "alert", children: t("homepage.untracked.summary.error", "The details could not be loaded.") }),
|
|
1553
|
+
/* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: loadSummary, children: t("common.tryAgain", "Try again") })
|
|
1554
|
+
] });
|
|
1555
|
+
} else if (summary) {
|
|
1556
|
+
const since = summary.trackingSince ? formatDate(summary.trackingSince, { dateStyle: "medium" }) : null;
|
|
1557
|
+
panel = /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
1558
|
+
/* @__PURE__ */ jsxs(Groups, { children: [
|
|
1559
|
+
/* @__PURE__ */ jsxs(
|
|
1560
|
+
Group,
|
|
1561
|
+
{
|
|
1562
|
+
title: t("homepage.untracked.summary.tracking", "Created before or after tracking"),
|
|
1563
|
+
hint: since ? t(
|
|
1564
|
+
"homepage.untracked.summary.trackingSince",
|
|
1565
|
+
"This plugin has linked new sign-ins since {date}.",
|
|
1566
|
+
{ date: since }
|
|
1567
|
+
) : t(
|
|
1568
|
+
"homepage.untracked.summary.trackingUnknown",
|
|
1569
|
+
"The tracking start date is not known yet."
|
|
1570
|
+
),
|
|
1571
|
+
children: [
|
|
1572
|
+
/* @__PURE__ */ jsx(
|
|
1573
|
+
Row,
|
|
1574
|
+
{
|
|
1575
|
+
label: t(
|
|
1576
|
+
"homepage.untracked.summary.before",
|
|
1577
|
+
"Before tracking (expire on their own)"
|
|
1578
|
+
),
|
|
1579
|
+
value: num(summary.beforeTracking)
|
|
1580
|
+
}
|
|
1581
|
+
),
|
|
1582
|
+
/* @__PURE__ */ jsx(
|
|
1583
|
+
Row,
|
|
1584
|
+
{
|
|
1585
|
+
label: t("homepage.untracked.summary.after", "After tracking (possible gap)"),
|
|
1586
|
+
value: num(summary.afterTracking)
|
|
1587
|
+
}
|
|
1588
|
+
)
|
|
1589
|
+
]
|
|
1590
|
+
}
|
|
1591
|
+
),
|
|
1592
|
+
/* @__PURE__ */ jsxs(
|
|
1593
|
+
Group,
|
|
1594
|
+
{
|
|
1595
|
+
title: t("homepage.untracked.summary.source", "How Strapi created them"),
|
|
1596
|
+
hint: t(
|
|
1597
|
+
"homepage.untracked.summary.sourceHint",
|
|
1598
|
+
"“Token only” comes from code that issues a token without Strapi’s sign-in details: GraphQL email confirmation, custom login routes or other plugins."
|
|
1599
|
+
),
|
|
1600
|
+
children: [
|
|
1601
|
+
/* @__PURE__ */ jsx(
|
|
1602
|
+
Row,
|
|
1603
|
+
{
|
|
1604
|
+
label: t("homepage.untracked.summary.signIn", "Sign-in with device details"),
|
|
1605
|
+
value: num(summary.bySource.signIn)
|
|
1606
|
+
}
|
|
1607
|
+
),
|
|
1608
|
+
/* @__PURE__ */ jsx(
|
|
1609
|
+
Row,
|
|
1610
|
+
{
|
|
1611
|
+
label: t("homepage.untracked.summary.passwordChange", "Password change or reset"),
|
|
1612
|
+
value: num(summary.bySource.passwordChange)
|
|
1613
|
+
}
|
|
1614
|
+
),
|
|
1615
|
+
/* @__PURE__ */ jsx(
|
|
1616
|
+
Row,
|
|
1617
|
+
{
|
|
1618
|
+
label: t("homepage.untracked.summary.tokenOnly", "Token only"),
|
|
1619
|
+
value: num(summary.bySource.tokenOnly)
|
|
1620
|
+
}
|
|
1621
|
+
)
|
|
1622
|
+
]
|
|
1623
|
+
}
|
|
1624
|
+
),
|
|
1625
|
+
/* @__PURE__ */ jsxs(Group, { title: t("homepage.untracked.summary.expiring", "Expiry"), children: [
|
|
1626
|
+
/* @__PURE__ */ jsx(
|
|
1627
|
+
Row,
|
|
1628
|
+
{
|
|
1629
|
+
label: t("homepage.untracked.summary.within7", "Expire within 7 days"),
|
|
1630
|
+
value: t("homepage.untracked.summary.share", "{count} ({share})", {
|
|
1631
|
+
count: num(summary.expiring.within7Days),
|
|
1632
|
+
share: pct(summary.expiring.within7Days, summary.total)
|
|
1633
|
+
})
|
|
1634
|
+
}
|
|
1635
|
+
),
|
|
1636
|
+
/* @__PURE__ */ jsx(
|
|
1637
|
+
Row,
|
|
1638
|
+
{
|
|
1639
|
+
label: t("homepage.untracked.summary.within30", "Expire within 30 days"),
|
|
1640
|
+
value: t("homepage.untracked.summary.share", "{count} ({share})", {
|
|
1641
|
+
count: num(summary.expiring.within30Days),
|
|
1642
|
+
share: pct(summary.expiring.within30Days, summary.total)
|
|
1643
|
+
})
|
|
1644
|
+
}
|
|
1645
|
+
)
|
|
1646
|
+
] }),
|
|
1647
|
+
/* @__PURE__ */ jsxs(Group, { title: t("homepage.untracked.summary.months", "Created per month"), children: [
|
|
1648
|
+
summary.byMonth.map((entry) => {
|
|
1649
|
+
const date = monthToDate(entry.month);
|
|
1650
|
+
return /* @__PURE__ */ jsx(
|
|
1651
|
+
Row,
|
|
1652
|
+
{
|
|
1653
|
+
label: date ? formatDate(date, { month: "long", year: "numeric", timeZone: "UTC" }) : entry.month,
|
|
1654
|
+
value: num(entry.count)
|
|
1655
|
+
},
|
|
1656
|
+
entry.month
|
|
1657
|
+
);
|
|
1658
|
+
}),
|
|
1659
|
+
summary.earlier > 0 ? /* @__PURE__ */ jsx(
|
|
1660
|
+
Row,
|
|
1661
|
+
{
|
|
1662
|
+
label: t("homepage.untracked.summary.earlier", "Earlier"),
|
|
1663
|
+
value: num(summary.earlier)
|
|
1664
|
+
}
|
|
1665
|
+
) : null
|
|
1666
|
+
] }),
|
|
1667
|
+
/* @__PURE__ */ jsxs(
|
|
1668
|
+
Group,
|
|
1669
|
+
{
|
|
1670
|
+
title: t("homepage.untracked.summary.devices", "Devices"),
|
|
1671
|
+
hint: summary.deviceSample.complete ? t(
|
|
1672
|
+
"homepage.untracked.summary.devicesHint",
|
|
1673
|
+
"From the device label Strapi stores; Strapi stores no device type."
|
|
1674
|
+
) : t(
|
|
1675
|
+
"homepage.untracked.summary.devicesSample",
|
|
1676
|
+
"From the device label Strapi stores, for the first {limit, number} sign-ins.",
|
|
1677
|
+
{ limit: summary.deviceSample.limit }
|
|
1678
|
+
),
|
|
1679
|
+
children: [
|
|
1680
|
+
/* @__PURE__ */ jsx(
|
|
1681
|
+
Row,
|
|
1682
|
+
{
|
|
1683
|
+
label: t("homepage.untracked.summary.desktop", "Desktop"),
|
|
1684
|
+
value: num(summary.byDevice.desktop)
|
|
1685
|
+
}
|
|
1686
|
+
),
|
|
1687
|
+
/* @__PURE__ */ jsx(
|
|
1688
|
+
Row,
|
|
1689
|
+
{
|
|
1690
|
+
label: t("homepage.untracked.summary.mobile", "Mobile"),
|
|
1691
|
+
value: num(summary.byDevice.mobile)
|
|
1692
|
+
}
|
|
1693
|
+
),
|
|
1694
|
+
/* @__PURE__ */ jsx(
|
|
1695
|
+
Row,
|
|
1696
|
+
{
|
|
1697
|
+
label: t("homepage.untracked.summary.unknownDevice", "Unknown device"),
|
|
1698
|
+
value: num(summary.byDevice.unknown)
|
|
1699
|
+
}
|
|
1700
|
+
)
|
|
1701
|
+
]
|
|
1702
|
+
}
|
|
1703
|
+
)
|
|
1704
|
+
] }),
|
|
1705
|
+
/* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
|
|
1706
|
+
"homepage.untracked.summary.next",
|
|
1707
|
+
"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."
|
|
1708
|
+
) })
|
|
1709
|
+
] });
|
|
1710
|
+
}
|
|
1711
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, "data-untracked-sessions": tone, children: [
|
|
1712
|
+
/* @__PURE__ */ jsx(PersistentAlert, { variant: tone, title, titleAs: "h2", stacked: true, action: actions, children: /* @__PURE__ */ jsx(ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: body }) }),
|
|
1713
|
+
/* @__PURE__ */ jsx(
|
|
1714
|
+
Box,
|
|
1715
|
+
{
|
|
1716
|
+
id: panelId,
|
|
1717
|
+
hidden: !open,
|
|
1718
|
+
width: "100%",
|
|
1719
|
+
background: "neutral0",
|
|
1720
|
+
hasRadius: true,
|
|
1721
|
+
shadow: "tableShadow",
|
|
1722
|
+
padding: { initial: 4, medium: 6 },
|
|
1723
|
+
"aria-live": "polite",
|
|
1724
|
+
"aria-busy": summaryState === "loading",
|
|
1725
|
+
children: open ? panel : null
|
|
1726
|
+
}
|
|
1727
|
+
)
|
|
1728
|
+
] });
|
|
1729
|
+
};
|
|
1313
1730
|
const CLOCK_TICK_MS = 30 * 1e3;
|
|
1314
1731
|
const ANALYTICS_PATH = `/settings/${pluginId}/analytics`;
|
|
1315
1732
|
const CONFIGURATION_PATH = `/settings/${pluginId}/general`;
|
|
@@ -1776,11 +2193,14 @@ const HomePage = () => {
|
|
|
1776
2193
|
children: /* @__PURE__ */ jsx(ReadableText, { variant: "omega", textColor: "neutral800", tag: "span", children: t("homepage.error.load", "Sessions could not be loaded.") })
|
|
1777
2194
|
}
|
|
1778
2195
|
) : null,
|
|
1779
|
-
showSessionData && stats.nativeOnly > 0 ? /* @__PURE__ */ jsx(
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
2196
|
+
showSessionData && stats.nativeOnly > 0 ? /* @__PURE__ */ jsx(
|
|
2197
|
+
UntrackedSessionsNotice,
|
|
2198
|
+
{
|
|
2199
|
+
stats,
|
|
2200
|
+
onChanged: fetchSessions,
|
|
2201
|
+
fallbackFocusRef: dashboardRef
|
|
2202
|
+
}
|
|
2203
|
+
) : null,
|
|
1784
2204
|
loading ? /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsx(Loader, { children: t("homepage.loading", "Loading sessions") }) }) : null,
|
|
1785
2205
|
showSessionData && stats.total > 0 ? /* @__PURE__ */ jsx(HowSessionsWork, {}) : null,
|
|
1786
2206
|
showSessionData && /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
|