strapi-plugin-magic-sessionmanager 4.8.0 → 4.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +90 -5
  2. package/README.md +379 -641
  3. package/dist/admin/Analytics-dyJmyxO-.mjs +418 -0
  4. package/dist/admin/Analytics-lVDnHBYp.js +420 -0
  5. package/dist/admin/App-CdgiY_Y7.js +1896 -0
  6. package/dist/admin/App-Cgf_CSjw.mjs +1894 -0
  7. package/dist/admin/License-1XUfQty5.js +443 -0
  8. package/dist/admin/License-C4WSYoqY.mjs +443 -0
  9. package/dist/admin/OnlineUsersWidget-DJC4V1KS.mjs +255 -0
  10. package/dist/admin/OnlineUsersWidget-DMPtuIpm.js +274 -0
  11. package/dist/admin/SectionCard-BlWv8CRt.js +54 -0
  12. package/dist/admin/SectionCard-D51bv4Hi.mjs +55 -0
  13. package/dist/admin/Settings-0QsyY7fe.js +3570 -0
  14. package/dist/admin/Settings-DgeuUiMF.mjs +3568 -0
  15. package/dist/admin/de-BFKoGEVT.js +544 -0
  16. package/dist/admin/de-j0oZH9Pz.mjs +544 -0
  17. package/dist/admin/en-UY4Tb5tE.mjs +544 -0
  18. package/dist/admin/en-s7Ksdkcg.js +544 -0
  19. package/dist/admin/es-07OGMe_5.js +544 -0
  20. package/dist/admin/es-DGBcZwQy.mjs +544 -0
  21. package/dist/admin/fr-B6-DWhGO.mjs +544 -0
  22. package/dist/admin/fr-ETj_2UBY.js +544 -0
  23. package/dist/admin/index-Ck19e8qw.mjs +1760 -0
  24. package/dist/admin/index-D-Nr0TCm.js +1761 -0
  25. package/dist/admin/index.js +1 -1
  26. package/dist/admin/index.mjs +2 -2
  27. package/dist/admin/maskSensitiveValue-BWcSjow7.js +9 -0
  28. package/dist/admin/maskSensitiveValue-lLRhN_S7.mjs +10 -0
  29. package/dist/admin/pt-C7PwrQtV.js +544 -0
  30. package/dist/admin/pt-YMRLm9gx.mjs +544 -0
  31. package/dist/server/index.js +1092 -463
  32. package/dist/server/index.mjs +1092 -463
  33. package/package.json +10 -1
  34. package/pics/analytics.png +0 -0
  35. package/pics/dashboard-dark.png +0 -0
  36. package/pics/dashboard.png +0 -0
  37. package/pics/dashboardsessionmodal.png +0 -0
  38. package/pics/mobile-dashboard.png +0 -0
  39. package/pics/mobile-session.png +0 -0
  40. package/pics/sessioninfopanel.png +0 -0
  41. package/pics/settings1.png +0 -0
  42. package/pics/settings2.png +0 -0
  43. package/pics/widget.png +0 -0
  44. package/scripts/geoip-updater.cjs +35 -24
  45. package/dist/admin/Analytics-CaRlu5ad.js +0 -332
  46. package/dist/admin/Analytics-THqDbNX0.mjs +0 -330
  47. package/dist/admin/App-AbZwLHtF.js +0 -1263
  48. package/dist/admin/App-hSh7guii.mjs +0 -1261
  49. package/dist/admin/FormField-C8kIT2NE.mjs +0 -59
  50. package/dist/admin/FormField-b5KBvkrj.js +0 -60
  51. package/dist/admin/License-BXBVwUVu.mjs +0 -299
  52. package/dist/admin/License-CABdPwnd.js +0 -301
  53. package/dist/admin/OnlineUsersWidget-BnWFj9IM.mjs +0 -230
  54. package/dist/admin/OnlineUsersWidget-CPFAACSb.js +0 -230
  55. package/dist/admin/PluginPageLayout-BPFMcgrx.mjs +0 -42
  56. package/dist/admin/PluginPageLayout-DmNzMdqu.js +0 -43
  57. package/dist/admin/Settings-B4DNdeKx.js +0 -2152
  58. package/dist/admin/Settings-C4RsJosh.mjs +0 -2150
  59. package/dist/admin/de-AwIFTd9i.mjs +0 -450
  60. package/dist/admin/de-D23nmqnl.js +0 -450
  61. package/dist/admin/en-C5iYQ0mC.js +0 -450
  62. package/dist/admin/en-D6QEGeRh.mjs +0 -450
  63. package/dist/admin/es-CIXnsG-p.js +0 -435
  64. package/dist/admin/es-CnFfVdKw.mjs +0 -435
  65. package/dist/admin/fr-BglXE-W4.js +0 -435
  66. package/dist/admin/fr-DefoR7uH.mjs +0 -435
  67. package/dist/admin/index-BFVITQ-o.mjs +0 -624
  68. package/dist/admin/index-DlMm-NyK.js +0 -625
  69. package/dist/admin/maskSensitiveValue-1uGWmrfG.mjs +0 -20
  70. package/dist/admin/maskSensitiveValue-B9vhxPad.js +0 -19
  71. package/dist/admin/pt-J5sf7jiY.js +0 -435
  72. package/dist/admin/pt-TODwvNQA.mjs +0 -435
