@nivaro/react 0.3.133 → 0.3.134
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/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +13 -5
- package/dist/index.js +861 -860
- package/dist/shared/components/delivery-analytics/DeliveryAnalyticsView.js +1095 -0
- package/dist/shared/components/delivery-analytics/charts.js +157 -0
- package/dist/shared/components/delivery-analytics/drill.js +833 -0
- package/dist/shared/components/delivery-analytics/ui.js +290 -0
- package/dist/shared/components/delivery-analytics/url.js +105 -0
- package/package.json +1 -1
- package/dist/shared/components/notifications/NotificationAnalyticsView.js +0 -292
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useQuery as $ } from "@tanstack/react-query";
|
|
3
|
-
import { BarChart3 as M } from "lucide-react";
|
|
4
|
-
import { useState as f } from "react";
|
|
5
|
-
import { useNivaroClient as S } from "../../context.js";
|
|
6
|
-
import { get as C } from "../../lib/commands.js";
|
|
7
|
-
import { cn as x } from "../../lib/utils.js";
|
|
8
|
-
import { QueryErrorState as L } from "../QueryErrorState.js";
|
|
9
|
-
const c = (l) => `${Math.round(l * 100)}%`, y = (l) => l == null ? "—" : l < 60 ? `${Math.round(l)}m` : l < 1440 ? `${(l / 60).toFixed(1)}h` : `${(l / 1440).toFixed(1)}d`;
|
|
10
|
-
function m({ label: l, value: s, hint: i }) {
|
|
11
|
-
return /* @__PURE__ */ d("div", { className: "rounded-lg border border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card", children: [
|
|
12
|
-
/* @__PURE__ */ e("p", { className: "text-[12px] font-medium text-slate-500 dark:text-muted-foreground", children: l }),
|
|
13
|
-
/* @__PURE__ */ e("p", { className: "mt-1 text-[22px] font-semibold tabular-nums text-slate-900 dark:text-foreground", children: s }),
|
|
14
|
-
i && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: i })
|
|
15
|
-
] });
|
|
16
|
-
}
|
|
17
|
-
function h({ title: l, rows: s, keyLabel: i }) {
|
|
18
|
-
const o = Math.max(1, ...s.map((a) => a.sent));
|
|
19
|
-
return /* @__PURE__ */ d("div", { className: "rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [
|
|
20
|
-
/* @__PURE__ */ e("header", { className: "border-b border-slate-100 px-4 py-2.5 dark:border-border/60", children: /* @__PURE__ */ e("h3", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: l }) }),
|
|
21
|
-
s.length === 0 ? /* @__PURE__ */ e("p", { className: "px-4 py-4 text-[12px] text-slate-500 dark:text-muted-foreground", children: "Nothing in this window." }) : /* @__PURE__ */ d("table", { className: "w-full text-[12px] tabular-nums", children: [
|
|
22
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ d("tr", { className: "text-left text-[11px] text-slate-500 dark:text-muted-foreground", children: [
|
|
23
|
-
/* @__PURE__ */ e("th", { className: "px-4 py-1.5 font-semibold", children: i }),
|
|
24
|
-
/* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right font-semibold", children: "Sent" }),
|
|
25
|
-
/* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right font-semibold", children: "Read" }),
|
|
26
|
-
/* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right font-semibold", children: "Time to read" }),
|
|
27
|
-
/* @__PURE__ */ e(
|
|
28
|
-
"th",
|
|
29
|
-
{
|
|
30
|
-
className: "px-2 py-1.5 text-right font-semibold",
|
|
31
|
-
"data-tip": "Share of record notifications the recipient acted on (transition, comment or task) within the window",
|
|
32
|
-
children: "Acted"
|
|
33
|
-
}
|
|
34
|
-
),
|
|
35
|
-
/* @__PURE__ */ e(
|
|
36
|
-
"th",
|
|
37
|
-
{
|
|
38
|
-
className: "px-2 py-1.5 text-right font-semibold",
|
|
39
|
-
"data-tip": "Opened but never acted on within the window",
|
|
40
|
-
children: "Read, no action"
|
|
41
|
-
}
|
|
42
|
-
)
|
|
43
|
-
] }) }),
|
|
44
|
-
/* @__PURE__ */ e("tbody", { children: s.map((a) => /* @__PURE__ */ d("tr", { className: "border-t border-slate-100 dark:border-border", children: [
|
|
45
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-1.5", children: /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
|
|
46
|
-
/* @__PURE__ */ e("span", { className: "min-w-0 truncate text-slate-700 dark:text-foreground", children: a.label ?? a.key.replace(/_/g, " ") }),
|
|
47
|
-
/* @__PURE__ */ e(
|
|
48
|
-
"span",
|
|
49
|
-
{
|
|
50
|
-
className: "h-1.5 rounded-full bg-nvr-cyan/40",
|
|
51
|
-
style: { width: `${Math.max(4, a.sent / o * 80)}px` }
|
|
52
|
-
}
|
|
53
|
-
)
|
|
54
|
-
] }) }),
|
|
55
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right text-slate-700 dark:text-foreground", children: a.sent }),
|
|
56
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right", children: /* @__PURE__ */ e(
|
|
57
|
-
"span",
|
|
58
|
-
{
|
|
59
|
-
className: x(
|
|
60
|
-
a.read_rate >= 0.6 ? "text-emerald-700 dark:text-emerald-400" : a.read_rate >= 0.3 ? "text-slate-700 dark:text-foreground" : "text-amber-700 dark:text-amber-400"
|
|
61
|
-
),
|
|
62
|
-
children: c(a.read_rate)
|
|
63
|
-
}
|
|
64
|
-
) }),
|
|
65
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right text-slate-500", children: y(a.median_minutes_to_read) }),
|
|
66
|
-
/* @__PURE__ */ e(
|
|
67
|
-
"td",
|
|
68
|
-
{
|
|
69
|
-
className: "px-2 py-1.5 text-right text-slate-700 dark:text-foreground",
|
|
70
|
-
"data-tip": a.acted_eligible ? `${a.acted} of ${a.acted_eligible} record notifications` : "",
|
|
71
|
-
children: a.acted_rate == null ? "—" : c(a.acted_rate)
|
|
72
|
-
}
|
|
73
|
-
),
|
|
74
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right", children: a.read_ignored_rate == null ? /* @__PURE__ */ e("span", { className: "text-slate-400", children: "—" }) : /* @__PURE__ */ e(
|
|
75
|
-
"span",
|
|
76
|
-
{
|
|
77
|
-
className: a.read_ignored_rate >= 0.5 ? "text-amber-700 dark:text-amber-400" : "text-slate-500",
|
|
78
|
-
children: c(a.read_ignored_rate)
|
|
79
|
-
}
|
|
80
|
-
) })
|
|
81
|
-
] }, a.key)) })
|
|
82
|
-
] })
|
|
83
|
-
] });
|
|
84
|
-
}
|
|
85
|
-
function p({ title: l, counts: s }) {
|
|
86
|
-
const i = Object.entries(s).filter(([, a]) => a > 0), o = i.reduce((a, [, n]) => a + n, 0);
|
|
87
|
-
return /* @__PURE__ */ d("div", { className: "rounded-lg border border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card", children: [
|
|
88
|
-
/* @__PURE__ */ e("p", { className: "text-[12px] font-medium text-slate-500 dark:text-muted-foreground", children: l }),
|
|
89
|
-
o === 0 ? /* @__PURE__ */ e("p", { className: "mt-1 text-[12px] text-slate-500 dark:text-muted-foreground", children: "No tracked deliveries yet." }) : /* @__PURE__ */ e("ul", { className: "mt-1 space-y-0.5 text-[12px]", children: i.sort((a, n) => n[1] - a[1]).map(([a, n]) => /* @__PURE__ */ d("li", { className: "flex items-center justify-between", children: [
|
|
90
|
-
/* @__PURE__ */ e("span", { className: "text-slate-600 dark:text-muted-foreground", children: a.replace(/_/g, " ") }),
|
|
91
|
-
/* @__PURE__ */ d("span", { className: "tabular-nums text-slate-800 dark:text-foreground", children: [
|
|
92
|
-
n,
|
|
93
|
-
/* @__PURE__ */ e("span", { className: "ml-1 text-[10.5px] text-slate-500 dark:text-muted-foreground", children: c(n / o) })
|
|
94
|
-
] })
|
|
95
|
-
] }, a)) })
|
|
96
|
-
] });
|
|
97
|
-
}
|
|
98
|
-
function D({
|
|
99
|
-
className: l,
|
|
100
|
-
compactHeader: s = !1
|
|
101
|
-
}) {
|
|
102
|
-
var g;
|
|
103
|
-
const i = S(), [o, a] = f(30), [n, N] = f(24), { data: r, isLoading: k, isError: v, error: w, refetch: _ } = $({
|
|
104
|
-
queryKey: ["notification-analytics", o, n],
|
|
105
|
-
queryFn: () => i.request(
|
|
106
|
-
C("/notifications/analytics", { days: o, acted_hours: n })
|
|
107
|
-
).then((t) => t.data)
|
|
108
|
-
}), u = (r == null ? void 0 : r.series) ?? [], b = Math.max(1, ...u.map((t) => t.sent));
|
|
109
|
-
return /* @__PURE__ */ d("div", { className: x("flex flex-1 min-h-0 flex-col", l), "data-nvr-notification-analytics": !0, children: [
|
|
110
|
-
/* @__PURE__ */ e(
|
|
111
|
-
"header",
|
|
112
|
-
{
|
|
113
|
-
className: x(
|
|
114
|
-
s ? "flex min-h-16 shrink-0 flex-col justify-center border-b border-slate-200 bg-white px-4 py-3 sm:px-6 dark:border-border dark:bg-card" : "shrink-0 border-b border-slate-200 bg-white px-6 py-4 dark:border-border dark:bg-card"
|
|
115
|
-
),
|
|
116
|
-
children: /* @__PURE__ */ d("div", { className: "flex items-center gap-2.5", children: [
|
|
117
|
-
!s && /* @__PURE__ */ e(M, { className: "h-5 w-5 text-muted-foreground" }),
|
|
118
|
-
/* @__PURE__ */ d("div", { children: [
|
|
119
|
-
!s && /* @__PURE__ */ e("h1", { className: "text-[17px] font-semibold text-slate-900 dark:text-foreground", children: "Notification analytics" }),
|
|
120
|
-
/* @__PURE__ */ e(
|
|
121
|
-
"p",
|
|
122
|
-
{
|
|
123
|
-
className: x(
|
|
124
|
-
s ? "m-0 max-w-[72ch] text-[12px] leading-relaxed text-slate-600 dark:text-muted-foreground" : "mt-0.5 text-[12.5px] text-slate-500 dark:text-muted-foreground"
|
|
125
|
-
),
|
|
126
|
-
children: "Where the noise comes from and whether anyone reads it — by category, sender, collection and channel, plus what people have muted."
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
] }),
|
|
130
|
-
/* @__PURE__ */ e("span", { className: "flex-1" }),
|
|
131
|
-
/* @__PURE__ */ e("div", { className: "inline-flex rounded-md border border-slate-200 p-0.5 dark:border-border", children: [7, 30, 90].map((t) => /* @__PURE__ */ d(
|
|
132
|
-
"button",
|
|
133
|
-
{
|
|
134
|
-
type: "button",
|
|
135
|
-
onClick: () => a(t),
|
|
136
|
-
"aria-pressed": o === t,
|
|
137
|
-
className: x(
|
|
138
|
-
"rounded px-2.5 py-1 text-[12px] font-medium",
|
|
139
|
-
o === t ? "bg-slate-900 text-white dark:bg-nvr-cyan dark:text-[#172940]" : "text-slate-600 hover:bg-slate-100 dark:text-muted-foreground dark:hover:bg-muted"
|
|
140
|
-
),
|
|
141
|
-
children: [
|
|
142
|
-
t,
|
|
143
|
-
"d"
|
|
144
|
-
]
|
|
145
|
-
},
|
|
146
|
-
t
|
|
147
|
-
)) }),
|
|
148
|
-
/* @__PURE__ */ d(
|
|
149
|
-
"div",
|
|
150
|
-
{
|
|
151
|
-
className: "inline-flex items-center rounded-md border border-slate-200 p-0.5 dark:border-border",
|
|
152
|
-
"data-tip": "How long after a notification an action still counts as acted",
|
|
153
|
-
children: [
|
|
154
|
-
/* @__PURE__ */ e("span", { className: "px-2 text-[12px] text-slate-500 dark:text-muted-foreground", children: "Acted within" }),
|
|
155
|
-
[4, 24, 72].map((t) => /* @__PURE__ */ d(
|
|
156
|
-
"button",
|
|
157
|
-
{
|
|
158
|
-
type: "button",
|
|
159
|
-
onClick: () => N(t),
|
|
160
|
-
"aria-pressed": n === t,
|
|
161
|
-
"aria-label": `Acted within ${t} hours`,
|
|
162
|
-
className: x(
|
|
163
|
-
"rounded px-2.5 py-1 text-[12px] font-medium",
|
|
164
|
-
n === t ? "bg-slate-900 text-white dark:bg-nvr-cyan dark:text-[#172940]" : "text-slate-600 hover:bg-slate-100 dark:text-muted-foreground dark:hover:bg-muted"
|
|
165
|
-
),
|
|
166
|
-
children: [
|
|
167
|
-
t,
|
|
168
|
-
"h"
|
|
169
|
-
]
|
|
170
|
-
},
|
|
171
|
-
t
|
|
172
|
-
))
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
)
|
|
176
|
-
] })
|
|
177
|
-
}
|
|
178
|
-
),
|
|
179
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto bg-slate-50 p-6 dark:bg-background", children: v && !r ? /* @__PURE__ */ e(
|
|
180
|
-
L,
|
|
181
|
-
{
|
|
182
|
-
error: w,
|
|
183
|
-
what: "notification analytics",
|
|
184
|
-
onRetry: () => void _()
|
|
185
|
-
}
|
|
186
|
-
) : k || !r ? /* @__PURE__ */ e("p", { className: "text-[13px] text-slate-500 dark:text-muted-foreground", children: "Loading…" }) : /* @__PURE__ */ d("div", { className: "space-y-5", children: [
|
|
187
|
-
/* @__PURE__ */ d("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-5", children: [
|
|
188
|
-
/* @__PURE__ */ e(m, { label: "Sent", value: String(r.total), hint: `last ${r.days} days` }),
|
|
189
|
-
/* @__PURE__ */ e(m, { label: "Read rate", value: c(r.read_rate), hint: `${r.read} read` }),
|
|
190
|
-
/* @__PURE__ */ e(
|
|
191
|
-
m,
|
|
192
|
-
{
|
|
193
|
-
label: "Median time to read",
|
|
194
|
-
value: y(r.median_minutes_to_read),
|
|
195
|
-
hint: "rows read since read tracking began"
|
|
196
|
-
}
|
|
197
|
-
),
|
|
198
|
-
/* @__PURE__ */ e(
|
|
199
|
-
m,
|
|
200
|
-
{
|
|
201
|
-
label: `Acted within ${n}h`,
|
|
202
|
-
value: ((g = r.acted) == null ? void 0 : g.acted_rate) == null ? "—" : c(r.acted.acted_rate),
|
|
203
|
-
hint: r.acted ? `${r.acted.acted} of ${r.acted.acted_eligible} record notifications` : void 0
|
|
204
|
-
}
|
|
205
|
-
),
|
|
206
|
-
/* @__PURE__ */ e(
|
|
207
|
-
m,
|
|
208
|
-
{
|
|
209
|
-
label: "Muted records",
|
|
210
|
-
value: String(r.mutes.total),
|
|
211
|
-
hint: `${r.mutes.muting_users} of ${r.mutes.active_users} active users mute something`
|
|
212
|
-
}
|
|
213
|
-
)
|
|
214
|
-
] }),
|
|
215
|
-
r.truncated && /* @__PURE__ */ e("p", { className: "text-[11.5px] text-amber-700 dark:text-amber-400", children: "Window capped at 20,000 rows — figures cover the newest 20,000." }),
|
|
216
|
-
/* @__PURE__ */ d("div", { className: "rounded-lg border border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card", children: [
|
|
217
|
-
/* @__PURE__ */ e("p", { className: "text-[12px] font-medium text-slate-500 dark:text-muted-foreground", children: "Per day · sent (bar) and read (filled)" }),
|
|
218
|
-
/* @__PURE__ */ d("div", { className: "mt-2 flex h-24 items-end gap-px", children: [
|
|
219
|
-
u.map((t) => /* @__PURE__ */ d(
|
|
220
|
-
"div",
|
|
221
|
-
{
|
|
222
|
-
className: "relative flex-1",
|
|
223
|
-
"data-tip": `${t.day}: ${t.sent} sent, ${t.read} read`,
|
|
224
|
-
title: `${t.day}: ${t.sent} sent, ${t.read} read`,
|
|
225
|
-
children: [
|
|
226
|
-
/* @__PURE__ */ e(
|
|
227
|
-
"div",
|
|
228
|
-
{
|
|
229
|
-
className: "w-full rounded-t-sm bg-nvr-cyan/25",
|
|
230
|
-
style: { height: `${t.sent / b * 96}px` }
|
|
231
|
-
}
|
|
232
|
-
),
|
|
233
|
-
/* @__PURE__ */ e(
|
|
234
|
-
"div",
|
|
235
|
-
{
|
|
236
|
-
className: "absolute bottom-0 w-full rounded-t-sm bg-nvr-cyan",
|
|
237
|
-
style: { height: `${t.read / b * 96}px` }
|
|
238
|
-
}
|
|
239
|
-
)
|
|
240
|
-
]
|
|
241
|
-
},
|
|
242
|
-
t.day
|
|
243
|
-
)),
|
|
244
|
-
u.length === 0 && /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: "No notifications in this window." })
|
|
245
|
-
] })
|
|
246
|
-
] }),
|
|
247
|
-
/* @__PURE__ */ d("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
|
|
248
|
-
/* @__PURE__ */ e(h, { title: "By category", rows: r.by_category, keyLabel: "Category" }),
|
|
249
|
-
/* @__PURE__ */ e(h, { title: "By sender", rows: r.by_sender, keyLabel: "Sender" }),
|
|
250
|
-
/* @__PURE__ */ e(h, { title: "By lane", rows: r.by_lane, keyLabel: "Lane" }),
|
|
251
|
-
/* @__PURE__ */ e(h, { title: "By kind", rows: r.by_kind, keyLabel: "Kind" }),
|
|
252
|
-
/* @__PURE__ */ e(h, { title: "By collection", rows: r.by_collection, keyLabel: "Collection" }),
|
|
253
|
-
/* @__PURE__ */ d("div", { className: "rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [
|
|
254
|
-
/* @__PURE__ */ d("header", { className: "border-b border-slate-100 px-4 py-2.5 dark:border-border/60", children: [
|
|
255
|
-
/* @__PURE__ */ e("h3", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "Most muted sources" }),
|
|
256
|
-
/* @__PURE__ */ e("p", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: "Records people asked to stop hearing about, against what that collection sent." })
|
|
257
|
-
] }),
|
|
258
|
-
r.mutes.top.length === 0 ? /* @__PURE__ */ e("p", { className: "px-4 py-4 text-[12px] text-slate-500 dark:text-muted-foreground", children: "Nobody has muted a record." }) : /* @__PURE__ */ d("table", { className: "w-full text-[12px] tabular-nums", children: [
|
|
259
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ d("tr", { className: "text-left text-[11px] text-slate-500 dark:text-muted-foreground", children: [
|
|
260
|
-
/* @__PURE__ */ e("th", { className: "px-4 py-1.5 font-semibold", children: "Collection" }),
|
|
261
|
-
/* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right font-semibold", children: "Mutes" }),
|
|
262
|
-
/* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right font-semibold", children: "Sent" }),
|
|
263
|
-
/* @__PURE__ */ e("th", { className: "px-2 py-1.5 text-right font-semibold", children: "Mute rate" })
|
|
264
|
-
] }) }),
|
|
265
|
-
/* @__PURE__ */ e("tbody", { children: r.mutes.top.map((t) => /* @__PURE__ */ d(
|
|
266
|
-
"tr",
|
|
267
|
-
{
|
|
268
|
-
className: "border-t border-slate-100 dark:border-border",
|
|
269
|
-
children: [
|
|
270
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-1.5 text-slate-700 dark:text-foreground", children: t.collection.replace(/_/g, " ") }),
|
|
271
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right", children: t.mutes }),
|
|
272
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right text-slate-500", children: t.sent }),
|
|
273
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1.5 text-right text-amber-700 dark:text-amber-400", children: t.sent ? c(t.mute_rate) : "—" })
|
|
274
|
-
]
|
|
275
|
-
},
|
|
276
|
-
t.collection
|
|
277
|
-
)) })
|
|
278
|
-
] })
|
|
279
|
-
] })
|
|
280
|
-
] }),
|
|
281
|
-
/* @__PURE__ */ d("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-4", children: [
|
|
282
|
-
/* @__PURE__ */ e(p, { title: "In-app", counts: r.channels.inapp }),
|
|
283
|
-
/* @__PURE__ */ e(p, { title: "Push", counts: r.channels.push }),
|
|
284
|
-
/* @__PURE__ */ e(p, { title: "Email", counts: r.channels.email }),
|
|
285
|
-
/* @__PURE__ */ e(p, { title: "SMS", counts: r.channels.sms })
|
|
286
|
-
] })
|
|
287
|
-
] }) })
|
|
288
|
-
] });
|
|
289
|
-
}
|
|
290
|
-
export {
|
|
291
|
-
D as NotificationAnalyticsView
|
|
292
|
-
};
|