@webex/plugin-meetings 3.13.0-next.12 → 3.13.0-next.14

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.
Files changed (100) hide show
  1. package/.repo-context.json +577 -0
  2. package/.sdd/manifest.json +1320 -428
  3. package/AGENTS.md +528 -72
  4. package/dist/aiEnableRequest/index.js +1 -1
  5. package/dist/breakouts/breakout.js +1 -1
  6. package/dist/breakouts/index.js +1 -1
  7. package/dist/config.js +1 -1
  8. package/dist/interpretation/index.js +1 -1
  9. package/dist/interpretation/siLanguage.js +1 -1
  10. package/dist/webinar/index.js +1 -1
  11. package/docs/adr/0001-migrate-existing-docs-into-sdd.md +141 -0
  12. package/docs/adr/index.md +26 -0
  13. package/docs/architecture.md +816 -0
  14. package/docs/getting-started.md +177 -0
  15. package/docs/index.md +53 -0
  16. package/docs/specs/README.md +126 -0
  17. package/package.json +21 -21
  18. package/schemas/repo-context.schema.json +796 -0
  19. package/src/aiEnableRequest/docs/README.md +376 -0
  20. package/src/annotation/docs/README.md +402 -0
  21. package/src/breakouts/docs/README.md +643 -0
  22. package/src/controls-options-manager/docs/README.md +365 -0
  23. package/src/hashTree/docs/README.md +566 -0
  24. package/src/interceptors/docs/README.md +434 -0
  25. package/src/interpretation/docs/README.md +420 -0
  26. package/src/locus-info/docs/README.md +609 -0
  27. package/src/media/docs/README.md +488 -0
  28. package/src/meeting/docs/README.md +834 -0
  29. package/src/meeting-info/docs/README.md +352 -0
  30. package/src/meetings/docs/README.md +549 -0
  31. package/src/member/docs/README.md +347 -0
  32. package/src/members/docs/README.md +514 -0
  33. package/src/metrics/docs/README.md +287 -0
  34. package/src/multistream/docs/README.md +523 -0
  35. package/src/personal-meeting-room/docs/README.md +322 -0
  36. package/src/reachability/docs/README.md +548 -0
  37. package/src/reactions/docs/README.md +296 -0
  38. package/src/reconnection-manager/docs/README.md +485 -0
  39. package/src/recording-controller/docs/README.md +335 -0
  40. package/src/roap/docs/README.md +444 -0
  41. package/src/webinar/docs/README.md +425 -0
  42. package/.sdd/templates/.source.json +0 -30
  43. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +0 -111
  44. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +0 -321
  45. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +0 -59
  46. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +0 -49
  47. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +0 -42
  48. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +0 -120
  49. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +0 -206
  50. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +0 -90
  51. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +0 -68
  52. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +0 -111
  53. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +0 -57
  54. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +0 -69
  55. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +0 -96
  56. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +0 -84
  57. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +0 -82
  58. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +0 -94
  59. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +0 -64
  60. package/.sdd/templates/component-repo/template-map.json +0 -112
  61. package/ai-docs/ARCHITECTURE.md +0 -208
  62. package/ai-docs/CONTRACTS.md +0 -267
  63. package/ai-docs/DATA_MODEL.md +0 -64
  64. package/ai-docs/GETTING_STARTED.md +0 -73
  65. package/ai-docs/GLOSSARY.md +0 -56
  66. package/ai-docs/REVIEW_CHECKLIST.md +0 -45
  67. package/ai-docs/RULES.md +0 -79
  68. package/ai-docs/SECURITY.md +0 -74
  69. package/ai-docs/SERVICE_STATE.md +0 -59
  70. package/ai-docs/SPEC_INDEX.md +0 -85
  71. package/ai-docs/TEST_INDEX.md +0 -45
  72. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +0 -61
  73. package/ai-docs/patterns/defensive-error-propagation.md +0 -55
  74. package/ai-docs/patterns/event-scope-emission.md +0 -46
  75. package/ai-docs/patterns/source-to-test-path-mirroring.md +0 -45
  76. package/ai-docs/patterns/stateless-plugin-request-classes.md +0 -53
  77. package/ai-docs/patterns/typed-constants-and-enum-values.md +0 -47
  78. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +0 -223
  79. package/src/annotation/ai-docs/annotation-spec.md +0 -236
  80. package/src/breakouts/ai-docs/breakouts-spec.md +0 -324
  81. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +0 -243
  82. package/src/hashTree/ai-docs/hash-tree-spec.md +0 -267
  83. package/src/interceptors/ai-docs/interceptors-spec.md +0 -247
  84. package/src/interpretation/ai-docs/interpretation-spec.md +0 -256
  85. package/src/locus-info/ai-docs/locus-info-spec.md +0 -293
  86. package/src/media/ai-docs/media-spec.md +0 -267
  87. package/src/meeting/ai-docs/meeting-spec.md +0 -404
  88. package/src/meeting-info/ai-docs/meeting-info-spec.md +0 -261
  89. package/src/meetings/ai-docs/meetings-spec.md +0 -298
  90. package/src/member/ai-docs/member-spec.md +0 -196
  91. package/src/members/ai-docs/members-spec.md +0 -256
  92. package/src/metrics/ai-docs/metrics-spec.md +0 -185
  93. package/src/multistream/ai-docs/multistream-spec.md +0 -295
  94. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +0 -234
  95. package/src/reachability/ai-docs/reachability-spec.md +0 -261
  96. package/src/reactions/ai-docs/reactions-spec.md +0 -198
  97. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +0 -272
  98. package/src/recording-controller/ai-docs/recording-controller-spec.md +0 -223
  99. package/src/roap/ai-docs/roap-spec.md +0 -241
  100. package/src/webinar/ai-docs/webinar-spec.md +0 -243
