@mondaydotcomorg/z2h-shared-utils 0.7.3 → 0.7.4

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/CHANGELOG.md ADDED
@@ -0,0 +1,468 @@
1
+ # CHANGELOG
2
+
3
+ ## `0.7.3` (October 5, 2026, 13:41)
4
+
5
+ ### Improvements
6
+
7
+ - [#509](https://github.com/DaPulse/bigbrain-z2h/pull/509) refactor(z2h): move bucket and app-name constants to z2h-shared-utils (@eitan-ts)
8
+ - Added: New `constants.ts` module exporting S3 bucket, manifest, skills, and app-name configuration constants that were previously only available from `@mondaydotcomorg/z2h-cli`. These constants are now part of the public API of this package.
9
+ *Usage:*
10
+ ```ts
11
+ import { BUCKET_WRITE_NAME, REGION, MANIFEST_KEY } from '@mondaydotcomorg/z2h-shared-utils';
12
+ ```
13
+ - Added: `BUCKET_WRITE_NAME` constant (`'prod-use1-bigbrain-zth-mf-assets'`) for the S3 bucket used for writing Z2H microfrontend assets.
14
+ - Added: `REGION` constant (`'us-east-1'`) for the AWS region of the Z2H asset bucket.
15
+ - Added: `BUCKET_WRITE_URL` constant computed as `https://${BUCKET_WRITE_NAME}.s3.${REGION}.amazonaws.com` for direct S3 uploads.
16
+ - Added: `BUCKET_READ_DNS_NAME` constant (`'bigbrain-zth-mf-assets'`) for the CloudFront/DNS-fronted bucket name.
17
+ - Added: `BUCKET_READ_DNS_URL` constant (`https://${BUCKET_READ_DNS_NAME}.bigbrain.me`) for reading deployed assets via CDN.
18
+ - Added: `S3_PREVIEWS_FOLDER` constant (`'previews'`) defining the root prefix for ephemeral preview uploads.
19
+ - Added: `MANIFEST_KEY` constant (`'mf-assets'`) for the S3 key where the manifest JSON lives (without `.json` extension, as TridentSkeleton appends `/mf-assets` to the bucket base).
20
+ - Added: `MANIFEST_READ_URL` constant computed as `${BUCKET_READ_DNS_URL}/${MANIFEST_KEY}` for fetching the production manifest.
21
+ - Added: `S3_SKILLS_BUCKET_NAME` constant (`'prod-use1-bigbrain-zth-skills'`) for the read-only skills bucket used by the broker and agent.
22
+ - Added: `DATAVIZ_SKILLS_PREFIX` constant (`'dataviz/'`) for the S3 prefix where data-cookbook publishes design-system skills.
23
+ - Added: `APP_NAME_PATTERN` regular expression (`/^[a-z][a-z0-9-]{1,49}$/`) for validating Z2H app names (lowercase kebab-case, starts with a letter, 2-50 characters). The backend broker rejects names that don't match this pattern with HTTP 400.
24
+ *Usage:*
25
+ ```ts
26
+ import { APP_NAME_PATTERN } from '@mondaydotcomorg/z2h-shared-utils';
27
+ if (!APP_NAME_PATTERN.test(appName)) {
28
+ throw new Error('Invalid app name format');
29
+ }
30
+ ```
31
+ - Added: `PREVIEW_APP_NAME_PREFIX` constant (`'zth-preview-'`) for the naming convention of preview deployments.
32
+ - Changed: Package now exports all constants from the new `constants.ts` module via the main `index.ts` entry point.
33
+
34
+ ## `0.7.2` (October 1, 2026, 13:00)
35
+
36
+ ### Bug Fixes
37
+
38
+ - [#494](https://github.com/DaPulse/bigbrain-z2h/pull/494) fix(z2h-cli): track only opted-in commands under enum event names (@arielmonday)
39
+ - Added 8 new CLI event name constants to the `Z2hCliEvents` object: `deploySuccess` (`'z2h_app_deploy_success'`), `previewSuccess` (`'z2h_app_preview_success'`), `createSuccess` (`'z2h_app_created'`), `templatesSuccess` (`'z2h_cli_templates_success'`), `generateAppTemplateSuccess` (`'z2h_cli_generate_app_template_success'`), `editSuccess` (`'z2h_app_edit_pulled'`), `buildSuccess` (`'z2h_app_build_success'`), and `deleteSuccess` (`'z2h_app_delete_success'`).
40
+ - Exported a new type `Z2hCliEventName` from `observability/events.ts` and `observability/index.ts`, defined as `(typeof Z2hCliEvents)[keyof typeof Z2hCliEvents]`. This type represents all valid CLI event names and is used in `z2h-cli` to enforce that the `event` field in `CommandSpec` only accepts known event names.
41
+ *Usage:*
42
+ ```ts
43
+ import { Z2hCliEvents, type Z2hCliEventName } from '@mondaydotcomorg/z2h-shared-utils/observability';
44
+
45
+ function trackCommand(event: Z2hCliEventName) {
46
+ // event is constrained to Z2hCliEvents values
47
+ }
48
+ trackCommand(Z2hCliEvents.deploySuccess); // ✓
49
+ trackCommand('z2h_cli_unknown'); // ✗ Type error
50
+ ```
51
+
52
+ ## `0.7.1` (September 30, 2026, 09:49)
53
+
54
+ ### Improvements
55
+
56
+ - [#488](https://github.com/DaPulse/bigbrain-z2h/pull/488) feat(z2h): sandbox run — backend invoke runs the local handler before deploy (@EranZidkiya)
57
+ - Added: New `sandbox` entry in the `BackendRunnerEvents` object for observability of sandbox runs, including four new metric/event names: `successMetric: 'z2h.backend_sandbox.success'`, `failureMetric: 'z2h.backend_sandbox.error'`, `biEvent: 'z2h_backend_sandbox_run'`, and `channelCallMetric: 'z2h.backend_sandbox.channel_call'`.
58
+ *Usage:*
59
+ ```typescript
60
+ import { BackendRunnerEvents } from '@mondaydotcomorg/z2h-shared-utils';
61
+ // Access sandbox metrics:
62
+ const successMetric = BackendRunnerEvents.sandbox.successMetric; // 'z2h.backend_sandbox.success'
63
+ const channelMetric = BackendRunnerEvents.sandbox.channelCallMetric; // 'z2h.backend_sandbox.channel_call'
64
+ ```
65
+
66
+ ## `0.7.0` (September 30, 2026, 03:58)
67
+
68
+ ### New Features
69
+
70
+ - [#478](https://github.com/DaPulse/bigbrain-z2h/pull/478) Feat/yarin/custom pat channel zth-runner channel integration (@yarinmonday)
71
+
72
+ ## `0.6.2` (September 17, 2026, 10:56)
73
+
74
+ ### Bug Fixes
75
+
76
+ - [#445](https://github.com/DaPulse/bigbrain-z2h/pull/445) fix(bigbrain-zth-agent): add run-limit guards to stop stuck subagent loops before recursion crash (@arielmonday)
77
+ - Added: New event constants in `Z2hAgentEvents` for tracking agent run limit hits. The `subagents.runLimitHit` event (`'z2h.subagents.run_limit_hit'`) fires when a subagent (cli-runner or general-purpose) reaches its configured call limit before hitting LangGraph's hard recursion limit. The `mainAgent.runLimitHit` event (`'z2h.main_agent.run_limit_hit'`) fires when the main agent hits LangGraph's hard recursion limit. These events enable Datadog metric emission for monitoring stuck loops that would otherwise cause crashes.
78
+ *Usage:*
79
+ ```ts
80
+ import { Z2hAgentEvents } from '@mondaydotcomorg/z2h-shared-utils';
81
+
82
+ // Emit when subagent hits run limit
83
+ metrics.increment(Z2hAgentEvents.subagents.runLimitHit, { thread_id: threadId });
84
+
85
+ // Emit when main agent hits hard limit
86
+ metrics.increment(Z2hAgentEvents.mainAgent.runLimitHit, { thread_id: threadId });
87
+ ```
88
+
89
+ ## `0.6.1` (September 16, 2026, 12:43)
90
+
91
+ ### Bug Fixes
92
+
93
+ - [#447](https://github.com/DaPulse/bigbrain-z2h/pull/447) fix(z2h-shared-utils): stop eagerly loading trident-backend-api from root barrel (@eitan-ts)
94
+ - **Breaking**: Removed `secrets/` module from the root barrel export (`src/index.ts`). The `secrets/` module statically imports `@mondaydotcomorg/trident-backend-api`, which is declared as an optional peer dependency. This eager re-export caused `MODULE_NOT_FOUND` errors in downstream packages like `z2h-cli` that import unrelated constants from the root barrel but do not have `trident-backend-api` installed. To access secrets functionality, consumers must now use the subpath export `@mondaydotcomorg/z2h-shared-utils/secrets` instead of importing from the package root.
95
+ *Before:*
96
+ ```ts
97
+ import { encryptSecret, decryptSecret } from '@mondaydotcomorg/z2h-shared-utils';
98
+ ```
99
+ *After:*
100
+ ```ts
101
+ import { encryptSecret, decryptSecret } from '@mondaydotcomorg/z2h-shared-utils/secrets';
102
+ ```
103
+ - Fixed: Fresh global installations of `@mondaydotcomorg/z2h-cli` (versions ≥0.28.0) no longer crash with `MODULE_NOT_FOUND: Cannot find module '@mondaydotcomorg/trident-backend-api'` when running any CLI command. The CLI imports `ALWAYS_ON_CHANNELS` and `DECLARED_INTEGRATIONS` from `z2h-shared-utils` but never uses `trident-backend-api`, so the removed re-export eliminates the transitive static import that caused the crash.
104
+
105
+ ## `0.6.0` (September 16, 2026, 09:13)
106
+
107
+ ### New Features
108
+
109
+ - [#426](https://github.com/DaPulse/bigbrain-z2h/pull/426) feat(z2h-cli): validate backend handlers with acorn AST (@eitan-ts)
110
+ - Added: Backend channel constants and types exported from package root. `ALWAYS_ON_CHANNELS` is a readonly array `['db', 'llm', 'snowflake']` representing channels that need no OAuth and are never declared. `DECLARED_INTEGRATIONS` is a readonly array `['monday']` representing OAuth-gated integrations that must be declared.
111
+ *Usage:*
112
+ ```ts
113
+ import { ALWAYS_ON_CHANNELS, DECLARED_INTEGRATIONS, type AlwaysOnChannel, type DeclaredIntegration } from '@mondaydotcomorg/z2h-shared-utils';
114
+ ```
115
+ - Added: `AlwaysOnChannel` type, a union of always-on channel names: `'db' | 'llm' | 'snowflake'`.
116
+ - Added: `DeclaredIntegration` type, a union of declared integration names: `'monday'`.
117
+ - Added: `handlerParseError` event constant (`'z2h_cli_handler_parse_error'`) to `Z2hCliEvents` object in `@mondaydotcomorg/z2h-shared-utils/observability/events`. This event is emitted by the CLI when a backend handler fails to parse.
118
+
119
+ ## `0.5.0` (September 15, 2026, 10:53)
120
+
121
+ ### New Features
122
+
123
+ - [#435](https://github.com/DaPulse/bigbrain-z2h/pull/435) feat(z2h-shared-utils): add secret-cipher — AES-256-GCM encryption for PATs at rest (@yarinmonday)
124
+ - Added: New `encryptSecret` function for encrypting plaintext secrets using AES-256-GCM encryption. The function returns a versioned encrypted blob string with embedded salt, IV, and authentication tag. The encryption key is derived via scrypt from a passphrase stored in the `z2h_secrets_key` configuration variable.
125
+ ```ts
126
+ import { encryptSecret } from '@mondaydotcomorg/z2h-shared-utils';
127
+
128
+ const encrypted = encryptSecret('my-secret-token');
129
+ // Returns: 'v1:<iv>:<salt>:<tag>:<encrypted-data>' (all base64-encoded)
130
+ ```
131
+ - Added: New `decryptSecret` function for decrypting encrypted secret blobs produced by `encryptSecret`. The function validates the blob format, version, and authentication tag before decrypting.
132
+ ```ts
133
+ import { decryptSecret } from '@mondaydotcomorg/z2h-shared-utils';
134
+
135
+ const plaintext = decryptSecret(encryptedBlob);
136
+ // Returns: 'my-secret-token'
137
+ ```
138
+ - Added: Internal key derivation caching mechanism that caches up to 256 derived keys by (passphrase-hash, salt) pairs to optimize repeated encryption/decryption operations without re-running scrypt.
139
+ - Changed: Package now exports public API from `src/secrets/secret-cipher.ts` via the main entry point. Previously the package exported an empty object.
140
+ *Before:*
141
+ ```ts
142
+ // src/index.ts
143
+ export {};
144
+ ```
145
+ *After:*
146
+ ```ts
147
+ // src/index.ts
148
+ export * from './secrets';
149
+ ```
150
+ - Added: Encryption scheme uses a versioned format (`v1:` prefix) to support future key rotation or algorithm changes without breaking existing encrypted blobs.
151
+ - Added: The implementation enforces a full-length GCM authentication tag (16 bytes) to maintain 2^128 forgery resistance and prevent truncation attacks.
152
+ - Added: Each encrypted blob includes a unique random 16-byte salt, ensuring that encrypting the same plaintext multiple times produces different ciphertext outputs.
153
+ - Added: The passphrase source function reads from `Api.getPart('configurationVariables')?.get('z2h_secrets_key')` expecting a `{ key: string }` object structure. The `encryptSecret` and `decryptSecret` functions will throw an error if this configuration variable is not set.
154
+
155
+ ## `0.4.3` (September 9, 2026, 10:21)
156
+
157
+ ### Improvements
158
+
159
+ - [#419](https://github.com/DaPulse/bigbrain-z2h/pull/419) feat(zth-backend-runner): emit a Datadog metric for the snowflake channel cache (@eitan-ts)
160
+ - Added: New `cacheMetric` event constant (`'z2h.channel.snowflake.cache'`) to `BackendRunnerEvents.snowflake` for tracking Snowflake query cache hits and misses in Datadog. This metric is incremented by the snowflake channel with `appName` and `result` tags (`hit` or `miss`) to provide visibility into cache effectiveness.
161
+ *Usage:*
162
+ ```ts
163
+ import { BackendRunnerEvents } from '@mondaydotcomorg/z2h-shared-utils';
164
+
165
+ // The new metric is available at:
166
+ BackendRunnerEvents.snowflake.cacheMetric // 'z2h.channel.snowflake.cache'
167
+ ```
168
+
169
+ ## Unreleased
170
+
171
+ ### Improvements
172
+
173
+ - Added `BackendRunnerEvents.snowflake.cacheMetric` (`'z2h.channel.snowflake.cache'`) — a Datadog counter for the snowflake channel's Redis-backed query cache, tagged by `appName` and `result` (`hit`/`miss`), so cache effectiveness is visible in Datadog rather than only in the BI event.
174
+
175
+ ## `0.4.2` (September 8, 2026, 11:37)
176
+
177
+ ### Improvements
178
+
179
+ - [#414](https://github.com/DaPulse/bigbrain-z2h/pull/414) feat(zth-backend-runner): emit per-channel success and failure telemetry (@eitan-ts)
180
+ - Changed: Renamed `BackendRunnerEvents.invoke.succeeded` to `BackendRunnerEvents.invoke.successMetric` to clarify it emits a Datadog metric rather than a BI event.
181
+ *Before:*
182
+ ```ts
183
+ BackendRunnerEvents.invoke.succeeded // 'z2h.backend_invoke.success'
184
+ ```
185
+ *After:*
186
+ ```ts
187
+ BackendRunnerEvents.invoke.successMetric // 'z2h.backend_invoke.success'
188
+ ```
189
+
190
+ - Changed: Renamed `BackendRunnerEvents.invoke.failed` to `BackendRunnerEvents.invoke.failureMetric` to clarify it emits a Datadog metric rather than a BI event.
191
+ *Before:*
192
+ ```ts
193
+ BackendRunnerEvents.invoke.failed // 'z2h.backend_invoke.error'
194
+ ```
195
+ *After:*
196
+ ```ts
197
+ BackendRunnerEvents.invoke.failureMetric // 'z2h.backend_invoke.error'
198
+ ```
199
+
200
+ - Added: New `BackendRunnerEvents.invoke.biEvent` constant with value `'z2h_backend_invoke'` for tracking invoke outcomes via BI events.
201
+ *Usage:*
202
+ ```ts
203
+ BackendRunnerEvents.invoke.biEvent // 'z2h_backend_invoke'
204
+ ```
205
+
206
+ - Added: New `BackendRunnerEvents.channel` section containing three telemetry constants for unified channel call tracking:
207
+ - `callMetric`: `'z2h.channel.call'` (Datadog metric for success/failure by app, channel, method)
208
+ - `durationMetric`: `'z2h.channel.duration_ms'` (Datadog metric for latency by app, channel, method)
209
+ - `biEvent`: `'z2h_channel_call'` (BI event with outcome field)
210
+ *Usage:*
211
+ ```ts
212
+ BackendRunnerEvents.channel.callMetric // 'z2h.channel.call'
213
+ BackendRunnerEvents.channel.durationMetric // 'z2h.channel.duration_ms'
214
+ BackendRunnerEvents.channel.biEvent // 'z2h_channel_call'
215
+ ```
216
+
217
+ - Changed: Updated top-level JSDoc comment to clarify that `*Metric`-suffixed properties emit Datadog metrics via `metric.*` with bounded tags, while other properties are BI events sent via `trackEvent`. This distinguishes between the two telemetry destinations and their constraints.
218
+
219
+ ## Unreleased
220
+
221
+ ### Improvements
222
+
223
+ - **Breaking**: Split `BackendRunnerEvents.invoke` into separate Datadog-metric and BI-event names, matching the `*Metric` / `biEvent` convention already used by `Z2hAgentEvents.toolCall`. `succeeded` is now `successMetric` and `failed` is now `failureMetric` (both keep their existing name strings), and the new `biEvent` (`'z2h_backend_invoke'`) replaces them as the BI event name. Success and failure are now distinguished by an `outcome` field on the event rather than by two separate event names, so analytics querying `z2h.backend_invoke.success` / `z2h.backend_invoke.error` as BI events must move to `z2h_backend_invoke` and filter on `outcome`.
224
+ *Before:*
225
+ ```ts
226
+ BackendRunnerEvents.invoke.succeeded; // 'z2h.backend_invoke.success'
227
+ BackendRunnerEvents.invoke.failed; // 'z2h.backend_invoke.error'
228
+ ```
229
+ *After:*
230
+ ```ts
231
+ BackendRunnerEvents.invoke.successMetric; // 'z2h.backend_invoke.success' (Datadog)
232
+ BackendRunnerEvents.invoke.failureMetric; // 'z2h.backend_invoke.error' (Datadog)
233
+ BackendRunnerEvents.invoke.biEvent; // 'z2h_backend_invoke' (BI, has `outcome`)
234
+ ```
235
+ - Added `BackendRunnerEvents.channel` constants for the unified per-channel call counter, duration distribution, and BI event. These names support success and failure rates grouped by app, channel, and method.
236
+
237
+ ## `0.4.1` (September 6, 2026, 09:22)
238
+
239
+ ### Improvements
240
+
241
+ - [#372](https://github.com/DaPulse/bigbrain-z2h/pull/372) refactor(z2h-cli): single command wrapper for telemetry + bounded failure reasons (@eitan-ts)
242
+ - **Breaking**: Changed `BackendRunnerEvents.invoke.succeeded` event name from `'z2h_backend_invoke_succeeded'` to `'z2h.backend_invoke.success'`. Update any code that references this event name constant or queries the old event name in analytics.
243
+ *Before:*
244
+ ```ts
245
+ BackendRunnerEvents.invoke.succeeded; // 'z2h_backend_invoke_succeeded'
246
+ ```
247
+ *After:*
248
+ ```ts
249
+ BackendRunnerEvents.invoke.succeeded; // 'z2h.backend_invoke.success'
250
+ ```
251
+ - **Breaking**: Changed `BackendRunnerEvents.invoke.failed` event name from `'z2h_backend_invoke_failed'` to `'z2h.backend_invoke.error'`. Update any code that references this event name constant or queries the old event name in analytics.
252
+ *Before:*
253
+ ```ts
254
+ BackendRunnerEvents.invoke.failed; // 'z2h_backend_invoke_failed'
255
+ ```
256
+ *After:*
257
+ ```ts
258
+ BackendRunnerEvents.invoke.failed; // 'z2h.backend_invoke.error'
259
+ ```
260
+ - Added: New `BackendRunnerEvents.integrationOAuth` object with three metric name constants: `revokeMetric` (`'z2h.integration_oauth.revoke'`), `revokeFailedMetric` (`'z2h.integration_oauth.revoke.error'`), and `tokenRequestMetric` (`'z2h.integration_oauth.token_request'`).
261
+ - Added: New `BackendRunnerEvents.integrationToken` object with three metric name constants: `decryptFailedMetric` (`'z2h.integration_token.decrypt_failed'`), `unexpectedShapeMetric` (`'z2h.integration_token.unexpected_shape'`), and `refreshMetric` (`'z2h.integration_token.refresh'`).
262
+ - Added: New `Z2hCliEvents` object exported from `@mondaydotcomorg/z2h-shared-utils/observability`, containing `error: 'z2h_cli_error'` for CLI error telemetry.
263
+ - **Breaking**: `trackEvent` is no longer exported from the root `@mondaydotcomorg/z2h-shared-utils/observability` entry. It now requires the Trident runtime and is only available via the new `/observability/trident` subpath export.
264
+ *Before:*
265
+ ```ts
266
+ import { trackEvent } from '@mondaydotcomorg/z2h-shared-utils/observability';
267
+ ```
268
+ *After:*
269
+ ```ts
270
+ import { trackEvent } from '@mondaydotcomorg/z2h-shared-utils/observability/trident';
271
+ ```
272
+ - Added: New `/observability/trident` subpath export for Trident-runtime-specific helpers. This subpath exports `trackEvent`, which depends on `@mondaydotcomorg/trident-backend-api`. Use the root `/observability` export for standalone processes (e.g., CLIs) that don't have the Trident runtime.
273
+ - Changed: `createHttpTracker` now returns an object with two methods: `trackEvent` and `trackDuration`. Previously it returned only the `trackEvent` function.
274
+ *Before:*
275
+ ```ts
276
+ const trackEvent = createHttpTracker(deps);
277
+ await trackEvent('event_name', { data });
278
+ ```
279
+ *After:*
280
+ ```ts
281
+ const { trackEvent, trackDuration } = createHttpTracker(deps);
282
+ await trackEvent('event_name', { data });
283
+ await trackDuration('event_name', async () => { /* work */ }, { data });
284
+ ```
285
+ - Added: New `HttpTracker` interface exported from `@mondaydotcomorg/z2h-shared-utils/observability`, defining the shape returned by `createHttpTracker`.
286
+ ```ts
287
+ interface HttpTracker {
288
+ trackEvent(name: string, data: Record<string, unknown>): Promise<void>;
289
+ trackDuration<T>(name: string, fn: () => Promise<T>, data?: Record<string, unknown>): Promise<T>;
290
+ }
291
+ ```
292
+ - Changed: `trackDuration` method now included in the `HttpTracker` return value. It times the provided function and automatically sends a `duration_ms` dimension with the event. If the function throws, the event is not sent and the error propagates.
293
+ - Changed: `trackEvent` in the Trident-runtime tracker (from `/observability/trident`) now returns `Promise<void>` instead of `void`, making it consistent with the HTTP tracker.
294
+ - Changed: Trident-runtime tracker warning message simplified from "bigbrain API part unavailable, was Runtime.init() called? Dropping event." to "bigbrain API part unavailable. Dropping event."
295
+ - Added: TypeScript `typesVersions` mapping for the new `/observability/trident` subpath export to support `moduleResolution: 'node'` (node10 resolution).
296
+
297
+ ## `0.4.0` (September 6, 2026, 07:21)
298
+
299
+ ### New Features
300
+
301
+ - [#378](https://github.com/DaPulse/bigbrain-z2h/pull/378) feat(dashboard-templates): release the z2h-dashboard-templates package (@EranZidkiya)
302
+ - Added: `dashboardTemplateHooks.ts` module defining TypeScript interfaces for dashboard template lifecycle hooks. These types enable templates to define custom transformation and setup logic that executes during dashboard generation.
303
+
304
+ - Added: `DashboardTemplateSetupAPI` interface exposing a `createBackend(handlerName: string, content: string): void` method. This API is passed to setup hooks, allowing them to programmatically create backend handler files during generation.
305
+ *Usage example:*
306
+ ```ts
307
+ function setupBackend(config, setupAPI: DashboardTemplateSetupAPI) {
308
+ setupAPI.createBackend('widget_query_0', 'export default async function handler() { ... }');
309
+ }
310
+ ```
311
+
312
+ - Added: `ToFrontendConfigHook<TConfig>` type alias for config transformation hooks. Functions of this type receive the raw config object and return a potentially modified config that will be embedded in the frontend bundle.
313
+ *Signature:*
314
+ ```ts
315
+ type ToFrontendConfigHook<TConfig = Record<string, unknown>> = (rawConfig: TConfig) => TConfig;
316
+ ```
317
+ *Usage example:*
318
+ ```ts
319
+ const toFrontendConfig: ToFrontendConfigHook<MyConfig> = (rawConfig) => {
320
+ // Strip server-only fields like SQL queries before bundling
321
+ return { ...rawConfig, widgets: rawConfig.widgets.map(w => omit(w, 'sql')) };
322
+ };
323
+ ```
324
+
325
+ - Added: `SetupBackendHook<TConfig>` type alias for backend setup hooks. Functions of this type receive the raw config and the `DashboardTemplateSetupAPI`, enabling them to create backend handlers based on config data.
326
+ *Signature:*
327
+ ```ts
328
+ type SetupBackendHook<TConfig = Record<string, unknown>> = (
329
+ rawConfig: TConfig,
330
+ setupAPI: DashboardTemplateSetupAPI
331
+ ) => void;
332
+ ```
333
+ *Usage example:*
334
+ ```ts
335
+ const setupBackend: SetupBackendHook<DashboardConfig> = (config, setupAPI) => {
336
+ config.widgets.forEach((widget, i) => {
337
+ setupAPI.createBackend(`widget_query_${i}`, generateHandlerCode(widget.sql));
338
+ });
339
+ };
340
+ ```
341
+
342
+ ## `0.3.4` (September 3, 2026, 06:26)
343
+
344
+ ### Bug Fixes
345
+
346
+ - [#403](https://github.com/DaPulse/bigbrain-z2h/pull/403) fix(z2h-shared-utils): preserve tracker this binding in trackEvent (@eitan-ts)
347
+ - Fixed: `trackEvent` function now correctly preserves the `this` binding when calling `tracker.sendBiEvent`. Previously, the function destructured `sendBiEvent` off the tracker instance, which caused the method to lose its `this` context. Since `sendBiEvent` internally calls `this.sendBiEventAsync`, this resulted in crashes with "Cannot read properties of undefined (reading 'sendBiEventAsync')" on every invocation. The fix ensures `sendBiEvent` is called through the tracker instance instead of as a detached reference. This bug affected any Studio agent reply that invoked a tool (write, deploy, `ls`, etc.), as `toolTelemetryMiddleware` calls `trackEvent` on every tool call.
348
+ *Before (broken):*
349
+ ```ts
350
+ const sendBiEvent = Api.getPart('bigbrain')?.tracker?.sendBiEvent;
351
+ if (!sendBiEvent) { return; }
352
+ sendBiEvent({ name, source, data });
353
+ ```
354
+ *After (fixed):*
355
+ ```ts
356
+ const tracker = Api.getPart('bigbrain')?.tracker;
357
+ if (!tracker) { return; }
358
+ tracker.sendBiEvent({ name, source, data });
359
+ ```
360
+
361
+ ## `0.3.3` (September 2, 2026, 15:08)
362
+
363
+ ### Improvements
364
+
365
+ - [#396](https://github.com/DaPulse/bigbrain-z2h/pull/396) feat(bigbrain-zth-agent): tool-call latency metric, cli-help gap counter, shared tracker (@eitan-ts)
366
+ - Added: New `Z2hAgentEvents` constant exported from `observability` module, providing standardized event and metric names for the z2h agent. This constant includes `subagents.cliHelpUnavailable` for tracking CLI help availability issues, and `toolCall.softFailureMetric` and `toolCall.biEvent` for tool call telemetry.
367
+ *Usage:*
368
+ ```ts
369
+ import { Z2hAgentEvents } from '@mondaydotcomorg/z2h-shared-utils';
370
+
371
+ // Track CLI help unavailability
372
+ metric.increment(Z2hAgentEvents.subagents.cliHelpUnavailable);
373
+
374
+ // Track tool call soft failures
375
+ metric.increment(Z2hAgentEvents.toolCall.softFailureMetric);
376
+
377
+ // Track tool call BI event
378
+ trackEvent(Z2hAgentEvents.toolCall.biEvent, eventData);
379
+ ```
380
+ - Changed: Documentation comments for `BackendRunnerEvents` and `Z2hServiceEvents` constants have been simplified. `BackendRunnerEvents` comment changed from "BI events tracked via `trackEvent` in zth-backend-runner, grouped by emitter" to "BI events tracked in zth-backend-runner, grouped by domain". `Z2hServiceEvents` comment changed from "Metric names emitted by `bigbrain-zth` via `metric.increment`/`metric.distribution`, grouped by domain" to "Metric names emitted by `bigbrain-zth`, grouped by domain". These changes clarify the grouping approach and remove implementation details from the documentation.
381
+ - Changed: The public API surface of the observability module now exports `Z2hAgentEvents` alongside the existing `BackendRunnerEvents` and `Z2hServiceEvents` exports.
382
+ *Before:*
383
+ ```ts
384
+ export { BackendRunnerEvents, Z2hServiceEvents } from './events';
385
+ ```
386
+ *After:*
387
+ ```ts
388
+ export { BackendRunnerEvents, Z2hServiceEvents, Z2hAgentEvents } from './events';
389
+ ```
390
+
391
+ ## `0.3.2` (September 2, 2026, 14:48)
392
+
393
+ ### Improvements
394
+
395
+ - [#385](https://github.com/DaPulse/bigbrain-z2h/pull/385) feat(z2h-obs): app load-failure origin split + Snowflake telemetry alignment (@eitan-ts)
396
+
397
+ ## `0.3.1` (September 2, 2026, 14:20)
398
+
399
+ ### Improvements
400
+
401
+ - [#393](https://github.com/DaPulse/bigbrain-z2h/pull/393) obs: emit BI events for backend-runner invoke/Snowflake, move shared to z2h-shared-utils (@eitan-ts)
402
+ - **Breaking**: The main package entry point (`index.ts`) no longer re-exports observability utilities. Imports must now use the specific `/observability` subpath.
403
+ *Before:*
404
+ ```ts
405
+ import { trackEvent } from '@mondaydotcomorg/z2h-shared-utils';
406
+ ```
407
+ *After:*
408
+ ```ts
409
+ import { trackEvent } from '@mondaydotcomorg/z2h-shared-utils/observability';
410
+ ```
411
+ - **Added**: New `BackendRunnerEvents` constant that provides a centralized registry of BI event names tracked by the backend runner. This prevents string literal duplication and serves as a single source of truth for tracked events.
412
+ *Usage:*
413
+ ```ts
414
+ import { BackendRunnerEvents } from '@mondaydotcomorg/z2h-shared-utils/observability';
415
+ trackEvent(BackendRunnerEvents.invoke.succeeded, { /* ... */ });
416
+ ```
417
+ - **Added**: Event definitions for backend invoke lifecycle (`z2h_backend_invoke_succeeded`, `z2h_backend_invoke_failed`) to track handler execution outcomes in the BI pipeline.
418
+ - **Added**: Event definition for Snowflake query execution (`z2h_snowflake_query_executed`) to track database query activity.
419
+ - **Added**: Event definitions for LLM calls (`z2h_llm_call`) and integration flows (`z2h_integration_connect_started`, `z2h_integration_connected`, `z2h_integration_connect_declined`) to support future observability requirements across backend runner channels.
420
+
421
+ ## `0.3.0` (September 2, 2026, 11:05)
422
+
423
+ ### New Features
424
+
425
+ - [#399](https://github.com/DaPulse/bigbrain-z2h/pull/399) refactor(z2h-cli): extract MF scaffold templates into z2h-shared-utils (@EranZidkiya)
426
+ - Added: New `mfScaffold.ts` module exposing microfrontend scaffold templates via the `./mf-scaffold` subpath export. This module provides reusable template strings and functions for generating Trident MF wrapper code, configuration files, and TypeScript declarations.
427
+ *Usage:*
428
+ ```ts
429
+ import {
430
+ WRAPPER_TEMPLATE,
431
+ tridentrcTemplate,
432
+ dtsFileTemplate,
433
+ TSCONFIG_TEMPLATE,
434
+ } from '@mondaydotcomorg/z2h-shared-utils/mf-scaffold';
435
+ ```
436
+ - Added: `WRAPPER_TEMPLATE` export — a complete React microfrontend wrapper template string with typed root management (`Map<HTMLElement, ReactDOM.Root>`), error boundary, and lifecycle methods (`init`, `render(element: HTMLElement)`, `unmount`).
437
+ - Added: `tridentrcTemplate(appName: string, port: number): string` export — generates `.tridentrc.js` configuration content for a given app name and port.
438
+ - Added: `dtsFileTemplate(): string` export — generates TypeScript declaration file content for common asset module types (CSS/SCSS modules, images, WASM, HTML, Rive files).
439
+ - Added: `TSCONFIG_TEMPLATE` export — a complete TypeScript configuration object for microfrontend projects with `moduleResolution: "bundler"`, React JSX transform, and appropriate compiler options for Trident MF builds.
440
+
441
+ ## `0.2.0` (August 31, 2026, 08:25)
442
+
443
+ ### New Features
444
+
445
+ - [#386](https://github.com/DaPulse/bigbrain-z2h/pull/386) feat(z2h-shared-utils): add shared utils package (observability/createTracker) (@eitan-ts)
446
+ - Added: New package `@mondaydotcomorg/z2h-shared-utils` providing shared backend-microservice utilities, initially focused on observability/tracking capabilities.
447
+ - Added: `trackEvent(name, data, source)` function for components running inside the Trident backend runtime (after `Runtime.init()`). Reads the live execution context via `Api.getPart('context')` from `@mondaydotcomorg/trident-backend-api` and automatically attaches the current user's name to all events. No-ops with a console warning if the bigbrain API part is unavailable, rather than throwing an error.
448
+ ```ts
449
+ import { trackEvent } from '@mondaydotcomorg/z2h-shared-utils';
450
+
451
+ trackEvent('feature_used', { feature: 'export' }, 'my-service');
452
+ // Automatically includes { user_name: '...' } from execution context
453
+ ```
454
+ - Added: `createHttpTracker({ url, source, getContext })` factory function for standalone processes that never bootstrap the Trident runtime (e.g., CLI tools). Returns an async tracker function that posts events directly over HTTP instead of using the bigbrain API. Network errors and timeouts (5s) are silently swallowed to ensure tracking failures never interrupt the caller.
455
+ ```ts
456
+ import { createHttpTracker } from '@mondaydotcomorg/z2h-shared-utils';
457
+
458
+ const trackEvent = createHttpTracker({
459
+ url: 'https://tracking.example.com/events',
460
+ source: 'z2h-cli',
461
+ getContext: () => ({ cli_version: '1.0.0' })
462
+ });
463
+
464
+ await trackEvent('command_run', { command: 'deploy' });
465
+ // Posts: { name: 'command_run', source: 'z2h-cli', data: { cli_version: '1.0.0', command: 'deploy' } }
466
+ ```
467
+ - Added: `HttpTrackerDeps` TypeScript interface defining the shape of dependencies for `createHttpTracker`: `url` (string), `source` (string), and `getContext` (function returning a record of context data).
468
+ - Changed: Package structure uses `src/observability/` as a scoped directory to allow future unrelated shared utilities to coexist without organizational churn.
@@ -10,4 +10,7 @@ export declare const S3_SKILLS_BUCKET_NAME = "prod-use1-bigbrain-zth-skills";
10
10
  export declare const DATAVIZ_SKILLS_PREFIX = "dataviz/";
11
11
  export declare const APP_NAME_PATTERN: RegExp;
12
12
  export declare const PREVIEW_APP_NAME_PREFIX = "zth-preview-";
13
+ export declare const APP_USAGE_BUCKET_NAME = "de-integration-bigbrain";
14
+ export declare const APP_USAGE_PREFIX = "prod/studio/entity=app_usage";
15
+ export declare const appUsageFolder: (appName: string, appId: number) => string;
13
16
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AACpE,eAAO,MAAM,MAAM,cAAc,CAAC;AAClC,eAAO,MAAM,gBAAgB,wEAA4D,CAAC;AAE1F,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,+CAAgD,CAAC;AAGjF,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAI7C,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,iBAAiB,yDAA2C,CAAC;AAG1E,eAAO,MAAM,qBAAqB,kCAAkC,CAAC;AAGrE,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAGhD,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AAEzD,eAAO,MAAM,uBAAuB,iBAAiB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AACpE,eAAO,MAAM,MAAM,cAAc,CAAC;AAClC,eAAO,MAAM,gBAAgB,wEAA4D,CAAC;AAE1F,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,+CAAgD,CAAC;AAGjF,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAI7C,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,iBAAiB,yDAA2C,CAAC;AAG1E,eAAO,MAAM,qBAAqB,kCAAkC,CAAC;AAGrE,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAGhD,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AAEzD,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAGtD,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAC/D,eAAO,MAAM,gBAAgB,iCAAiC,CAAC;AAC/D,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,OAAO,MAAM,WAA8C,CAAC"}
package/dist/constants.js CHANGED
@@ -18,8 +18,14 @@ const DATAVIZ_SKILLS_PREFIX = 'dataviz/';
18
18
  // Lowercase kebab-case, starts with a letter, 2-50 chars. Broker rejects anything else with 400.
19
19
  const APP_NAME_PATTERN = /^[a-z][a-z0-9-]{1,49}$/;
20
20
  const PREVIEW_APP_NAME_PREFIX = 'zth-preview-';
21
+ // Every object dropped under this prefix becomes one appended row in BIGBRAIN.L0.STUDIO_APP_USAGE.
22
+ const APP_USAGE_BUCKET_NAME = 'de-integration-bigbrain';
23
+ const APP_USAGE_PREFIX = 'prod/studio/entity=app_usage';
24
+ const appUsageFolder = (appName, appId) => `${APP_USAGE_PREFIX}/${appName}_${appId}`;
21
25
 
22
26
  exports.APP_NAME_PATTERN = APP_NAME_PATTERN;
27
+ exports.APP_USAGE_BUCKET_NAME = APP_USAGE_BUCKET_NAME;
28
+ exports.APP_USAGE_PREFIX = APP_USAGE_PREFIX;
23
29
  exports.BUCKET_READ_DNS_NAME = BUCKET_READ_DNS_NAME;
24
30
  exports.BUCKET_READ_DNS_URL = BUCKET_READ_DNS_URL;
25
31
  exports.BUCKET_WRITE_NAME = BUCKET_WRITE_NAME;
@@ -31,3 +37,4 @@ exports.PREVIEW_APP_NAME_PREFIX = PREVIEW_APP_NAME_PREFIX;
31
37
  exports.REGION = REGION;
32
38
  exports.S3_PREVIEWS_FOLDER = S3_PREVIEWS_FOLDER;
33
39
  exports.S3_SKILLS_BUCKET_NAME = S3_SKILLS_BUCKET_NAME;
40
+ exports.appUsageFolder = appUsageFolder;
@@ -10,4 +10,7 @@ export declare const S3_SKILLS_BUCKET_NAME = "prod-use1-bigbrain-zth-skills";
10
10
  export declare const DATAVIZ_SKILLS_PREFIX = "dataviz/";
11
11
  export declare const APP_NAME_PATTERN: RegExp;
12
12
  export declare const PREVIEW_APP_NAME_PREFIX = "zth-preview-";
13
+ export declare const APP_USAGE_BUCKET_NAME = "de-integration-bigbrain";
14
+ export declare const APP_USAGE_PREFIX = "prod/studio/entity=app_usage";
15
+ export declare const appUsageFolder: (appName: string, appId: number) => string;
13
16
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AACpE,eAAO,MAAM,MAAM,cAAc,CAAC;AAClC,eAAO,MAAM,gBAAgB,wEAA4D,CAAC;AAE1F,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,+CAAgD,CAAC;AAGjF,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAI7C,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,iBAAiB,yDAA2C,CAAC;AAG1E,eAAO,MAAM,qBAAqB,kCAAkC,CAAC;AAGrE,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAGhD,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AAEzD,eAAO,MAAM,uBAAuB,iBAAiB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,qCAAqC,CAAC;AACpE,eAAO,MAAM,MAAM,cAAc,CAAC;AAClC,eAAO,MAAM,gBAAgB,wEAA4D,CAAC;AAE1F,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,+CAAgD,CAAC;AAGjF,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAI7C,eAAO,MAAM,YAAY,cAAc,CAAC;AACxC,eAAO,MAAM,iBAAiB,yDAA2C,CAAC;AAG1E,eAAO,MAAM,qBAAqB,kCAAkC,CAAC;AAGrE,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAGhD,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AAEzD,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAGtD,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAC/D,eAAO,MAAM,gBAAgB,iCAAiC,CAAC;AAC/D,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,OAAO,MAAM,WAA8C,CAAC"}
@@ -16,5 +16,9 @@ const DATAVIZ_SKILLS_PREFIX = 'dataviz/';
16
16
  // Lowercase kebab-case, starts with a letter, 2-50 chars. Broker rejects anything else with 400.
17
17
  const APP_NAME_PATTERN = /^[a-z][a-z0-9-]{1,49}$/;
18
18
  const PREVIEW_APP_NAME_PREFIX = 'zth-preview-';
19
+ // Every object dropped under this prefix becomes one appended row in BIGBRAIN.L0.STUDIO_APP_USAGE.
20
+ const APP_USAGE_BUCKET_NAME = 'de-integration-bigbrain';
21
+ const APP_USAGE_PREFIX = 'prod/studio/entity=app_usage';
22
+ const appUsageFolder = (appName, appId) => `${APP_USAGE_PREFIX}/${appName}_${appId}`;
19
23
 
20
- export { APP_NAME_PATTERN, BUCKET_READ_DNS_NAME, BUCKET_READ_DNS_URL, BUCKET_WRITE_NAME, BUCKET_WRITE_URL, DATAVIZ_SKILLS_PREFIX, MANIFEST_KEY, MANIFEST_READ_URL, PREVIEW_APP_NAME_PREFIX, REGION, S3_PREVIEWS_FOLDER, S3_SKILLS_BUCKET_NAME };
24
+ export { APP_NAME_PATTERN, APP_USAGE_BUCKET_NAME, APP_USAGE_PREFIX, BUCKET_READ_DNS_NAME, BUCKET_READ_DNS_URL, BUCKET_WRITE_NAME, BUCKET_WRITE_URL, DATAVIZ_SKILLS_PREFIX, MANIFEST_KEY, MANIFEST_READ_URL, PREVIEW_APP_NAME_PREFIX, REGION, S3_PREVIEWS_FOLDER, S3_SKILLS_BUCKET_NAME, appUsageFolder };
@@ -1,2 +1,2 @@
1
- export { APP_NAME_PATTERN, BUCKET_READ_DNS_NAME, BUCKET_READ_DNS_URL, BUCKET_WRITE_NAME, BUCKET_WRITE_URL, DATAVIZ_SKILLS_PREFIX, MANIFEST_KEY, MANIFEST_READ_URL, PREVIEW_APP_NAME_PREFIX, REGION, S3_PREVIEWS_FOLDER, S3_SKILLS_BUCKET_NAME } from './constants.mjs';
1
+ export { APP_NAME_PATTERN, APP_USAGE_BUCKET_NAME, APP_USAGE_PREFIX, BUCKET_READ_DNS_NAME, BUCKET_READ_DNS_URL, BUCKET_WRITE_NAME, BUCKET_WRITE_URL, DATAVIZ_SKILLS_PREFIX, MANIFEST_KEY, MANIFEST_READ_URL, PREVIEW_APP_NAME_PREFIX, REGION, S3_PREVIEWS_FOLDER, S3_SKILLS_BUCKET_NAME, appUsageFolder } from './constants.mjs';
2
2
  export { ALWAYS_ON_CHANNELS, DECLARED_INTEGRATIONS } from './integrations.mjs';
@@ -78,6 +78,16 @@ export declare const Z2hAgentEvents: {
78
78
  readonly softFailureMetric: "z2h.agent_tool_call.soft_failure";
79
79
  readonly biEvent: "z2h_agent_tool_call";
80
80
  };
81
+ readonly asyncRun: {
82
+ readonly started: "z2h.agent_run.started";
83
+ readonly finished: "z2h.agent_run.finished";
84
+ readonly durationMs: "z2h.agent_run.duration_ms";
85
+ readonly sendMessageResponse: "z2h.send_message.response";
86
+ readonly busyRejected: "z2h.agent_run.busy_rejected";
87
+ readonly leaseHeartbeatFailed: "z2h.agent_run.lease_heartbeat_failed";
88
+ readonly redisUnavailable: "z2h.agent_run.redis_unavailable";
89
+ readonly statusPoll: "z2h.agent_status.poll";
90
+ };
81
91
  };
82
92
  /**
83
93
  * BI events tracked in `z2h-cli`. Every event the CLI sends is named here.
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/observability/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCtB,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC;AAEX,oDAAoD;AACpD,eAAO,MAAM,cAAc;;;;;;;;;;;;CAYjB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;CAWf,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/observability/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCtB,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC;AAEX,oDAAoD;AACpD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;CAuBjB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;CAWf,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
@@ -78,6 +78,17 @@ const Z2hAgentEvents = {
78
78
  softFailureMetric: 'z2h.agent_tool_call.soft_failure',
79
79
  biEvent: 'z2h_agent_tool_call',
80
80
  },
81
+ // send_message / get_message_status wait-or-jobId flow (active-run lease in Redis).
82
+ asyncRun: {
83
+ started: 'z2h.agent_run.started',
84
+ finished: 'z2h.agent_run.finished',
85
+ durationMs: 'z2h.agent_run.duration_ms',
86
+ sendMessageResponse: 'z2h.send_message.response',
87
+ busyRejected: 'z2h.agent_run.busy_rejected',
88
+ leaseHeartbeatFailed: 'z2h.agent_run.lease_heartbeat_failed',
89
+ redisUnavailable: 'z2h.agent_run.redis_unavailable',
90
+ statusPoll: 'z2h.agent_status.poll',
91
+ },
81
92
  };
82
93
  /**
83
94
  * BI events tracked in `z2h-cli`. Every event the CLI sends is named here.
package/dist/index.js CHANGED
@@ -6,6 +6,8 @@ const integrations = require('./integrations.js');
6
6
 
7
7
 
8
8
  exports.APP_NAME_PATTERN = constants.APP_NAME_PATTERN;
9
+ exports.APP_USAGE_BUCKET_NAME = constants.APP_USAGE_BUCKET_NAME;
10
+ exports.APP_USAGE_PREFIX = constants.APP_USAGE_PREFIX;
9
11
  exports.BUCKET_READ_DNS_NAME = constants.BUCKET_READ_DNS_NAME;
10
12
  exports.BUCKET_READ_DNS_URL = constants.BUCKET_READ_DNS_URL;
11
13
  exports.BUCKET_WRITE_NAME = constants.BUCKET_WRITE_NAME;
@@ -17,5 +19,6 @@ exports.PREVIEW_APP_NAME_PREFIX = constants.PREVIEW_APP_NAME_PREFIX;
17
19
  exports.REGION = constants.REGION;
18
20
  exports.S3_PREVIEWS_FOLDER = constants.S3_PREVIEWS_FOLDER;
19
21
  exports.S3_SKILLS_BUCKET_NAME = constants.S3_SKILLS_BUCKET_NAME;
22
+ exports.appUsageFolder = constants.appUsageFolder;
20
23
  exports.ALWAYS_ON_CHANNELS = integrations.ALWAYS_ON_CHANNELS;
21
24
  exports.DECLARED_INTEGRATIONS = integrations.DECLARED_INTEGRATIONS;
@@ -78,6 +78,16 @@ export declare const Z2hAgentEvents: {
78
78
  readonly softFailureMetric: "z2h.agent_tool_call.soft_failure";
79
79
  readonly biEvent: "z2h_agent_tool_call";
80
80
  };
81
+ readonly asyncRun: {
82
+ readonly started: "z2h.agent_run.started";
83
+ readonly finished: "z2h.agent_run.finished";
84
+ readonly durationMs: "z2h.agent_run.duration_ms";
85
+ readonly sendMessageResponse: "z2h.send_message.response";
86
+ readonly busyRejected: "z2h.agent_run.busy_rejected";
87
+ readonly leaseHeartbeatFailed: "z2h.agent_run.lease_heartbeat_failed";
88
+ readonly redisUnavailable: "z2h.agent_run.redis_unavailable";
89
+ readonly statusPoll: "z2h.agent_status.poll";
90
+ };
81
91
  };
82
92
  /**
83
93
  * BI events tracked in `z2h-cli`. Every event the CLI sends is named here.
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/observability/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCtB,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC;AAEX,oDAAoD;AACpD,eAAO,MAAM,cAAc;;;;;;;;;;;;CAYjB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;CAWf,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/observability/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCtB,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC;AAEX,oDAAoD;AACpD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;CAuBjB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;CAWf,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
@@ -80,6 +80,17 @@ const Z2hAgentEvents = {
80
80
  softFailureMetric: 'z2h.agent_tool_call.soft_failure',
81
81
  biEvent: 'z2h_agent_tool_call',
82
82
  },
83
+ // send_message / get_message_status wait-or-jobId flow (active-run lease in Redis).
84
+ asyncRun: {
85
+ started: 'z2h.agent_run.started',
86
+ finished: 'z2h.agent_run.finished',
87
+ durationMs: 'z2h.agent_run.duration_ms',
88
+ sendMessageResponse: 'z2h.send_message.response',
89
+ busyRejected: 'z2h.agent_run.busy_rejected',
90
+ leaseHeartbeatFailed: 'z2h.agent_run.lease_heartbeat_failed',
91
+ redisUnavailable: 'z2h.agent_run.redis_unavailable',
92
+ statusPoll: 'z2h.agent_status.poll',
93
+ },
83
94
  };
84
95
  /**
85
96
  * BI events tracked in `z2h-cli`. Every event the CLI sends is named here.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondaydotcomorg/z2h-shared-utils",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -77,4 +77,4 @@
77
77
  "url": "https://github.com/DaPulse/bigbrain-z2h.git",
78
78
  "directory": "packages/z2h-shared-utils"
79
79
  }
80
- }
80
+ }
package/src/constants.ts CHANGED
@@ -23,3 +23,8 @@ export const DATAVIZ_SKILLS_PREFIX = 'dataviz/';
23
23
  export const APP_NAME_PATTERN = /^[a-z][a-z0-9-]{1,49}$/;
24
24
 
25
25
  export const PREVIEW_APP_NAME_PREFIX = 'zth-preview-';
26
+
27
+ // Every object dropped under this prefix becomes one appended row in BIGBRAIN.L0.STUDIO_APP_USAGE.
28
+ export const APP_USAGE_BUCKET_NAME = 'de-integration-bigbrain';
29
+ export const APP_USAGE_PREFIX = 'prod/studio/entity=app_usage';
30
+ export const appUsageFolder = (appName: string, appId: number) => `${APP_USAGE_PREFIX}/${appName}_${appId}`;
@@ -80,6 +80,17 @@ export const Z2hAgentEvents = {
80
80
  softFailureMetric: 'z2h.agent_tool_call.soft_failure',
81
81
  biEvent: 'z2h_agent_tool_call',
82
82
  },
83
+ // send_message / get_message_status wait-or-jobId flow (active-run lease in Redis).
84
+ asyncRun: {
85
+ started: 'z2h.agent_run.started',
86
+ finished: 'z2h.agent_run.finished',
87
+ durationMs: 'z2h.agent_run.duration_ms',
88
+ sendMessageResponse: 'z2h.send_message.response',
89
+ busyRejected: 'z2h.agent_run.busy_rejected',
90
+ leaseHeartbeatFailed: 'z2h.agent_run.lease_heartbeat_failed',
91
+ redisUnavailable: 'z2h.agent_run.redis_unavailable',
92
+ statusPoll: 'z2h.agent_status.poll',
93
+ },
83
94
  } as const;
84
95
 
85
96
  /**