@@ -1,230 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const react = require("react");
5
- const reactIntl = require("react-intl");
6
- const designSystem = require("@strapi/design-system");
7
- const index = require("./index-DlMm-NyK.js");
8
- const icons = require("@strapi/icons");
9
- const admin = require("@strapi/strapi/admin");
10
- function getSessionUserKey(session) {
11
- return session?.user?.documentId || session?.user?.id || session?.user?.email || session?.user?.username || null;
12
- }
13
- function normalizeUserCounts(response) {
14
- const totalUsers = response?.data?.totalUsers;
15
- const blockedUsers = response?.data?.blockedUsers;
16
- if (response?.success !== true || !Number.isSafeInteger(totalUsers) || totalUsers < 0 || !Number.isSafeInteger(blockedUsers) || blockedUsers < 0 || blockedUsers > totalUsers) {
17
- return null;
18
- }
19
- return { totalUsers, blockedUsers };
20
- }
21
- function computeOnlineUserStats(sessions, {
22
- now = Date.now(),
23
- totalUsers = null,
24
- blockedUsers = null
25
- } = {}) {
26
- const fifteenMin = 15 * 60 * 1e3;
27
- const thirtyMin = 30 * 60 * 1e3;
28
- const onlineNow = /* @__PURE__ */ new Set();
29
- const last15min = /* @__PURE__ */ new Set();
30
- const last30min = /* @__PURE__ */ new Set();
31
- for (const session of sessions || []) {
32
- if (!session?.isActive) continue;
33
- const userKey = getSessionUserKey(session);
34
- if (!userKey) continue;
35
- const lastActive = session.lastActive ? new Date(session.lastActive) : new Date(session.loginTime);
36
- const lastActiveMs = lastActive.getTime();
37
- if (!Number.isFinite(lastActiveMs)) continue;
38
- const timeSinceActive = now - lastActiveMs;
39
- if (timeSinceActive < fifteenMin) {
40
- onlineNow.add(userKey);
41
- last15min.add(userKey);
42
- last30min.add(userKey);
43
- } else if (timeSinceActive < thirtyMin) {
44
- last30min.add(userKey);
45
- }
46
- }
47
- const hasTotalUsers = Number.isSafeInteger(totalUsers) && totalUsers >= 0;
48
- const hasBlockedUsers = Number.isSafeInteger(blockedUsers) && blockedUsers >= 0;
49
- return {
50
- onlineNow: onlineNow.size,
51
- last15min: last15min.size,
52
- last30min: last30min.size,
53
- offline: hasTotalUsers ? Math.max(0, totalUsers - onlineNow.size) : null,
54
- totalUsers: hasTotalUsers ? totalUsers : null,
55
- blocked: hasBlockedUsers ? blockedUsers : null
56
- };
57
- }
58
- const OnlineUsersWidget = () => {
59
- const { formatMessage } = reactIntl.useIntl();
60
- const { get } = admin.useFetchClient();
61
- const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
62
- const [stats, setStats] = react.useState({
63
- onlineNow: 0,
64
- offline: null,
65
- last15min: 0,
66
- last30min: 0,
67
- totalUsers: null,
68
- blocked: null
69
- });
70
- const [loading, setLoading] = react.useState(true);
71
- const [loadError, setLoadError] = react.useState(false);
72
- const [userCountsUnavailable, setUserCountsUnavailable] = react.useState(false);
73
- const requestInProgress = react.useRef(false);
74
- const fetchStats = react.useCallback(async ({ showLoading = true } = {}) => {
75
- if (requestInProgress.current) return;
76
- requestInProgress.current = true;
77
- if (showLoading) setLoading(true);
78
- try {
79
- const { data: sessionResponse } = await get("/magic-sessionmanager/sessions");
80
- const sessions = sessionResponse?.data;
81
- if (!Array.isArray(sessions)) throw new Error("Invalid session response");
82
- let userCounts = null;
83
- let countsUnavailable = false;
84
- try {
85
- const { data: userStatsResponse } = await get("/magic-sessionmanager/users/stats");
86
- userCounts = normalizeUserCounts(userStatsResponse);
87
- if (!userCounts) throw new Error("Invalid user statistics response");
88
- } catch (error) {
89
- index.logSafeAdminError("onlineUsers.userCounts", error);
90
- countsUnavailable = true;
91
- }
92
- setStats(computeOnlineUserStats(sessions, userCounts || {}));
93
- setUserCountsUnavailable(countsUnavailable);
94
- setLoadError(false);
95
- } catch (error) {
96
- index.logSafeAdminError("onlineUsers.loadSessions", error);
97
- setLoadError(true);
98
- } finally {
99
- if (showLoading) setLoading(false);
100
- requestInProgress.current = false;
101
- }
102
- }, [get]);
103
- react.useEffect(() => {
104
- void fetchStats();
105
- const interval = setInterval(() => {
106
- void fetchStats({ showLoading: false });
107
- }, 3e4);
108
- return () => clearInterval(interval);
109
- }, [fetchStats]);
110
- const StatCard = ({ icon: Icon, label, value, color }) => /* @__PURE__ */ jsxRuntime.jsx(
111
- designSystem.Box,
112
- {
113
- padding: 4,
114
- background: "neutral0",
115
- hasRadius: true,
116
- shadow: "tableShadow",
117
- style: {
118
- textDecoration: "none",
119
- cursor: "default",
120
- transition: "box-shadow 0.2s",
121
- border: "1px solid rgba(128, 128, 128, 0.1)"
122
- },
123
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "center", children: [
124
- /* @__PURE__ */ jsxRuntime.jsx(
125
- designSystem.Box,
126
- {
127
- padding: 2,
128
- background: `${color}100`,
129
- hasRadius: true,
130
- style: {
131
- display: "flex",
132
- alignItems: "center",
133
- justifyContent: "center"
134
- },
135
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { width: "16px", height: "16px", fill: `${color}600` })
136
- }
137
- ),
138
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: [
139
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: label }),
140
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "bold", textColor: "neutral800", children: value ?? t("common.unavailable", "Unavailable") })
141
- ] })
142
- ] }) })
143
- }
144
- );
145
- if (loading) {
146
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t("common.loading", "Loading...") }) });
147
- }
148
- if (loadError) {
149
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, role: "alert", children: /* @__PURE__ */ jsxRuntime.jsx(
150
- designSystem.Alert,
151
- {
152
- variant: "danger",
153
- title: t("widget.error.title", "Session statistics could not be loaded"),
154
- closeLabel: "",
155
- action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: () => {
156
- void fetchStats();
157
- }, children: t("common.retry", "Retry") }),
158
- children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "span", children: t("widget.error.description", "Try again. If the problem continues, check Session Manager API access.") })
159
- }
160
- ) });
161
- }
162
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 0, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, children: [
163
- userCountsUnavailable && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { role: "status", children: /* @__PURE__ */ jsxRuntime.jsx(
164
- designSystem.Alert,
165
- {
166
- variant: "warning",
167
- title: t("widget.partial.title", "Some user counts are unavailable"),
168
- closeLabel: "",
169
- children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "span", children: t("widget.partial.description", "Session activity is shown, but total and blocked user counts could not be loaded.") })
170
- }
171
- ) }),
172
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 3, gridCols: 2, children: [
173
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
174
- StatCard,
175
- {
176
- icon: icons.Check,
177
- label: t("widget.stats.onlineNow", "Online Now"),
178
- value: stats.onlineNow,
179
- color: "success"
180
- }
181
- ) }),
182
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
183
- StatCard,
184
- {
185
- icon: icons.Cross,
186
- label: t("widget.stats.offline", "Offline"),
187
- value: stats.offline,
188
- color: "neutral"
189
- }
190
- ) }),
191
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
192
- StatCard,
193
- {
194
- icon: icons.Clock,
195
- label: t("widget.stats.last15min", "Last 15 min"),
196
- value: stats.last15min,
197
- color: "primary"
198
- }
199
- ) }),
200
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
201
- StatCard,
202
- {
203
- icon: icons.Clock,
204
- label: t("widget.stats.last30min", "Last 30 min"),
205
- value: stats.last30min,
206
- color: "secondary"
207
- }
208
- ) }),
209
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
210
- StatCard,
211
- {
212
- icon: icons.User,
213
- label: t("widget.stats.totalUsers", "Total Users"),
214
- value: stats.totalUsers,
215
- color: "neutral"
216
- }
217
- ) }),
218
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
219
- StatCard,
220
- {
221
- icon: icons.Cross,
222
- label: t("widget.stats.blocked", "Blocked"),
223
- value: stats.blocked,
224
- color: "danger"
225
- }
226
- ) })
227
- ] })
228
- ] }) });
229
- };
230
- exports.default = OnlineUsersWidget;
@@ -1,42 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Main, Flex } from "@strapi/design-system";
3
- import styled from "styled-components";
4
- import { Layouts } from "@strapi/strapi/admin";
5
- import { e as paragraphRhythm } from "./index-BFVITQ-o.mjs";
6
- const PageContent = styled(Flex)`
7
- width: 100%;
8
- min-width: 0;
9
-
10
- ${paragraphRhythm}
11
- `;
12
- const PluginPageLayout = ({
13
- headingId,
14
- title,
15
- subtitle,
16
- primaryAction,
17
- children
18
- }) => /* @__PURE__ */ jsxs(Main, { "aria-labelledby": headingId, children: [
19
- /* @__PURE__ */ jsx(
20
- Layouts.Header,
21
- {
22
- id: headingId,
23
- title,
24
- subtitle,
25
- primaryAction
26
- }
27
- ),
28
- /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(
29
- PageContent,
30
- {
31
- direction: "column",
32
- gap: 4,
33
- padding: { initial: 3, small: 6 },
34
- alignItems: "stretch",
35
- "data-text-rhythm": "page",
36
- children
37
- }
38
- ) })
39
- ] });
40
- export {
41
- PluginPageLayout as P
42
- };
@@ -1,43 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const designSystem = require("@strapi/design-system");
4
- const styled = require("styled-components");
5
- const admin = require("@strapi/strapi/admin");
6
- const index = require("./index-DlMm-NyK.js");
7
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
8
- const styled__default = /* @__PURE__ */ _interopDefault(styled);
9
- const PageContent = styled__default.default(designSystem.Flex)`
10
- width: 100%;
11
- min-width: 0;
12
-
13
- ${index.paragraphRhythm}
14
- `;
15
- const PluginPageLayout = ({
16
- headingId,
17
- title,
18
- subtitle,
19
- primaryAction,
20
- children
21
- }) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { "aria-labelledby": headingId, children: [
22
- /* @__PURE__ */ jsxRuntime.jsx(
23
- admin.Layouts.Header,
24
- {
25
- id: headingId,
26
- title,
27
- subtitle,
28
- primaryAction
29
- }
30
- ),
31
- /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
32
- PageContent,
33
- {
34
- direction: "column",
35
- gap: 4,
36
- padding: { initial: 3, small: 6 },
37
- alignItems: "stretch",
38
- "data-text-rhythm": "page",
39
- children
40
- }
41
- ) })
42
- ] });
43
- exports.PluginPageLayout = PluginPageLayout;