@liiift-studio/sanity-visitor-insights 0.47.0 → 0.48.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.d.mts +39 -9
- package/dist/index.d.ts +39 -9
- package/dist/index.js +372 -249
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +372 -249
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/server/reports/reports.test.ts +9 -0
- package/src/studio/CrossSourceTimeline.tsx +207 -12
- package/src/studio/palette.test.ts +118 -0
- package/src/studio/palette.ts +95 -0
- package/src/studio/panels.test.tsx +91 -12
- package/src/studio/panels.tsx +24 -13
package/dist/index.d.mts
CHANGED
|
@@ -403,6 +403,34 @@ interface SortableTableProps<Row> {
|
|
|
403
403
|
*/
|
|
404
404
|
declare function SortableTable<Row>({ caption, columns, rows, rowKey, initialSort, filterPlaceholder, filterOn, exportName, truncatedNote, onExclude, }: SortableTableProps<Row>): React.ReactElement;
|
|
405
405
|
|
|
406
|
+
/**
|
|
407
|
+
* The series palette, and the rules that keep it honest.
|
|
408
|
+
*
|
|
409
|
+
* Every chart in this package was drawn in `currentColor` at varying alpha, so five series on one
|
|
410
|
+
* chart were five greys separated by dash pattern alone. That is legible in a screenshot and not
|
|
411
|
+
* in use: a reader tracking co-movement between GA4 and Vercel had to keep which-line-is-which in
|
|
412
|
+
* their head while looking at the shape.
|
|
413
|
+
*
|
|
414
|
+
* Three constraints decided these values, and all three are enforced by tests rather than asserted
|
|
415
|
+
* here:
|
|
416
|
+
*
|
|
417
|
+
* 1. ONE SET FOR BOTH THEMES. The Studio ships light and dark and this component is not told which
|
|
418
|
+
* it is in. Rather than swap palettes at a breakpoint we cannot observe, every colour clears
|
|
419
|
+
* 3:1 — the WCAG floor for a graphical object — against BOTH a white card and Sanity's dark
|
|
420
|
+
* card. That is what pins them to mid-lightness.
|
|
421
|
+
*
|
|
422
|
+
* 2. HUE FAMILY MEANS SOURCE. The two GA4 series are deliberately neighbours in the warm range,
|
|
423
|
+
* because they are the same instrument measuring two things; Vercel, orders and revenue each
|
|
424
|
+
* get their own family. So the palette carries a fact rather than just distinguishing rows.
|
|
425
|
+
*
|
|
426
|
+
* 3. COLOUR IS NEVER THE ONLY CHANNEL. Completeness stays encoded as a dash pattern and every
|
|
427
|
+
* value stays readable in the tooltip. The two GA4 hues are close enough to converge for a
|
|
428
|
+
* deuteranope — which is acceptable precisely because dash and label still separate them, and
|
|
429
|
+
* unacceptable for any pair that does not have that second channel.
|
|
430
|
+
*/
|
|
431
|
+
/** One series colour. The key names what it measures, not what it looks like. */
|
|
432
|
+
type SeriesKey = 'vercel' | 'ga4Pageviews' | 'ga4Sessions' | 'orders' | 'revenue';
|
|
433
|
+
|
|
406
434
|
/**
|
|
407
435
|
* One time axis, every source stacked against it.
|
|
408
436
|
*
|
|
@@ -433,15 +461,6 @@ interface SeriesPoint {
|
|
|
433
461
|
}
|
|
434
462
|
/** How a value should be written out. */
|
|
435
463
|
type SeriesUnit = 'count' | 'money' | 'percent';
|
|
436
|
-
/**
|
|
437
|
-
* One row of the chart: one answer, with what a lossier source saw underneath it.
|
|
438
|
-
*
|
|
439
|
-
* A row shows a SINGLE line by default. Two peer lines make the reader reconcile before they get
|
|
440
|
-
* an answer, and at a glance a foundry owner wants "how much", not "here are two measurements that
|
|
441
|
-
* disagree". The disagreement is still drawn — as a filled region, and in full on hover — because
|
|
442
|
-
* hiding it entirely would switch off the alarm: the 24 August collapse was visible precisely
|
|
443
|
-
* because two lines came apart.
|
|
444
|
-
*/
|
|
445
464
|
interface Series {
|
|
446
465
|
key: string;
|
|
447
466
|
label: string;
|
|
@@ -449,6 +468,15 @@ interface Series {
|
|
|
449
468
|
source: 'GA4' | 'Vercel' | 'Sanity' | 'Mailchimp';
|
|
450
469
|
/** Whether the line's source sees everything. Drives the stroke and the wording. */
|
|
451
470
|
complete: boolean;
|
|
471
|
+
/**
|
|
472
|
+
* Which series colour this row draws in.
|
|
473
|
+
*
|
|
474
|
+
* Optional, and falling back to the row's `source`, so a caller that adds a row gets a colour
|
|
475
|
+
* consistent with every other row from the same upstream rather than an uncoloured one. Set it
|
|
476
|
+
* explicitly only where the source does not decide the meaning — coverage is computed FROM GA4
|
|
477
|
+
* and Vercel and belongs to neither.
|
|
478
|
+
*/
|
|
479
|
+
color?: SeriesKey;
|
|
452
480
|
unit: SeriesUnit;
|
|
453
481
|
/**
|
|
454
482
|
* How the row is drawn. Defaults to `line`.
|
|
@@ -494,6 +522,8 @@ interface Series {
|
|
|
494
522
|
*/
|
|
495
523
|
shortfall?: {
|
|
496
524
|
label: string;
|
|
525
|
+
/** The lossier source's colour. Falls back to its `source`, as the row's own does. */
|
|
526
|
+
color?: SeriesKey;
|
|
497
527
|
source: Series['source'];
|
|
498
528
|
points: SeriesPoint[];
|
|
499
529
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -403,6 +403,34 @@ interface SortableTableProps<Row> {
|
|
|
403
403
|
*/
|
|
404
404
|
declare function SortableTable<Row>({ caption, columns, rows, rowKey, initialSort, filterPlaceholder, filterOn, exportName, truncatedNote, onExclude, }: SortableTableProps<Row>): React.ReactElement;
|
|
405
405
|
|
|
406
|
+
/**
|
|
407
|
+
* The series palette, and the rules that keep it honest.
|
|
408
|
+
*
|
|
409
|
+
* Every chart in this package was drawn in `currentColor` at varying alpha, so five series on one
|
|
410
|
+
* chart were five greys separated by dash pattern alone. That is legible in a screenshot and not
|
|
411
|
+
* in use: a reader tracking co-movement between GA4 and Vercel had to keep which-line-is-which in
|
|
412
|
+
* their head while looking at the shape.
|
|
413
|
+
*
|
|
414
|
+
* Three constraints decided these values, and all three are enforced by tests rather than asserted
|
|
415
|
+
* here:
|
|
416
|
+
*
|
|
417
|
+
* 1. ONE SET FOR BOTH THEMES. The Studio ships light and dark and this component is not told which
|
|
418
|
+
* it is in. Rather than swap palettes at a breakpoint we cannot observe, every colour clears
|
|
419
|
+
* 3:1 — the WCAG floor for a graphical object — against BOTH a white card and Sanity's dark
|
|
420
|
+
* card. That is what pins them to mid-lightness.
|
|
421
|
+
*
|
|
422
|
+
* 2. HUE FAMILY MEANS SOURCE. The two GA4 series are deliberately neighbours in the warm range,
|
|
423
|
+
* because they are the same instrument measuring two things; Vercel, orders and revenue each
|
|
424
|
+
* get their own family. So the palette carries a fact rather than just distinguishing rows.
|
|
425
|
+
*
|
|
426
|
+
* 3. COLOUR IS NEVER THE ONLY CHANNEL. Completeness stays encoded as a dash pattern and every
|
|
427
|
+
* value stays readable in the tooltip. The two GA4 hues are close enough to converge for a
|
|
428
|
+
* deuteranope — which is acceptable precisely because dash and label still separate them, and
|
|
429
|
+
* unacceptable for any pair that does not have that second channel.
|
|
430
|
+
*/
|
|
431
|
+
/** One series colour. The key names what it measures, not what it looks like. */
|
|
432
|
+
type SeriesKey = 'vercel' | 'ga4Pageviews' | 'ga4Sessions' | 'orders' | 'revenue';
|
|
433
|
+
|
|
406
434
|
/**
|
|
407
435
|
* One time axis, every source stacked against it.
|
|
408
436
|
*
|
|
@@ -433,15 +461,6 @@ interface SeriesPoint {
|
|
|
433
461
|
}
|
|
434
462
|
/** How a value should be written out. */
|
|
435
463
|
type SeriesUnit = 'count' | 'money' | 'percent';
|
|
436
|
-
/**
|
|
437
|
-
* One row of the chart: one answer, with what a lossier source saw underneath it.
|
|
438
|
-
*
|
|
439
|
-
* A row shows a SINGLE line by default. Two peer lines make the reader reconcile before they get
|
|
440
|
-
* an answer, and at a glance a foundry owner wants "how much", not "here are two measurements that
|
|
441
|
-
* disagree". The disagreement is still drawn — as a filled region, and in full on hover — because
|
|
442
|
-
* hiding it entirely would switch off the alarm: the 24 August collapse was visible precisely
|
|
443
|
-
* because two lines came apart.
|
|
444
|
-
*/
|
|
445
464
|
interface Series {
|
|
446
465
|
key: string;
|
|
447
466
|
label: string;
|
|
@@ -449,6 +468,15 @@ interface Series {
|
|
|
449
468
|
source: 'GA4' | 'Vercel' | 'Sanity' | 'Mailchimp';
|
|
450
469
|
/** Whether the line's source sees everything. Drives the stroke and the wording. */
|
|
451
470
|
complete: boolean;
|
|
471
|
+
/**
|
|
472
|
+
* Which series colour this row draws in.
|
|
473
|
+
*
|
|
474
|
+
* Optional, and falling back to the row's `source`, so a caller that adds a row gets a colour
|
|
475
|
+
* consistent with every other row from the same upstream rather than an uncoloured one. Set it
|
|
476
|
+
* explicitly only where the source does not decide the meaning — coverage is computed FROM GA4
|
|
477
|
+
* and Vercel and belongs to neither.
|
|
478
|
+
*/
|
|
479
|
+
color?: SeriesKey;
|
|
452
480
|
unit: SeriesUnit;
|
|
453
481
|
/**
|
|
454
482
|
* How the row is drawn. Defaults to `line`.
|
|
@@ -494,6 +522,8 @@ interface Series {
|
|
|
494
522
|
*/
|
|
495
523
|
shortfall?: {
|
|
496
524
|
label: string;
|
|
525
|
+
/** The lossier source's colour. Falls back to its `source`, as the row's own does. */
|
|
526
|
+
color?: SeriesKey;
|
|
497
527
|
source: Series['source'];
|
|
498
528
|
points: SeriesPoint[];
|
|
499
529
|
};
|