@gooddata/sdk-ui-pluggable-application 11.42.0-alpha.2 → 11.42.0-alpha.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/esm/index.d.ts CHANGED
@@ -7,4 +7,5 @@ export { type IClientPlatformContext, PlatformContextProvider, type IPlatformCon
7
7
  export { createBackendForModule, type ICreateBackendForModuleOptions } from "./backend.js";
8
8
  export { AppProviders, type IAppProvidersProps } from "./AppProviders.js";
9
9
  export { type IPluggableAppEventsContextValue, type IPluggableAppEventsProviderProps, PluggableAppEventsProvider, usePluggableAppEvents, } from "./events.js";
10
+ export { type IModuleTelemetryMetadata, type IPluggableAppTelemetryProviderProps, enrichTelemetryCallbacks, PluggableAppTelemetryProvider, usePluggableAppTelemetry, } from "./telemetry.js";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,EACH,KAAK,sBAAsB,EAC3B,uBAAuB,EACvB,KAAK,6BAA6B,EAClC,kBAAkB,EAClB,wBAAwB,GAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,KAAK,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EACH,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACrC,0BAA0B,EAC1B,qBAAqB,GACxB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,OAAO,EACH,KAAK,sBAAsB,EAC3B,uBAAuB,EACvB,KAAK,6BAA6B,EAClC,kBAAkB,EAClB,wBAAwB,GAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,KAAK,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EACH,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACrC,0BAA0B,EAC1B,qBAAqB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,KAAK,wBAAwB,EAC7B,KAAK,mCAAmC,EACxC,wBAAwB,EACxB,6BAA6B,EAC7B,wBAAwB,GAC3B,MAAM,gBAAgB,CAAC"}
package/esm/index.js CHANGED
@@ -9,3 +9,4 @@ export { PlatformContextProvider, usePlatformContext, usePlatformContextStrict,
9
9
  export { createBackendForModule } from "./backend.js";
10
10
  export { AppProviders } from "./AppProviders.js";
11
11
  export { PluggableAppEventsProvider, usePluggableAppEvents, } from "./events.js";
12
+ export { enrichTelemetryCallbacks, PluggableAppTelemetryProvider, usePluggableAppTelemetry, } from "./telemetry.js";
@@ -9,6 +9,7 @@ import { IAuthCredentials } from '@gooddata/sdk-pluggable-application-model';
9
9
  import { ILocale } from '@gooddata/sdk-model';
10
10
  import { IPlatformContext } from '@gooddata/sdk-pluggable-application-model';
11
11
  import { IPluggableAppEvent } from '@gooddata/sdk-pluggable-application-model';
12
+ import { IPluggableAppTelemetryCallbacks } from '@gooddata/sdk-pluggable-application-model';
12
13
  import { ITranslations } from '@gooddata/sdk-ui';
13
14
  import { JSX } from 'react/jsx-runtime';
14
15
  import { PropsWithChildren } from 'react';
@@ -66,6 +67,19 @@ export declare function AppProviders({ ctx, packageName, resolveMessages: resolv
66
67
  */
67
68
  export declare function createBackendForModule(auth: IAuthCredentials, options: ICreateBackendForModuleOptions): IAnalyticalBackend;
68
69
 
70
+ /**
71
+ * Wraps host telemetry callbacks so every `trackEvent` call also reports the module's runtime metadata.
72
+ *
73
+ * @remarks
74
+ * The metadata is merged into the event `data` before the host's own `data` keys, so an explicit key in
75
+ * the call site's `data` wins on collision (mirroring how the host merges its common properties).
76
+ * `trackPageView` and `trackTiming` are passed through unchanged — they carry no `data` slot today.
77
+ * Returns `undefined` when given `undefined`, so a standalone module (mounted outside the host) stays a no-op.
78
+ *
79
+ * @alpha
80
+ */
81
+ export declare function enrichTelemetryCallbacks(callbacks: IPluggableAppTelemetryCallbacks | undefined, metadata: IModuleTelemetryMetadata): IPluggableAppTelemetryCallbacks | undefined;
82
+
69
83
  /**
70
84
  * Props for {@link AppProviders}.
71
85
  *
@@ -137,6 +151,33 @@ export declare interface ICreateBackendForModuleOptions {
137
151
  packageVersion?: string;
138
152
  }
139
153
 
154
+ /**
155
+ * Metadata describing the module runtime that owns the telemetry callbacks.
156
+ *
157
+ * @remarks
158
+ * Attached to every {@link @gooddata/sdk-pluggable-application-model#IPluggableAppTelemetryCallbacks.trackEvent}
159
+ * payload so events can be attributed to the module's own React / SDK versions. These may differ from the
160
+ * host's (which the host attaches as `hostReactVersion` / `hostSdkVersion`) when a module bundles its own
161
+ * React instead of consuming the host's shared singleton.
162
+ *
163
+ * Capture the versions at the module's mount entry — `import { version } from "react"` and
164
+ * `import { LIB_VERSION } from "@gooddata/sdk-pluggable-application-model"` — and pass them in. Reading them
165
+ * inside this shared library would resolve to the host's copies under module federation.
166
+ *
167
+ * @alpha
168
+ */
169
+ export declare interface IModuleTelemetryMetadata {
170
+ /**
171
+ * Version of React that rendered the module, e.g. `import { version } from "react"`.
172
+ */
173
+ moduleReactVersion?: string;
174
+ /**
175
+ * Version of the GoodData SDK the module is built against, e.g.
176
+ * `import { LIB_VERSION } from "@gooddata/sdk-pluggable-application-model"`.
177
+ */
178
+ moduleSdkVersion?: string;
179
+ }
180
+
140
181
  /**
141
182
  * Props for {@link PlatformContextProvider}.
142
183
  *
@@ -186,6 +227,18 @@ export declare interface IPluggableAppEventsProviderProps extends PropsWithChild
186
227
  onEvent?: (event: IPluggableAppEvent) => void;
187
228
  }
188
229
 
230
+ /**
231
+ * Props for {@link PluggableAppTelemetryProvider}.
232
+ *
233
+ * @alpha
234
+ */
235
+ export declare interface IPluggableAppTelemetryProviderProps extends PropsWithChildren, IModuleTelemetryMetadata {
236
+ /**
237
+ * Host telemetry callbacks passed through pluggable mount options.
238
+ */
239
+ onTelemetryEvent?: IPluggableAppTelemetryCallbacks;
240
+ }
241
+
189
242
  /**
190
243
  * React provider that binds platform context into React context.
191
244
  *
@@ -200,6 +253,18 @@ export declare function PlatformContextProvider({ value, children }: IPlatformCo
200
253
  */
201
254
  export declare function PluggableAppEventsProvider({ onEvent, children }: IPluggableAppEventsProviderProps): JSX.Element;
202
255
 
256
+ /**
257
+ * React provider exposing telemetry callbacks enriched with the module's runtime metadata.
258
+ *
259
+ * @remarks
260
+ * Components consume the enriched callbacks via {@link usePluggableAppTelemetry} and never handle the
261
+ * module metadata themselves — it lives in the provider's closure. No-ops safely when `onTelemetryEvent`
262
+ * is absent (e.g. standalone runs outside the host).
263
+ *
264
+ * @alpha
265
+ */
266
+ export declare function PluggableAppTelemetryProvider({ onTelemetryEvent, moduleReactVersion, moduleSdkVersion, children }: IPluggableAppTelemetryProviderProps): JSX.Element;
267
+
203
268
  /**
204
269
  * Returns client platform context snapshot (or undefined if not available yet).
205
270
  *
@@ -221,4 +286,11 @@ export declare function usePlatformContextStrict(context?: string): IClientPlatf
221
286
  */
222
287
  export declare function usePluggableAppEvents(): IPluggableAppEventsContextValue;
223
288
 
289
+ /**
290
+ * Returns telemetry callbacks enriched with the module's runtime metadata.
291
+ *
292
+ * @alpha
293
+ */
294
+ export declare function usePluggableAppTelemetry(): IPluggableAppTelemetryCallbacks;
295
+
224
296
  export { }
@@ -0,0 +1,69 @@
1
+ import { type PropsWithChildren } from "react";
2
+ import { type IPluggableAppTelemetryCallbacks } from "@gooddata/sdk-pluggable-application-model";
3
+ /**
4
+ * Metadata describing the module runtime that owns the telemetry callbacks.
5
+ *
6
+ * @remarks
7
+ * Attached to every {@link @gooddata/sdk-pluggable-application-model#IPluggableAppTelemetryCallbacks.trackEvent}
8
+ * payload so events can be attributed to the module's own React / SDK versions. These may differ from the
9
+ * host's (which the host attaches as `hostReactVersion` / `hostSdkVersion`) when a module bundles its own
10
+ * React instead of consuming the host's shared singleton.
11
+ *
12
+ * Capture the versions at the module's mount entry — `import { version } from "react"` and
13
+ * `import { LIB_VERSION } from "@gooddata/sdk-pluggable-application-model"` — and pass them in. Reading them
14
+ * inside this shared library would resolve to the host's copies under module federation.
15
+ *
16
+ * @alpha
17
+ */
18
+ export interface IModuleTelemetryMetadata {
19
+ /**
20
+ * Version of React that rendered the module, e.g. `import { version } from "react"`.
21
+ */
22
+ moduleReactVersion?: string;
23
+ /**
24
+ * Version of the GoodData SDK the module is built against, e.g.
25
+ * `import { LIB_VERSION } from "@gooddata/sdk-pluggable-application-model"`.
26
+ */
27
+ moduleSdkVersion?: string;
28
+ }
29
+ /**
30
+ * Wraps host telemetry callbacks so every `trackEvent` call also reports the module's runtime metadata.
31
+ *
32
+ * @remarks
33
+ * The metadata is merged into the event `data` before the host's own `data` keys, so an explicit key in
34
+ * the call site's `data` wins on collision (mirroring how the host merges its common properties).
35
+ * `trackPageView` and `trackTiming` are passed through unchanged — they carry no `data` slot today.
36
+ * Returns `undefined` when given `undefined`, so a standalone module (mounted outside the host) stays a no-op.
37
+ *
38
+ * @alpha
39
+ */
40
+ export declare function enrichTelemetryCallbacks(callbacks: IPluggableAppTelemetryCallbacks | undefined, metadata: IModuleTelemetryMetadata): IPluggableAppTelemetryCallbacks | undefined;
41
+ /**
42
+ * Props for {@link PluggableAppTelemetryProvider}.
43
+ *
44
+ * @alpha
45
+ */
46
+ export interface IPluggableAppTelemetryProviderProps extends PropsWithChildren, IModuleTelemetryMetadata {
47
+ /**
48
+ * Host telemetry callbacks passed through pluggable mount options.
49
+ */
50
+ onTelemetryEvent?: IPluggableAppTelemetryCallbacks;
51
+ }
52
+ /**
53
+ * React provider exposing telemetry callbacks enriched with the module's runtime metadata.
54
+ *
55
+ * @remarks
56
+ * Components consume the enriched callbacks via {@link usePluggableAppTelemetry} and never handle the
57
+ * module metadata themselves — it lives in the provider's closure. No-ops safely when `onTelemetryEvent`
58
+ * is absent (e.g. standalone runs outside the host).
59
+ *
60
+ * @alpha
61
+ */
62
+ export declare function PluggableAppTelemetryProvider({ onTelemetryEvent, moduleReactVersion, moduleSdkVersion, children }: IPluggableAppTelemetryProviderProps): import("react/jsx-runtime").JSX.Element;
63
+ /**
64
+ * Returns telemetry callbacks enriched with the module's runtime metadata.
65
+ *
66
+ * @alpha
67
+ */
68
+ export declare function usePluggableAppTelemetry(): IPluggableAppTelemetryCallbacks;
69
+ //# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAsC,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAE,KAAK,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAEjG;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,wBAAwB;IACrC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACpC,SAAS,EAAE,+BAA+B,GAAG,SAAS,EACtD,QAAQ,EAAE,wBAAwB,GACnC,+BAA+B,GAAG,SAAS,CAU7C;AAaD;;;;GAIG;AACH,MAAM,WAAW,mCAAoC,SAAQ,iBAAiB,EAAE,wBAAwB;IACpG;;OAEG;IACH,gBAAgB,CAAC,EAAE,+BAA+B,CAAC;CACtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAAC,EAC1C,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACX,EAAE,mCAAmC,2CAarC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,+BAA+B,CAE1E"}
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // (C) 2026 GoodData Corporation
3
+ import { createContext, useContext, useMemo } from "react";
4
+ /**
5
+ * Wraps host telemetry callbacks so every `trackEvent` call also reports the module's runtime metadata.
6
+ *
7
+ * @remarks
8
+ * The metadata is merged into the event `data` before the host's own `data` keys, so an explicit key in
9
+ * the call site's `data` wins on collision (mirroring how the host merges its common properties).
10
+ * `trackPageView` and `trackTiming` are passed through unchanged — they carry no `data` slot today.
11
+ * Returns `undefined` when given `undefined`, so a standalone module (mounted outside the host) stays a no-op.
12
+ *
13
+ * @alpha
14
+ */
15
+ export function enrichTelemetryCallbacks(callbacks, metadata) {
16
+ if (!callbacks) {
17
+ return undefined;
18
+ }
19
+ return {
20
+ ...callbacks,
21
+ trackEvent(eventName, data, options) {
22
+ callbacks.trackEvent(eventName, { ...metadata, ...data }, options);
23
+ },
24
+ };
25
+ }
26
+ const noop = () => undefined;
27
+ const defaultTelemetry = {
28
+ trackEvent: noop,
29
+ trackPageView: noop,
30
+ trackTiming: noop,
31
+ };
32
+ const PluggableAppTelemetryContext = createContext(defaultTelemetry);
33
+ PluggableAppTelemetryContext.displayName = "PluggableAppTelemetryContext";
34
+ /**
35
+ * React provider exposing telemetry callbacks enriched with the module's runtime metadata.
36
+ *
37
+ * @remarks
38
+ * Components consume the enriched callbacks via {@link usePluggableAppTelemetry} and never handle the
39
+ * module metadata themselves — it lives in the provider's closure. No-ops safely when `onTelemetryEvent`
40
+ * is absent (e.g. standalone runs outside the host).
41
+ *
42
+ * @alpha
43
+ */
44
+ export function PluggableAppTelemetryProvider({ onTelemetryEvent, moduleReactVersion, moduleSdkVersion, children, }) {
45
+ const value = useMemo(() => enrichTelemetryCallbacks(onTelemetryEvent, { moduleReactVersion, moduleSdkVersion }) ??
46
+ defaultTelemetry, [onTelemetryEvent, moduleReactVersion, moduleSdkVersion]);
47
+ return (_jsx(PluggableAppTelemetryContext.Provider, { value: value, children: children }));
48
+ }
49
+ /**
50
+ * Returns telemetry callbacks enriched with the module's runtime metadata.
51
+ *
52
+ * @alpha
53
+ */
54
+ export function usePluggableAppTelemetry() {
55
+ return useContext(PluggableAppTelemetryContext);
56
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddata/sdk-ui-pluggable-application",
3
- "version": "11.42.0-alpha.2",
3
+ "version": "11.42.0-alpha.4",
4
4
  "description": "GoodData SDK React helpers for pluggable applications",
5
5
  "license": "MIT",
6
6
  "author": "GoodData Corporation",
@@ -24,12 +24,12 @@
24
24
  "react-intl": "7.1.11",
25
25
  "ts-invariant": "0.10.3",
26
26
  "tslib": "2.8.1",
27
- "@gooddata/sdk-backend-base": "11.42.0-alpha.2",
28
- "@gooddata/sdk-backend-tiger": "11.42.0-alpha.2",
29
- "@gooddata/sdk-backend-spi": "11.42.0-alpha.2",
30
- "@gooddata/sdk-model": "11.42.0-alpha.2",
31
- "@gooddata/sdk-pluggable-application-model": "11.42.0-alpha.2",
32
- "@gooddata/sdk-ui": "11.42.0-alpha.2"
27
+ "@gooddata/sdk-backend-base": "11.42.0-alpha.4",
28
+ "@gooddata/sdk-backend-spi": "11.42.0-alpha.4",
29
+ "@gooddata/sdk-backend-tiger": "11.42.0-alpha.4",
30
+ "@gooddata/sdk-model": "11.42.0-alpha.4",
31
+ "@gooddata/sdk-pluggable-application-model": "11.42.0-alpha.4",
32
+ "@gooddata/sdk-ui": "11.42.0-alpha.4"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@microsoft/api-documenter": "^7.17.0",
@@ -61,8 +61,8 @@
61
61
  "react-dom": "19.1.1",
62
62
  "typescript": "5.9.3",
63
63
  "vitest": "4.1.8",
64
- "@gooddata/oxlint-config": "11.42.0-alpha.2",
65
- "@gooddata/eslint-config": "11.42.0-alpha.2"
64
+ "@gooddata/oxlint-config": "11.42.0-alpha.4",
65
+ "@gooddata/eslint-config": "11.42.0-alpha.4"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "react": "^18.0.0 || ^19.0.0",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "scripts": {
72
72
  "_phase:build": "npm run build",
73
- "_phase:test": "echo \"No tests for @gooddata/sdk-ui-pluggable-application\"",
73
+ "_phase:test": "npm run test-once",
74
74
  "_phase:validate": "npm run validate",
75
75
  "api-extractor": "mkdir -p api && [ -z \"${CI}\" ] && (api-extractor run -l) || (api-extractor run)",
76
76
  "build": "npm-run-all -p build-check build-ts && npm run api-extractor",