strapi-plugin-magic-sessionmanager 4.7.2 → 4.9.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +380 -663
  3. package/dist/admin/Analytics-B6d-39Qh.js +420 -0
  4. package/dist/admin/Analytics-DxOWXHn8.mjs +418 -0
  5. package/dist/admin/App-ZsSGj7n8.mjs +1894 -0
  6. package/dist/admin/App-mRFV50K6.js +1896 -0
  7. package/dist/admin/License-BE6UQ_V3.mjs +443 -0
  8. package/dist/admin/License-DXt2oi6u.js +443 -0
  9. package/dist/admin/OnlineUsersWidget-CFvM3Vbp.js +273 -0
  10. package/dist/admin/OnlineUsersWidget-_tJ6aeWl.mjs +254 -0
  11. package/dist/admin/SectionCard-BlWv8CRt.js +54 -0
  12. package/dist/admin/SectionCard-D51bv4Hi.mjs +55 -0
  13. package/dist/admin/Settings-BUc12TP5.js +3570 -0
  14. package/dist/admin/Settings-dtW7cjTX.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-C_SyRULc.mjs +1750 -0
  24. package/dist/admin/index-D4kEnXSp.js +1751 -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 +3555 -6350
  32. package/dist/server/index.mjs +3555 -6350
  33. package/package.json +30 -19
  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 +266 -36
  45. package/scripts/update-geoip-db.mjs +3 -0
  46. package/dist/admin/Analytics-CsrpxJwQ.mjs +0 -497
  47. package/dist/admin/Analytics-D03ZNNMR.js +0 -499
  48. package/dist/admin/App-B2VCS3cz.js +0 -1481
  49. package/dist/admin/App-qxKnK7G2.mjs +0 -1479
  50. package/dist/admin/License-ClW7sZLR.mjs +0 -318
  51. package/dist/admin/License-fixnQ7wF.js +0 -320
  52. package/dist/admin/OnlineUsersWidget-mR_OMiwi.mjs +0 -185
  53. package/dist/admin/OnlineUsersWidget-qb9utPBy.js +0 -185
  54. package/dist/admin/Settings-U3V4eGMo.mjs +0 -2038
  55. package/dist/admin/Settings-gv2BF54w.js +0 -2040
  56. package/dist/admin/StyledButtons-Cz8oYhmc.mjs +0 -418
  57. package/dist/admin/StyledButtons-DDuxnYz8.js +0 -419
  58. package/dist/admin/de-BnqGCokx.js +0 -316
  59. package/dist/admin/de-JBE-iylO.mjs +0 -316
  60. package/dist/admin/en-BRmVwd8-.js +0 -316
  61. package/dist/admin/en-kQWtdEai.mjs +0 -316
  62. package/dist/admin/es-CH691xcL.js +0 -301
  63. package/dist/admin/es-DOQvBxih.mjs +0 -301
  64. package/dist/admin/fr-CLExO0w_.js +0 -301
  65. package/dist/admin/fr-CmfCpepX.mjs +0 -301
  66. package/dist/admin/index-B_lFjUAg.mjs +0 -551
  67. package/dist/admin/index-Duc7cR_d.js +0 -552
  68. package/dist/admin/pt-BJ_F0yNi.js +0 -301
  69. package/dist/admin/pt-BSzZdyAH.mjs +0 -301
  70. package/dist/admin/sessionStatus-D_fWEzgj.js +0 -11
  71. package/dist/admin/sessionStatus-kwggjEMw.mjs +0 -12
