strapi-plugin-magic-sessionmanager 4.7.2 → 4.8.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 (52) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +17 -38
  3. package/dist/admin/Analytics-CaRlu5ad.js +332 -0
  4. package/dist/admin/Analytics-THqDbNX0.mjs +330 -0
  5. package/dist/admin/App-AbZwLHtF.js +1263 -0
  6. package/dist/admin/App-hSh7guii.mjs +1261 -0
  7. package/dist/admin/FormField-C8kIT2NE.mjs +59 -0
  8. package/dist/admin/FormField-b5KBvkrj.js +60 -0
  9. package/dist/admin/License-BXBVwUVu.mjs +299 -0
  10. package/dist/admin/License-CABdPwnd.js +301 -0
  11. package/dist/admin/OnlineUsersWidget-BnWFj9IM.mjs +230 -0
  12. package/dist/admin/OnlineUsersWidget-CPFAACSb.js +230 -0
  13. package/dist/admin/PluginPageLayout-BPFMcgrx.mjs +42 -0
  14. package/dist/admin/PluginPageLayout-DmNzMdqu.js +43 -0
  15. package/dist/admin/Settings-B4DNdeKx.js +2152 -0
  16. package/dist/admin/Settings-C4RsJosh.mjs +2150 -0
  17. package/dist/admin/{de-JBE-iylO.mjs → de-AwIFTd9i.mjs} +154 -20
  18. package/dist/admin/{de-BnqGCokx.js → de-D23nmqnl.js} +154 -20
  19. package/dist/admin/{en-BRmVwd8-.js → en-C5iYQ0mC.js} +155 -21
  20. package/dist/admin/{en-kQWtdEai.mjs → en-D6QEGeRh.mjs} +155 -21
  21. package/dist/admin/{es-CH691xcL.js → es-CIXnsG-p.js} +154 -20
  22. package/dist/admin/{es-DOQvBxih.mjs → es-CnFfVdKw.mjs} +154 -20
  23. package/dist/admin/{fr-CLExO0w_.js → fr-BglXE-W4.js} +154 -20
  24. package/dist/admin/{fr-CmfCpepX.mjs → fr-DefoR7uH.mjs} +154 -20
  25. package/dist/admin/index-BFVITQ-o.mjs +624 -0
  26. package/dist/admin/{index-Duc7cR_d.js → index-DlMm-NyK.js} +261 -188
  27. package/dist/admin/index.js +1 -1
  28. package/dist/admin/index.mjs +1 -1
  29. package/dist/admin/maskSensitiveValue-1uGWmrfG.mjs +20 -0
  30. package/dist/admin/maskSensitiveValue-B9vhxPad.js +19 -0
  31. package/dist/admin/{pt-BJ_F0yNi.js → pt-J5sf7jiY.js} +154 -20
  32. package/dist/admin/{pt-BSzZdyAH.mjs → pt-TODwvNQA.mjs} +154 -20
  33. package/dist/server/index.js +4396 -7820
  34. package/dist/server/index.mjs +4396 -7820
  35. package/package.json +21 -19
  36. package/scripts/geoip-updater.cjs +234 -15
  37. package/scripts/update-geoip-db.mjs +3 -0
  38. package/dist/admin/Analytics-CsrpxJwQ.mjs +0 -497
  39. package/dist/admin/Analytics-D03ZNNMR.js +0 -499
  40. package/dist/admin/App-B2VCS3cz.js +0 -1481
  41. package/dist/admin/App-qxKnK7G2.mjs +0 -1479
  42. package/dist/admin/License-ClW7sZLR.mjs +0 -318
  43. package/dist/admin/License-fixnQ7wF.js +0 -320
  44. package/dist/admin/OnlineUsersWidget-mR_OMiwi.mjs +0 -185
  45. package/dist/admin/OnlineUsersWidget-qb9utPBy.js +0 -185
  46. package/dist/admin/Settings-U3V4eGMo.mjs +0 -2038
  47. package/dist/admin/Settings-gv2BF54w.js +0 -2040
  48. package/dist/admin/StyledButtons-Cz8oYhmc.mjs +0 -418
  49. package/dist/admin/StyledButtons-DDuxnYz8.js +0 -419
  50. package/dist/admin/index-B_lFjUAg.mjs +0 -551
  51. package/dist/admin/sessionStatus-D_fWEzgj.js +0 -11
  52. package/dist/admin/sessionStatus-kwggjEMw.mjs +0 -12
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ # [4.8.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.7.2...v4.8.0) (2026-11-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * align CI installs with lockfile settings ([ad9e7ed](https://github.com/Schero94/Magic-Sessionmanager/commit/ad9e7eda60e4a5e5f7479532085946869e3d7f96))
7
+ * pass npm credentials to release workflow ([6a6d17d](https://github.com/Schero94/Magic-Sessionmanager/commit/6a6d17d740c8b6a80d72b057a548a8c649ba3651))
8
+
9
+
10
+ ### Features
11
+
12
+ * add Strapi-native end-user session management ([2f00880](https://github.com/Schero94/Magic-Sessionmanager/commit/2f00880337bf590e4e5cbc8059c31fd0d18aee05))
13
+ * improve session settings and admin access ([36ccd50](https://github.com/Schero94/Magic-Sessionmanager/commit/36ccd503433a7b8d6ade9e7d0ec971ba124518aa))
14
+
15
+ ## [Unreleased]
16
+
17
+ ### Added
18
+
19
+ * Add native Strapi Users & Permissions end-user session support for `jwtManagement: 'refresh'` while retaining `legacy-support`, Magic session metadata and history, and existing endpoint contracts. The plugin does not change host authentication configuration. Strapi administrator-account sessions remain out of scope.
20
+
1
21
  ## [4.7.2](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.7.1...v4.7.2) (2026-07-11)
2
22
 
3
23
 
package/README.md CHANGED
@@ -9,6 +9,8 @@ Free and open under the MIT license. All features are available without a paid l
9
9
  [![NPM](https://img.shields.io/npm/v/strapi-plugin-magic-sessionmanager.svg)](https://www.npmjs.com/package/strapi-plugin-magic-sessionmanager)
10
10
  [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
11
11
 
12
+ [Project site](https://schero94.github.io/Magic-Sessionmanager/)
13
+
12
14
  ---
13
15
 
14
16
  ## 📸 What It Looks Like
@@ -190,9 +192,7 @@ SESSION_ENCRYPTION_KEY=your-key-here
190
192
  **Need to kick someone out?**
191
193
  1. Find their session
192
194
  2. Click **"Terminate"**
193
- 3. Done! They're logged out immediately
194
-
195
- **Even works if they have refresh tokens!** (See below)
195
+ 3. Magic Sessionmanager asks the configured session manager to revoke it. The behavior depends on the mode below.
196
196
 
197
197
  ### 3. Session Details
198
198
 
@@ -222,52 +222,29 @@ Each login = separate session. You can see them all and logout each individually
222
222
 
223
223
  ---
224
224
 
225
- ## 🔒 Refresh Token Protection (Advanced)
226
-
227
- ### The Problem (Without This Plugin)
228
-
229
- ```
230
- Admin kicks out a user
231
- ↓
232
- User has "refresh token"
233
- ↓
234
- User gets new login token automatically
235
- ↓
236
- User is back in! 😱
237
- ```
225
+ ## 🔒 Session management modes
238
226
 
239
- ### The Solution (With This Plugin)
227
+ Magic Sessionmanager supports Strapi Users & Permissions end-user sessions in both the native refresh mode and the existing `legacy-support` mode.
240
228
 
241
- ```
242
- Admin kicks out a user
243
- ↓
244
- User tries to use refresh token
245
- ↓
246
- Plugin blocks it! 🚫
247
- ↓
248
- User MUST login again
249
- ```
229
+ ### Native Users & Permissions sessions
250
230
 
251
- **How to enable:**
252
-
253
- Add to `config/plugins.ts`:
231
+ Set `jwtManagement` to `refresh` in the host application's Users & Permissions configuration to use Strapi's native session manager:
254
232
 
255
233
  ```typescript
256
234
  'users-permissions': {
257
235
  config: {
258
- jwtManagement: 'refresh', // Enable refresh tokens
259
- sessions: {
260
- accessTokenLifespan: 3600, // 1 hour
261
- maxRefreshTokenLifespan: 2592000, // 30 days
262
- },
236
+ jwtManagement: 'refresh',
263
237
  },
264
238
  }
265
239
  ```
266
240
 
267
- **What this does:**
268
- - Users stay logged in longer (better experience)
269
- - But admins can still force-logout completely (better security)
270
- - Best of both worlds! ✅
241
+ In this mode, Strapi issues, rotates and revokes native sessions. Magic Sessionmanager uses that state for end-user sessions while keeping its metadata and session history, such as device, IP, GeoIP and security details. It does not issue or rotate a second token family. Rows created natively without a Magic metadata record can still appear with a `native_` ID. Missing IP, device or GeoIP values are shown as unavailable.
242
+
243
+ The existing Magic endpoints keep their paths, methods, permissions and response envelopes. The plugin does not change the host application's authentication configuration or migrate existing session records. Set `jwtManagement: 'refresh'` in the host application to opt into native session management. Its default Content API permission setup targets only the Authenticated role and never adds these actions to Public. If an administrator saves the Authenticated role before the first protected Magic request, the plugin preserves that role's permission choices. Strapi administrator-account sessions are not managed by this plugin.
244
+
245
+ ### Existing `legacy-support` mode
246
+
247
+ When Users & Permissions uses `jwtManagement: 'legacy-support'`, Magic Sessionmanager keeps its existing plugin-owned session behavior. It does not switch the host to refresh mode or migrate legacy session records. Existing Magic endpoints remain available in either mode.
271
248
 
272
249
  ---
273
250
 
@@ -614,6 +591,8 @@ Authorization: Bearer <JWT>
614
591
  Terminates a specific session (not the current one). Useful for "Log out other devices".
615
592
  Use the `id` / `documentId` value from the session response. The separate `sessionId` field is a tracking identifier stored on the session record.
616
593
 
594
+ For a native-only row, use its `native_` value from `id`. Native-only rows may not have a `documentId` or Magic metadata.
595
+
617
596
  ```bash
618
597
  DELETE /api/magic-sessionmanager/my-sessions/:documentId
619
598
  Authorization: Bearer <JWT>
@@ -0,0 +1,332 @@
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 admin = require("@strapi/strapi/admin");
7
+ const styled = require("styled-components");
8
+ const designSystem = require("@strapi/design-system");
9
+ const icons = require("@strapi/icons");
10
+ const index = require("./index-DlMm-NyK.js");
11
+ const PluginPageLayout = require("./PluginPageLayout-DmNzMdqu.js");
12
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
13
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
14
+ function increment(target, key) {
15
+ target[key] = (target[key] || 0) + 1;
16
+ }
17
+ function getUserKey(session) {
18
+ return session?.user?.documentId || session?.user?.id || session?.user?.email || session?.user?.username || null;
19
+ }
20
+ function getDurationMinutes(session, now) {
21
+ const start = Date.parse(session?.loginTime);
22
+ if (!Number.isFinite(start)) return null;
23
+ const endValue = session.logoutTime || session.lastActive;
24
+ const end = endValue ? Date.parse(endValue) : now;
25
+ if (!Number.isFinite(end)) return null;
26
+ return Math.max(0, Math.floor((end - start) / 6e4));
27
+ }
28
+ function computeSessionAnalytics(sessions = [], { now = Date.now() } = {}) {
29
+ const dayAgo = now - 24 * 60 * 60 * 1e3;
30
+ const weekAgo = now - 7 * 24 * 60 * 60 * 1e3;
31
+ const devices = {};
32
+ const browsers = {};
33
+ const operatingSystems = {};
34
+ const loginHours = Array(24).fill(0);
35
+ const uniqueUsers = /* @__PURE__ */ new Set();
36
+ const uniqueIPs = /* @__PURE__ */ new Set();
37
+ const durations = [];
38
+ let todayLogins = 0;
39
+ let weekLogins = 0;
40
+ let loggedOut = 0;
41
+ let terminated = 0;
42
+ for (const session of sessions) {
43
+ const ua = String(session?.userAgent || "").toLowerCase();
44
+ const loginTime = Date.parse(session?.loginTime);
45
+ if (Number.isFinite(loginTime)) {
46
+ if (loginTime > dayAgo) todayLogins++;
47
+ if (loginTime > weekAgo) weekLogins++;
48
+ loginHours[new Date(loginTime).getHours()]++;
49
+ }
50
+ if (ua.includes("tablet") || ua.includes("ipad") || ua.includes("android") && !ua.includes("mobile")) {
51
+ increment(devices, "Tablet");
52
+ } else if (ua.includes("mobile") || ua.includes("android") || ua.includes("iphone")) {
53
+ increment(devices, "Mobile");
54
+ } else {
55
+ increment(devices, "Desktop");
56
+ }
57
+ if (ua.includes("edg")) increment(browsers, "Edge");
58
+ else if (ua.includes("chrome")) increment(browsers, "Chrome");
59
+ else if (ua.includes("firefox")) increment(browsers, "Firefox");
60
+ else if (ua.includes("safari")) increment(browsers, "Safari");
61
+ else if (ua.includes("postman") || ua.includes("curl")) increment(browsers, "API Client");
62
+ else increment(browsers, "Other");
63
+ if (ua.includes("android")) increment(operatingSystems, "Android");
64
+ else if (ua.includes("ios") || ua.includes("iphone") || ua.includes("ipad")) increment(operatingSystems, "iOS");
65
+ else if (ua.includes("windows") || ua.includes("win32") || ua.includes("win64")) increment(operatingSystems, "Windows");
66
+ else if (ua.includes("mac") || ua.includes("darwin")) increment(operatingSystems, "macOS");
67
+ else if (ua.includes("linux")) increment(operatingSystems, "Linux");
68
+ else increment(operatingSystems, "Other");
69
+ const userKey = getUserKey(session);
70
+ if (userKey) uniqueUsers.add(userKey);
71
+ if (session?.ipAddress) uniqueIPs.add(session.ipAddress);
72
+ const status = index.getSessionStatus(session);
73
+ if (status === "loggedout") loggedOut++;
74
+ else if (!session?.isActive && status === "terminated") terminated++;
75
+ const duration = getDurationMinutes(session, now);
76
+ if (duration !== null) durations.push(duration);
77
+ }
78
+ const mobileCount = (devices.Mobile || 0) + (devices.Tablet || 0);
79
+ return {
80
+ totalSessions: sessions.length,
81
+ activeSessions: sessions.filter((session) => session?.isActive && session?.isTrulyActive).length,
82
+ todayLogins,
83
+ weekLogins,
84
+ devices,
85
+ browsers,
86
+ operatingSystems,
87
+ loginHours,
88
+ peakHour: loginHours.indexOf(Math.max(...loginHours)),
89
+ uniqueUsers: uniqueUsers.size,
90
+ uniqueIPs: uniqueIPs.size,
91
+ loggedOut,
92
+ terminated,
93
+ mobileRatio: sessions.length > 0 ? Math.round(mobileCount / sessions.length * 100) : 0,
94
+ avgSessionDuration: durations.length > 0 ? Math.floor(durations.reduce((sum, duration) => sum + duration, 0) / durations.length) : 0
95
+ };
96
+ }
97
+ const Container = styled__default.default(designSystem.Box)`
98
+ width: 100%;
99
+ min-width: 0;
100
+ `;
101
+ const StatsGrid = styled__default.default.div`
102
+ display: grid;
103
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
104
+ gap: 12px;
105
+ min-width: 0;
106
+ margin-bottom: 16px;
107
+ `;
108
+ const StatCard = styled__default.default(designSystem.Box)`
109
+ background: ${(p) => p.theme.colors.neutral0};
110
+ border: 1px solid ${(p) => p.theme.colors.neutral150};
111
+ border-top: 3px solid ${(p) => p.theme.colors.primary600};
112
+ border-radius: 4px;
113
+ min-width: 0;
114
+ padding: 16px;
115
+ display: flex;
116
+ flex-direction: column;
117
+ align-items: flex-start;
118
+ gap: 4px;
119
+
120
+ && > p {
121
+ max-width: none;
122
+ margin: 0;
123
+ line-height: 1.25;
124
+ }
125
+
126
+ && > p + p {
127
+ margin-block-start: 0;
128
+ }
129
+ `;
130
+ const StatIcon = styled__default.default(designSystem.Box)`
131
+ width: 36px;
132
+ height: 36px;
133
+ border-radius: 4px;
134
+ display: flex;
135
+ align-items: center;
136
+ justify-content: center;
137
+ background: ${(p) => p.theme.colors.primary100};
138
+ color: ${(p) => p.theme.colors.primary600};
139
+ margin-bottom: 8px;
140
+
141
+ svg {
142
+ width: 20px;
143
+ height: 20px;
144
+ }
145
+ `;
146
+ const ChartCard = styled__default.default(designSystem.Box)`
147
+ background: ${(p) => p.theme.colors.neutral0};
148
+ border-radius: 4px;
149
+ border: 1px solid ${(p) => p.theme.colors.neutral150};
150
+ min-width: 0;
151
+ padding: 20px;
152
+ `;
153
+ const BarChart = styled__default.default.div`
154
+ display: flex;
155
+ flex-direction: column;
156
+ gap: 12px;
157
+ min-width: 0;
158
+ `;
159
+ const BarRow = styled__default.default.div`
160
+ display: flex;
161
+ align-items: center;
162
+ gap: 12px;
163
+ min-width: 0;
164
+ `;
165
+ const BarContainer = styled__default.default.div`
166
+ flex: 1;
167
+ min-width: 0;
168
+ height: 28px;
169
+ background: ${(p) => p.theme.colors.neutral100};
170
+ border-radius: 4px;
171
+ overflow: hidden;
172
+ position: relative;
173
+ `;
174
+ const BarFill = styled__default.default.div`
175
+ height: 100%;
176
+ width: ${(props) => `${Math.max(0, Math.min(100, props.$percentage || 0))}%`};
177
+ background: ${(p) => p.theme.colors.primary600};
178
+ border-radius: 4px;
179
+ `;
180
+ const LoadingOverlay = styled__default.default(designSystem.Flex)`
181
+ min-height: 240px;
182
+ align-items: center;
183
+ justify-content: center;
184
+ `;
185
+ const AnalyticsPage = () => {
186
+ const { formatMessage } = reactIntl.useIntl();
187
+ const { get } = admin.useFetchClient();
188
+ const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
189
+ const [loading, setLoading] = react.useState(true);
190
+ const [analytics, setAnalytics] = react.useState(null);
191
+ const [loadError, setLoadError] = react.useState(false);
192
+ react.useEffect(() => {
193
+ fetchAnalytics();
194
+ }, []);
195
+ const fetchAnalytics = async () => {
196
+ setLoading(true);
197
+ setLoadError(false);
198
+ try {
199
+ const { data } = await get(`/${index.pluginId}/sessions`);
200
+ const sessions = data.data || [];
201
+ setAnalytics(computeSessionAnalytics(sessions));
202
+ } catch (err) {
203
+ setLoadError(true);
204
+ index.logSafeAdminError("analytics.load", err);
205
+ } finally {
206
+ setLoading(false);
207
+ }
208
+ };
209
+ if (loading) {
210
+ return /* @__PURE__ */ jsxRuntime.jsx(
211
+ PluginPageLayout.PluginPageLayout,
212
+ {
213
+ headingId: "magic-sessionmanager-analytics-title",
214
+ title: t("analytics.title", "Session Analytics"),
215
+ subtitle: t("analytics.subtitle", "Session activity and device trends"),
216
+ children: /* @__PURE__ */ jsxRuntime.jsx(LoadingOverlay, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: t("analytics.loading", "Loading analytics data...") }) })
217
+ }
218
+ );
219
+ }
220
+ if (loadError) {
221
+ return /* @__PURE__ */ jsxRuntime.jsx(
222
+ PluginPageLayout.PluginPageLayout,
223
+ {
224
+ headingId: "magic-sessionmanager-analytics-title",
225
+ title: t("analytics.title", "Session Analytics"),
226
+ subtitle: t("analytics.subtitle", "Session activity and device trends"),
227
+ children: /* @__PURE__ */ jsxRuntime.jsx(
228
+ designSystem.Alert,
229
+ {
230
+ variant: "danger",
231
+ title: t("analytics.error.title", "Analytics could not be loaded"),
232
+ closeLabel: t("common.close", "Close"),
233
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: fetchAnalytics, children: t("common.retry", "Retry") }),
234
+ children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "span", children: t("analytics.error.description", "Try again. If the problem continues, check session API access and permissions.") })
235
+ }
236
+ )
237
+ }
238
+ );
239
+ }
240
+ const maxDevices = Math.max(...Object.values(analytics?.devices || {}), 1);
241
+ const maxBrowsers = Math.max(...Object.values(analytics?.browsers || {}), 1);
242
+ const hasSessions = Number(analytics?.totalSessions) > 0;
243
+ return /* @__PURE__ */ jsxRuntime.jsx(
244
+ PluginPageLayout.PluginPageLayout,
245
+ {
246
+ headingId: "magic-sessionmanager-analytics-title",
247
+ title: t("analytics.title", "Session Analytics"),
248
+ subtitle: t("analytics.subtitle", "Session activity and device trends"),
249
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Container, { children: [
250
+ /* @__PURE__ */ jsxRuntime.jsxs(StatsGrid, { children: [
251
+ /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { padding: 4, background: "neutral0", children: [
252
+ /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChartBubble, {}) }),
253
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "semiBold", tag: "p", children: analytics?.totalSessions || 0 }),
254
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t("analytics.stats.total", "Total sessions") })
255
+ ] }),
256
+ /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { padding: 4, background: "neutral0", children: [
257
+ /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}) }),
258
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "semiBold", tag: "p", children: analytics?.activeSessions || 0 }),
259
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t("analytics.stats.active", "Online now") })
260
+ ] }),
261
+ /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { padding: 4, background: "neutral0", children: [
262
+ /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Clock, {}) }),
263
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "semiBold", tag: "p", children: analytics?.todayLogins || 0 }),
264
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t("analytics.stats.today", "Logins today") })
265
+ ] }),
266
+ /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { padding: 4, background: "neutral0", children: [
267
+ /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Clock, {}) }),
268
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "semiBold", tag: "p", children: analytics?.weekLogins || 0 }),
269
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t("analytics.stats.week", "Logins this week") })
270
+ ] })
271
+ ] }),
272
+ hasSessions ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
273
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, wrap: "wrap", style: { marginBottom: "28px" }, children: [
274
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 320px", minWidth: 0 }, children: /* @__PURE__ */ jsxRuntime.jsxs(ChartCard, { children: [
275
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", style: { marginBottom: 16 }, children: [
276
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Monitor, {}),
277
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", fontWeight: "semiBold", tag: "h2", children: t("analytics.devices.title", "Devices") })
278
+ ] }),
279
+ /* @__PURE__ */ jsxRuntime.jsx(BarChart, { children: analytics?.devices && Object.entries(analytics.devices).sort(([, a], [, b]) => b - a).map(([device, count]) => /* @__PURE__ */ jsxRuntime.jsxs(BarRow, { children: [
280
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral700", style: { flex: "0 0 96px", minWidth: 0, overflowWrap: "anywhere" }, children: device }),
281
+ /* @__PURE__ */ jsxRuntime.jsxs(BarContainer, { children: [
282
+ /* @__PURE__ */ jsxRuntime.jsx(
283
+ BarFill,
284
+ {
285
+ $percentage: count / maxDevices * 100
286
+ }
287
+ ),
288
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "semiBold", textColor: "neutral800", style: { position: "absolute", top: "50%", right: 8, transform: "translateY(-50%)", fontVariantNumeric: "tabular-nums" }, children: count })
289
+ ] })
290
+ ] }, device)) })
291
+ ] }) }),
292
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 320px", minWidth: 0 }, children: /* @__PURE__ */ jsxRuntime.jsxs(ChartCard, { children: [
293
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", style: { marginBottom: 16 }, children: [
294
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Monitor, {}),
295
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", fontWeight: "semiBold", tag: "h2", children: t("analytics.browsers.title", "Browsers") })
296
+ ] }),
297
+ /* @__PURE__ */ jsxRuntime.jsx(BarChart, { children: analytics?.browsers && Object.entries(analytics.browsers).sort(([, a], [, b]) => b - a).map(([browser, count]) => /* @__PURE__ */ jsxRuntime.jsxs(BarRow, { children: [
298
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral700", style: { flex: "0 0 96px", minWidth: 0, overflowWrap: "anywhere" }, children: browser }),
299
+ /* @__PURE__ */ jsxRuntime.jsxs(BarContainer, { children: [
300
+ /* @__PURE__ */ jsxRuntime.jsx(
301
+ BarFill,
302
+ {
303
+ $percentage: count / maxBrowsers * 100
304
+ }
305
+ ),
306
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "semiBold", textColor: "neutral800", style: { position: "absolute", top: "50%", right: 8, transform: "translateY(-50%)", fontVariantNumeric: "tabular-nums" }, children: count })
307
+ ] })
308
+ ] }, browser)) })
309
+ ] }) })
310
+ ] }),
311
+ /* @__PURE__ */ jsxRuntime.jsxs(ChartCard, { children: [
312
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", justifyContent: "space-between", children: [
313
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
314
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Clock, {}),
315
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", fontWeight: "semiBold", tag: "h2", children: t("analytics.duration.title", "Average session duration") })
316
+ ] }),
317
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { variant: "primary", size: "M", children: t("analytics.duration.minutes", "{count} min", { count: analytics?.avgSessionDuration || 0 }) })
318
+ ] }),
319
+ analytics?.avgSessionDuration > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 4, padding: 4, background: "neutral100", hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", children: t("analytics.duration.description", "Average time between login and last activity. Higher values can indicate idle or abandoned sessions.") }) })
320
+ ] })
321
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
322
+ designSystem.EmptyStateLayout,
323
+ {
324
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ChartBubble, { "aria-hidden": "true" }),
325
+ content: t("analytics.empty", "Session analytics will appear here after end users sign in.")
326
+ }
327
+ )
328
+ ] })
329
+ }
330
+ );
331
+ };
332
+ exports.default = AnalyticsPage;