@@ -0,0 +1,287 @@
1
+ ---
2
+ type: Module Spec
3
+ title: 'Meetings metrics specification'
4
+ description: Responsibilities, boundaries, behavioral metric names, field flattening, invariants, and verification for the metrics module of plugin-meetings.
5
+ tags: [module, specification]
6
+ ---
7
+ <!-- sdd-generated-metadata
8
+ doc_kind: module-spec
9
+ generated_from: module-spec@0.3.0
10
+ generated_by: claude-code
11
+ approved_by: rarajes2@cisco.com
12
+ updated_at: 2026-11-17T03:14:21Z
13
+ validation_status: pass-with-warnings
14
+ -->
15
+
16
+ # Meetings metrics
17
+
18
+ This source-local document at `src/metrics/docs/README.md` owns the stable specification for
19
+ **the metrics module** of `@webex/plugin-meetings`: the process-wide `Metrics` singleton that stores
20
+ the Webex host, flattens nested metric fields, and submits behavioral metrics through
21
+ `webex.internal.metrics`, plus the `BEHAVIORAL_METRICS` name catalog. Ground every claim in package
22
+ evidence and link to the [package architecture](../../../docs/architecture.md) instead of repeating
23
+ broader facts. No service specification exists because this package is a library.
24
+
25
+ Related context — start here: root [package agent instructions](../../../AGENTS.md) · router
26
+ [documentation index](../../../docs/index.md) · system [package architecture](../../../docs/architecture.md).
27
+ This is the canonical source-local spec for `src/metrics/`.
28
+
29
+ Repo architecture: [package architecture](../../../docs/architecture.md) · Registry:
30
+ [documentation index](../../../docs/index.md) · Coverage state and contracts baseline: `.sdd/manifest.json`.
31
+
32
+ ## Metadata
33
+
34
+ | Field | Value |
35
+ |---|---|
36
+ | Owner | @webex/web-client, @webex/web-sdk |
37
+ | Source path | `src/metrics` |
38
+ | Resource kind | module |
39
+ | Status | Draft |
40
+ | Last verified | 2026-11-16 at `0b8c34db7f` |
41
+ | Module id | `plugin-meetings/metrics` |
42
+ | Parent spec | — |
43
+ | Doc kind | Module spec |
44
+ | Coverage score | Pending coverage assessment |
45
+ | Validation status | not-run |
46
+
47
+ ## Applicability
48
+
49
+ | Condition ID | Status | Evidence or reason | Owned section |
50
+ | ------------ | ------ | ------------------ | ------------- |
51
+ | `module.has_tiers` | N/A | No tier policy exists in `package.json` or `.sdd/manifest.json` | Tier |
52
+ | `module.has_ui` | N/A | `src/metrics/index.ts` renders nothing | UI use-case flow |
53
+ | `module.crosses_service_boundaries` | Applicable | `src/metrics/index.ts` hands every metric to the internal metrics plugin, which batches it to the metrics service | Cross-boundary use-case flow |
54
+ | `module.holds_client_state` | N/A | The only field is the stored Webex host in `src/metrics/index.ts`; no client-visible state | Client state model |
55
+ | `module.enforces_domain_rules` | Applicable | Field flattening rules and the singleton rule in `src/metrics/index.ts`; the name catalog in `src/metrics/constants.ts` | Business rules and invariants |
56
+ | `module.is_concurrent_async` | N/A | Every method in `src/metrics/index.ts` is synchronous; batching is owned by the metrics plugin | Concurrency and reactive flow |
57
+ | `module.owns_persistence` | N/A | Nothing is stored by `src/metrics/index.ts` | Data, schema, and migration discipline |
58
+ | `module.stateful_transitions` | N/A | No state machine in `src/metrics/index.ts` | State machine |
59
+ | `module.exposes_wire_protocol` | N/A | The wire payload is built by the metrics plugin, not by `src/metrics/index.ts` | Protocol and wire format |
60
+ | `module.ui_multi_screen` | N/A | No UI | UI flow |
61
+ | `module.large_data_model` | N/A | One string map in `src/metrics/constants.ts` | Data model |
62
+ | `module.returns_caller_errors` | N/A | No method in `src/metrics/index.ts` rejects or throws its own error; dependency throws propagate unchanged | Caller-visible failure modes |
63
+ | `module.module_specific_conventions` | N/A | Repository-wide rules in `AGENTS.md` apply unchanged | Module-specific rules |
64
+ | `module.published_package` | N/A | `src/index.ts` does not re-export the module | Export stability |
65
+ | `module.embedded_in_host` | N/A | No mount or theme contract | Host integration and theming |
66
+ | `module.has_design_tradeoff` | N/A | No recorded trade-off in `src/metrics/index.ts` | Key design trade-off |
67
+ | `module.has_submodules` | N/A | The module directory has no child module | Sub-modules |
68
+
69
+ ## Evidence register
70
+
71
+ Requirements cite current source and mirrored tests. Current code wins over retained prose when they
72
+ conflict; commit and PR history are excluded. Missing evidence stays a gap.
73
+
74
+ | Evidence | What it establishes |
75
+ | -------- | ------------------- |
76
+ | `src/metrics/index.ts` | Class `Metrics` whose constructor returns the first-created instance; the default export is that instance; `initialSetup(webex)`, `sendBehavioralMetric(metricName, metricFields = {}, metricTags = {})`, and `prepareMetricFields(payload = {}, prefix = '')`. Its JSDoc says the fields are flattened because Amplitude does not accept nested objects |
77
+ | `src/metrics/constants.ts` | Default export `BEHAVIORAL_METRICS`: 97 keys mapped to metric names, all prefixed `js_sdk_` except `meetings_registration_step` |
78
+ | `src/meetings/index.ts` | `Meetings` calls `Metrics.initialSetup(this.webex)` inside its `READY` handler, after the static, logger, and media-logger setup |
79
+ | `test/unit/spec/metrics/index.js` | Two `sendBehavioralMetric` cases (one call; name, type, fields, and tags with `calledWithMatch`) and eight `prepareMetricFields` cases (empty object, root literals including `null`, flat and nested objects, arrays, arrays in objects, arrays in arrays, prefix) |
80
+ | Sibling package internal-plugin-metrics, files src/metrics.js and src/client-metrics-batcher.js | `submitClientMetrics(eventName, props)` throws without a name, merges environment tags and fields, uses `props.type` or else `config.metrics.type`, and returns the batcher's promise; the batcher POSTs `{metrics: payload}` to the `metrics` service `clientmetrics` resource |
81
+ | Observation, no stated WHY | No default for `config.metrics.type` exists in `src/config.ts` or in the @webex/internal-plugin-metrics package's src/config.js, so `type` is `undefined` unless the host config sets it (`src/metrics/index.ts`, `src/config.ts`) |
82
+ | Observation, no stated WHY | `meetings_registration_step` is the only name in `src/metrics/constants.ts` without the `js_sdk_` prefix |
83
+
84
+ ## Purpose and boundary
85
+
86
+ - Responsibility: Initializes meeting behavioral telemetry, flattens metric fields, and submits
87
+ established metric names/tags through the Webex metrics host.
88
+ - In scope: the `Metrics` singleton (`initialSetup`, `sendBehavioralMetric`,
89
+ `prepareMetricFields`) and the `BEHAVIORAL_METRICS` name catalog.
90
+ - Out of scope: batching, environment tags and fields, the HTTP request, and retry
91
+ (`@webex/internal-plugin-metrics`); call diagnostic and call analyzer events
92
+ (`webex.internal.newMetrics`, used directly by other modules); deciding when a metric is sent
93
+ (the calling modules).
94
+ - Consumers: 15 files in 10 sibling modules import both `src/metrics/index.ts` and
95
+ `src/metrics/constants.ts`: meetings, meeting, meeting-info, locus-info, hashTree, media,
96
+ multistream, reachability, reconnection manager, and roap (each specified at
97
+ `src/<module>/docs/README.md`).
98
+
99
+ ## Structure and key files
100
+
101
+ `src/metrics` contains 2 direct source/reference file(s) and has 1 mirrored unit-test file(s). Stack:
102
+ TypeScript/JavaScript in the Node 22.14 Yarn workspace; Webex core/plugin abstractions and
103
+ Mocha/Sinon/`@webex/test-helper-chai` tests.
104
+
105
+ ```text
106
+ src/metrics/
107
+ ├── constants.ts — module constants and wire values (BEHAVIORAL_METRICS names)
108
+ ├── index.ts — module facade/controller or primary exports (the Metrics singleton)
109
+ └── docs/README.md — canonical module specification
110
+ ```
111
+
112
+ | File | Holds |
113
+ |---|---|
114
+ | `src/metrics/constants.ts` | module constants and wire values: the `BEHAVIORAL_METRICS` key-to-name map |
115
+ | `src/metrics/index.ts` | module facade/controller or primary exports: the `Metrics` class and its default singleton instance |
116
+ | `test/unit/spec/metrics/index.js` | mirrored characterization/unit coverage |
117
+
118
+ ## Public surface
119
+
120
+ | Contract ID | Type | Surface | Purpose | Compatibility / deprecation | Schema / detail link | Root index |
121
+ |---|---|---|---|---|---|---|
122
+ | `meetings-metrics` | singleton setup | default singleton `initialSetup(webex)` | Store the Webex host used by later behavioral submissions. | Repeated setup replaces the host; there is no one-time guard or readiness check. | `src/metrics/index.ts` | [package architecture](../../../docs/architecture.md) |
123
+ | `meetings-metrics` | pure normalization | `prepareMetricFields(payload, prefix)` | Flatten nested objects/arrays and wrap root literals for clients that reject nested metric fields. | Preserve underscore path construction, array indices, and `{value}` root-literal behavior. | `src/metrics/index.ts` | [package architecture](../../../docs/architecture.md) |
124
+ | `meetings-metrics` | remote side effect | `sendBehavioralMetric(metricName, metricFields, metricTags)` | Forward the metric name, configured metrics type, fields, and tags to `submitClientMetrics()`. | The method returns `void` and does not expose an operational-metric API or promise. | `src/metrics/index.ts` | [package architecture](../../../docs/architecture.md) |
125
+ | `meetings-metrics` | name catalog | default export `BEHAVIORAL_METRICS` of `src/metrics/constants.ts` | Name every behavioral metric the package sends. | Values are measurement names; renaming one starts a new measurement. | `src/metrics/constants.ts` | [package architecture](../../../docs/architecture.md) |
126
+
127
+ Contract ID `meetings-metrics` is internal to the package: `src/index.ts` does not re-export the
128
+ module. It is indexed in the [package architecture](../../../docs/architecture.md) and registered in
129
+ `.sdd/manifest.json`; this module requires `internal-plugin-metrics-api`.
130
+
131
+ Compatibility notes:
132
+
133
+ - Prefer additive fields/options and preserve current return and rejection semantics. Internal helpers are not public merely because they are exported within the source directory.
134
+
135
+ ## Dependencies
136
+
137
+ Webex metrics plugin/host, behavioral metric constants, logging/error handling, and callers in
138
+ meeting/feature modules.
139
+
140
+ | Dependency | Why it is required | Failure behavior |
141
+ | ---------- | ------------------ | ---------------- |
142
+ | `@webex/internal-plugin-metrics` through `webex.internal.metrics` (contract `internal-plugin-metrics-api`) | `submitClientMetrics` builds the payload, adds environment tags and fields, and batches it to the metrics service | Throws synchronously without a metric name; its promise is discarded here, so batch failures never reach the caller |
143
+ | The Webex host stored by `initialSetup` | Supplies `internal.metrics` and `config.metrics.type` | Before `initialSetup`, `sendBehavioralMetric` throws a `TypeError` reading `internal` of `undefined` |
144
+ | `src/metrics/constants.ts` (within the module) | Callers pass its names as `metricName` | — |
145
+
146
+ The module itself does no logging and catches no error.
147
+
148
+ ## Requirements
149
+
150
+ | ID | WHAT | WHY | Source Evidence | Test / Example Evidence | Assumptions / Gaps | Confidence |
151
+ |---|---|---|---|---|---|---|
152
+ | `METRICS-R-001` | `initialSetup(webex)` replaces the singleton's stored Webex host on every call. | Later behavioral submissions must use the host supplied by the owning SDK instance without implying an idempotence guard the implementation does not have. | `src/metrics/index.ts` | `test/unit/spec/metrics/index.js` | repeat setup is not covered explicitly | PRESENT |
153
+ | `METRICS-R-002` | `prepareMetricFields` recursively flattens objects and arrays into underscore-delimited keys and wraps a top-level literal as `{value}`. | The behavioral metrics client cannot accept nested field objects, so callers need a deterministic flattening helper. | `src/metrics/index.ts` | `test/unit/spec/metrics/index.js` | no cycle or size bound is implemented | PRESENT |
154
+ | `METRICS-R-003` | `sendBehavioralMetric` calls `webex.internal.metrics.submitClientMetrics` with the configured metric type, supplied fields, and tags; the method returns no independent result. | The facade must preserve the actual behavioral-metrics boundary without inventing an operational-metrics API or lifecycle guarantee. | `src/metrics/index.ts` | `test/unit/spec/metrics/index.js` | thrown dependency errors propagate synchronously; the promise `submitClientMetrics` returns is discarded, so a batch failure is not observed | PRESENT |
155
+ | `METRICS-R-004` | The `Metrics` constructor returns the first instance it created, and the module's default export is that instance, so every importer in the process shares one stored host. | The JSDoc names `initialSetup` the initializer of the Metrics singleton; `Meetings` calls it once on `READY` and every other module only imports the instance. | `src/metrics/index.ts`, `src/meetings/index.ts` | `test/unit/spec/metrics/index.js` | the singleton constructor is not asserted | PRESENT |
156
+ | `METRICS-R-005` | Callers name metrics with the `BEHAVIORAL_METRICS` values of `src/metrics/constants.ts`; each value is sent unchanged as the metric name. | The JSDoc defines the name as the measurement the metrics service aggregates, so a changed value starts a different measurement. | `src/metrics/constants.ts`, `src/metrics/index.ts` | None found | no test pins the catalog values | PRESENT |
157
+
158
+ ## Design overview
159
+
160
+ `src/metrics/index.ts` is a singleton facade that stores the current Webex host, flattens
161
+ caller-supplied fields, and forwards behavioral metrics to `submitClientMetrics`. `constants.ts`
162
+ defines meeting metric names and fields. The module owns no listener, timer, or remote controller.
163
+
164
+ `prepareMetricFields` is pure: it does not touch the stored host. `sendBehavioralMetric` does not
165
+ flatten; callers that send nested data call `prepareMetricFields` first (for example
166
+ `src/reachability/index.ts` does so for its completion metric). Environment metadata such as browser,
167
+ OS, and SDK versions is added by the metrics plugin, not here.
168
+
169
+ ## Data flow and sequence coverage
170
+
171
+ Call style: synchronous in-process calls on the default `Metrics` instance; the metrics plugin then
172
+ batches the payload and sends it over HTTPS (`POST` to the `metrics` service `clientmetrics`
173
+ resource). There are two operation groups: submission and field preparation.
174
+
175
+ ```mermaid
176
+ flowchart LR
177
+ Owner[Meeting feature owner] --> Metrics[index.ts]
178
+ Constants[constants.ts] --> Metrics
179
+ Metrics --> Flatten[prepareMetricFields recursive flattening]
180
+ Metrics --> Behavioral[sendBehavioralMetric to submitClientMetrics]
181
+ ```
182
+
183
+ Sequence coverage:
184
+
185
+ | Operation group | Diagram | Failure coverage |
186
+ |---|---|---|
187
+ | UC-1…UC-2 — behavioral metrics operation groups | Behavioral metrics primary sequence | uninitialized host submission failure and nested/array/literal field normalization |
188
+ | UC-2 — field preparation | Behavioral metrics alternate/failure sequence | literal, array, object, and optional-prefix branches |
189
+
190
+ Behavioral metrics primary sequence:
191
+
192
+ ```mermaid
193
+ sequenceDiagram
194
+ participant O as Meeting feature owner
195
+ participant M as Metrics
196
+ participant W as Webex metrics client
197
+ O->>M: sendBehavioralMetric(name, fields, tags)
198
+ M->>W: submitClientMetrics(name, {type, fields, tags})
199
+ W-->>M: batcher promise (discarded), or synchronous throw
200
+ M-->>O: undefined, unless the dependency throws
201
+ ```
202
+
203
+ Behavioral metrics alternate/failure sequence:
204
+
205
+ ```mermaid
206
+ sequenceDiagram
207
+ participant C as Caller / current input owner
208
+ participant M as Metrics
209
+ C->>M: prepareMetricFields(value, optional prefix)
210
+ M->>M: recursively visit objects and arrays
211
+ alt nested value
212
+ M-->>C: flattened underscore-delimited object
213
+ else top-level literal or null
214
+ M-->>C: value wrapped as {value}
215
+ end
216
+ ```
217
+
218
+ ## Class and component relationships
219
+
220
+ ```mermaid
221
+ classDiagram
222
+ class Owner
223
+ class Metrics
224
+ class Constants
225
+ class Flatten
226
+ class Behavioral
227
+ Owner --> Metrics
228
+ Constants --> Metrics
229
+ Metrics --> Flatten
230
+ Metrics --> Behavioral
231
+ ```
232
+
233
+ The arrows identify ownership and delegation inside `src/metrics/`; files that only declare types or
234
+ constants are not presented as transports. `Owner` is a calling module, `Metrics` is the singleton in
235
+ `src/metrics/index.ts`, `Constants` is `BEHAVIORAL_METRICS`, `Flatten` is `prepareMetricFields`, and
236
+ `Behavioral` is the `sendBehavioralMetric` path into `webex.internal.metrics`.
237
+
238
+ ## Use cases and flows
239
+
240
+ | Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
241
+ | -------- | --------------- | ------------------------- | ---------------------------- | -------- |
242
+ | `UC-1` | `Meetings` on `READY`, then any meeting feature owner | Initialize the singleton with a Webex host and forward a named behavioral metric with configured type plus caller-supplied fields/tags. | Before setup the call throws a `TypeError`; a missing name throws in the metrics plugin; batch failures are not observed | `src/metrics/index.ts`, `src/meetings/index.ts`, `test/unit/spec/metrics/index.js` |
243
+ | `UC-2` | A caller with nested metric data, such as reachability | Flatten nested objects, arrays, prefixed values, null, and root literals into the exact field shape accepted by the metrics client. | No cycle or size bound; a cyclic object recurses until the stack overflows | `src/metrics/index.ts`, `src/reachability/index.ts`, `test/unit/spec/metrics/index.js` |
244
+
245
+ ### Cross-boundary use-case flow
246
+
247
+ | Boundary | Transport and ordering | Compatibility | Timeout, retry, and recovery |
248
+ | -------- | ---------------------- | ------------- | ---------------------------- |
249
+ | `webex.internal.metrics` (internal-plugin-metrics, `UC-1`) | In-process call; the plugin queues the payload in its client metrics batcher | `submitClientMetrics(name, {type, fields, tags})`; caller tags are overridden by the plugin's environment tags of the same name | Owned by the batcher; nothing here waits, retries, or recovers |
250
+ | Metrics service `clientmetrics` (through the batcher) | HTTPS `POST` of `{metrics: [payload]}` batches | Payload shape owned by internal-plugin-metrics | Owned by the batcher and its configuration |
251
+
252
+ ## Business rules and invariants
253
+
254
+ - Behavioral submission requires `initialSetup` to have assigned a Webex host; the facade does not
255
+ validate metric names or remove sensitive fields. Flattening is deterministic but unbounded, so
256
+ callers remain responsible for bounded, non-sensitive input. Enforced under `src/metrics/`.
257
+
258
+ | ID | Invariant | WHY | Enforcement source | Test evidence |
259
+ | -- | --------- | --- | ------------------ | ------------- |
260
+ | `INV-001` | A flattened key joins the path with `_`: object keys by name and array items by index; a literal with a prefix becomes `{[prefix]: value}` and a root literal (including `null`) becomes `{value}`. | Amplitude does not accept nested objects as metric fields (JSDoc of `prepareMetricFields`). | `src/metrics/index.ts` | `test/unit/spec/metrics/index.js` |
261
+ | `INV-002` | `sendBehavioralMetric` passes `fields` and `tags` through unchanged, defaulting each to `{}`. | Flattening is the caller's choice; the JSDoc tells callers to use `prepareMetricFields` before sending nested data. | `src/metrics/index.ts` | `test/unit/spec/metrics/index.js` |
262
+
263
+ ## Pitfalls and constraints
264
+
265
+ - Flattening arbitrary service payloads can create unbounded or sensitive tags. Callers must submit an intentional bounded projection.
266
+ - Verify both typed constants/enums and raw wire values before changing a logical condition in this legacy package.
267
+ - `sendBehavioralMetric` called before `Meetings` reaches `READY` throws, because no host is stored yet.
268
+ - Two flattened paths can collide (`{a_b: 1, a: {b: 2}}` yields one `a_b` key; the later entry wins).
269
+ - Caller tags named like the metrics plugin's environment tags (`app_name`, `browser`, `os`, `domain`,
270
+ and others) are overwritten by the plugin.
271
+
272
+ ## Verification
273
+
274
+ Use the current mirrored suites: `test/unit/spec/metrics/index.js`. Characterize the metrics-specific
275
+ use cases above and each listed failure condition; add cleanup or transition cases only for resources
276
+ and state this module actually owns.
277
+
278
+ | Behavior / Requirement | Existing test evidence | Gap |
279
+ |---|---|---|
280
+ | `METRICS-R-001` | `test/unit/spec/metrics/index.js` | cover singleton setup, submission, and recursive flattening branches |
281
+ | `METRICS-R-002` | `test/unit/spec/metrics/index.js` | nested arrays and a root `null` are covered; add prefixed primitives and nested `null` values |
282
+ | `METRICS-R-003` | `test/unit/spec/metrics/index.js` | assert the exact `submitClientMetrics` call and the method's `undefined` return |
283
+ | `METRICS-R-004` | `test/unit/spec/metrics/index.js` | the suite uses the default instance but never constructs a second one |
284
+ | `METRICS-R-005` | None found | no case pins a `BEHAVIORAL_METRICS` value |
285
+
286
+ A module specification is complete only when its public surface, invariants, failure modes, and test
287
+ evidence agree with the implementation.