@@ -1,185 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState, useCallback, useEffect } from "react";
3
- import { useIntl } from "react-intl";
4
- import { Box, Typography, Flex, Grid } from "@strapi/design-system";
5
- import { Check, Cross, Clock, User } from "@strapi/icons";
6
- import { useFetchClient } from "@strapi/strapi/admin";
7
- import { g as getTranslation } from "./index-B_lFjUAg.mjs";
8
- function getSessionUserKey(session) {
9
- return session?.user?.documentId || session?.user?.id || session?.user?.email || session?.user?.username || null;
10
- }
11
- function computeOnlineUserStats(sessions, {
12
- now = Date.now(),
13
- totalUsers = 0,
14
- blockedUsers = 0
15
- } = {}) {
16
- const fifteenMin = 15 * 60 * 1e3;
17
- const thirtyMin = 30 * 60 * 1e3;
18
- const onlineNow = /* @__PURE__ */ new Set();
19
- const last15min = /* @__PURE__ */ new Set();
20
- const last30min = /* @__PURE__ */ new Set();
21
- for (const session of sessions || []) {
22
- if (!session?.isActive) continue;
23
- const userKey = getSessionUserKey(session);
24
- if (!userKey) continue;
25
- const lastActive = session.lastActive ? new Date(session.lastActive) : new Date(session.loginTime);
26
- const lastActiveMs = lastActive.getTime();
27
- if (!Number.isFinite(lastActiveMs)) continue;
28
- const timeSinceActive = now - lastActiveMs;
29
- if (timeSinceActive < fifteenMin) {
30
- onlineNow.add(userKey);
31
- last15min.add(userKey);
32
- last30min.add(userKey);
33
- } else if (timeSinceActive < thirtyMin) {
34
- last30min.add(userKey);
35
- }
36
- }
37
- return {
38
- onlineNow: onlineNow.size,
39
- last15min: last15min.size,
40
- last30min: last30min.size,
41
- offline: Math.max(0, totalUsers - onlineNow.size),
42
- totalUsers,
43
- blocked: blockedUsers
44
- };
45
- }
46
- const OnlineUsersWidget = () => {
47
- const { formatMessage } = useIntl();
48
- const { get } = useFetchClient();
49
- const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
50
- const [stats, setStats] = useState({
51
- onlineNow: 0,
52
- offline: 0,
53
- last15min: 0,
54
- last30min: 0,
55
- totalUsers: 0,
56
- blocked: 0
57
- });
58
- const [loading, setLoading] = useState(true);
59
- const fetchStats = useCallback(async () => {
60
- try {
61
- const { data } = await get("/magic-sessionmanager/sessions");
62
- const sessions = data.data || [];
63
- try {
64
- const { data: usersData } = await get("/content-manager/collection-types/plugin::users-permissions.user?pageSize=1");
65
- const totalUsers = usersData?.pagination?.total || 0;
66
- const { data: blockedData } = await get("/content-manager/collection-types/plugin::users-permissions.user?filters[$and][0][blocked][$eq]=true&pageSize=1");
67
- const blockedUsers = blockedData?.pagination?.total || 0;
68
- setStats(computeOnlineUserStats(sessions, {
69
- totalUsers,
70
- blockedUsers
71
- }));
72
- } catch (err) {
73
- console.error("[OnlineUsersWidget] Error fetching user count:", err);
74
- setStats(computeOnlineUserStats(sessions));
75
- }
76
- } catch (err) {
77
- console.error("[OnlineUsersWidget] Error:", err);
78
- } finally {
79
- setLoading(false);
80
- }
81
- }, [get]);
82
- useEffect(() => {
83
- fetchStats();
84
- const interval = setInterval(fetchStats, 3e4);
85
- return () => clearInterval(interval);
86
- }, [fetchStats]);
87
- const StatCard = ({ icon: Icon, label, value, color }) => /* @__PURE__ */ jsx(
88
- Box,
89
- {
90
- as: "a",
91
- padding: 4,
92
- background: "neutral0",
93
- hasRadius: true,
94
- shadow: "tableShadow",
95
- style: {
96
- textDecoration: "none",
97
- cursor: "default",
98
- transition: "box-shadow 0.2s",
99
- border: "1px solid rgba(128, 128, 128, 0.1)"
100
- },
101
- children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", alignItems: "flex-start", children: /* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "center", children: [
102
- /* @__PURE__ */ jsx(
103
- Box,
104
- {
105
- padding: 2,
106
- background: `${color}100`,
107
- hasRadius: true,
108
- style: {
109
- display: "flex",
110
- alignItems: "center",
111
- justifyContent: "center"
112
- },
113
- children: /* @__PURE__ */ jsx(Icon, { width: "16px", height: "16px", fill: `${color}600` })
114
- }
115
- ),
116
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: [
117
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: label }),
118
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", textColor: "neutral800", children: value })
119
- ] })
120
- ] }) })
121
- }
122
- );
123
- if (loading) {
124
- return /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("common.loading", "Loading...") }) });
125
- }
126
- return /* @__PURE__ */ jsx(Box, { padding: 0, children: /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 3, children: /* @__PURE__ */ jsxs(Grid.Root, { gap: 3, gridCols: 2, children: [
127
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
128
- StatCard,
129
- {
130
- icon: Check,
131
- label: t("widget.stats.onlineNow", "Online Now"),
132
- value: stats.onlineNow,
133
- color: "success"
134
- }
135
- ) }),
136
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
137
- StatCard,
138
- {
139
- icon: Cross,
140
- label: t("widget.stats.offline", "Offline"),
141
- value: stats.offline,
142
- color: "neutral"
143
- }
144
- ) }),
145
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
146
- StatCard,
147
- {
148
- icon: Clock,
149
- label: t("widget.stats.last15min", "Last 15 min"),
150
- value: stats.last15min,
151
- color: "primary"
152
- }
153
- ) }),
154
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
155
- StatCard,
156
- {
157
- icon: Clock,
158
- label: t("widget.stats.last30min", "Last 30 min"),
159
- value: stats.last30min,
160
- color: "secondary"
161
- }
162
- ) }),
163
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
164
- StatCard,
165
- {
166
- icon: User,
167
- label: t("widget.stats.totalUsers", "Total Users"),
168
- value: stats.totalUsers,
169
- color: "neutral"
170
- }
171
- ) }),
172
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
173
- StatCard,
174
- {
175
- icon: Cross,
176
- label: t("widget.stats.blocked", "Blocked"),
177
- value: stats.blocked,
178
- color: "danger"
179
- }
180
- ) })
181
- ] }) }) });
182
- };
183
- export {
184
- OnlineUsersWidget as default
185
- };
@@ -1,185 +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 icons = require("@strapi/icons");
8
- const admin = require("@strapi/strapi/admin");
9
- const index = require("./index-Duc7cR_d.js");
10
- function getSessionUserKey(session) {
11
- return session?.user?.documentId || session?.user?.id || session?.user?.email || session?.user?.username || null;
12
- }
13
- function computeOnlineUserStats(sessions, {
14
- now = Date.now(),
15
- totalUsers = 0,
16
- blockedUsers = 0
17
- } = {}) {
18
- const fifteenMin = 15 * 60 * 1e3;
19
- const thirtyMin = 30 * 60 * 1e3;
20
- const onlineNow = /* @__PURE__ */ new Set();
21
- const last15min = /* @__PURE__ */ new Set();
22
- const last30min = /* @__PURE__ */ new Set();
23
- for (const session of sessions || []) {
24
- if (!session?.isActive) continue;
25
- const userKey = getSessionUserKey(session);
26
- if (!userKey) continue;
27
- const lastActive = session.lastActive ? new Date(session.lastActive) : new Date(session.loginTime);
28
- const lastActiveMs = lastActive.getTime();
29
- if (!Number.isFinite(lastActiveMs)) continue;
30
- const timeSinceActive = now - lastActiveMs;
31
- if (timeSinceActive < fifteenMin) {
32
- onlineNow.add(userKey);
33
- last15min.add(userKey);
34
- last30min.add(userKey);
35
- } else if (timeSinceActive < thirtyMin) {
36
- last30min.add(userKey);
37
- }
38
- }
39
- return {
40
- onlineNow: onlineNow.size,
41
- last15min: last15min.size,
42
- last30min: last30min.size,
43
- offline: Math.max(0, totalUsers - onlineNow.size),
44
- totalUsers,
45
- blocked: blockedUsers
46
- };
47
- }
48
- const OnlineUsersWidget = () => {
49
- const { formatMessage } = reactIntl.useIntl();
50
- const { get } = admin.useFetchClient();
51
- const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
52
- const [stats, setStats] = react.useState({
53
- onlineNow: 0,
54
- offline: 0,
55
- last15min: 0,
56
- last30min: 0,
57
- totalUsers: 0,
58
- blocked: 0
59
- });
60
- const [loading, setLoading] = react.useState(true);
61
- const fetchStats = react.useCallback(async () => {
62
- try {
63
- const { data } = await get("/magic-sessionmanager/sessions");
64
- const sessions = data.data || [];
65
- try {
66
- const { data: usersData } = await get("/content-manager/collection-types/plugin::users-permissions.user?pageSize=1");
67
- const totalUsers = usersData?.pagination?.total || 0;
68
- const { data: blockedData } = await get("/content-manager/collection-types/plugin::users-permissions.user?filters[$and][0][blocked][$eq]=true&pageSize=1");
69
- const blockedUsers = blockedData?.pagination?.total || 0;
70
- setStats(computeOnlineUserStats(sessions, {
71
- totalUsers,
72
- blockedUsers
73
- }));
74
- } catch (err) {
75
- console.error("[OnlineUsersWidget] Error fetching user count:", err);
76
- setStats(computeOnlineUserStats(sessions));
77
- }
78
- } catch (err) {
79
- console.error("[OnlineUsersWidget] Error:", err);
80
- } finally {
81
- setLoading(false);
82
- }
83
- }, [get]);
84
- react.useEffect(() => {
85
- fetchStats();
86
- const interval = setInterval(fetchStats, 3e4);
87
- return () => clearInterval(interval);
88
- }, [fetchStats]);
89
- const StatCard = ({ icon: Icon, label, value, color }) => /* @__PURE__ */ jsxRuntime.jsx(
90
- designSystem.Box,
91
- {
92
- as: "a",
93
- padding: 4,
94
- background: "neutral0",
95
- hasRadius: true,
96
- shadow: "tableShadow",
97
- style: {
98
- textDecoration: "none",
99
- cursor: "default",
100
- transition: "box-shadow 0.2s",
101
- border: "1px solid rgba(128, 128, 128, 0.1)"
102
- },
103
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "center", children: [
104
- /* @__PURE__ */ jsxRuntime.jsx(
105
- designSystem.Box,
106
- {
107
- padding: 2,
108
- background: `${color}100`,
109
- hasRadius: true,
110
- style: {
111
- display: "flex",
112
- alignItems: "center",
113
- justifyContent: "center"
114
- },
115
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { width: "16px", height: "16px", fill: `${color}600` })
116
- }
117
- ),
118
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: [
119
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: label }),
120
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "bold", textColor: "neutral800", children: value })
121
- ] })
122
- ] }) })
123
- }
124
- );
125
- if (loading) {
126
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("common.loading", "Loading...") }) });
127
- }
128
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 0, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", gap: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 3, gridCols: 2, children: [
129
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
130
- StatCard,
131
- {
132
- icon: icons.Check,
133
- label: t("widget.stats.onlineNow", "Online Now"),
134
- value: stats.onlineNow,
135
- color: "success"
136
- }
137
- ) }),
138
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
139
- StatCard,
140
- {
141
- icon: icons.Cross,
142
- label: t("widget.stats.offline", "Offline"),
143
- value: stats.offline,
144
- color: "neutral"
145
- }
146
- ) }),
147
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
148
- StatCard,
149
- {
150
- icon: icons.Clock,
151
- label: t("widget.stats.last15min", "Last 15 min"),
152
- value: stats.last15min,
153
- color: "primary"
154
- }
155
- ) }),
156
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
157
- StatCard,
158
- {
159
- icon: icons.Clock,
160
- label: t("widget.stats.last30min", "Last 30 min"),
161
- value: stats.last30min,
162
- color: "secondary"
163
- }
164
- ) }),
165
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
166
- StatCard,
167
- {
168
- icon: icons.User,
169
- label: t("widget.stats.totalUsers", "Total Users"),
170
- value: stats.totalUsers,
171
- color: "neutral"
172
- }
173
- ) }),
174
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
175
- StatCard,
176
- {
177
- icon: icons.Cross,
178
- label: t("widget.stats.blocked", "Blocked"),
179
- value: stats.blocked,
180
- color: "danger"
181
- }
182
- ) })
183
- ] }) }) });
184
- };
185
- exports.default = OnlineUsersWidget;