@orangelogic/design-system 2.174.0 → 2.175.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orangelogic/design-system",
3
3
  "type": "module",
4
- "version": "2.174.0",
4
+ "version": "2.175.0",
5
5
  "license": "UNLICENSED",
6
6
  "types": "library/types.d.ts",
7
7
  "scripts": {
@@ -1,5 +1,7 @@
1
1
  import { Editor } from 'grapesjs';
2
2
 
3
+ export * from './metrics';
4
+ export * from './measure';
3
5
  export type TelemetryPluginOptions = {
4
6
  bootStartedAt: number;
5
7
  };
@@ -1,28 +1,16 @@
1
1
  import { Component } from 'grapesjs';
2
+ import { UiActionName } from './metrics';
2
3
 
3
- export declare const UiAction: {
4
- readonly AddBlock: "add_block";
5
- readonly ConfigureWorkflow: "configure_workflow";
6
- readonly DeviceSwitch: "device_switch";
7
- readonly DuplicateBlock: "duplicate_block";
8
- readonly EditorBoot: "editor_boot";
9
- readonly MoveBlock: "move_block";
10
- readonly OpenConfig: "open_config";
11
- readonly PickAsset: "pick_asset";
12
- readonly PickAssetFormat: "pick_asset_format";
13
- readonly PickDownloadFormat: "pick_download_format";
14
- readonly Redo: "redo";
15
- readonly RemoveBlock: "remove_block";
16
- readonly RichTextEdit: "rich_text_edit";
17
- readonly SaveConfig: "save_config";
18
- readonly SelectBlock: "select_block";
19
- readonly Undo: "undo";
20
- };
21
- export type UiActionName = (typeof UiAction)[keyof typeof UiAction];
22
4
  /** Mirrors the CMS5_BO.Data.MetricsIsEnabled parameter, passed in by the host VForm. */
23
5
  export declare function setEditorMetricsEnabled(enabled: boolean): void;
24
6
  /** Whether metrics are currently armed - the same flag `measureSync` and friends check. */
25
7
  export declare function isEditorMetricsEnabled(): boolean;
8
+ /**
9
+ * Record one editor action.
10
+ *
11
+ * Mode is always 'edit' from here - the content builder only exists in edit mode. It is
12
+ * passed explicitly rather than defaulted downstream so the call says what it means.
13
+ */
26
14
  export declare function dispatch(action: string, durationMs: number, component: string, blockType?: string): void;
27
15
  /**
28
16
  * Derive the block-type label from a GrapesJS component.
@@ -0,0 +1,106 @@
1
+ /**
2
+ * CMS5 browser metrics: what is measured, what the samples are called, and which label
3
+ * values are allowed to exist.
4
+ *
5
+ * Cortex owns the OpenTelemetry SDK, the exporter and the resource, and publishes an
6
+ * instrument factory on `window.OLTelemetry`. This module owns everything above that
7
+ * line. Only the factory crosses it, so the page runs one MeterProvider and one export
8
+ * stream however many bundles are loaded, and this repository ships no SDK of its own.
9
+ *
10
+ * The metric definitions and the label vocabularies used to live on the Cortex side, so
11
+ * that a frontend release could not introduce a new label value - and therefore new
12
+ * metric series - without a corresponding change there. They moved here because they
13
+ * describe this repository's own blocks and editor actions and went stale whenever it
14
+ * shipped without a matching Cortex change: a `cx-sb-` prefix rule once excluded fifteen
15
+ * of the twenty-one block types, including the two most common ones, so an ordinary page
16
+ * of headings and text produced no block metrics at all and simply looked idle.
17
+ *
18
+ * The bound those lists provided has moved with them, not been dropped. Every set below
19
+ * is closed, and a value outside it collapses to `unknown` rather than being dropped, so
20
+ * a missing entry shows up as a visible bucket in Grafana instead of silently
21
+ * disappearing. Adding a value here adds metric series - treat it as a change with a cost.
22
+ *
23
+ * When Cortex is older than the API, every entry point below is a no-op: the components
24
+ * behave exactly as they do with telemetry switched off.
25
+ *
26
+ * How things are *timed* lives in `./measure`; when the measurement is armed lives in
27
+ * `./index` (edit mode, the GrapesJS plugin) and `./content-render` (view mode).
28
+ */
29
+ export declare const COMPONENT_CONTENT_BUILDER = "cx-content-builder";
30
+ /** Stamped by CMS5_PageViewer_Content_VForm from the server's own edit-mode state. */
31
+ export declare const METRICS_MARKER_SELECTOR = "[data-cms5-metrics=\"true\"]";
32
+ /**
33
+ * Site-builder mode. The same page content is served in both, so without this label a
34
+ * block painted inside the editor canvas and the same block on the published page land in
35
+ * one series - and they are not the same thing. One is behind an authenticated editor
36
+ * with the builder bundle loaded; the other is what a visitor actually waits for.
37
+ */
38
+ export declare const MODE_EDIT = "edit";
39
+ export declare const MODE_VIEW = "view";
40
+ export declare const UiAction: {
41
+ readonly AddBlock: "add_block";
42
+ readonly ConfigureWorkflow: "configure_workflow";
43
+ readonly DeviceSwitch: "device_switch";
44
+ readonly DuplicateBlock: "duplicate_block";
45
+ readonly EditorBoot: "editor_boot";
46
+ readonly MoveBlock: "move_block";
47
+ readonly OpenConfig: "open_config";
48
+ readonly PickAsset: "pick_asset";
49
+ readonly PickAssetFormat: "pick_asset_format";
50
+ readonly PickDownloadFormat: "pick_download_format";
51
+ readonly Redo: "redo";
52
+ readonly RemoveBlock: "remove_block";
53
+ readonly RichTextEdit: "rich_text_edit";
54
+ readonly SaveConfig: "save_config";
55
+ readonly SelectBlock: "select_block";
56
+ readonly Undo: "undo";
57
+ };
58
+ export type UiActionName = (typeof UiAction)[keyof typeof UiAction];
59
+ /**
60
+ * Element name of every block the builder can place, mapped to its metric label.
61
+ *
62
+ * A table rather than a prefix rule, because block tags are not uniform: only six are
63
+ * named `cx-sb-*` and the rest reuse general-purpose design-system elements
64
+ * (`cx-header`, `cx-text`, `cx-gallery`, ...).
65
+ *
66
+ * The label is the GrapesJS block name, not the tag: that is the word the author sees in
67
+ * the block picker, and it survives a component being re-pointed at a different element.
68
+ * Gallery and Carousel are two picker entries backed by one element, so they necessarily
69
+ * share a label - the DOM cannot tell them apart.
70
+ */
71
+ export declare const BLOCK_TAG_LABELS: Map<string, string>;
72
+ /**
73
+ * The blocks whose render time is worth measuring on a published page: content the
74
+ * visitor is waiting for. The column containers are excluded - they resolve with the page
75
+ * itself, so timing them measures the framework rather than the content, and because one
76
+ * wraps every block they would dominate the sample.
77
+ */
78
+ export declare const CONTENT_BLOCK_TAGS: string[];
79
+ /**
80
+ * Blocks that render a placeholder and then fetch, so their Lit render completing says
81
+ * nothing about when the user actually sees content. These signal the real end instead.
82
+ */
83
+ export declare const LOADING_BLOCK_TAGS: Set<string>;
84
+ /**
85
+ * The mode the server said this page is in.
86
+ *
87
+ * Read from the stamp rather than inferred from the DOM: the editor mounts
88
+ * asynchronously, so anything guessed from the markup at load time would be a race.
89
+ */
90
+ export declare function detectMode(container?: Element | null): string;
91
+ export declare function blockLabelOf(tagName: string): string | undefined;
92
+ export declare function recordUiAction(action: string, seconds: number, component: string, mode: string, blockType?: string): void;
93
+ export declare function recordBlockRender(seconds: number, blockType: string | undefined, mode: string): void;
94
+ export declare function recordContentRender(seconds: number, mode: string): void;
95
+ export declare function countContentRenderAbandoned(mode: string): void;
96
+ /**
97
+ * Tell Cortex which mode this page is in, so its own page-level histograms carry the
98
+ * dimension too.
99
+ *
100
+ * Page load, TTFB and the web vitals are recorded by Cortex, not here, and they need the
101
+ * split as much as these metrics do: opening a page for editing boots the editor inside
102
+ * the page load, so the authoring cost lands in the published page's timings unless the
103
+ * two populations can be told apart. Cortex cannot read this itself without knowing what
104
+ * CMS5 is, which is the arrangement this module exists to avoid.
105
+ */
106
+ export declare function declarePageMode(mode: string): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orangelogic/design-system",
3
3
  "type": "module",
4
- "version": "2.174.0",
4
+ "version": "2.175.0",
5
5
  "license": "UNLICENSED",
6
6
  "types": "library/types.d.ts",
7
7
  "scripts": {