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
@@ -1,499 +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 admin = require("@strapi/strapi/admin");
6
- const styled = require("styled-components");
7
- const designSystem = require("@strapi/design-system");
8
- const icons = require("@strapi/icons");
9
- const index = require("./index-Duc7cR_d.js");
10
- const sessionStatus = require("./sessionStatus-D_fWEzgj.js");
11
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
12
- const styled__default = /* @__PURE__ */ _interopDefault(styled);
13
- function increment(target, key) {
14
- target[key] = (target[key] || 0) + 1;
15
- }
16
- function getUserKey(session) {
17
- return session?.user?.documentId || session?.user?.id || session?.user?.email || session?.user?.username || null;
18
- }
19
- function getDurationMinutes(session, now) {
20
- const start = Date.parse(session?.loginTime);
21
- if (!Number.isFinite(start)) return null;
22
- const endValue = session.logoutTime || session.lastActive;
23
- const end = endValue ? Date.parse(endValue) : now;
24
- if (!Number.isFinite(end)) return null;
25
- return Math.max(0, Math.floor((end - start) / 6e4));
26
- }
27
- function computeSessionAnalytics(sessions = [], { now = Date.now() } = {}) {
28
- const dayAgo = now - 24 * 60 * 60 * 1e3;
29
- const weekAgo = now - 7 * 24 * 60 * 60 * 1e3;
30
- const devices = {};
31
- const browsers = {};
32
- const operatingSystems = {};
33
- const loginHours = Array(24).fill(0);
34
- const uniqueUsers = /* @__PURE__ */ new Set();
35
- const uniqueIPs = /* @__PURE__ */ new Set();
36
- const durations = [];
37
- let todayLogins = 0;
38
- let weekLogins = 0;
39
- let loggedOut = 0;
40
- let terminated = 0;
41
- for (const session of sessions) {
42
- const ua = String(session?.userAgent || "").toLowerCase();
43
- const loginTime = Date.parse(session?.loginTime);
44
- if (Number.isFinite(loginTime)) {
45
- if (loginTime > dayAgo) todayLogins++;
46
- if (loginTime > weekAgo) weekLogins++;
47
- loginHours[new Date(loginTime).getHours()]++;
48
- }
49
- if (ua.includes("tablet") || ua.includes("ipad") || ua.includes("android") && !ua.includes("mobile")) {
50
- increment(devices, "Tablet");
51
- } else if (ua.includes("mobile") || ua.includes("android") || ua.includes("iphone")) {
52
- increment(devices, "Mobile");
53
- } else {
54
- increment(devices, "Desktop");
55
- }
56
- if (ua.includes("edg")) increment(browsers, "Edge");
57
- else if (ua.includes("chrome")) increment(browsers, "Chrome");
58
- else if (ua.includes("firefox")) increment(browsers, "Firefox");
59
- else if (ua.includes("safari")) increment(browsers, "Safari");
60
- else if (ua.includes("postman") || ua.includes("curl")) increment(browsers, "API Client");
61
- else increment(browsers, "Other");
62
- if (ua.includes("android")) increment(operatingSystems, "Android");
63
- else if (ua.includes("ios") || ua.includes("iphone") || ua.includes("ipad")) increment(operatingSystems, "iOS");
64
- else if (ua.includes("windows") || ua.includes("win32") || ua.includes("win64")) increment(operatingSystems, "Windows");
65
- else if (ua.includes("mac") || ua.includes("darwin")) increment(operatingSystems, "macOS");
66
- else if (ua.includes("linux")) increment(operatingSystems, "Linux");
67
- else increment(operatingSystems, "Other");
68
- const userKey = getUserKey(session);
69
- if (userKey) uniqueUsers.add(userKey);
70
- if (session?.ipAddress) uniqueIPs.add(session.ipAddress);
71
- const status = sessionStatus.getSessionStatus(session);
72
- if (status === "loggedout") loggedOut++;
73
- else if (!session?.isActive && status === "terminated") terminated++;
74
- const duration = getDurationMinutes(session, now);
75
- if (duration !== null) durations.push(duration);
76
- }
77
- const mobileCount = (devices.Mobile || 0) + (devices.Tablet || 0);
78
- return {
79
- totalSessions: sessions.length,
80
- activeSessions: sessions.filter((session) => session?.isActive && session?.isTrulyActive).length,
81
- todayLogins,
82
- weekLogins,
83
- devices,
84
- browsers,
85
- operatingSystems,
86
- loginHours,
87
- peakHour: loginHours.indexOf(Math.max(...loginHours)),
88
- uniqueUsers: uniqueUsers.size,
89
- uniqueIPs: uniqueIPs.size,
90
- loggedOut,
91
- terminated,
92
- mobileRatio: sessions.length > 0 ? Math.round(mobileCount / sessions.length * 100) : 0,
93
- avgSessionDuration: durations.length > 0 ? Math.floor(durations.reduce((sum, duration) => sum + duration, 0) / durations.length) : 0
94
- };
95
- }
96
- const theme = {
97
- shadows: {
98
- sm: "0 1px 3px 0 rgba(0, 0, 0, 0.1)",
99
- md: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",
100
- lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1)",
101
- xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1)"
102
- },
103
- transitions: {
104
- normal: "300ms cubic-bezier(0.4, 0, 0.2, 1)",
105
- slow: "500ms cubic-bezier(0.4, 0, 0.2, 1)"
106
- },
107
- spacing: { xl: "32px", "2xl": "48px" },
108
- borderRadius: { lg: "12px", xl: "16px" }
109
- };
110
- const fadeIn = styled.keyframes`
111
- from { opacity: 0; transform: translateY(20px); }
112
- to { opacity: 1; transform: translateY(0); }
113
- `;
114
- const slideIn = styled.keyframes`
115
- from { opacity: 0; transform: translateX(-20px); }
116
- to { opacity: 1; transform: translateX(0); }
117
- `;
118
- const shimmer = styled.keyframes`
119
- 0% { background-position: -200% 0; }
120
- 100% { background-position: 200% 0; }
121
- `;
122
- const pulse = styled.keyframes`
123
- 0%, 100% { opacity: 1; }
124
- 50% { opacity: 0.8; }
125
- `;
126
- const float = styled.keyframes`
127
- 0%, 100% { transform: translateY(0px); }
128
- 50% { transform: translateY(-5px); }
129
- `;
130
- const growBar = styled.keyframes`
131
- from { width: 0; }
132
- to { width: var(--bar-width); }
133
- `;
134
- const Container = styled__default.default(designSystem.Box)`
135
- ${styled.css`animation: ${fadeIn} 0.6s;`}
136
- min-height: 100vh;
137
- max-width: 1440px;
138
- margin: 0 auto;
139
- padding: ${theme.spacing.xl} 24px 0;
140
- `;
141
- const Header = styled__default.default(designSystem.Box)`
142
- background: linear-gradient(135deg, ${"var(--colors-primary600, #0284C7)"} 0%, ${"var(--colors-secondary600, #9333EA)"} 100%);
143
- border-radius: ${theme.borderRadius.xl};
144
- padding: ${theme.spacing.xl} ${theme.spacing["2xl"]};
145
- margin-bottom: ${theme.spacing.xl};
146
- position: relative;
147
- overflow: hidden;
148
- box-shadow: ${theme.shadows.xl};
149
-
150
- &::before {
151
- content: '';
152
- position: absolute;
153
- top: 0;
154
- left: -100%;
155
- width: 200%;
156
- height: 100%;
157
- background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
158
- ${styled.css`animation: ${shimmer} 3s infinite;`}
159
- }
160
-
161
- &::after {
162
- content: '';
163
- position: absolute;
164
- top: 0;
165
- right: 0;
166
- width: 100%;
167
- height: 100%;
168
- background-image: radial-gradient(circle at 20% 80%, transparent 50%, rgba(255, 255, 255, 0.1) 50%);
169
- background-size: 15px 15px;
170
- opacity: 0.3;
171
- }
172
- `;
173
- const HeaderContent = styled__default.default(designSystem.Flex)`
174
- position: relative;
175
- z-index: 1;
176
- `;
177
- const Title = styled__default.default(designSystem.Typography)`
178
- color: ${(p) => p.theme.colors.neutral0};
179
- font-size: 2.25rem;
180
- font-weight: 700;
181
- letter-spacing: -0.025em;
182
- text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
183
- display: flex;
184
- align-items: center;
185
- gap: 16px;
186
- margin-bottom: 8px;
187
-
188
- svg {
189
- width: 32px;
190
- height: 32px;
191
- ${styled.css`animation: ${float} 3s ease-in-out infinite;`}
192
- }
193
- `;
194
- const Subtitle = styled__default.default(designSystem.Typography)`
195
- color: rgba(255, 255, 255, 0.95);
196
- font-size: 1rem;
197
- font-weight: 400;
198
- letter-spacing: 0.01em;
199
- `;
200
- const StatsGrid = styled__default.default.div`
201
- display: grid;
202
- grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
203
- gap: 24px;
204
- margin-bottom: 40px;
205
- `;
206
- const StatCard = styled__default.default(designSystem.Box)`
207
- background: ${(p) => p.theme.colors.neutral0};
208
- border-radius: ${theme.borderRadius.lg};
209
- padding: 32px;
210
- position: relative;
211
- overflow: hidden;
212
- transition: all ${theme.transitions.normal};
213
- ${styled.css`animation: ${fadeIn} ${theme.transitions.slow} backwards;`}
214
- animation-delay: ${(props) => props.$delay || "0s"};
215
- box-shadow: ${theme.shadows.sm};
216
- border: 1px solid ${"rgba(128, 128, 128, 0.2)"};
217
- text-align: center;
218
- display: flex;
219
- flex-direction: column;
220
- align-items: center;
221
- justify-content: center;
222
-
223
- &:hover {
224
- transform: translateY(-6px);
225
- box-shadow: ${theme.shadows.xl};
226
- border-color: ${(props) => props.$borderColor || "var(--colors-primary600, #0EA5E9)"};
227
-
228
- .stat-icon {
229
- transform: scale(1.15) rotate(5deg);
230
- }
231
-
232
- .stat-value {
233
- transform: scale(1.08);
234
- color: ${(props) => props.$accentColor || "var(--colors-primary600, #0284C7)"};
235
- }
236
- }
237
- `;
238
- const StatIcon = styled__default.default(designSystem.Box)`
239
- width: 80px;
240
- height: 80px;
241
- border-radius: ${theme.borderRadius.lg};
242
- display: flex;
243
- align-items: center;
244
- justify-content: center;
245
- background: ${(props) => props.$bg || "rgba(2, 132, 199, 0.12)"};
246
- transition: all ${theme.transitions.normal};
247
- margin: 0 auto 24px;
248
- box-shadow: ${theme.shadows.sm};
249
-
250
- svg {
251
- width: 40px;
252
- height: 40px;
253
- color: ${(props) => props.$color || "var(--colors-primary600, #0284C7)"};
254
- }
255
- `;
256
- const StatValue = styled__default.default(designSystem.Typography)`
257
- font-size: 3.5rem;
258
- font-weight: 700;
259
- color: ${"var(--colors-neutral800)"};
260
- line-height: 1;
261
- margin-bottom: 12px;
262
- transition: all ${theme.transitions.normal};
263
- text-align: center;
264
- `;
265
- const StatLabel = styled__default.default(designSystem.Typography)`
266
- font-size: 1rem;
267
- color: ${"var(--colors-neutral600)"};
268
- font-weight: 500;
269
- text-align: center;
270
- `;
271
- const ChartCard = styled__default.default(designSystem.Box)`
272
- background: ${(p) => p.theme.colors.neutral0};
273
- border-radius: ${theme.borderRadius.lg};
274
- padding: 36px;
275
- box-shadow: ${theme.shadows.md};
276
- border: 1px solid ${"rgba(128, 128, 128, 0.2)"};
277
- margin-bottom: 28px;
278
- ${styled.css`animation: ${slideIn} ${theme.transitions.slow};`}
279
- transition: all ${theme.transitions.normal};
280
-
281
- &:hover {
282
- box-shadow: ${theme.shadows.lg};
283
- border-color: ${"rgba(2, 132, 199, 0.2)"};
284
- }
285
- `;
286
- const ChartTitle = styled__default.default(designSystem.Typography)`
287
- font-size: 1.25rem;
288
- font-weight: 700;
289
- color: ${"var(--colors-neutral800)"};
290
- margin-bottom: 24px;
291
- display: flex;
292
- align-items: center;
293
- gap: 12px;
294
-
295
- svg {
296
- width: 24px;
297
- height: 24px;
298
- color: ${"var(--colors-primary600, #0284C7)"};
299
- }
300
- `;
301
- const BarChart = styled__default.default.div`
302
- display: flex;
303
- flex-direction: column;
304
- gap: 20px;
305
- `;
306
- const BarRow = styled__default.default.div`
307
- display: flex;
308
- align-items: center;
309
- gap: 20px;
310
- ${styled.css`animation: ${fadeIn} 0.6s backwards;`}
311
- animation-delay: ${(props) => props.$delay || "0s"};
312
- `;
313
- const BarLabel = styled__default.default(designSystem.Typography)`
314
- min-width: 110px;
315
- font-size: 15px;
316
- font-weight: 600;
317
- color: ${"var(--colors-neutral700)"};
318
- `;
319
- const BarContainer = styled__default.default.div`
320
- flex: 1;
321
- height: 40px;
322
- background: ${"var(--colors-neutral100)"};
323
- border-radius: 10px;
324
- overflow: hidden;
325
- position: relative;
326
- box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
327
- `;
328
- const BarFill = styled__default.default.div`
329
- height: 100%;
330
- background: linear-gradient(90deg, ${(props) => props.$color1 || "var(--colors-primary600, #0EA5E9)"}, ${(props) => props.$color2 || "var(--colors-primary600, #0284C7)"});
331
- border-radius: 10px;
332
- --bar-width: ${(props) => props.$percentage || 0}%;
333
- ${styled.css`animation: ${growBar} 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;`}
334
- animation-delay: ${(props) => props.$delay || "0s"};
335
- display: flex;
336
- align-items: center;
337
- justify-content: flex-end;
338
- padding-right: 16px;
339
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
340
- `;
341
- const BarValue = styled__default.default(designSystem.Typography)`
342
- color: white;
343
- font-size: 15px;
344
- font-weight: 700;
345
- text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
346
- `;
347
- const LoadingOverlay = styled__default.default.div`
348
- display: flex;
349
- flex-direction: column;
350
- align-items: center;
351
- justify-content: center;
352
- min-height: 400px;
353
- gap: 24px;
354
-
355
- .loader-icon {
356
- ${styled.css`animation: ${pulse} 2s ease-in-out infinite;`}
357
- }
358
- `;
359
- const AnalyticsPage = () => {
360
- const { get } = admin.useFetchClient();
361
- const [loading, setLoading] = react.useState(true);
362
- const [analytics, setAnalytics] = react.useState(null);
363
- react.useEffect(() => {
364
- fetchAnalytics();
365
- }, []);
366
- const fetchAnalytics = async () => {
367
- setLoading(true);
368
- try {
369
- const { data } = await get(`/${index.pluginId}/sessions`);
370
- const sessions = data.data || [];
371
- setAnalytics(computeSessionAnalytics(sessions));
372
- } catch (err) {
373
- console.error("[Analytics] Error:", err);
374
- } finally {
375
- setLoading(false);
376
- }
377
- };
378
- if (loading) {
379
- return /* @__PURE__ */ jsxRuntime.jsx(Container, { children: /* @__PURE__ */ jsxRuntime.jsxs(LoadingOverlay, { children: [
380
- /* @__PURE__ */ jsxRuntime.jsx(icons.ChartBubble, { className: "loader-icon", style: { width: "64px", height: "64px", color: "var(--colors-primary600, #0284C7)" } }),
381
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { children: "Loading analytics data..." })
382
- ] }) });
383
- }
384
- const maxDevices = Math.max(...Object.values(analytics?.devices || {}), 1);
385
- const maxBrowsers = Math.max(...Object.values(analytics?.browsers || {}), 1);
386
- Math.max(...Object.values(analytics?.operatingSystems || {}), 1);
387
- Math.max(...analytics?.loginHours || [], 1);
388
- const deviceColors = {
389
- "Desktop": ["var(--colors-primary600, #0EA5E9)", "var(--colors-primary600, #0284C7)"],
390
- "Mobile": ["var(--colors-success600, #22C55E)", "var(--colors-success600, #16A34A)"],
391
- "Tablet": ["var(--colors-warning600, #F59E0B)", "var(--colors-warning600, #D97706)"]
392
- };
393
- const browserColors = {
394
- "Chrome": ["var(--colors-success600, #22C55E)", "var(--colors-success600, #16A34A)"],
395
- "Firefox": ["var(--colors-warning600, #F59E0B)", "var(--colors-warning600, #D97706)"],
396
- "Safari": ["var(--colors-primary600, #0EA5E9)", "var(--colors-primary600, #0284C7)"],
397
- "Edge": ["var(--colors-secondary500, #A855F7)", "var(--colors-secondary600, #9333EA)"],
398
- "API Client": ["var(--colors-neutral600)", "var(--colors-neutral700)"],
399
- "Other": ["var(--colors-neutral500)", "var(--colors-neutral600)"]
400
- };
401
- return /* @__PURE__ */ jsxRuntime.jsxs(Container, { children: [
402
- /* @__PURE__ */ jsxRuntime.jsx(Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(HeaderContent, { direction: "column", alignItems: "flex-start", gap: 2, children: [
403
- /* @__PURE__ */ jsxRuntime.jsxs(Title, { children: [
404
- /* @__PURE__ */ jsxRuntime.jsx(icons.ChartBubble, {}),
405
- " Session Analytics"
406
- ] }),
407
- /* @__PURE__ */ jsxRuntime.jsx(Subtitle, { children: "Comprehensive insights and statistics about user sessions" })
408
- ] }) }),
409
- /* @__PURE__ */ jsxRuntime.jsxs(StatsGrid, { children: [
410
- /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { $delay: "0.1s", $borderColor: "var(--colors-primary600, #0EA5E9)", $accentColor: "var(--colors-primary600, #0284C7)", children: [
411
- /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { className: "stat-icon", $bg: "rgba(2, 132, 199, 0.12)", $color: "var(--colors-primary600, #0284C7)", children: /* @__PURE__ */ jsxRuntime.jsx(icons.ChartBubble, {}) }),
412
- /* @__PURE__ */ jsxRuntime.jsx(StatValue, { className: "stat-value", children: analytics?.totalSessions || 0 }),
413
- /* @__PURE__ */ jsxRuntime.jsx(StatLabel, { children: "Total Sessions" })
414
- ] }),
415
- /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { $delay: "0.2s", $borderColor: "var(--colors-success600, #22C55E)", $accentColor: "var(--colors-success600, #16A34A)", children: [
416
- /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { className: "stat-icon", $bg: "rgba(22, 163, 74, 0.12)", $color: "var(--colors-success600, #16A34A)", children: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}) }),
417
- /* @__PURE__ */ jsxRuntime.jsx(StatValue, { className: "stat-value", children: analytics?.activeSessions || 0 }),
418
- /* @__PURE__ */ jsxRuntime.jsx(StatLabel, { children: "Active Now" })
419
- ] }),
420
- /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { $delay: "0.3s", $borderColor: "var(--colors-warning600, #F59E0B)", $accentColor: "var(--colors-warning600, #D97706)", children: [
421
- /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { className: "stat-icon", $bg: "rgba(234, 179, 8, 0.12)", $color: "var(--colors-warning600, #D97706)", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Clock, {}) }),
422
- /* @__PURE__ */ jsxRuntime.jsx(StatValue, { className: "stat-value", children: analytics?.todayLogins || 0 }),
423
- /* @__PURE__ */ jsxRuntime.jsx(StatLabel, { children: "Today's Logins" })
424
- ] }),
425
- /* @__PURE__ */ jsxRuntime.jsxs(StatCard, { $delay: "0.4s", $borderColor: "var(--colors-secondary500, #A855F7)", $accentColor: "var(--colors-secondary600, #9333EA)", children: [
426
- /* @__PURE__ */ jsxRuntime.jsx(StatIcon, { className: "stat-icon", $bg: "rgba(139, 92, 246, 0.12)", $color: "var(--colors-secondary600, #9333EA)", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Clock, {}) }),
427
- /* @__PURE__ */ jsxRuntime.jsx(StatValue, { className: "stat-value", children: analytics?.weekLogins || 0 }),
428
- /* @__PURE__ */ jsxRuntime.jsx(StatLabel, { children: "This Week" })
429
- ] })
430
- ] }),
431
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 4, wrap: "wrap", style: { marginBottom: "28px" }, children: [
432
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: "450px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(ChartCard, { children: [
433
- /* @__PURE__ */ jsxRuntime.jsxs(ChartTitle, { children: [
434
- /* @__PURE__ */ jsxRuntime.jsx(icons.Monitor, {}),
435
- "Device Distribution"
436
- ] }),
437
- /* @__PURE__ */ jsxRuntime.jsx(BarChart, { children: analytics?.devices && Object.entries(analytics.devices).sort(([, a], [, b]) => b - a).map(([device, count], idx) => /* @__PURE__ */ jsxRuntime.jsxs(BarRow, { $delay: `${0.5 + idx * 0.1}s`, children: [
438
- /* @__PURE__ */ jsxRuntime.jsx(BarLabel, { children: device }),
439
- /* @__PURE__ */ jsxRuntime.jsx(BarContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(
440
- BarFill,
441
- {
442
- $percentage: count / maxDevices * 100,
443
- $color1: deviceColors[device]?.[0] || "var(--colors-neutral500)",
444
- $color2: deviceColors[device]?.[1] || "var(--colors-neutral600)",
445
- $delay: `${0.5 + idx * 0.1}s`,
446
- children: /* @__PURE__ */ jsxRuntime.jsx(BarValue, { children: count })
447
- }
448
- ) })
449
- ] }, device)) })
450
- ] }) }),
451
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: 1, minWidth: "450px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(ChartCard, { children: [
452
- /* @__PURE__ */ jsxRuntime.jsxs(ChartTitle, { children: [
453
- /* @__PURE__ */ jsxRuntime.jsx(icons.Monitor, {}),
454
- "Browser Usage"
455
- ] }),
456
- /* @__PURE__ */ jsxRuntime.jsx(BarChart, { children: analytics?.browsers && Object.entries(analytics.browsers).sort(([, a], [, b]) => b - a).map(([browser, count], idx) => /* @__PURE__ */ jsxRuntime.jsxs(BarRow, { $delay: `${0.5 + idx * 0.1}s`, children: [
457
- /* @__PURE__ */ jsxRuntime.jsx(BarLabel, { children: browser }),
458
- /* @__PURE__ */ jsxRuntime.jsx(BarContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(
459
- BarFill,
460
- {
461
- $percentage: count / maxBrowsers * 100,
462
- $color1: browserColors[browser]?.[0] || "var(--colors-neutral500)",
463
- $color2: browserColors[browser]?.[1] || "var(--colors-neutral600)",
464
- $delay: `${0.5 + idx * 0.1}s`,
465
- children: /* @__PURE__ */ jsxRuntime.jsx(BarValue, { children: count })
466
- }
467
- ) })
468
- ] }, browser)) })
469
- ] }) })
470
- ] }),
471
- /* @__PURE__ */ jsxRuntime.jsxs(ChartCard, { children: [
472
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", justifyContent: "space-between", children: [
473
- /* @__PURE__ */ jsxRuntime.jsxs(ChartTitle, { style: { marginBottom: 0 }, children: [
474
- /* @__PURE__ */ jsxRuntime.jsx(icons.Clock, {}),
475
- "Average Session Duration"
476
- ] }),
477
- /* @__PURE__ */ jsxRuntime.jsxs(
478
- designSystem.Badge,
479
- {
480
- backgroundColor: "primary600",
481
- textColor: "neutral0",
482
- style: {
483
- fontSize: "18px",
484
- fontWeight: "700",
485
- padding: "12px 24px",
486
- boxShadow: theme.shadows.md
487
- },
488
- children: [
489
- analytics?.avgSessionDuration || 0,
490
- " minutes"
491
- ]
492
- }
493
- )
494
- ] }),
495
- analytics?.avgSessionDuration > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, padding: 5, background: "primary50", hasRadius: true, style: { border: `1px solid ${"rgba(2, 132, 199, 0.12)"}` }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "primary700", style: { fontSize: "14px", lineHeight: "1.8", fontWeight: "500" }, children: "ℹ️ Average time between login and last activity across all sessions. Lower values indicate more frequent activity, higher values may indicate idle or abandoned sessions." }) })
496
- ] })
497
- ] });
498
- };
499
- exports.default = AnalyticsPage;