@liiift-studio/sanity-visitor-insights 0.50.0 → 0.51.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/dist/index.js CHANGED
@@ -266,6 +266,30 @@ var SEND_WINDOW_DAYS = 3;
266
266
  // src/studio/Figure.tsx
267
267
  var import_react2 = __toESM(require("react"));
268
268
  var import_sanity_ui_compat = require("@liiift-studio/sanity-ui-compat");
269
+
270
+ // src/studio/palette.ts
271
+ var SERIES = {
272
+ /** The complete, server-side count. The reference every other line is read against. */
273
+ vercel: "#4C8FD0",
274
+ /** GA4's pageviews — the like-for-like counterpart to Vercel's. */
275
+ ga4Pageviews: "#DD6B3F",
276
+ /** GA4's sessions. Warm, like its sibling above: same instrument, different unit. */
277
+ ga4Sessions: "#BC861F",
278
+ /** Orders, from the foundry's own records. Exact. */
279
+ orders: "#2E9E6B",
280
+ /** Revenue, same source, different unit. */
281
+ revenue: "#BF5D9B"
282
+ };
283
+ var REGION_ALPHA = 0.18;
284
+ function seriesFill(key, alpha = REGION_ALPHA) {
285
+ const hex = SERIES[key];
286
+ const r = parseInt(hex.slice(1, 3), 16);
287
+ const g = parseInt(hex.slice(3, 5), 16);
288
+ const b = parseInt(hex.slice(5, 7), 16);
289
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
290
+ }
291
+
292
+ // src/studio/Figure.tsx
269
293
  var import_jsx_runtime = require("react/jsx-runtime");
270
294
  var REASON_TEXT = {
271
295
  not_instrumented: "Not tracked on this site",
@@ -524,7 +548,10 @@ function FunnelChart({ stages, measurement }) {
524
548
  const active = activeKey === stage.key;
525
549
  const delta = previous ? previous.value - stage.value : 0;
526
550
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { style: funnelItem, children: [
527
- previous && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: funnelGap, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sanity_ui_compat.Text, { size: 0, muted: true, children: gapLabel(delta, measurement) }) }),
551
+ previous && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: funnelGap, "aria-hidden": "true", children: [
552
+ measurement === "sequence" && delta > 0 && entry > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: lostTrack, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { ...lostFill, width: `${Math.max(1, Math.min(1, delta / entry) * 100)}%` } }) }),
553
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sanity_ui_compat.Text, { size: 0, muted: true, children: gapLabel(delta, measurement) })
554
+ ] }),
528
555
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
529
556
  "div",
530
557
  {
@@ -564,9 +591,30 @@ var funnelList = { listStyle: "none", margin: 0, padding: 0 };
564
591
  var funnelItem = { display: "grid", gap: 4 };
565
592
  var funnelGap = {
566
593
  display: "flex",
594
+ alignItems: "center",
567
595
  justifyContent: "flex-end",
596
+ gap: 8,
568
597
  padding: "4px 2px"
569
598
  };
599
+ var lostTrack = {
600
+ width: "38%",
601
+ maxWidth: 200,
602
+ height: 6,
603
+ borderRadius: 2,
604
+ overflow: "hidden",
605
+ background: "currentColor",
606
+ opacity: 0.1,
607
+ // Right to left: the bar grows back toward the funnel it came out of, which reads as leaving
608
+ // rather than as another quantity accumulating alongside.
609
+ display: "flex",
610
+ justifyContent: "flex-end"
611
+ };
612
+ var lostFill = {
613
+ height: "100%",
614
+ borderRadius: 2,
615
+ background: SERIES.ga4Pageviews,
616
+ opacity: 0.75
617
+ };
570
618
  function funnelStage(active) {
571
619
  return {
572
620
  display: "grid",
@@ -581,10 +629,11 @@ function funnelStage(active) {
581
629
  var barFill = {
582
630
  height: "100%",
583
631
  borderRadius: 2,
584
- // currentColor at an alpha that clears 3:1 against the card in both themes, so the mark works
585
- // from one declaration rather than needing a palette.
586
- background: "currentColor",
587
- opacity: 0.55
632
+ // The reference blue, as everywhere else the tool draws "people who were here". Previously
633
+ // currentColor at 0.55, which made the funnel a stack of grey bars whose only variable was
634
+ // length — legible, and giving the eye nothing to hold on to across five rungs.
635
+ background: SERIES.vercel,
636
+ opacity: 0.85
588
637
  };
589
638
  var barTrack = {
590
639
  height: 8,
@@ -1026,30 +1075,6 @@ var import_sanity_ui_compat2 = require("@liiift-studio/sanity-ui-compat");
1026
1075
  var import_d3_scale = require("d3-scale");
1027
1076
  var import_d3_shape = require("d3-shape");
1028
1077
  var import_d3_array = require("d3-array");
1029
-
1030
- // src/studio/palette.ts
1031
- var SERIES = {
1032
- /** The complete, server-side count. The reference every other line is read against. */
1033
- vercel: "#4C8FD0",
1034
- /** GA4's pageviews — the like-for-like counterpart to Vercel's. */
1035
- ga4Pageviews: "#DD6B3F",
1036
- /** GA4's sessions. Warm, like its sibling above: same instrument, different unit. */
1037
- ga4Sessions: "#BC861F",
1038
- /** Orders, from the foundry's own records. Exact. */
1039
- orders: "#2E9E6B",
1040
- /** Revenue, same source, different unit. */
1041
- revenue: "#BF5D9B"
1042
- };
1043
- var REGION_ALPHA = 0.18;
1044
- function seriesFill(key, alpha = REGION_ALPHA) {
1045
- const hex = SERIES[key];
1046
- const r = parseInt(hex.slice(1, 3), 16);
1047
- const g = parseInt(hex.slice(3, 5), 16);
1048
- const b = parseInt(hex.slice(5, 7), 16);
1049
- return `rgba(${r}, ${g}, ${b}, ${alpha})`;
1050
- }
1051
-
1052
- // src/studio/CrossSourceTimeline.tsx
1053
1078
  var import_jsx_runtime2 = require("react/jsx-runtime");
1054
1079
  function colorFor(source, unit, explicit) {
1055
1080
  if (explicit) return explicit;