@oneclick.dev/cms-core-modules 0.0.77 → 0.0.78
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/AppointmentDetailsCard-BfBwWxTU.js +1 -0
- package/dist/{AppointmentDetailsCard-i4Ky8WnK.mjs → AppointmentDetailsCard-SMNXi117.mjs} +43 -42
- package/dist/AppointmentListTable-Dk-CnNR6.js +1 -0
- package/dist/{AppointmentListTable-G5dIeCYj.mjs → AppointmentListTable-vMSMt0M5.mjs} +24 -23
- package/dist/{CountryBreakdownCard-Dc_vZ9dJ.mjs → CountryBreakdownCard-B_VhBsm8.mjs} +27 -26
- package/dist/CountryBreakdownCard-Ghg0Wz-h.js +1 -0
- package/dist/{DeviceBreakdownCard-BJcQNo8a.mjs → DeviceBreakdownCard-CQR65Zr_.mjs} +50 -49
- package/dist/DeviceBreakdownCard-Cpcj75Rv.js +1 -0
- package/dist/PeakHoursCard-CFIg8dys.js +1 -0
- package/dist/{PeakHoursCard-hV8PdGsf.mjs → PeakHoursCard-_1JS0tpZ.mjs} +51 -50
- package/dist/{ProductDetailsCard-CJBkZSER.mjs → ProductDetailsCard-C5gqBJag.mjs} +20 -19
- package/dist/ProductDetailsCard-Ce11f_9r.js +1 -0
- package/dist/RealtimeCard-CatAzdxv.js +1 -0
- package/dist/{RealtimeCard-CRJHS64l.mjs → RealtimeCard-CtX6Yyk-.mjs} +33 -32
- package/dist/SearchTermsCard-BPAdRL-r.js +1 -0
- package/dist/{SearchTermsCard-Dwa-P7My.mjs → SearchTermsCard-DzSu9jzo.mjs} +38 -37
- package/dist/TopPagesCard-BA9Are_Z.js +1 -0
- package/dist/{TopPagesCard-Dv52to_J.mjs → TopPagesCard-D7lH_QYV.mjs} +27 -26
- package/dist/TrafficSourcesCard-DV13ZOBq.js +1 -0
- package/dist/{TrafficSourcesCard-CMhcj2k2.mjs → TrafficSourcesCard-Fng3fVh7.mjs} +53 -52
- package/dist/VisitorStatsCard-CAzAZtKD.js +1 -0
- package/dist/{VisitorStatsCard-BHn4oSnt.mjs → VisitorStatsCard-CuXXnMBc.mjs} +22 -21
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +11 -11
- package/package.json +3 -2
- package/dist/AppointmentDetailsCard-CtK0Cj_O.js +0 -1
- package/dist/AppointmentListTable-CQ3uXfa8.js +0 -1
- package/dist/CountryBreakdownCard-BUfJ-umQ.js +0 -1
- package/dist/DeviceBreakdownCard-CsoK6JUO.js +0 -1
- package/dist/PeakHoursCard-BNl_U1r_.js +0 -1
- package/dist/ProductDetailsCard-BwktdlIf.js +0 -1
- package/dist/RealtimeCard-CxtqQHee.js +0 -1
- package/dist/SearchTermsCard-DGRbo5ZP.js +0 -1
- package/dist/TopPagesCard-pZ-nAsaI.js +0 -1
- package/dist/TrafficSourcesCard-CBOPV1J1.js +0 -1
- package/dist/VisitorStatsCard-tApB_7v8.js +0 -1
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { defineComponent as O, computed as _, ref as
|
|
1
|
+
import { defineComponent as O, computed as _, ref as f, onMounted as H, resolveComponent as J, openBlock as u, createElementBlock as m, unref as s, createVNode as l, createElementVNode as o, toDisplayString as i, Fragment as C, renderList as W, normalizeStyle as X, createTextVNode as g, createCommentVNode as Y, withCtx as Z } from "vue";
|
|
2
2
|
import { Loader2 as ee, Search as z, MousePointerClick as A, Eye as se, TrendingUp as N, Hash as te, Users as oe, ExternalLink as ne } from "lucide-vue-next";
|
|
3
|
-
|
|
3
|
+
import { useRoute as ae, useModuleApi as re } from "@oneclick.dev/cms-kit";
|
|
4
|
+
const ie = { class: "w-full" }, le = {
|
|
4
5
|
key: 0,
|
|
5
6
|
class: "flex items-center gap-2 py-3"
|
|
6
|
-
},
|
|
7
|
+
}, ce = {
|
|
7
8
|
key: 1,
|
|
8
9
|
class: "text-xs text-destructive py-2"
|
|
9
|
-
},
|
|
10
|
+
}, de = {
|
|
10
11
|
key: 2,
|
|
11
12
|
class: "rounded-xl border bg-background p-4 text-center space-y-2"
|
|
12
|
-
},
|
|
13
|
+
}, ue = {
|
|
13
14
|
key: 3,
|
|
14
15
|
class: "rounded-xl border bg-background overflow-hidden"
|
|
15
|
-
},
|
|
16
|
+
}, me = { class: "px-3 py-2 border-b bg-muted/40 flex items-center justify-between" }, ge = { class: "flex items-center gap-2" }, pe = { class: "text-xs font-medium" }, fe = { class: "text-[10px] text-muted-foreground" }, he = { class: "divide-y" }, xe = { class: "flex items-center gap-2 mb-1.5" }, _e = { class: "text-[10px] font-medium text-muted-foreground w-5 text-right shrink-0" }, ve = { class: "text-xs font-medium truncate flex-1" }, ye = { class: "ml-7 space-y-1.5" }, be = { class: "h-1.5 rounded-full bg-muted overflow-hidden" }, ke = {
|
|
16
17
|
key: 0,
|
|
17
18
|
class: "flex items-center gap-3 text-[10px] text-muted-foreground"
|
|
18
|
-
},
|
|
19
|
+
}, Se = { class: "flex items-center gap-1" }, Te = { class: "flex items-center gap-1" }, $e = { class: "flex items-center gap-1" }, we = { class: "flex items-center gap-1" }, Le = {
|
|
19
20
|
key: 1,
|
|
20
21
|
class: "flex items-center gap-3 text-[10px] text-muted-foreground"
|
|
21
|
-
},
|
|
22
|
+
}, Ce = { class: "flex items-center gap-1" }, ze = { class: "flex items-center gap-1" }, Ae = { class: "flex items-center gap-1" }, Ne = { class: "px-3 py-2 border-t bg-muted/20 flex items-center justify-between" }, De = { class: "text-[10px] text-muted-foreground" }, Re = /* @__PURE__ */ O({
|
|
22
23
|
__name: "SearchTermsCard",
|
|
23
24
|
props: {
|
|
24
25
|
toolName: {},
|
|
@@ -30,7 +31,7 @@ const ae = { class: "w-full" }, re = {
|
|
|
30
31
|
},
|
|
31
32
|
emits: ["submit"],
|
|
32
33
|
setup(T, { emit: D }) {
|
|
33
|
-
const p = T, F = D, P =
|
|
34
|
+
const p = T, F = D, P = ae(), M = _(() => P.params.slug), R = re(p.instanceId), v = f(!0), h = f(null), n = f([]), $ = f(0), y = f(null), x = f("google_ads"), U = (e) => e.label || e.query || e.sessionGoogleAdsQuery || e.landingPagePlusQueryString || "—";
|
|
34
35
|
function j() {
|
|
35
36
|
const e = p.resolvedArgs?._cachedData;
|
|
36
37
|
return e ? (x.value = e.source || "google_ads", e.source === "search_console" ? n.value = (e.searchTerms || []).map((t) => ({
|
|
@@ -48,7 +49,7 @@ const ae = { class: "w-full" }, re = {
|
|
|
48
49
|
}
|
|
49
50
|
async function E() {
|
|
50
51
|
const { startDate: e, endDate: t } = p.resolvedArgs || {};
|
|
51
|
-
v.value = !0,
|
|
52
|
+
v.value = !0, h.value = null;
|
|
52
53
|
try {
|
|
53
54
|
const c = new URLSearchParams();
|
|
54
55
|
e && c.set("startDate", e), t && c.set("endDate", t);
|
|
@@ -89,7 +90,7 @@ const ae = { class: "w-full" }, re = {
|
|
|
89
90
|
suggestion: K()
|
|
90
91
|
});
|
|
91
92
|
} catch (c) {
|
|
92
|
-
|
|
93
|
+
h.value = c?.data?.statusMessage || c?.message || "Failed to load search data", w(`Error loading search data: ${h.value}`);
|
|
93
94
|
} finally {
|
|
94
95
|
v.value = !1;
|
|
95
96
|
}
|
|
@@ -108,64 +109,64 @@ const ae = { class: "w-full" }, re = {
|
|
|
108
109
|
});
|
|
109
110
|
return (e, t) => {
|
|
110
111
|
const c = J("NuxtLink");
|
|
111
|
-
return u(), m("div",
|
|
112
|
-
s(v) ? (u(), m("div",
|
|
112
|
+
return u(), m("div", ie, [
|
|
113
|
+
s(v) ? (u(), m("div", le, [
|
|
113
114
|
l(s(ee), { class: "size-4 animate-spin text-muted-foreground" }),
|
|
114
115
|
t[0] || (t[0] = o("span", { class: "text-xs text-muted-foreground" }, "Loading search data…", -1))
|
|
115
|
-
])) : s(
|
|
116
|
+
])) : s(h) ? (u(), m("div", ce, i(s(h)), 1)) : s(n).length === 0 ? (u(), m("div", de, [
|
|
116
117
|
l(s(z), { class: "size-8 text-muted-foreground mx-auto" }),
|
|
117
118
|
t[1] || (t[1] = o("p", { class: "text-sm text-muted-foreground" }, "No search data found for this period.", -1))
|
|
118
|
-
])) : (u(), m("div",
|
|
119
|
-
o("div",
|
|
120
|
-
o("div",
|
|
119
|
+
])) : (u(), m("div", ue, [
|
|
120
|
+
o("div", me, [
|
|
121
|
+
o("div", ge, [
|
|
121
122
|
l(s(z), { class: "size-3.5 text-primary" }),
|
|
122
|
-
o("span",
|
|
123
|
+
o("span", pe, i(s(Q)), 1)
|
|
123
124
|
]),
|
|
124
|
-
o("span",
|
|
125
|
+
o("span", fe, i(s(q)), 1)
|
|
125
126
|
]),
|
|
126
|
-
o("div",
|
|
127
|
+
o("div", he, [
|
|
127
128
|
(u(!0), m(C, null, W(s(n), (a, d) => (u(), m("div", {
|
|
128
129
|
key: d,
|
|
129
130
|
class: "px-3 py-2.5 hover:bg-muted/30 transition-colors"
|
|
130
131
|
}, [
|
|
131
|
-
o("div",
|
|
132
|
-
o("span",
|
|
133
|
-
o("span",
|
|
132
|
+
o("div", xe, [
|
|
133
|
+
o("span", _e, i(d + 1) + ".", 1),
|
|
134
|
+
o("span", ve, i(U(a)), 1)
|
|
134
135
|
]),
|
|
135
|
-
o("div",
|
|
136
|
-
o("div",
|
|
136
|
+
o("div", ye, [
|
|
137
|
+
o("div", be, [
|
|
137
138
|
o("div", {
|
|
138
139
|
class: "h-full rounded-full bg-amber-500/70 transition-all",
|
|
139
140
|
style: X({ width: `${((s(S) ? a.clicks : a.sessions) || 0) / s(I) * 100}%` })
|
|
140
141
|
}, null, 4)
|
|
141
142
|
]),
|
|
142
|
-
s(S) ? (u(), m("div",
|
|
143
|
-
o("span",
|
|
143
|
+
s(S) ? (u(), m("div", ke, [
|
|
144
|
+
o("span", Se, [
|
|
144
145
|
l(s(A), { class: "size-2.5" }),
|
|
145
146
|
g(" " + i(b(a.clicks)) + " clicks ", 1)
|
|
146
147
|
]),
|
|
147
|
-
o("span",
|
|
148
|
+
o("span", Te, [
|
|
148
149
|
l(s(se), { class: "size-2.5" }),
|
|
149
150
|
g(" " + i(b(a.impressions)) + " impr. ", 1)
|
|
150
151
|
]),
|
|
151
|
-
o("span",
|
|
152
|
+
o("span", $e, [
|
|
152
153
|
l(s(N), { class: "size-2.5" }),
|
|
153
154
|
g(" " + i(L(a.ctr)) + " CTR ", 1)
|
|
154
155
|
]),
|
|
155
|
-
o("span",
|
|
156
|
+
o("span", we, [
|
|
156
157
|
l(s(te), { class: "size-2.5" }),
|
|
157
158
|
g(" pos " + i(V(a.position)), 1)
|
|
158
159
|
])
|
|
159
|
-
])) : (u(), m("div",
|
|
160
|
-
o("span",
|
|
160
|
+
])) : (u(), m("div", Le, [
|
|
161
|
+
o("span", Ce, [
|
|
161
162
|
l(s(A), { class: "size-2.5" }),
|
|
162
163
|
g(" " + i(b(a.sessions)) + " sessions ", 1)
|
|
163
164
|
]),
|
|
164
|
-
o("span",
|
|
165
|
+
o("span", ze, [
|
|
165
166
|
l(s(oe), { class: "size-2.5" }),
|
|
166
167
|
g(" " + i(b(a.totalUsers)) + " users ", 1)
|
|
167
168
|
]),
|
|
168
|
-
o("span",
|
|
169
|
+
o("span", Ae, [
|
|
169
170
|
l(s(N), { class: "size-2.5" }),
|
|
170
171
|
g(" " + i(L(a.engagementRate)) + " engaged ", 1)
|
|
171
172
|
])
|
|
@@ -173,8 +174,8 @@ const ae = { class: "w-full" }, re = {
|
|
|
173
174
|
])
|
|
174
175
|
]))), 128))
|
|
175
176
|
]),
|
|
176
|
-
o("div",
|
|
177
|
-
o("span",
|
|
177
|
+
o("div", Ne, [
|
|
178
|
+
o("span", De, [
|
|
178
179
|
g(i(s(n).length) + " result" + i(s(n).length === 1 ? "" : "s") + " ", 1),
|
|
179
180
|
s(y) ? (u(), m(C, { key: 0 }, [
|
|
180
181
|
g(" · fetched " + i(G(s(y))), 1)
|
|
@@ -197,5 +198,5 @@ const ae = { class: "w-full" }, re = {
|
|
|
197
198
|
}
|
|
198
199
|
});
|
|
199
200
|
export {
|
|
200
|
-
|
|
201
|
+
Re as default
|
|
201
202
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),c=require("lucide-vue-next"),h=require("@oneclick.dev/cms-kit"),B={class:"w-full"},T={key:0,class:"flex items-center gap-2 py-3"},L={key:1,class:"text-xs text-destructive py-2"},$={key:2,class:"rounded-xl border bg-background p-4 text-center"},A={key:3,class:"rounded-xl border bg-background overflow-hidden"},M={class:"px-3 py-2 border-b bg-muted/40 flex items-center justify-between"},C={class:"flex items-center gap-2"},z={class:"text-[10px] text-muted-foreground"},F={class:"divide-y"},I={class:"flex items-center gap-2 mb-1.5"},j={class:"text-[10px] font-medium text-muted-foreground w-5 text-right shrink-0"},U=["title"],q={class:"ml-7 space-y-1.5"},O={class:"h-1.5 rounded-full bg-muted overflow-hidden"},R={class:"flex items-center gap-3 text-[10px] text-muted-foreground"},K={class:"flex items-center gap-1"},G={class:"flex items-center gap-1"},H={class:"flex items-center gap-1"},J={class:"px-3 py-2 border-t bg-muted/20 flex items-center justify-between"},Q={class:"text-[10px] text-muted-foreground"},W=e.defineComponent({__name:"TopPagesCard",props:{toolName:{},instanceId:{},instanceName:{},moduleType:{},resolvedArgs:{},status:{}},emits:["submit"],setup(f,{emit:y}){const l=f,V=y,N=h.useRoute(),_=e.computed(()=>N.params.slug),k=h.useModuleApi(l.instanceId),d=e.ref(!0),i=e.ref(null),r=e.ref([]),u=e.ref(0),m=e.ref(null);function E(){const t=l.resolvedArgs?._cachedData;return t?(r.value=t.pages?.map(s=>({pagePath:s.page,screenPageViews:s.views,totalUsers:s.users,averageSessionDuration:b(s.avgDuration)}))||[],u.value=t.totalPagesTracked||r.value.length,m.value=l.resolvedArgs._fetchedAt||null,d.value=!1,!0):!1}function b(t){if(!t)return 0;const s=t.match(/(\d+)m/),n=t.match(/(\d+)s/);return(s?parseInt(s[1])*60:0)+(n?parseInt(n[1]):0)}async function D(){const{startDate:t,endDate:s,limit:n}=l.resolvedArgs||{};d.value=!0,i.value=null;try{const o=new URLSearchParams;t&&o.set("startDate",t),s&&o.set("endDate",s),n&&o.set("limit",String(n));const a=await k.get(`/top-pages?${o.toString()}`);r.value=a.rows||[],u.value=a.rowCount||r.value.length,m.value=new Date().toISOString(),x({count:r.value.length,totalPagesTracked:u.value,pages:r.value.map(p=>({page:p.pagePath,views:p.screenPageViews,users:p.totalUsers,avgDuration:v(p.averageSessionDuration)}))})}catch(o){i.value=o?.data?.statusMessage||o?.message||"Failed to load top pages",x(`Error loading top pages: ${i.value}`)}finally{d.value=!1}}e.onMounted(()=>{l.status==="completed"&&E()||D()});function x(t){l.status!=="completed"&&V("submit",t)}const v=t=>{if(!t)return"0s";const s=Math.floor(t/60),n=Math.round(t%60);return s>0?`${s}m ${n}s`:`${n}s`},g=t=>t==null?"0":t.toLocaleString(),w=t=>t?new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"",S=e.computed(()=>r.value.length===0?1:Math.max(...r.value.map(t=>t.screenPageViews||0))),P=e.computed(()=>{const{startDate:t,endDate:s}=l.resolvedArgs||{};if(!t&&!s)return"Last 30 days";const n=t||"30daysAgo",o=s||"today",a=n.match(/^(\d+)daysAgo$/);return a?`Last ${a[1]} days`:`${n} → ${o}`});return(t,s)=>{const n=e.resolveComponent("NuxtLink");return e.openBlock(),e.createElementBlock("div",B,[e.unref(d)?(e.openBlock(),e.createElementBlock("div",T,[e.createVNode(e.unref(c.Loader2),{class:"size-4 animate-spin text-muted-foreground"}),s[0]||(s[0]=e.createElementVNode("span",{class:"text-xs text-muted-foreground"},"Loading top pages…",-1))])):e.unref(i)?(e.openBlock(),e.createElementBlock("div",L,e.toDisplayString(e.unref(i)),1)):e.unref(r).length===0?(e.openBlock(),e.createElementBlock("div",$,[e.createVNode(e.unref(c.FileText),{class:"size-8 text-muted-foreground mx-auto mb-2"}),s[1]||(s[1]=e.createElementVNode("p",{class:"text-sm text-muted-foreground"},"No page data found for this period.",-1))])):(e.openBlock(),e.createElementBlock("div",A,[e.createElementVNode("div",M,[e.createElementVNode("div",C,[e.createVNode(e.unref(c.FileText),{class:"size-3.5 text-primary"}),s[2]||(s[2]=e.createElementVNode("span",{class:"text-xs font-medium"},"Most Popular Pages",-1))]),e.createElementVNode("span",z,e.toDisplayString(e.unref(P)),1)]),e.createElementVNode("div",F,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),(o,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,class:"px-3 py-2.5 hover:bg-muted/30 transition-colors"},[e.createElementVNode("div",I,[e.createElementVNode("span",j,e.toDisplayString(a+1)+".",1),e.createElementVNode("span",{class:"text-xs font-medium truncate flex-1",title:o.pagePath},e.toDisplayString(o.pagePath),9,U)]),e.createElementVNode("div",q,[e.createElementVNode("div",O,[e.createElementVNode("div",{class:"h-full rounded-full bg-primary/70 transition-all",style:e.normalizeStyle({width:`${(o.screenPageViews||0)/e.unref(S)*100}%`})},null,4)]),e.createElementVNode("div",R,[e.createElementVNode("span",K,[e.createVNode(e.unref(c.Eye),{class:"size-2.5"}),e.createTextVNode(" "+e.toDisplayString(g(o.screenPageViews))+" views ",1)]),e.createElementVNode("span",G,[e.createVNode(e.unref(c.Users),{class:"size-2.5"}),e.createTextVNode(" "+e.toDisplayString(g(o.totalUsers))+" users ",1)]),e.createElementVNode("span",H,[e.createVNode(e.unref(c.Clock),{class:"size-2.5"}),e.createTextVNode(" "+e.toDisplayString(v(o.averageSessionDuration)),1)])])])]))),128))]),e.createElementVNode("div",J,[e.createElementVNode("span",Q,[e.createTextVNode(" Top "+e.toDisplayString(e.unref(r).length)+" of "+e.toDisplayString(g(e.unref(u)))+" pages ",1),e.unref(m)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(" · fetched "+e.toDisplayString(w(e.unref(m))),1)],64)):e.createCommentVNode("",!0)]),e.createVNode(n,{to:`/projects/${e.unref(_)}/modules/${f.instanceId}`,class:"inline-flex items-center gap-1.5 text-xs text-primary hover:underline"},{default:e.withCtx(()=>[e.createVNode(e.unref(c.ExternalLink),{class:"size-3"}),s[3]||(s[3]=e.createTextVNode(" View full report ",-1))]),_:1},8,["to"])])]))])}}});exports.default=W;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { defineComponent as U, computed as w, ref as f, onMounted as j, resolveComponent as F, openBlock as d, createElementBlock as c, unref as s, createVNode as u, createElementVNode as a, toDisplayString as i, Fragment as P, renderList as B, normalizeStyle as R, createTextVNode as g, createCommentVNode as O, withCtx as q } from "vue";
|
|
2
2
|
import { Loader2 as G, FileText as S, Eye as H, Users as J, Clock as K, ExternalLink as Q } from "lucide-vue-next";
|
|
3
|
-
|
|
3
|
+
import { useRoute as W, useModuleApi as X } from "@oneclick.dev/cms-kit";
|
|
4
|
+
const Y = { class: "w-full" }, Z = {
|
|
4
5
|
key: 0,
|
|
5
6
|
class: "flex items-center gap-2 py-3"
|
|
6
|
-
},
|
|
7
|
+
}, ee = {
|
|
7
8
|
key: 1,
|
|
8
9
|
class: "text-xs text-destructive py-2"
|
|
9
|
-
},
|
|
10
|
+
}, te = {
|
|
10
11
|
key: 2,
|
|
11
12
|
class: "rounded-xl border bg-background p-4 text-center"
|
|
12
|
-
},
|
|
13
|
+
}, se = {
|
|
13
14
|
key: 3,
|
|
14
15
|
class: "rounded-xl border bg-background overflow-hidden"
|
|
15
|
-
},
|
|
16
|
+
}, ae = { class: "px-3 py-2 border-b bg-muted/40 flex items-center justify-between" }, oe = { class: "flex items-center gap-2" }, ne = { class: "text-[10px] text-muted-foreground" }, re = { class: "divide-y" }, ie = { class: "flex items-center gap-2 mb-1.5" }, le = { class: "text-[10px] font-medium text-muted-foreground w-5 text-right shrink-0" }, de = ["title"], ce = { class: "ml-7 space-y-1.5" }, ue = { class: "h-1.5 rounded-full bg-muted overflow-hidden" }, me = { class: "flex items-center gap-3 text-[10px] text-muted-foreground" }, ge = { class: "flex items-center gap-1" }, pe = { class: "flex items-center gap-1" }, fe = { class: "flex items-center gap-1" }, xe = { class: "px-3 py-2 border-t bg-muted/20 flex items-center justify-between" }, ve = { class: "text-[10px] text-muted-foreground" }, we = /* @__PURE__ */ U({
|
|
16
17
|
__name: "TopPagesCard",
|
|
17
18
|
props: {
|
|
18
19
|
toolName: {},
|
|
@@ -24,7 +25,7 @@ const W = { class: "w-full" }, X = {
|
|
|
24
25
|
},
|
|
25
26
|
emits: ["submit"],
|
|
26
27
|
setup(b, { emit: L }) {
|
|
27
|
-
const m = b, $ = L, V =
|
|
28
|
+
const m = b, $ = L, V = W(), A = w(() => V.params.slug), N = X(m.instanceId), x = f(!0), p = f(null), r = f([]), v = f(0), h = f(null);
|
|
28
29
|
function C() {
|
|
29
30
|
const e = m.resolvedArgs?._cachedData;
|
|
30
31
|
return e ? (r.value = e.pages?.map((t) => ({
|
|
@@ -80,50 +81,50 @@ const W = { class: "w-full" }, X = {
|
|
|
80
81
|
});
|
|
81
82
|
return (e, t) => {
|
|
82
83
|
const n = F("NuxtLink");
|
|
83
|
-
return d(), c("div",
|
|
84
|
-
s(x) ? (d(), c("div",
|
|
84
|
+
return d(), c("div", Y, [
|
|
85
|
+
s(x) ? (d(), c("div", Z, [
|
|
85
86
|
u(s(G), { class: "size-4 animate-spin text-muted-foreground" }),
|
|
86
87
|
t[0] || (t[0] = a("span", { class: "text-xs text-muted-foreground" }, "Loading top pages…", -1))
|
|
87
|
-
])) : s(p) ? (d(), c("div",
|
|
88
|
+
])) : s(p) ? (d(), c("div", ee, i(s(p)), 1)) : s(r).length === 0 ? (d(), c("div", te, [
|
|
88
89
|
u(s(S), { class: "size-8 text-muted-foreground mx-auto mb-2" }),
|
|
89
90
|
t[1] || (t[1] = a("p", { class: "text-sm text-muted-foreground" }, "No page data found for this period.", -1))
|
|
90
|
-
])) : (d(), c("div",
|
|
91
|
-
a("div",
|
|
92
|
-
a("div",
|
|
91
|
+
])) : (d(), c("div", se, [
|
|
92
|
+
a("div", ae, [
|
|
93
|
+
a("div", oe, [
|
|
93
94
|
u(s(S), { class: "size-3.5 text-primary" }),
|
|
94
95
|
t[2] || (t[2] = a("span", { class: "text-xs font-medium" }, "Most Popular Pages", -1))
|
|
95
96
|
]),
|
|
96
|
-
a("span",
|
|
97
|
+
a("span", ne, i(s(E)), 1)
|
|
97
98
|
]),
|
|
98
|
-
a("div",
|
|
99
|
+
a("div", re, [
|
|
99
100
|
(d(!0), c(P, null, B(s(r), (o, l) => (d(), c("div", {
|
|
100
101
|
key: l,
|
|
101
102
|
class: "px-3 py-2.5 hover:bg-muted/30 transition-colors"
|
|
102
103
|
}, [
|
|
103
|
-
a("div",
|
|
104
|
-
a("span",
|
|
104
|
+
a("div", ie, [
|
|
105
|
+
a("span", le, i(l + 1) + ".", 1),
|
|
105
106
|
a("span", {
|
|
106
107
|
class: "text-xs font-medium truncate flex-1",
|
|
107
108
|
title: o.pagePath
|
|
108
|
-
}, i(o.pagePath), 9,
|
|
109
|
+
}, i(o.pagePath), 9, de)
|
|
109
110
|
]),
|
|
110
|
-
a("div",
|
|
111
|
-
a("div",
|
|
111
|
+
a("div", ce, [
|
|
112
|
+
a("div", ue, [
|
|
112
113
|
a("div", {
|
|
113
114
|
class: "h-full rounded-full bg-primary/70 transition-all",
|
|
114
115
|
style: R({ width: `${(o.screenPageViews || 0) / s(I) * 100}%` })
|
|
115
116
|
}, null, 4)
|
|
116
117
|
]),
|
|
117
|
-
a("div",
|
|
118
|
-
a("span",
|
|
118
|
+
a("div", me, [
|
|
119
|
+
a("span", ge, [
|
|
119
120
|
u(s(H), { class: "size-2.5" }),
|
|
120
121
|
g(" " + i(y(o.screenPageViews)) + " views ", 1)
|
|
121
122
|
]),
|
|
122
|
-
a("span",
|
|
123
|
+
a("span", pe, [
|
|
123
124
|
u(s(J), { class: "size-2.5" }),
|
|
124
125
|
g(" " + i(y(o.totalUsers)) + " users ", 1)
|
|
125
126
|
]),
|
|
126
|
-
a("span",
|
|
127
|
+
a("span", fe, [
|
|
127
128
|
u(s(K), { class: "size-2.5" }),
|
|
128
129
|
g(" " + i(D(o.averageSessionDuration)), 1)
|
|
129
130
|
])
|
|
@@ -131,8 +132,8 @@ const W = { class: "w-full" }, X = {
|
|
|
131
132
|
])
|
|
132
133
|
]))), 128))
|
|
133
134
|
]),
|
|
134
|
-
a("div",
|
|
135
|
-
a("span",
|
|
135
|
+
a("div", xe, [
|
|
136
|
+
a("span", ve, [
|
|
136
137
|
g(" Top " + i(s(r).length) + " of " + i(y(s(v))) + " pages ", 1),
|
|
137
138
|
s(h) ? (d(), c(P, { key: 0 }, [
|
|
138
139
|
g(" · fetched " + i(z(s(h))), 1)
|
|
@@ -155,5 +156,5 @@ const W = { class: "w-full" }, X = {
|
|
|
155
156
|
}
|
|
156
157
|
});
|
|
157
158
|
export {
|
|
158
|
-
|
|
159
|
+
we as default
|
|
159
160
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),i=require("lucide-vue-next"),v=require("@oneclick.dev/cms-kit"),C={class:"w-full"},L={key:0,class:"flex items-center gap-2 py-3"},$={key:1,class:"text-xs text-destructive py-2"},U={key:2,class:"rounded-xl border bg-background p-4 text-center"},z={key:3,class:"rounded-xl border bg-background overflow-hidden"},A={class:"px-3 py-2 border-b bg-muted/40 flex items-center justify-between"},T={class:"flex items-center gap-2"},F={class:"text-[10px] text-muted-foreground"},G={key:0,class:"px-3 pt-3 pb-2"},j={class:"h-3 rounded-full bg-muted overflow-hidden flex"},M=["title"],R={class:"flex flex-wrap gap-x-3 gap-y-1 mt-2"},q={class:"text-[10px] text-muted-foreground"},I={class:"text-[10px] font-medium"},P={key:1,class:"border-t"},O={class:"divide-y"},K={class:"text-xs font-medium truncate flex-1"},H={class:"flex items-center gap-3 text-[10px] text-muted-foreground shrink-0"},J={class:"flex items-center gap-1"},Q={class:"flex items-center gap-1"},W={class:"px-3 py-2 border-t bg-muted/20 flex items-center justify-between"},X={key:0,class:"text-[10px] text-muted-foreground"},Y=e.defineComponent({__name:"TrafficSourcesCard",props:{toolName:{},instanceId:{},instanceName:{},moduleType:{},resolvedArgs:{},status:{}},emits:["submit"],setup(g,{emit:_}){const l=g,N=_,E=v.useRoute(),V=e.computed(()=>E.params.slug),x=v.useModuleApi(l.instanceId),m=e.ref(!0),u=e.ref(null),c=e.ref([]),a=e.ref([]),p=e.ref(null);function S(){const s=l.resolvedArgs?._cachedData;return s?(a.value=(s.topChannels||[]).map(t=>({sessionDefaultChannelGroup:t.channel,sessions:t.sessions,totalUsers:t.users,newUsers:t.newUsers,engagementRate:parseFloat(t.engagementRate)/100})),c.value=(s.topSources||[]).map(t=>({sessionSource:t.source,sessions:t.sessions,totalUsers:t.users})),p.value=l.resolvedArgs._fetchedAt||null,m.value=!1,!0):!1}async function B(){const{startDate:s,endDate:t}=l.resolvedArgs||{};m.value=!0,u.value=null;try{const o=new URLSearchParams;s&&o.set("startDate",s),t&&o.set("endDate",t);const[n,d]=await Promise.all([x.get(`/top-sources?${o.toString()}`),x.get(`/acquisition/channels?${o.toString()}`)]);c.value=n.rows||[],a.value=d.rows||[],p.value=new Date().toISOString(),h({topChannels:a.value.map(r=>({channel:r.sessionDefaultChannelGroup,sessions:r.sessions,users:r.totalUsers,newUsers:r.newUsers,engagementRate:`${(r.engagementRate*100).toFixed(1)}%`})),topSources:c.value.map(r=>({source:r.sessionSource,sessions:r.sessions,users:r.totalUsers}))})}catch(o){u.value=o?.data?.statusMessage||o?.message||"Failed to load traffic sources",h(`Error loading traffic sources: ${u.value}`)}finally{m.value=!1}}e.onMounted(()=>{l.status==="completed"&&S()||B()});function h(s){l.status!=="completed"&&N("submit",s)}const f=s=>s==null?"0":Math.round(s).toLocaleString(),D=s=>s?new Date(s).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"",b=e.computed(()=>a.value.reduce((s,t)=>s+(t.sessions||0),0)),y=["bg-primary/70","bg-blue-500/70","bg-emerald-500/70","bg-amber-500/70","bg-purple-500/70","bg-pink-500/70","bg-cyan-500/70","bg-orange-500/70","bg-indigo-500/70","bg-rose-500/70"],k=["bg-primary","bg-blue-500","bg-emerald-500","bg-amber-500","bg-purple-500","bg-pink-500","bg-cyan-500","bg-orange-500","bg-indigo-500","bg-rose-500"],w=e.computed(()=>{const{startDate:s,endDate:t}=l.resolvedArgs||{};if(!s&&!t)return"Last 30 days";const o=s||"30daysAgo",n=o.match(/^(\d+)daysAgo$/);return n?`Last ${n[1]} days`:`${o} → ${t||"today"}`});return(s,t)=>{const o=e.resolveComponent("NuxtLink");return e.openBlock(),e.createElementBlock("div",C,[e.unref(m)?(e.openBlock(),e.createElementBlock("div",L,[e.createVNode(e.unref(i.Loader2),{class:"size-4 animate-spin text-muted-foreground"}),t[0]||(t[0]=e.createElementVNode("span",{class:"text-xs text-muted-foreground"},"Loading traffic sources…",-1))])):e.unref(u)?(e.openBlock(),e.createElementBlock("div",$,e.toDisplayString(e.unref(u)),1)):e.unref(a).length===0&&e.unref(c).length===0?(e.openBlock(),e.createElementBlock("div",U,[e.createVNode(e.unref(i.Globe),{class:"size-8 text-muted-foreground mx-auto mb-2"}),t[1]||(t[1]=e.createElementVNode("p",{class:"text-sm text-muted-foreground"},"No traffic source data found for this period.",-1))])):(e.openBlock(),e.createElementBlock("div",z,[e.createElementVNode("div",A,[e.createElementVNode("div",T,[e.createVNode(e.unref(i.Globe),{class:"size-3.5 text-primary"}),t[2]||(t[2]=e.createElementVNode("span",{class:"text-xs font-medium"},"Traffic Sources",-1))]),e.createElementVNode("span",F,e.toDisplayString(e.unref(w)),1)]),e.unref(a).length>0?(e.openBlock(),e.createElementBlock("div",G,[e.createElementVNode("div",j,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a),(n,d)=>(e.openBlock(),e.createElementBlock("div",{key:n.sessionDefaultChannelGroup,class:e.normalizeClass(["h-full first:rounded-l-full last:rounded-r-full",y[d%y.length]]),style:e.normalizeStyle({width:`${e.unref(b)>0?(n.sessions||0)/e.unref(b)*100:0}%`}),title:`${n.sessionDefaultChannelGroup}: ${f(n.sessions)} sessions`},null,14,M))),128))]),e.createElementVNode("div",R,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a).slice(0,6),(n,d)=>(e.openBlock(),e.createElementBlock("div",{key:n.sessionDefaultChannelGroup,class:"flex items-center gap-1.5"},[e.createElementVNode("span",{class:e.normalizeClass(["size-2 rounded-full shrink-0",k[d%k.length]])},null,2),e.createElementVNode("span",q,e.toDisplayString(n.sessionDefaultChannelGroup),1),e.createElementVNode("span",I,e.toDisplayString(f(n.sessions)),1)]))),128))])])):e.createCommentVNode("",!0),e.unref(c).length>0?(e.openBlock(),e.createElementBlock("div",P,[t[3]||(t[3]=e.createElementVNode("div",{class:"px-3 py-1.5 bg-muted/20"},[e.createElementVNode("span",{class:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide"},"Top Sources")],-1)),e.createElementVNode("div",O,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c),n=>(e.openBlock(),e.createElementBlock("div",{key:n.sessionSource,class:"px-3 py-2 flex items-center justify-between hover:bg-muted/30 transition-colors"},[e.createElementVNode("span",K,e.toDisplayString(n.sessionSource),1),e.createElementVNode("div",H,[e.createElementVNode("span",J,[e.createVNode(e.unref(i.MousePointerClick),{class:"size-2.5"}),e.createTextVNode(" "+e.toDisplayString(f(n.sessions)),1)]),e.createElementVNode("span",Q,[e.createVNode(e.unref(i.Users),{class:"size-2.5"}),e.createTextVNode(" "+e.toDisplayString(f(n.totalUsers)),1)])])]))),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",W,[e.unref(p)?(e.openBlock(),e.createElementBlock("span",X," Fetched "+e.toDisplayString(D(e.unref(p))),1)):e.createCommentVNode("",!0),e.createVNode(o,{to:`/projects/${e.unref(V)}/modules/${g.instanceId}`,class:"inline-flex items-center gap-1.5 text-xs text-primary hover:underline"},{default:e.withCtx(()=>[e.createVNode(e.unref(i.ExternalLink),{class:"size-3"}),t[4]||(t[4]=e.createTextVNode(" View full report ",-1))]),_:1},8,["to"])])]))])}}});exports.default=Y;
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { defineComponent as I, computed as _, ref as x, onMounted as P, resolveComponent as B, openBlock as r, createElementBlock as a, unref as s, createVNode as m, createElementVNode as
|
|
1
|
+
import { defineComponent as I, computed as _, ref as x, onMounted as P, resolveComponent as B, openBlock as r, createElementBlock as a, unref as s, createVNode as m, createElementVNode as o, toDisplayString as d, Fragment as y, renderList as k, normalizeStyle as q, normalizeClass as N, createCommentVNode as S, createTextVNode as w, withCtx as O } from "vue";
|
|
2
2
|
import { Loader2 as H, Globe as z, MousePointerClick as J, Users as K, ExternalLink as Q } from "lucide-vue-next";
|
|
3
|
-
|
|
3
|
+
import { useRoute as W, useModuleApi as X } from "@oneclick.dev/cms-kit";
|
|
4
|
+
const Y = { class: "w-full" }, Z = {
|
|
4
5
|
key: 0,
|
|
5
6
|
class: "flex items-center gap-2 py-3"
|
|
6
|
-
},
|
|
7
|
+
}, ee = {
|
|
7
8
|
key: 1,
|
|
8
9
|
class: "text-xs text-destructive py-2"
|
|
9
|
-
},
|
|
10
|
+
}, se = {
|
|
10
11
|
key: 2,
|
|
11
12
|
class: "rounded-xl border bg-background p-4 text-center"
|
|
12
|
-
},
|
|
13
|
+
}, te = {
|
|
13
14
|
key: 3,
|
|
14
15
|
class: "rounded-xl border bg-background overflow-hidden"
|
|
15
|
-
},
|
|
16
|
+
}, oe = { class: "px-3 py-2 border-b bg-muted/40 flex items-center justify-between" }, ne = { class: "flex items-center gap-2" }, re = { class: "text-[10px] text-muted-foreground" }, ae = {
|
|
16
17
|
key: 0,
|
|
17
18
|
class: "px-3 pt-3 pb-2"
|
|
18
|
-
},
|
|
19
|
+
}, le = { class: "h-3 rounded-full bg-muted overflow-hidden flex" }, ie = ["title"], ue = { class: "flex flex-wrap gap-x-3 gap-y-1 mt-2" }, de = { class: "text-[10px] text-muted-foreground" }, ce = { class: "text-[10px] font-medium" }, me = {
|
|
19
20
|
key: 1,
|
|
20
21
|
class: "border-t"
|
|
21
|
-
},
|
|
22
|
+
}, pe = { class: "divide-y" }, ge = { class: "text-xs font-medium truncate flex-1" }, fe = { class: "flex items-center gap-3 text-[10px] text-muted-foreground shrink-0" }, xe = { class: "flex items-center gap-1" }, he = { class: "flex items-center gap-1" }, be = { class: "px-3 py-2 border-t bg-muted/20 flex items-center justify-between" }, ve = {
|
|
22
23
|
key: 0,
|
|
23
24
|
class: "text-[10px] text-muted-foreground"
|
|
24
|
-
},
|
|
25
|
+
}, Se = /* @__PURE__ */ I({
|
|
25
26
|
__name: "TrafficSourcesCard",
|
|
26
27
|
props: {
|
|
27
28
|
toolName: {},
|
|
@@ -33,7 +34,7 @@ const W = { class: "w-full" }, X = {
|
|
|
33
34
|
},
|
|
34
35
|
emits: ["submit"],
|
|
35
36
|
setup(D, { emit: G }) {
|
|
36
|
-
const c = D, F = G, R =
|
|
37
|
+
const c = D, F = G, R = W(), T = _(() => R.params.slug), C = X(c.instanceId), h = x(!0), g = x(null), p = x([]), u = x([]), b = x(null);
|
|
37
38
|
function j() {
|
|
38
39
|
const t = c.resolvedArgs?._cachedData;
|
|
39
40
|
return t ? (u.value = (t.topChannels || []).map((e) => ({
|
|
@@ -54,11 +55,11 @@ const W = { class: "w-full" }, X = {
|
|
|
54
55
|
try {
|
|
55
56
|
const l = new URLSearchParams();
|
|
56
57
|
t && l.set("startDate", t), e && l.set("endDate", e);
|
|
57
|
-
const [
|
|
58
|
+
const [n, f] = await Promise.all([
|
|
58
59
|
C.get(`/top-sources?${l.toString()}`),
|
|
59
60
|
C.get(`/acquisition/channels?${l.toString()}`)
|
|
60
61
|
]);
|
|
61
|
-
p.value =
|
|
62
|
+
p.value = n.rows || [], u.value = f.rows || [], b.value = (/* @__PURE__ */ new Date()).toISOString(), $({
|
|
62
63
|
topChannels: u.value.map((i) => ({
|
|
63
64
|
channel: i.sessionDefaultChannelGroup,
|
|
64
65
|
sessions: i.sessions,
|
|
@@ -109,73 +110,73 @@ const W = { class: "w-full" }, X = {
|
|
|
109
110
|
], E = _(() => {
|
|
110
111
|
const { startDate: t, endDate: e } = c.resolvedArgs || {};
|
|
111
112
|
if (!t && !e) return "Last 30 days";
|
|
112
|
-
const l = t || "30daysAgo",
|
|
113
|
-
return
|
|
113
|
+
const l = t || "30daysAgo", n = l.match(/^(\d+)daysAgo$/);
|
|
114
|
+
return n ? `Last ${n[1]} days` : `${l} → ${e || "today"}`;
|
|
114
115
|
});
|
|
115
116
|
return (t, e) => {
|
|
116
117
|
const l = B("NuxtLink");
|
|
117
|
-
return r(), a("div",
|
|
118
|
-
s(h) ? (r(), a("div",
|
|
118
|
+
return r(), a("div", Y, [
|
|
119
|
+
s(h) ? (r(), a("div", Z, [
|
|
119
120
|
m(s(H), { class: "size-4 animate-spin text-muted-foreground" }),
|
|
120
|
-
e[0] || (e[0] =
|
|
121
|
-
])) : s(g) ? (r(), a("div",
|
|
121
|
+
e[0] || (e[0] = o("span", { class: "text-xs text-muted-foreground" }, "Loading traffic sources…", -1))
|
|
122
|
+
])) : s(g) ? (r(), a("div", ee, d(s(g)), 1)) : s(u).length === 0 && s(p).length === 0 ? (r(), a("div", se, [
|
|
122
123
|
m(s(z), { class: "size-8 text-muted-foreground mx-auto mb-2" }),
|
|
123
|
-
e[1] || (e[1] =
|
|
124
|
-
])) : (r(), a("div",
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
e[1] || (e[1] = o("p", { class: "text-sm text-muted-foreground" }, "No traffic source data found for this period.", -1))
|
|
125
|
+
])) : (r(), a("div", te, [
|
|
126
|
+
o("div", oe, [
|
|
127
|
+
o("div", ne, [
|
|
127
128
|
m(s(z), { class: "size-3.5 text-primary" }),
|
|
128
|
-
e[2] || (e[2] =
|
|
129
|
+
e[2] || (e[2] = o("span", { class: "text-xs font-medium" }, "Traffic Sources", -1))
|
|
129
130
|
]),
|
|
130
|
-
|
|
131
|
+
o("span", re, d(s(E)), 1)
|
|
131
132
|
]),
|
|
132
|
-
s(u).length > 0 ? (r(), a("div",
|
|
133
|
-
|
|
134
|
-
(r(!0), a(y, null, k(s(u), (
|
|
135
|
-
key:
|
|
133
|
+
s(u).length > 0 ? (r(), a("div", ae, [
|
|
134
|
+
o("div", le, [
|
|
135
|
+
(r(!0), a(y, null, k(s(u), (n, f) => (r(), a("div", {
|
|
136
|
+
key: n.sessionDefaultChannelGroup,
|
|
136
137
|
class: N(["h-full first:rounded-l-full last:rounded-r-full", U[f % U.length]]),
|
|
137
|
-
style: q({ width: `${s(L) > 0 ? (
|
|
138
|
-
title: `${
|
|
139
|
-
}, null, 14,
|
|
138
|
+
style: q({ width: `${s(L) > 0 ? (n.sessions || 0) / s(L) * 100 : 0}%` }),
|
|
139
|
+
title: `${n.sessionDefaultChannelGroup}: ${v(n.sessions)} sessions`
|
|
140
|
+
}, null, 14, ie))), 128))
|
|
140
141
|
]),
|
|
141
|
-
|
|
142
|
-
(r(!0), a(y, null, k(s(u).slice(0, 6), (
|
|
143
|
-
key:
|
|
142
|
+
o("div", ue, [
|
|
143
|
+
(r(!0), a(y, null, k(s(u).slice(0, 6), (n, f) => (r(), a("div", {
|
|
144
|
+
key: n.sessionDefaultChannelGroup,
|
|
144
145
|
class: "flex items-center gap-1.5"
|
|
145
146
|
}, [
|
|
146
|
-
|
|
147
|
+
o("span", {
|
|
147
148
|
class: N(["size-2 rounded-full shrink-0", A[f % A.length]])
|
|
148
149
|
}, null, 2),
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
o("span", de, d(n.sessionDefaultChannelGroup), 1),
|
|
151
|
+
o("span", ce, d(v(n.sessions)), 1)
|
|
151
152
|
]))), 128))
|
|
152
153
|
])
|
|
153
154
|
])) : S("", !0),
|
|
154
|
-
s(p).length > 0 ? (r(), a("div",
|
|
155
|
-
e[3] || (e[3] =
|
|
156
|
-
|
|
155
|
+
s(p).length > 0 ? (r(), a("div", me, [
|
|
156
|
+
e[3] || (e[3] = o("div", { class: "px-3 py-1.5 bg-muted/20" }, [
|
|
157
|
+
o("span", { class: "text-[10px] font-medium text-muted-foreground uppercase tracking-wide" }, "Top Sources")
|
|
157
158
|
], -1)),
|
|
158
|
-
|
|
159
|
-
(r(!0), a(y, null, k(s(p), (
|
|
160
|
-
key:
|
|
159
|
+
o("div", pe, [
|
|
160
|
+
(r(!0), a(y, null, k(s(p), (n) => (r(), a("div", {
|
|
161
|
+
key: n.sessionSource,
|
|
161
162
|
class: "px-3 py-2 flex items-center justify-between hover:bg-muted/30 transition-colors"
|
|
162
163
|
}, [
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
o("span", ge, d(n.sessionSource), 1),
|
|
165
|
+
o("div", fe, [
|
|
166
|
+
o("span", xe, [
|
|
166
167
|
m(s(J), { class: "size-2.5" }),
|
|
167
|
-
w(" " + d(v(
|
|
168
|
+
w(" " + d(v(n.sessions)), 1)
|
|
168
169
|
]),
|
|
169
|
-
|
|
170
|
+
o("span", he, [
|
|
170
171
|
m(s(K), { class: "size-2.5" }),
|
|
171
|
-
w(" " + d(v(
|
|
172
|
+
w(" " + d(v(n.totalUsers)), 1)
|
|
172
173
|
])
|
|
173
174
|
])
|
|
174
175
|
]))), 128))
|
|
175
176
|
])
|
|
176
177
|
])) : S("", !0),
|
|
177
|
-
|
|
178
|
-
s(b) ? (r(), a("span",
|
|
178
|
+
o("div", be, [
|
|
179
|
+
s(b) ? (r(), a("span", ve, " Fetched " + d(V(s(b))), 1)) : S("", !0),
|
|
179
180
|
m(l, {
|
|
180
181
|
to: `/projects/${s(T)}/modules/${D.instanceId}`,
|
|
181
182
|
class: "inline-flex items-center gap-1.5 text-xs text-primary hover:underline"
|
|
@@ -193,5 +194,5 @@ const W = { class: "w-full" }, X = {
|
|
|
193
194
|
}
|
|
194
195
|
});
|
|
195
196
|
export {
|
|
196
|
-
|
|
197
|
+
Se as default
|
|
197
198
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),o=require("lucide-vue-next"),w=require("@oneclick.dev/cms-kit"),C={class:"w-full"},M={key:0,class:"flex items-center gap-2 py-3"},F={key:1,class:"text-xs text-destructive py-2"},L={key:2,class:"rounded-xl border bg-background overflow-hidden"},z={class:"px-3 py-2 border-b bg-muted/40 flex items-center justify-between"},j={class:"flex items-center gap-2"},T={class:"text-[10px] text-muted-foreground"},I={class:"grid grid-cols-2 sm:grid-cols-4 divide-x divide-y"},O={class:"flex items-center gap-1.5"},q={class:"text-[10px] text-muted-foreground uppercase tracking-wide"},K={class:"text-sm font-semibold"},Y={key:0,class:"flex items-center gap-0.5"},G={class:"px-3 py-2 border-t bg-muted/20 flex items-center justify-between"},H={key:0,class:"text-[10px] text-muted-foreground"},J=e.defineComponent({__name:"VisitorStatsCard",props:{toolName:{},instanceId:{},instanceName:{},moduleType:{},resolvedArgs:{},status:{}},emits:["submit"],setup(f,{emit:S}){const l=f,V=S,_=w.useRoute(),D=e.computed(()=>_.params.slug),N=w.useModuleApi(l.instanceId),u=e.ref(!0),c=e.ref(null),a=e.ref({}),i=e.ref({}),d=e.ref(null);function B(){const t=l.resolvedArgs?._cachedData;return t?(a.value={totalUsers:t.totalUsers||0,sessions:t.sessions||0,screenPageViews:t.pageViews||0,newUsers:t.newUsers||0,bounceRate:v(t.bounceRate),averageSessionDuration:E(t.avgSessionDuration),engagementRate:v(t.engagementRate),screenPageViewsPerSession:parseFloat(t.pagesPerSession)||0},i.value=Object.fromEntries(Object.entries(t.changes||{}).map(([s,n])=>[s,P(n)])),d.value=l.resolvedArgs._fetchedAt||null,u.value=!1,!0):!1}function v(t){return t?parseFloat(t)/100:0}function E(t){if(!t)return 0;const s=t.match(/(\d+)m/),n=t.match(/(\d+)s/);return(s?parseInt(s[1])*60:0)+(n?parseInt(n[1]):0)}function P(t){return!t||t==="N/A"?null:parseFloat(t.replace("+",""))}async function R(){const{startDate:t,endDate:s}=l.resolvedArgs||{};u.value=!0,c.value=null;try{const n=new URLSearchParams;t&&n.set("startDate",t),s&&n.set("endDate",s);const r=await N.get(`/report?${n.toString()}`);a.value=r.totals||{},i.value=r.changes||{},d.value=new Date().toISOString(),h({period:x.value,totalUsers:Math.round(a.value.totalUsers||0),sessions:Math.round(a.value.sessions||0),pageViews:Math.round(a.value.screenPageViews||0),newUsers:Math.round(a.value.newUsers||0),bounceRate:`${(a.value.bounceRate*100).toFixed(1)}%`,avgSessionDuration:y(a.value.averageSessionDuration),engagementRate:`${(a.value.engagementRate*100).toFixed(1)}%`,pagesPerSession:(a.value.screenPageViewsPerSession||0).toFixed(1),changes:Object.fromEntries(Object.entries(i.value).map(([A,p])=>[A,p!==null?`${p>0?"+":""}${p.toFixed(1)}%`:"N/A"]))})}catch(n){c.value=n?.data?.statusMessage||n?.message||"Failed to load visitor stats",h(`Error loading visitor stats: ${c.value}`)}finally{u.value=!1}}e.onMounted(()=>{l.status==="completed"&&B()||R()});function h(t){l.status!=="completed"&&V("submit",t)}const x=e.computed(()=>{const{startDate:t,endDate:s}=l.resolvedArgs||{};if(!t&&!s)return"Last 30 days";const n=t||"30daysAgo",r=n.match(/^(\d+)daysAgo$/);return n==="yesterday"&&(!s||s==="yesterday")?"Yesterday":r?`Last ${r[1]} days`:`${n} → ${s||"today"}`}),y=t=>{if(!t)return"0s";const s=Math.floor(t/60),n=Math.round(t%60);return s>0?`${s}m ${n}s`:`${n}s`},m=t=>t==null?"0":Math.round(t).toLocaleString(),k=t=>t==null?"0%":`${(t*100).toFixed(1)}%`,U=t=>t?new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"",g=(t,s=!1)=>{if(t==null)return"text-muted-foreground";const n=s?t<0:t>0,r=s?t>0:t<0;return n?"text-emerald-600 dark:text-emerald-400":r?"text-red-600 dark:text-red-400":"text-muted-foreground"},b=t=>t==null?null:`${t>0?"+":""}${t.toFixed(1)}%`,$=e.computed(()=>[{label:"Users",value:m(a.value.totalUsers),change:i.value.totalUsers,icon:o.Users},{label:"Sessions",value:m(a.value.sessions),change:i.value.sessions,icon:o.MousePointerClick},{label:"Page Views",value:m(a.value.screenPageViews),change:i.value.screenPageViews,icon:o.Eye},{label:"New Users",value:m(a.value.newUsers),change:i.value.newUsers,icon:o.Users},{label:"Bounce Rate",value:k(a.value.bounceRate),change:i.value.bounceRate,inverted:!0,icon:o.ArrowDownRight},{label:"Engagement",value:k(a.value.engagementRate),change:i.value.engagementRate,icon:o.Timer},{label:"Avg Duration",value:y(a.value.averageSessionDuration),change:i.value.averageSessionDuration,icon:o.Timer},{label:"Pages/Session",value:(a.value.screenPageViewsPerSession||0).toFixed(1),change:i.value.screenPageViewsPerSession,icon:o.Eye}]);return(t,s)=>{const n=e.resolveComponent("NuxtLink");return e.openBlock(),e.createElementBlock("div",C,[e.unref(u)?(e.openBlock(),e.createElementBlock("div",M,[e.createVNode(e.unref(o.Loader2),{class:"size-4 animate-spin text-muted-foreground"}),s[0]||(s[0]=e.createElementVNode("span",{class:"text-xs text-muted-foreground"},"Loading visitor statistics…",-1))])):e.unref(c)?(e.openBlock(),e.createElementBlock("div",F,e.toDisplayString(e.unref(c)),1)):(e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("div",z,[e.createElementVNode("div",j,[e.createVNode(e.unref(o.BarChart3),{class:"size-3.5 text-primary"}),s[1]||(s[1]=e.createElementVNode("span",{class:"text-xs font-medium"},"Visitor Statistics",-1))]),e.createElementVNode("span",T,e.toDisplayString(e.unref(x)),1)]),e.createElementVNode("div",I,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref($),r=>(e.openBlock(),e.createElementBlock("div",{key:r.label,class:"px-3 py-3 space-y-1"},[e.createElementVNode("div",O,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.icon),{class:"size-3 text-muted-foreground"})),e.createElementVNode("span",q,e.toDisplayString(r.label),1)]),e.createElementVNode("p",K,e.toDisplayString(r.value),1),b(r.change)?(e.openBlock(),e.createElementBlock("div",Y,[(r.change??0)>0?(e.openBlock(),e.createBlock(e.unref(o.ArrowUpRight),{key:0,class:e.normalizeClass(["size-2.5",g(r.change,r.inverted)])},null,8,["class"])):(r.change??0)<0?(e.openBlock(),e.createBlock(e.unref(o.ArrowDownRight),{key:1,class:e.normalizeClass(["size-2.5",g(r.change,r.inverted)])},null,8,["class"])):(e.openBlock(),e.createBlock(e.unref(o.Minus),{key:2,class:"size-2.5 text-muted-foreground"})),e.createElementVNode("span",{class:e.normalizeClass(["text-[10px] font-medium",g(r.change,r.inverted)])},e.toDisplayString(b(r.change)),3)])):e.createCommentVNode("",!0)]))),128))]),e.createElementVNode("div",G,[e.unref(d)?(e.openBlock(),e.createElementBlock("span",H," Fetched "+e.toDisplayString(U(e.unref(d))),1)):e.createCommentVNode("",!0),e.createVNode(n,{to:`/projects/${e.unref(D)}/modules/${f.instanceId}`,class:"inline-flex items-center gap-1.5 text-xs text-primary hover:underline"},{default:e.withCtx(()=>[e.createVNode(e.unref(o.ExternalLink),{class:"size-3"}),s[2]||(s[2]=e.createTextVNode(" View full report ",-1))]),_:1},8,["to"])])]))])}}});exports.default=J;
|