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