@servicetitan/docs-uikit 36.3.1 → 37.0.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.
@@ -3,6 +3,14 @@ title: BREAKING CHANGES
3
3
  sidebar_position: 0
4
4
  ---
5
5
 
6
+ ## v37.0.0
7
+
8
+ ### [@servicetitan/startup](./startup/)
9
+
10
+ Upgraded TypeScript from 5.x to 6.x, which turns several deprecated `tsconfig` options into hard errors and changes compiler defaults that can surface as new errors in consumer projects.
11
+
12
+ See the [TypeScript 6 upgrade guide](https://docs.st.dev/docs/frontend/upgrading-to-typescript-6) for the breaking changes and the `migrating-to-typescript-6` skill that automates the mechanical fixes.
13
+
6
14
  ## v36.0.0
7
15
 
8
16
  ### [@servicetitan/startup](./startup/)
@@ -46,7 +54,7 @@ This breaking change affects local development, even if you do not update the `@
46
54
 
47
55
  Removed support for hard-coded npm tokens in `.npmrc` files. The new `startup install` removes hard-coded authentication tokens from project `.npmrc` files and, in development environments, automatically adds a token to npm's per-user configuration that grants access to ServiceTitan's private packages.
48
56
 
49
- Projects that previously relied on hard-coded tokens must update their Github and Teamcity workflows to instead use the organization secret as described in the [startup install documentation](./startup/install#configuring-npm-token-in-ci):
57
+ Projects that previously relied on hard-coded tokens must update their Github and Teamcity workflows to instead use the organization secret as described in the [startup install documentation](./install#configuring-npm-token-in-ci):
50
58
 
51
59
  - Option 1: Inject the organization secret into `.npmrc`.
52
60
  - Option 2: Configure `.npmrc` to get the organization secret from an environment variable.
@@ -87,7 +87,11 @@ Shared uikit skills for ServiceTitan repos.
87
87
 
88
88
  #### Skills
89
89
 
90
- | Name | Description |
91
- | :------------------ | :------------------------------------------------------------------------------------------------------- |
92
- | `spell-check` | Check for spelling errors in code changes |
93
- | `switching-to-pnpm` | Migrate a project from npm to pnpm (see [migration guide](/docs/frontend/switching-to-pnpm)) |
90
+ | Name | Description |
91
+ | :---------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ |
92
+ | `check-shai-hulud` | Scan a developer machine for indicators of compromise from the 2026-05-19 Mini Shai-Hulud npm supply chain attack |
93
+ | `check-supply-chain` | Scan a developer machine for signs of npm supply chain compromise; routes to wave-specific skills such as `check-shai-hulud` |
94
+ | `running-startup-commands` | Run tests, lint, and builds via the `startup` CLI in projects that depend on `@servicetitan/startup` |
95
+ | `spell-check` | Check for spelling errors in code changes |
96
+ | `switching-to-pnpm` | Migrate a project from npm to pnpm (see [migration guide](/docs/frontend/switching-to-pnpm)) |
97
+ | `updating-mfe-check-workflow` | Diagnose and fix `mfe-check-shared-dependencies` workflow failures after the FAR-1776 reusable-workflow rewrite (validates each `mfe-path`/`host-path`) |
@@ -2,37 +2,71 @@
2
2
  title: DataDog RUM
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  #### [CHANGELOG (@servicetitan/datadog-rum)](https://github.com/servicetitan/uikit/blob/master/packages/datadog-rum/CHANGELOG.md)
6
9
 
7
- [`@servicetitan/datadog-rum`](https://github.com/servicetitan/uikit/tree/master/packages/datadog-rum) helps configure DataDog RUM JS SDK in standalone applications. It enriches RUM events with information useful for application and MFE monitoring, and troubleshooting.
10
+ [`@servicetitan/datadog-rum`](https://github.com/servicetitan/uikit/tree/master/packages/datadog-rum) configures DataDog RUM JS SDK and enriches its events for application and MFE monitoring and troubleshooting. It supports standalone applications and hosts that share a single RUM session with the MFEs they load.
8
11
 
9
- ## Configuration snippet
12
+ When a host loads MFEs (for example, the Monolith loading Task Hub), each MFE can register its own enrichment, tracing URLs, and persistent context through `init`. This avoids the failure mode where calling `datadogRum.init()` from more than one place would leak duplicate sessions and silently drop the second call's setup.
10
13
 
11
- ```tsx
12
- import { beforeSend, DatadogProvider } from '@servicetitan/datadog-rum';
13
- import { datadogRum } from '@datadog/browser-rum';
14
+ RUM events go through three enrichment stages: built-in attribution (MFE name, version, Cloudflare Ray ID), application-level handler, and per-service handlers.
14
15
 
15
- const isEnabled = /.*go\d*\.servicetitan\.com/.test(window.location.hostname);
16
+ ## End-to-end example
17
+
18
+ <Tabs
19
+ defaultValue="host"
20
+ values={[
21
+ { label: 'Host', value: 'host' },
22
+ { label: 'MFE', value: 'mfe' },
23
+ ]}
24
+ >
25
+ <TabItem value="host">
26
+
27
+ ```ts title="datadog-entry.ts"
28
+ import { init, type RumServiceRegistration } from '@servicetitan/datadog-rum';
29
+
30
+ export const isEnabled = /.*go\d*\.servicetitan\.com/.test(window.location.hostname);
31
+
32
+ let desktopRegistration: RumServiceRegistration | undefined;
16
33
 
17
34
  if (isEnabled) {
18
- datadogRum.init({
19
- applicationId: '<APPLICATION_ID>',
20
- clientToken: '<CLIENT_TOKEN>',
21
- site: 'datadoghq.com',
22
- service: '<SERVICE_NAME>',
23
- env: '<ENV_NAME>',
24
- version: '<APPLICATION_VERSION>',
25
- sessionSampleRate: 100,
26
- sessionReplaySampleRate: 0,
27
- defaultPrivacyLevel: 'mask-user-input',
28
- beforeSend: beforeSend(),
35
+ desktopRegistration = init({
36
+ service: {
37
+ name: 'desktop',
38
+ beforeSend: event => {
39
+ // enrich with 'desktop' service-specific context
40
+ },
41
+ },
42
+ application: {
43
+ applicationId: '<APPLICATION_ID>',
44
+ clientToken: '<CLIENT_TOKEN>',
45
+ env: window.location.hostname,
46
+ version: '<APPLICATION_VERSION>',
47
+ // Host-wide noise suppression. Locked at init, applies app-wide.
48
+ excludedActivityUrls: [/fullstory\.com/, /pendo\.io/, /\/Log\/Send/],
49
+ beforeSend: event => {
50
+ // optional: drop or transform events application-wide
51
+ return true;
52
+ },
53
+ },
29
54
  });
55
+
56
+ // Attach session-lifetime context to every 'desktop'-tagged event
57
+ desktopRegistration.setServiceContext({ logicalEnvironment: 'go5' });
30
58
  }
59
+ ```
60
+
61
+ ```tsx title="root.tsx"
62
+ import { DatadogProvider } from '@servicetitan/datadog-rum';
63
+ import { isEnabled } from './datadog-entry';
31
64
 
32
65
  const Root = () => {
33
66
  const user = useCurrentUser(); // application-specific hook that identifies the user
34
67
 
35
68
  return (
69
+ // Identify the current user to Datadog RUM
36
70
  <DatadogProvider isEnabled={isEnabled} user={user}>
37
71
  <Application />
38
72
  </DatadogProvider>
@@ -40,21 +74,268 @@ const Root = () => {
40
74
  };
41
75
  ```
42
76
 
43
- ## DatadogProvider
77
+ </TabItem>
78
+ <TabItem value="mfe">
79
+
80
+ ```tsx title="task-hub.tsx"
81
+ import { useEffect } from 'react';
82
+ import { useRumService } from '@servicetitan/datadog-rum';
83
+
84
+ const BFF_PATTERNS = [/\/api\/task-hub\//, /\/bff\//];
85
+
86
+ export const TaskHub = () => {
87
+ // Registers on mount; disposes automatically on unmount.
88
+ const { setServiceContext } = useRumService({
89
+ name: 'task-hub',
90
+ allowedTracingUrls: {
91
+ tracecontext: [url => BFF_PATTERNS.some(regex => regex.test(url))],
92
+ },
93
+ beforeSend: (event, context) => {
94
+ // attach MFE-specific context (transform-only — return value is ignored)
95
+ },
96
+ });
97
+
98
+ const orgId = useCurrentOrgId();
99
+
100
+ // Add persistent metadata to every event from this MFE
101
+ useEffect(() => {
102
+ setServiceContext({ logicalEnvironment: 'go5', orgId });
103
+ }, [orgId, setServiceContext]);
104
+
105
+ return <TaskHubApp />;
106
+ };
107
+ ```
108
+
109
+ For non-React entry points, use the imperative form:
110
+
111
+ ```ts title="task-hub-bootstrap.ts"
112
+ import { init } from '@servicetitan/datadog-rum';
113
+
114
+ const { cleanup, setServiceContext } = init({
115
+ service: {
116
+ name: 'task-hub',
117
+ allowedTracingUrls: {
118
+ tracecontext: [url => /\/api\/task-hub\//.test(url)],
119
+ },
120
+ beforeSend: (event, context) => {
121
+ // attach MFE-specific context
122
+ },
123
+ },
124
+ application: {
125
+ // optional — first caller wins; ignored if a host already initialized
126
+ applicationId: '<TASK_HUB_APPLICATION_ID>',
127
+ clientToken: '<TASK_HUB_CLIENT_TOKEN>',
128
+ env: window.location.hostname,
129
+ },
130
+ });
131
+
132
+ // Add persistent metadata to every event from this MFE
133
+ setServiceContext({ logicalEnvironment: 'go5', orgId: '123' });
134
+
135
+ // Tear down on MFE unmount
136
+ cleanup();
137
+ ```
138
+
139
+ </TabItem>
140
+ </Tabs>
141
+
142
+ ## API
143
+
144
+ | Name | Description |
145
+ | :------------------------------------ | :---------------------------------------------------------- |
146
+ | [`init`](#init) | Registers a service and optionally initializes the SDK |
147
+ | [`useRumService`](#userumservice) | React hook that registers a service and disposes on unmount |
148
+ | [`DatadogProvider`](#datadogprovider) | Identifies the current user to RUM (React component) |
149
+ | [`setUser`](#setuser) | Sets the current session user |
150
+ | [`beforeSend`](#beforesend) | Legacy event-enrichment helper |
151
+
152
+ Each app or MFE has a **service name** used to attribute every RUM event to its source. For MFEs loaded from unpkg, this name is inferred at event time from the package slug (`'task-hub'` for `@servicetitan/task-hub`) and is the key for per-service `beforeSend`, `allowedTracingUrls`, and persistent context lookups. The name you pass to [`init`](#init) or [`useRumService`](#userumservice) must exactly match this slug — i.e. the unscoped name in the MFE's `package.json`. A mismatch silently prevents per-service handlers from running for that MFE's events. `setServiceContext` is exposed as a property of the registration returned by [`init`](#init) and [`useRumService`](#userumservice), so the name is captured once at registration time and cannot drift.
153
+
154
+ ### `init`
155
+
156
+ Registers a service and, optionally, initializes the Datadog RUM SDK. Returns a [`RumServiceRegistration`](#rumserviceregistration) — `{ cleanup, setServiceContext }`, both bound to this service.
157
+
158
+ Any caller — host or MFE — may pass `application`. The first call that includes it initializes the SDK and becomes the SDK initializer; subsequent callers' `application` config is ignored with a warning. Callers that omit `application` register their service without attempting SDK init.
159
+
160
+ ```ts
161
+ import { init } from '@servicetitan/datadog-rum';
162
+
163
+ const { cleanup, setServiceContext } = init({
164
+ service: {
165
+ name: 'task-hub',
166
+ allowedTracingUrls: {
167
+ tracecontext: [url => /\/api\/task-hub\//.test(url)],
168
+ },
169
+ beforeSend: event => {
170
+ // transform-only (return value ignored)
171
+ },
172
+ },
173
+ application: {
174
+ applicationId: '<APPLICATION_ID>',
175
+ clientToken: '<CLIENT_TOKEN>',
176
+ env: window.location.hostname,
177
+ version: '<APPLICATION_VERSION>',
178
+ excludedActivityUrls: [/fullstory\.com/, /pendo\.io/, /\/Log\/Send/],
179
+ beforeSend: event => {
180
+ return true; // return false to drop the event app-wide
181
+ },
182
+ },
183
+ });
184
+
185
+ // Attach session-lifetime context merged into every 'task-hub'-tagged event
186
+ setServiceContext({ logicalEnvironment: 'go5', orgId: '123' });
187
+
188
+ // On teardown (e.g. MFE unmount):
189
+ cleanup();
190
+ ```
191
+
192
+ #### Parameters
193
+
194
+ `init` accepts an [`InitRumOptions`](#initrumoptions) object and returns a [`RumServiceRegistration`](#rumserviceregistration).
195
+
196
+ ##### `InitRumOptions` {#initrumoptions}
197
+
198
+ | Name | Type | Description |
199
+ | :------------ | :---------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
200
+ | `service` | [`ServiceConfig`](#serviceconfig) | Per-service handlers and tracing URL matchers |
201
+ | `application` | [`ApplicationConfig`](#applicationconfig) | (optional) SDK initialization config; first caller wins |
202
+ | `enabled` | `boolean` | (optional) Controls whether Datadog RUM data collection is turned on. Defaults to `true`. Set this instead of gating the `init` call to allow [runtime enablement for development](#dev-runtime-enable). |
203
+
204
+ ##### `RumServiceRegistration` {#rumserviceregistration}
44
205
 
45
- `DatadogProvider` is a higher-order component that supplies RUM SDK with:
206
+ | Name | Type | Description |
207
+ | :------------------ | :--------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
208
+ | `cleanup` | `() => void` | Removes this service's `beforeSend`, `allowedTracingUrls`, and persistent context. Idempotent. |
209
+ | `setServiceContext` | `(context: Context) => void` | Sets session-lifetime context merged into every event whose `event.service` matches this service's name. Replace semantics: a second call replaces the previous bag with no merge. |
210
+
211
+ ##### `ServiceConfig` {#serviceconfig}
212
+
213
+ | Name | Type | Description |
214
+ | :------------------- | :------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------ |
215
+ | `name` | `string` | Service name. For MFEs loaded from unpkg, must exactly match the unscoped `package.json` `name` (e.g. `'task-hub'` for `@servicetitan/task-hub`). |
216
+ | `beforeSend` | `ServiceBeforeSendHandler` | (optional) Transform-only per-service handler. Return value is **ignored** — services cannot drop events. |
217
+ | `allowedTracingUrls` | `Partial<Record<PropagatorType, TracingMatchOption[]>>` | (optional) URL matchers grouped by propagator type |
218
+
219
+ :::caution
220
+ A service's `beforeSend` cannot drop events. This is intentional: services share a session with the host and any other MFEs, so a bug in one service must not silently hide its own events from the host's monitoring. Use `application.beforeSend` for app-wide drop decisions.
221
+ :::
222
+
223
+ ##### `ApplicationConfig` {#applicationconfig}
224
+
225
+ Same shape as `datadogRum.init` config, minus `allowedTracingUrls` (built from service registrations) and `service` (derived from `service.name`), plus:
226
+
227
+ | Name | Type | Description |
228
+ | :----------- | :----------------------------- | :---------------------------------------------------------------------------------------------------------------------------- |
229
+ | `beforeSend` | `ApplicationBeforeSendHandler` | (optional) Application-level handler; runs for all events before service handlers. Return `false` to drop the event app-wide. |
230
+
231
+ Opinionated defaults (overridable):
232
+
233
+ - `sessionSampleRate: 100`
234
+ - `sessionReplaySampleRate: 0`
235
+ - `defaultPrivacyLevel: 'mask-user-input'`
236
+
237
+ Where:
238
+
239
+ - `PropagatorType` is `'datadog' | 'tracecontext' | 'b3' | 'b3multi'`.
240
+ - `TracingMatchOption` is `string` (prefix match), `RegExp`, or `(url: string) => boolean`.
241
+ - `ApplicationBeforeSendHandler` is `(event: RumEvent, context: RumEventDomainContext) => boolean | void`.
242
+ - `ServiceBeforeSendHandler` is `(event: RumEvent, context: RumEventDomainContext) => void`.
243
+
244
+ :::caution
245
+ `excludedActivityUrls` tells RUM which URLs not to count toward view-loading time. The exclusion applies app-wide; the first `application` config locks the list, so the host should set the complete list there. If an MFE set it, its choices would distort view metrics for the host and any other MFEs sharing the session.
246
+ :::
247
+
248
+ ### `useRumService`
249
+
250
+ React hook that wraps [`init`](#init) for service-only registration. The service is registered on mount and disposed on unmount; the config is captured on first render — changing it across renders does not re-register.
251
+
252
+ Returns a `RumService` — `{ setServiceContext }`, bound to this service. The handle is identity-stable across renders, so it can safely appear in dependency arrays.
253
+
254
+ On unmount the service's `beforeSend`, `allowedTracingUrls`, and any context previously set via `setServiceContext` are removed atomically. The SDK is **not** shut down — other services remain registered.
255
+
256
+ ```tsx
257
+ import { useEffect } from 'react';
258
+ import { useRumService } from '@servicetitan/datadog-rum';
259
+
260
+ const TaskHub = () => {
261
+ const { setServiceContext } = useRumService({
262
+ name: 'task-hub',
263
+ allowedTracingUrls: { tracecontext: [/\/api\/task-hub\//] },
264
+ beforeSend: event => {
265
+ // transform-only
266
+ },
267
+ });
268
+
269
+ const orgId = useCurrentOrgId();
270
+ useEffect(() => {
271
+ setServiceContext({ logicalEnvironment: 'go5', orgId });
272
+ }, [orgId, setServiceContext]);
273
+
274
+ return <TaskHubApp />;
275
+ };
276
+ ```
277
+
278
+ The hook accepts a [`ServiceConfig`](#serviceconfig) — the same shape used by `init`'s `service` field. It does **not** accept `application` config, since SDK initialization shouldn't be tied to a component's lifecycle.
279
+
280
+ ### Enabling RUM at runtime for development {#dev-runtime-enable}
281
+
282
+ To exercise RUM-related changes in an environment where the application ships RUM but leaves it off (for example a local or QA build), you can turn RUM on for your own browser — no code change. It only ever turns RUM **on**; it has no effect where RUM is already enabled.
283
+
284
+ An application opts in once by always calling [`init`](#init) and passing its enablement decision as `enabled`, instead of gating the `init` call:
285
+
286
+ ```ts title="datadog-entry.ts"
287
+ import { init } from '@servicetitan/datadog-rum';
288
+
289
+ const isEnabled = /.*go\d*\.servicetitan\.com/.test(window.location.hostname);
290
+
291
+ init({
292
+ service: { name: 'desktop' },
293
+ application: {
294
+ applicationId: '<APPLICATION_ID>',
295
+ clientToken: '<CLIENT_TOKEN>',
296
+ env: window.location.hostname,
297
+ },
298
+ enabled: isEnabled,
299
+ });
300
+ ```
301
+
302
+ In any environment where the application ships RUM but leaves it disabled (`enabled` is `false`), the package exposes `datadogRumForDev` on the global scope. A developer controls it directly from the browser devtools console — no import, no code change:
303
+
304
+ ```js
305
+ // In the browser devtools console:
306
+ datadogRumForDev.start(); // turn RUM on for the next 12 hours
307
+ datadogRumForDev.stop(); // clear the override; return to the shipped default
308
+ ```
309
+
310
+ `start()` records the override in `localStorage` and reloads the page to apply. The override expires automatically after 12 hours; calling `start()` again refreshes the 12-hour window. `stop()` removes the override, ends the current Datadog session, and reloads — returning to the application's shipped `enabled` value. It does **not** disable RUM that the application itself enabled. Both methods log to the console, so the override is never silent.
311
+
312
+ Sessions enabled this way are tagged with a `datadogRumForDev` context attribute. Filter `@context.datadogRumForDev:true` in Datadog RUM to find them, or `-@context.datadogRumForDev:true` to exclude them from production dashboards.
313
+
314
+ **Set `env` per host before relying on this** (e.g. `env: window.location.hostname`, as above). Because the override turns RUM on in an environment that normally doesn't report, a static or hardcoded `env` would file those dev sessions under your **production** `env` — colliding with prod data in dashboards and SLOs. A dynamic `env` keeps override-enabled lower-environment sessions in their own bucket.
315
+
316
+ #### Multiple tabs
317
+
318
+ Because the override lives in `localStorage`, it applies to every tab of the origin — useful for testing how a user navigates between pages and opens new tabs. Calling `start()` (or `stop()`) reloads the current tab and every other open tab of the application, so they all pick up the change. A tab opened afterward honors the override on its first load. All such tabs share a single Datadog RUM session, exactly as they would with normally-enabled RUM.
319
+
320
+ ### `DatadogProvider`
321
+
322
+ `DatadogProvider` provides the RUM SDK with:
46
323
 
47
324
  - Information about the user session
48
- - Sanitized view event names (`@view.name`) when hash-based routing is used
325
+ - Sanitized view event names (`@view.name`) for hash-based routing
326
+
327
+ :::note
328
+ `DatadogProvider` sets the user via [`setUser`](#setuser), so the same gating rules apply.
329
+ :::
49
330
 
50
- ### Usage
331
+ #### Usage
51
332
 
52
- Wrap your application with `DatadogProvider` close to the root. E.g.,
333
+ Wrap your application with `DatadogProvider` close to the root. For example,
53
334
 
54
335
  ```tsx
55
336
  import { DatadogProvider } from '@servicetitan/datadog-rum';
56
337
 
57
- const Root = () =>
338
+ const Root = () => {
58
339
  return (
59
340
  <DatadogProvider isEnabled={isEnabled} user={user}>
60
341
  ...
@@ -63,7 +344,7 @@ const Root = () =>
63
344
  };
64
345
  ```
65
346
 
66
- If your application uses hash-based routing, `DatadogProvider` should be placed inside `HashRouter`. E.g.,
347
+ If your application uses hash-based routing, place `DatadogProvider` inside `HashRouter`. For example,
67
348
 
68
349
  ```tsx
69
350
  import { HashRouter } from 'react-router-dom';
@@ -80,35 +361,57 @@ const Root = () => {
80
361
  };
81
362
  ```
82
363
 
83
- ### Parameters
364
+ #### Parameters
365
+
366
+ | Name | Type | Description |
367
+ | :---------- | :-------------------- | :------------------------------------------ |
368
+ | `isEnabled` | `boolean` | Activates the provider's instrumentation |
369
+ | `user` | [`RumUser`](#rumuser) | (optional) User session information |
370
+ | `options` | [`Options`](#options) | (optional) Additional configuration options |
371
+
372
+ ##### `RumUser` {#rumuser}
373
+
374
+ ```ts
375
+ import type { RumUser } from '@servicetitan/datadog-rum';
376
+ ```
377
+
378
+ | Name | Type | Description |
379
+ | :-------------- | :----------------------------- | :-------------------------------------- |
380
+ | `id` | `string` | User ID |
381
+ | `[key: string]` | `string \| number \| string[]` | (optional) Session-wide user attributes |
382
+
383
+ ##### `Options`
384
+
385
+ | Name | Type | Description |
386
+ | :------------ | :-------- | :----------------------------------------------------------- |
387
+ | `hashRouting` | `boolean` | Tracks hash-based routes as RUM views (with sanitized names) |
84
388
 
85
- | Name | Type | Description |
86
- | :---------- | :-------- | :------------------------------------------ |
87
- | `isEnabled` | `boolean` | Enables DD RUM instrumentation |
88
- | `user` | `User` | (optional) User session information |
89
- | `options` | `Options` | (optional) Additional configuration options |
389
+ ### `setUser`
90
390
 
91
- #### `User`
391
+ Sets the session user (see [`RumUser`](#rumuser) for the accepted shape). Behavior depends on initialization state:
92
392
 
93
- | Name | Type | Description |
94
- | :-------------- | :----------------------------- | :----------------------------------- |
95
- | `id` | `string` | User ID |
96
- | `[key: string]` | `string \| number \| string[]` | (optional) Arbitrary user attributes |
393
+ - **SDK initialized via `init`**: only the bundle whose `init` call initialized the SDK may set the user. That bundle can re-set freely (for example, login, logout, identity switch). Calls from any other bundle are silent no-ops.
394
+ - **SDK initialized directly via `datadogRum.init`**: `setUser` delegates straight to `datadogRum.setUser` without gating.
395
+ - **Neither initialized**: no-op.
97
396
 
98
- #### `Options`
397
+ ```ts
398
+ import { setUser } from '@servicetitan/datadog-rum';
399
+
400
+ setUser({ id: '7', email: 'user@example.com' });
401
+ ```
99
402
 
100
- | Name | Type | Description |
101
- | :------------ | :-------- | :------------------------------------------ |
102
- | `hashRouting` | `boolean` | Sanitizes view names for hash-based routing |
403
+ ### `beforeSend`
103
404
 
104
- ## `beforeSend`
405
+ :::caution
406
+ This is the legacy API, kept for backward compatibility. New applications should use [`init`](#init), which lets MFEs share a host's RUM session.
407
+ :::
105
408
 
106
- `beforeSend` is a callback function for enriching RUM events. Supported functionality:
409
+ `beforeSend` is a callback that enriches RUM events:
107
410
 
108
411
  - Adds MFE name and version for error and resource events coming from MFEs (`@error.service`, `@resource.service`, `@error.version`, and `@resource.version`)
109
412
  - Adds Cloudflare Ray ID for resource events (`@resource.cfRay`)
110
413
 
111
- ### Usage
414
+ #### Usage
112
415
 
113
416
  ```ts
114
417
  import { beforeSend } from '@servicetitan/datadog-rum';
@@ -127,7 +430,7 @@ if (isEnabled) {
127
430
  sessionSampleRate: 100,
128
431
  sessionReplaySampleRate: 0,
129
432
  defaultPrivacyLevel: 'mask-user-input',
130
- beforeSend: beforeSend(), // <--beforeSend() returns handler that enriches events
433
+ beforeSend: beforeSend(), // beforeSend() returns a handler that enriches events
131
434
  });
132
435
  }
133
436
  ```
@@ -22,7 +22,7 @@ The ESLint config bundles rules from ESLint core, `eslint-plugin-import`, `eslin
22
22
 
23
23
  #### In the Lerna project
24
24
 
25
- Use `mono` in a workspace-based monorepo. It discovers every workspace package at lint time and wires up `import/no-extraneous-dependencies` for each one, so imports are checked against both the package's own `package.json` and the repo root.
25
+ Use `mono` in a monorepo. It discovers every package at lint time and wires up `import/no-extraneous-dependencies` for each one, so imports are checked against both the package's own `package.json` and the repo root.
26
26
 
27
27
  ```js title="eslint.config.js"
28
28
  import { defineConfig } from 'eslint/config';
@@ -68,13 +68,13 @@ This rule requires a QA selector attribute on interactive elements so tests can
68
68
 
69
69
  **1. Interactive Anvil2 components.** The rule tracks imports from `@servicetitan/anvil2` and `@servicetitan/anvil2/beta`, then flags any of these components when rendered without a QA attribute. Aliased imports (for example, `Button as Btn`) resolve to the original export name before the check runs.
70
70
 
71
- | Category | Components |
72
- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
73
- | Form inputs | `Checkbox`, `Radio`, `Switch`, `TextField`, `Textarea`, `NumberField`, `SearchField`, `TimeField`, `DateField`, `DateFieldRange`, `DateFieldSingle`, `DateFieldYearless`, `Calendar`, `Pagination` |
74
- | Selection | `SelectCard`, `SegmentedControl`, `DaysOfTheWeek`, `SelectTrigger`, `Combobox.SearchField`, `Combobox.SelectTrigger` |
75
- | Actions | `Button`, `ButtonToggle`, `Link`, `Toolbar.Button`, `Toolbar.ButtonToggle`, `Toolbar.ButtonLink`, `Toolbar.Select` |
76
- | Navigation | `SideNavLink`, `SideNavCollapsible`, `SideNav.Link`, `SideNav.Collapsible`, `BreadcrumbsLink`, `Breadcrumbs.Link`, `Stepper.PrevButton`, `Stepper.NextButton`, `Stepper.Step` |
77
- | Overlays, menus | `Menu`, `Menu.Item`, `Popover.Button`, `Popover.Close`, `Tab.Button`, `EditCard`, `Chip` |
71
+ | Category | Components |
72
+ | :-------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
73
+ | Form inputs | `Checkbox`, `Radio`, `Switch`, `TextField`, `Textarea`, `NumberField`, `SearchField`, `TimeField`, `DateField`, `DateFieldRange`, `DateFieldSingle`, `DateFieldYearless`, `Calendar`, `Pagination` |
74
+ | Selection | `SelectCard`, `SegmentedControl`, `DaysOfTheWeek`, `SelectTrigger`, `Combobox.SearchField`, `Combobox.SelectTrigger` |
75
+ | Actions | `Button`, `ButtonToggle`, `Link`, `Toolbar.Button`, `Toolbar.ButtonToggle`, `Toolbar.ButtonLink`, `Toolbar.Select` |
76
+ | Navigation | `SideNavLink`, `SideNavCollapsible`, `SideNav.Link`, `SideNav.Collapsible`, `BreadcrumbsLink`, `Breadcrumbs.Link`, `Stepper.PrevButton`, `Stepper.NextButton`, `Stepper.Step` |
77
+ | Overlays, menus | `Menu`, `Menu.Item`, `Popover.Button`, `Popover.Close`, `Tab.Button`, `EditCard`, `Chip` |
78
78
 
79
79
  **2. Direct children of `Tooltip.Trigger` or `Popover.Trigger`.** The trigger forwards interactions to its child, so the attribute belongs on the child element rather than the trigger itself.
80
80
 
@@ -84,8 +84,8 @@ The rule skips elements that use JSX spread (`{...props}`), since the QA attribu
84
84
 
85
85
  ###### Options
86
86
 
87
- | Name | Type | Default | Description |
88
- | :----------- | :--------- | :----------- | :------------------------------------------------------------------------------------- |
87
+ | Name | Type | Default | Description |
88
+ | :----------- | :--------- | :------------ | :------------------------------------------------------------------------------- |
89
89
  | `attributes` | `string[]` | `['data-cy']` | Acceptable attribute names. At least one must be present on the flagged element. |
90
90
 
91
91
  The example below shows two ways to enable the rule. The first call uses the defaults and requires `data-cy`. The second call passes a `rules` override so the rule accepts `data-testid` instead, which is useful for projects that already use a different attribute convention.
package/docs/install.mdx CHANGED
@@ -40,7 +40,7 @@ The `npx --yes @servicetitan/install` command works regardless of which package
40
40
 
41
41
  ### pnpm support
42
42
 
43
- ✨ New in **36.2.0** ✨
43
+ ✨ New in **v36.2.0** ✨
44
44
 
45
45
  `@servicetitan/startup` includes experimental pnpm support. See the [Switching to pnpm](/docs/frontend/switching-to-pnpm) migration guide to get started.
46
46
 
@@ -58,9 +58,9 @@ pnpm support is experimental. It has been validated against several internal rep
58
58
  | `--token` | Only configure the npm authentication token. Don't install dependencies. |
59
59
  | `--fix` | Update the lock file without installing packages. |
60
60
 
61
- ## Install Script Protection (Preview)
61
+ ## Install Script Protection
62
62
 
63
- In npm projects `@servicetitan/install` runs all install scripts by default. A future release will flip this default to block untrusted packages from running any install script (`preinstall`, `install`, and `postinstall`), protecting against supply chain attacks. To help teams prepare, `@servicetitan/install` warns about installed packages with untrusted install scripts:
63
+ In npm projects `@servicetitan/install` blocks untrusted packages from running any install script (`preinstall`, `install`, and `postinstall`), protecting against supply chain attacks. When an installed package has an untrusted install script, `@servicetitan/install` skips it and warns:
64
64
 
65
65
  ```
66
66
  WARNING: The following packages have untrusted install scripts.
@@ -70,20 +70,24 @@ Review and add trusted packages to --allow-scripts:
70
70
 
71
71
  :::caution
72
72
  Audit each package in the warning. Verify it is trustworthy or remove the dependency.
73
- :::
74
73
 
75
- :::tip
76
74
  Not sure what an install script does? Ask Claude: "What does the install script for _X_ do?". Claude reads the package source and summarizes the behavior, so you can decide whether to trust it.
77
75
  :::
78
76
 
79
- To disable all install scripts, including the default allowlist, use `--no-allow-scripts`:
77
+ To allow a package to run its install script, use [`--allow-scripts`](#options):
78
+
79
+ ```sh
80
+ npx --yes @servicetitan/install --allow-scripts some-package
81
+ ```
82
+
83
+ To disable all install scripts, including the default allowlist, use [`--no-allow-scripts`](#options):
80
84
 
81
85
  ```sh
82
86
  npx --yes @servicetitan/install --no-allow-scripts
83
87
  ```
84
88
 
85
89
  :::tip
86
- `@servicetitan/install` checks for untrusted install scripts when the lockfile changes. If you see the warning after adding a new dependency, verify the package is trustworthy or remove it.
90
+ `@servicetitan/install` checks for untrusted install scripts on every install. If you see the warning after adding a new dependency, verify the package is trustworthy or remove it.
87
91
  :::
88
92
 
89
93
  ### Pnpm projects
@@ -42,7 +42,7 @@ export const DispatchModule: React.FC = () => <LazyDispatch />;
42
42
  | :----------------------- | :---------------------------------------- | :----------------------------------------------------------------- | :------------------------------------------------------------- |
43
43
  | `loader` | `() => Promise<React.ComponentType<any>>` | Function doing dynamic import of a module | Yes |
44
44
  | `name` | `string` | Module name | Yes |
45
- | `loadingComponent` | `React.ComponentType<any>` | Component to display while loading is in progress | No, defaults to `DefaultLoading` |
45
+ | `loadingComponent` | `React.ComponentType<any>` | Component to display while loading is in progress | No, defaults to `DefaultLoading` |
46
46
  | `loadingErrorComponent` | `React.ComponentType<any>` | Component to display if module loading fails | No, defaults to `DefaultLoadingError` |
47
47
  | `errorFallbackComponent` | `React.ComponentType<any>` | Component to pass to `@servicetitan/error-boundary` module wrapper | No, uses default component from `@servicetitan/error-boundary` |
48
48
 
@@ -6,22 +6,24 @@ A host is an application, or MFE, that uses [`Loader`](../web-components/loader)
6
6
 
7
7
  ## Configuration
8
8
 
9
- Set `cli.webpack.expose-shared-dependencies` to `true` in the application's `package.json`.
9
+ Set `cli.expose-shared-dependencies` to `true` in the application's `package.json`.
10
10
 
11
11
  :::caution
12
- `expose-shared-dependencies` only applies to applications. MFEs that load other MFEs do not need this setting or any additional configuration.
12
+ `expose-shared-dependencies` only applies to applications. MFEs that load other MFEs do not need this setting or any additional configuration. Setting it on a package marked `cli.web-component` fails the build.
13
13
  :::
14
14
 
15
15
  ```json title="package.json"
16
16
  {
17
17
  "cli": {
18
- "webpack": {
19
- "expose-shared-dependencies": true
20
- }
18
+ "expose-shared-dependencies": true
21
19
  }
22
20
  }
23
21
  ```
24
22
 
23
+ :::note
24
+ In versions before **36.4.0**, this setting was under `cli.webpack.expose-shared-dependencies`. The old location still works for backward compatibility.
25
+ :::
26
+
25
27
  ### Design system
26
28
 
27
29
  If the host uses `@servicetitan/design-system` remove all imports of design system styles from the code; `startup` handles that automatically. Alternatively, to customize the design system styles, move the imports to a file named `design-system.css` in the root directory of the application's source folder (the `rootDir` in `tsconfig.json`). E.g.,