@equinor/fusion-framework-module-analytics 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/esm/version.js +1 -1
  2. package/dist/tsconfig.tsbuildinfo +1 -1
  3. package/dist/types/collectors/create-schema.d.ts +2 -2
  4. package/dist/types/version.d.ts +1 -1
  5. package/package.json +11 -8
  6. package/CHANGELOG.md +0 -386
  7. package/docs/adapters.md +0 -79
  8. package/docs/collectors.md +0 -91
  9. package/docs/testing.md +0 -87
  10. package/docs/tracking-events.md +0 -16
  11. package/src/AnalyticsConfigurator.interface.ts +0 -77
  12. package/src/AnalyticsConfigurator.ts +0 -128
  13. package/src/AnalyticsProvider.interface.ts +0 -44
  14. package/src/AnalyticsProvider.ts +0 -150
  15. package/src/__tests__/MockAnalyticsAdapter.test.ts +0 -127
  16. package/src/__tests__/mock/analytics-mock-adapter.test.ts +0 -79
  17. package/src/adapters/AnalyticsAdapter.interface.ts +0 -36
  18. package/src/adapters/ConsoleAnalyticsAdapter.ts +0 -37
  19. package/src/adapters/FusionAnalyticsAdapter.ts +0 -95
  20. package/src/adapters/index.ts +0 -11
  21. package/src/collectors/AnalyticsCollector.interface.ts +0 -27
  22. package/src/collectors/AppLoadedCollector.ts +0 -94
  23. package/src/collectors/AppSelectedCollector.ts +0 -70
  24. package/src/collectors/ContextSelectedCollector.ts +0 -83
  25. package/src/collectors/create-schema.ts +0 -123
  26. package/src/collectors/index.ts +0 -12
  27. package/src/collectors/utils/app-key-schema.ts +0 -17
  28. package/src/collectors/utils/app-schema.ts +0 -22
  29. package/src/collectors/utils/context-schema.ts +0 -22
  30. package/src/collectors/utils/extract-app-key-metadata.ts +0 -15
  31. package/src/collectors/utils/extract-app-metadata.ts +0 -20
  32. package/src/collectors/utils/extract-context-metadata.ts +0 -19
  33. package/src/enable-analytics.ts +0 -44
  34. package/src/index.ts +0 -30
  35. package/src/logExporters/fusionOTLPLogExporter/FusionOTLPLogExporter.ts +0 -71
  36. package/src/logExporters/fusionOTLPLogExporter/HttpClientExporterTransport.ts +0 -123
  37. package/src/logExporters/index.ts +0 -10
  38. package/src/mock/MockAnalyticsAdapter.ts +0 -178
  39. package/src/mock/index.ts +0 -29
  40. package/src/module.ts +0 -59
  41. package/src/types.ts +0 -60
  42. package/src/version.ts +0 -2
  43. package/tsconfig.json +0 -29
  44. package/vitest.config.ts +0 -11
@@ -14,8 +14,8 @@ import { z } from 'zod';
14
14
  */
15
15
  export declare const createSchema: <TValue = AnyValue, TAttr = AnyValueMap>(value: z.ZodSchema<TValue>, attributes: z.ZodSchema<TAttr>) => z.ZodObject<{
16
16
  name: z.ZodString;
17
- value: z.ZodType<TValue, unknown, z.core.$ZodTypeInternals<TValue, unknown>>;
18
- attributes: z.ZodOptional<z.ZodType<TAttr, unknown, z.core.$ZodTypeInternals<TAttr, unknown>>>;
17
+ value: z.ZodSchema<TValue, unknown, z.core.$ZodTypeInternals<TValue, unknown>>;
18
+ attributes: z.ZodOptional<z.ZodSchema<TAttr, unknown, z.core.$ZodTypeInternals<TAttr, unknown>>>;
19
19
  }, z.core.$strip>;
20
20
  /** Inferred Zod schema type produced by {@link createSchema}. */
21
21
  export type CollectorSchema<TValue = AnyValue, TAttr = AnyValueMap> = ReturnType<typeof createSchema<TValue, TAttr>>;
@@ -1 +1 @@
1
- export declare const version = "3.1.0";
1
+ export declare const version = "3.1.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-analytics",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Fusion module for collecting and exporting application analytics using OpenTelemetry standards",
5
5
  "main": "dist/esm/index.js",
6
6
  "type": "module",
@@ -34,6 +34,9 @@
34
34
  ],
35
35
  "author": "",
36
36
  "license": "ISC",
37
+ "files": [
38
+ "dist"
39
+ ],
37
40
  "publishConfig": {
38
41
  "access": "public"
39
42
  },
@@ -53,19 +56,19 @@
53
56
  "rxjs": "^7.8.1",
54
57
  "uuid": "^14.0.0",
55
58
  "zod": "^4.4.3",
56
- "@equinor/fusion-framework-module-event": "6.1.0",
57
- "@equinor/fusion-framework-module-app": "8.1.0",
58
- "@equinor/fusion-framework-module-http": "8.1.0",
59
- "@equinor/fusion-framework-module": "6.1.3",
60
- "@equinor/fusion-framework-module-context": "9.0.0"
59
+ "@equinor/fusion-framework-module": "6.1.4",
60
+ "@equinor/fusion-framework-module-app": "8.1.2",
61
+ "@equinor/fusion-framework-module-context": "9.0.1",
62
+ "@equinor/fusion-framework-module-event": "6.1.1",
63
+ "@equinor/fusion-framework-module-http": "8.1.1"
61
64
  },
62
65
  "devDependencies": {
63
66
  "typescript": "^7.0.2",
64
67
  "vitest": "^4.1.10",
65
- "@equinor/fusion-observable": "^9.2.1"
68
+ "@equinor/fusion-observable": "^9.2.2"
66
69
  },
67
70
  "peerDependencies": {
68
- "@equinor/fusion-observable": "9.2.1"
71
+ "@equinor/fusion-observable": "9.2.2"
69
72
  },
70
73
  "scripts": {
71
74
  "build": "tsc -b",
package/CHANGELOG.md DELETED
@@ -1,386 +0,0 @@
1
- # @equinor/fusion-framework-module-analytics
2
-
3
- ## 3.1.0
4
-
5
- ### Minor Changes
6
-
7
- - f663b46: Add `MockAnalyticsAdapter` and `./mock` subpath for asserting on tracked analytics events in tests.
8
-
9
- ```ts
10
- import { enableAnalytics } from '@equinor/fusion-framework-module-analytics';
11
- import { MockAnalyticsAdapter } from '@equinor/fusion-framework-module-analytics/mock';
12
-
13
- const recorder = new MockAnalyticsAdapter();
14
-
15
- enableAnalytics(configurator, (builder) => {
16
- builder.setAdapter('mock', async () => recorder);
17
- });
18
-
19
- // ... exercise the app under test, then assert:
20
- const event = await recorder.waitForAnalytic('button-click');
21
- expect(event.attributes?.section).toBe('header');
22
- ```
23
-
24
- ### `getAnalytics(matcher?)`
25
-
26
- Returns recorded events synchronously, filtered by an event name, an array of names, or a predicate. Omit the matcher to get every recorded event.
27
-
28
- ### `waitForAnalytic(matcher, options?)`
29
-
30
- Resolves with the first matching event, resolving immediately if one was already recorded, or waiting for a future one. Supports an optional `timeout` (ms) and `AbortSignal` so a test cannot hang indefinitely, and rejects if the adapter is disposed before a match occurs.
31
-
32
- ### Patch Changes
33
-
34
- - Updated dependencies [f663b46]
35
- - Updated dependencies [f663b46]
36
- - Updated dependencies [f663b46]
37
- - Updated dependencies [f663b46]
38
- - Updated dependencies [f663b46]
39
- - Updated dependencies [f663b46]
40
- - Updated dependencies [f663b46]
41
- - Updated dependencies [f663b46]
42
- - Updated dependencies [f663b46]
43
- - Updated dependencies [f663b46]
44
- - Updated dependencies [f663b46]
45
- - Updated dependencies [f663b46]
46
- - Updated dependencies [f663b46]
47
- - Updated dependencies [f663b46]
48
- - @equinor/fusion-observable@9.2.1
49
- - @equinor/fusion-framework-module-app@8.1.0
50
- - @equinor/fusion-framework-module-context@9.0.0
51
- - @equinor/fusion-framework-module-event@6.1.0
52
- - @equinor/fusion-framework-module-http@8.1.0
53
- - @equinor/fusion-framework-module@6.1.3
54
-
55
- ## 3.0.8
56
-
57
- ### Patch Changes
58
-
59
- - Updated dependencies [6b449ae]
60
- - @equinor/fusion-observable@9.2.0
61
-
62
- ## 3.0.7
63
-
64
- ### Patch Changes
65
-
66
- - Updated dependencies [4a00a7a]
67
- - @equinor/fusion-framework-module-app@8.0.5
68
-
69
- ## 3.0.6
70
-
71
- ### Patch Changes
72
-
73
- - Updated dependencies [73bfe52]
74
- - @equinor/fusion-framework-module-context@8.0.3
75
-
76
- ## 3.0.5
77
-
78
- ### Patch Changes
79
-
80
- - Updated dependencies [1b9d026]
81
- - Updated dependencies [b92698d]
82
- - @equinor/fusion-framework-module-context@8.0.2
83
- - @equinor/fusion-framework-module@6.1.2
84
-
85
- ## 3.0.4
86
-
87
- ### Patch Changes
88
-
89
- - de2b4fb: Added missing TSDoc comments on class fields flagged by the new `require-property-tsdoc` fusion-lint rule.
90
- - Updated dependencies [de2b4fb]
91
- - @equinor/fusion-framework-module-app@8.0.4
92
- - @equinor/fusion-framework-module-http@8.0.5
93
-
94
- ## 3.0.3
95
-
96
- ### Patch Changes
97
-
98
- - 6cca3e0: Internal: bump `@opentelemetry/api-logs`, `@opentelemetry/exporter-logs-otlp-http`, `@opentelemetry/otlp-exporter-base`, `@opentelemetry/otlp-transformer`, `@opentelemetry/sdk-logs` from `0.220.0` to `0.221.0` and `@opentelemetry/resources` from `2.9.0` to `2.10.0`.
99
-
100
- `createOtlpNetworkExportDelegate` in `@opentelemetry/otlp-exporter-base@0.221.0` now requires an `ExporterMetrics` instance as its third argument. Updated `FusionOTLPLogExporter` to construct and pass one, matching the pattern used internally by the OpenTelemetry SDK's own OTLP log exporters.
101
-
102
- ## 3.0.2
103
-
104
- ### Patch Changes
105
-
106
- - 80c3e4a: Internal: resolve fusion-lint warnings across the analytics module.
107
- - Added intent comments above control-flow and RxJS `.pipe()` chains that were missing them.
108
- - Added missing constructor and method TSDoc (including `@param`/`@returns` tags).
109
- - Split `extractAppMetadata.ts` and `extractContextMetadata.ts` so each export lives in its own file, satisfying the `single-export-per-file` rule while preserving existing TSDoc.
110
- - Replaced ad-hoc `@TODO` comments in `AnalyticsProvider` with references to [#5098](https://github.com/equinor/fusion-framework/issues/5098).
111
-
112
- No public API changes.
113
-
114
- - 80c3e4a: Internal: renamed 45 source files across these packages to comply with the `filename-convention` lint rule (e.g. `AIConfigurator.ts` → `AiConfigurator.ts`, `BookmarkProvider.actions.ts` → `bookmark-actions.ts`, `errors/app-build-error.ts` → `errors/AppBuildError.ts`, `plugins/api/plugin.ts` → `plugins/api/ApiPlugin.ts`, `errors.ts` → `UnsupportedApiVersion.ts`, etc.). Also added `enable-signalr.ts` to the `filename-convention` exclude list since the suggested rename would incorrectly split the "SignalR" brand name. No public API changes.
115
- - Updated dependencies [80c3e4a]
116
- - Updated dependencies [80c3e4a]
117
- - Updated dependencies [80c3e4a]
118
- - Updated dependencies [80c3e4a]
119
- - Updated dependencies [80c3e4a]
120
- - Updated dependencies [80c3e4a]
121
- - Updated dependencies [80c3e4a]
122
- - Updated dependencies [80c3e4a]
123
- - Updated dependencies [80c3e4a]
124
- - Updated dependencies [80c3e4a]
125
- - Updated dependencies [80c3e4a]
126
- - Updated dependencies [80c3e4a]
127
- - Updated dependencies [80c3e4a]
128
- - Updated dependencies [80c3e4a]
129
- - Updated dependencies [80c3e4a]
130
- - Updated dependencies [80c3e4a]
131
- - Updated dependencies [80c3e4a]
132
- - Updated dependencies [80c3e4a]
133
- - Updated dependencies [80c3e4a]
134
- - Updated dependencies [80c3e4a]
135
- - Updated dependencies [80c3e4a]
136
- - Updated dependencies [80c3e4a]
137
- - @equinor/fusion-framework-module-app@8.0.3
138
- - @equinor/fusion-framework-module-context@8.0.1
139
- - @equinor/fusion-framework-module-event@6.0.1
140
- - @equinor/fusion-framework-module-http@8.0.4
141
- - @equinor/fusion-framework-module@6.1.1
142
- - @equinor/fusion-observable@9.1.1
143
-
144
- ## 3.0.1
145
-
146
- ### Patch Changes
147
-
148
- - c424e43: Updated OpenTelemetry dependencies (`api-logs`, `exporter-logs-otlp-http`, `otlp-exporter-base`, `otlp-transformer`, `resources`, `sdk-logs`) from `^0.218.0` to `^0.220.0`.
149
-
150
- ## 3.0.0
151
-
152
- ### Patch Changes
153
-
154
- - Updated dependencies [658af0e]
155
- - @equinor/fusion-observable@9.1.0
156
- - @equinor/fusion-framework-module-app@8.0.2
157
- - @equinor/fusion-framework-module-http@8.0.3
158
-
159
- ## 2.0.7
160
-
161
- ### Patch Changes
162
-
163
- - Updated dependencies [418c14d]
164
- - @equinor/fusion-observable@9.0.3
165
-
166
- ## 2.0.6
167
-
168
- ### Patch Changes
169
-
170
- - Updated dependencies [b7b1d9a]
171
- - Updated dependencies [b7b1d9a]
172
- - Updated dependencies [b7b1d9a]
173
- - Updated dependencies [8dd9b9a]
174
- - @equinor/fusion-framework-module@6.1.0
175
- - @equinor/fusion-observable@9.0.2
176
- - @equinor/fusion-framework-module-app@8.0.2
177
- - @equinor/fusion-framework-module-http@8.0.2
178
-
179
- ## 2.0.5
180
-
181
- ### Patch Changes
182
-
183
- - 5c1173d: Internal: bump opentelemetry group (@opentelemetry/api-logs, @opentelemetry/exporter-logs-otlp-http, @opentelemetry/otlp-exporter-base, @opentelemetry/otlp-transformer, @opentelemetry/sdk-logs) from 0.215.0 to 0.218.0 and @opentelemetry/resources from 2.7.0 to 2.7.1.
184
-
185
- ## 2.0.4
186
-
187
- ### Patch Changes
188
-
189
- - f045ac0: Internal: upgrade `zod` from 4.3.6 to 4.4.3 to resolve validation issues; no public API changes.
190
- - Updated dependencies [f045ac0]
191
- - @equinor/fusion-framework-module-app@8.0.2
192
- - @equinor/fusion-framework-module-http@8.0.1
193
-
194
- ## 2.0.3
195
-
196
- ### Patch Changes
197
-
198
- - a6355fe: Internal: bump `uuid` from `13.0.0` to `14.0.0`.
199
- - Updated dependencies [a6355fe]
200
- - @equinor/fusion-framework-module-app@8.0.1
201
- - @equinor/fusion-observable@9.0.1
202
-
203
- ## 2.0.2
204
-
205
- ### Patch Changes
206
-
207
- - faaba9f: Internal: Bump OpenTelemetry dependencies from 0.214.0 to 0.215.0 (`@opentelemetry/api-logs`, `exporter-logs-otlp-http`, `otlp-exporter-base`, `otlp-transformer`, `sdk-logs`) and `@opentelemetry/resources` from 2.6.1 to 2.7.0.
208
-
209
- ## 2.0.1
210
-
211
- ### Patch Changes
212
-
213
- - 3198879: Internal: update OpenTelemetry dependencies (0.213.x → 0.214.x, resources 2.6.0 → 2.6.1).
214
-
215
- Bumps all bundled OpenTelemetry packages used by the analytics module to the latest stable versions. Includes new features in the experimental packages (sampler and resource detection config, `OTEL_CONFIG_FILE` rename) and minor fixes. No changes to the public API surface of this module.
216
-
217
- ## 2.0.0
218
-
219
- ### Major Changes
220
-
221
- - abffa53: Major version bump for Fusion Framework React 19 release.
222
-
223
- All packages are bumped to the next major version as part of the React 19 upgrade. This release drops support for React versions below 18 and includes breaking changes across the framework.
224
-
225
- **Breaking changes:**
226
- - Peer dependencies now require React 18 or 19 (`^18.0.0 || ^19.0.0`)
227
- - React Router upgraded from v6 to v7
228
- - Navigation module refactored with new history API
229
- - `renderComponent` and `renderApp` now use `createRoot` API
230
-
231
- **Migration:**
232
- - Update your React version to 18.0.0 or higher before upgrading
233
- - Replace `NavigationProvider.createRouter()` with `@equinor/fusion-framework-react-router`
234
- - See individual package changelogs for package-specific migration steps
235
-
236
- ### Patch Changes
237
-
238
- - Updated dependencies [abffa53]
239
- - Updated dependencies [abffa53]
240
- - Updated dependencies [abffa53]
241
- - Updated dependencies [abffa53]
242
- - Updated dependencies [abffa53]
243
- - Updated dependencies [abffa53]
244
- - @equinor/fusion-framework-module@6.0.0
245
- - @equinor/fusion-framework-module-app@8.0.0
246
- - @equinor/fusion-framework-module-context@8.0.0
247
- - @equinor/fusion-framework-module-event@6.0.0
248
- - @equinor/fusion-framework-module-http@8.0.0
249
- - @equinor/fusion-observable@9.0.0
250
-
251
- ## 1.0.2
252
-
253
- ### Patch Changes
254
-
255
- - [#4157](https://github.com/equinor/fusion-framework/pull/4157) [`6aa8e1f`](https://github.com/equinor/fusion-framework/commit/6aa8e1f5c9d852b25e97aa7d98a63008c64d4581) Thanks [@Noggling](https://github.com/Noggling)! - Internal: patch release to align TypeScript types across packages for consistent type compatibility.
256
-
257
- - [#4066](https://github.com/equinor/fusion-framework/pull/4066) [`390b1b3`](https://github.com/equinor/fusion-framework/commit/390b1b3f014a8af9900a6589911f65f068a1e9c0) Thanks [@dependabot](https://github.com/apps/dependabot)! - Internal: update the analytics module OpenTelemetry logging packages to 0.212.x/2.5.1 for upstream exporter and resource handling fixes without changing the module API.
258
-
259
- - Updated dependencies [[`6aa8e1f`](https://github.com/equinor/fusion-framework/commit/6aa8e1f5c9d852b25e97aa7d98a63008c64d4581)]:
260
- - @equinor/fusion-framework-module-app@7.4.1
261
- - @equinor/fusion-framework-module-context@7.0.3
262
- - @equinor/fusion-framework-module-event@5.0.1
263
- - @equinor/fusion-framework-module-http@7.0.8
264
- - @equinor/fusion-framework-module@5.0.6
265
- - @equinor/fusion-observable@8.5.8
266
-
267
- ## 1.0.1
268
-
269
- ### Patch Changes
270
-
271
- - [#4149](https://github.com/equinor/fusion-framework/pull/4149) [`c0f86d0`](https://github.com/equinor/fusion-framework/commit/c0f86d00e939e00e08871aa6a7db3b51b7305220) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - Fix `extractContextMetadata` to use nullish coalescing (`?? undefined`) for
272
- optional fields (`externalId`, `title`, `source`), ensuring `null` values from
273
- `ContextItem` are coerced to `undefined` to comply with the Zod context schema.
274
-
275
- ## 1.0.0
276
-
277
- ### Major Changes
278
-
279
- - [#4119](https://github.com/equinor/fusion-framework/pull/4119) [`4e2ae5c`](https://github.com/equinor/fusion-framework/commit/4e2ae5cf55c4d7924d40f7cef0f0c563246132e8) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - `ContextSelectedCollector` now accepts an `AppModuleProvider` as a second
280
- constructor argument and includes the currently active application key
281
- (`appKey`) in the event attributes.
282
-
283
- This allows analytics consumers to correlate context-change events with the app
284
- that was active when the context switch occurred.
285
-
286
- **Breaking change for direct users of `ContextSelectedCollector`:** the
287
- constructor now requires a second argument:
288
-
289
- ```typescript
290
- // Before
291
- new ContextSelectedCollector(contextProvider);
292
- // After
293
- new ContextSelectedCollector(contextProvider, appProvider);
294
- ```
295
-
296
- The emitted event attributes schema is extended accordingly:
297
-
298
- ```typescript
299
- // attributes shape
300
- {
301
- previous: ContextMetadata | null | undefined;
302
- appKey?: string; // newly added — the appKey of the active app at the time of the context change
303
- }
304
- ```
305
-
306
- ## 0.3.0
307
-
308
- ### Minor Changes
309
-
310
- - [#4103](https://github.com/equinor/fusion-framework/pull/4103) [`cb94ac2`](https://github.com/equinor/fusion-framework/commit/cb94ac24744304a5cf61fc6e19d4217c92fa8a5c) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - Change the log processor from SimpleLogProcessor to BatchLogProcessor.
311
-
312
- This will accumulate all events happening within 5 seconds and send them as a
313
- batch. This will improve performance.
314
-
315
- ## 0.2.3
316
-
317
- ### Patch Changes
318
-
319
- - Updated dependencies [[`1f5a8e4`](https://github.com/equinor/fusion-framework/commit/1f5a8e475ea30fa1e0f32c7dab885a5a42c50bba)]:
320
- - @equinor/fusion-framework-module-event@5.0.0
321
- - @equinor/fusion-framework-module-app@7.4.0
322
- - @equinor/fusion-framework-module-context@7.0.2
323
-
324
- ## 0.2.2
325
-
326
- ### Patch Changes
327
-
328
- - [#3948](https://github.com/equinor/fusion-framework/pull/3948) [`62be8e9`](https://github.com/equinor/fusion-framework/commit/62be8e95e752e0237a15834facf3c01c7aaabc11) Thanks [@dependabot](https://github.com/apps/dependabot)! - Internal: update OpenTelemetry dependencies to latest versions (api-logs, exporter-logs-otlp-http, otlp-exporter-base, otlp-transformer, resources, sdk-logs). Includes bug fixes for circular reference handling in logs and improved error retry logic. No public API changes.
329
-
330
- - Updated dependencies [[`343f5f9`](https://github.com/equinor/fusion-framework/commit/343f5f9cc0acbd8e69b62cc73dda577c9015a620), [`122752b`](https://github.com/equinor/fusion-framework/commit/122752b075113b206583ec2c46240997162329b8)]:
331
- - @equinor/fusion-framework-module-app@7.3.0
332
- - @equinor/fusion-framework-module-event@4.4.1
333
-
334
- ## 0.2.1
335
-
336
- ### Patch Changes
337
-
338
- - [#3866](https://github.com/equinor/fusion-framework/pull/3866) [`f70d66f`](https://github.com/equinor/fusion-framework/commit/f70d66f1bc826e614140adb2c6ee052f98e3b3da) Thanks [@dependabot](https://github.com/apps/dependabot)! - Internal: Dedupe zod dependency to 4.3.5
339
-
340
- Deduplicated zod dependency to version 4.3.5 across all packages using `pnpm dedupe`. This aligns all packages (AI plugins upgraded from v3.25.76, other packages consolidated from v4.1.8/v4.1.11) to use the same latest stable version, improving consistency and reducing bundle size. All builds, tests, and linting pass successfully.
341
-
342
- - Updated dependencies [[`f70d66f`](https://github.com/equinor/fusion-framework/commit/f70d66f1bc826e614140adb2c6ee052f98e3b3da)]:
343
- - @equinor/fusion-framework-module-app@7.2.2
344
- - @equinor/fusion-framework-module-http@7.0.6
345
-
346
- ## 0.2.0
347
-
348
- ### Minor Changes
349
-
350
- - [#3849](https://github.com/equinor/fusion-framework/pull/3849) [`7caca57`](https://github.com/equinor/fusion-framework/commit/7caca573584ae4daedfb17e287d0329c2633771a) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - `trackFeature` now has an extra optional argument for passing additional analytics
351
- data.
352
-
353
- Example
354
-
355
- ```typescript
356
- const trackFeature = useTrackFeature();
357
-
358
- // Without extra data
359
- trackFeature("SomeComponent:loaded");
360
-
361
- // Send additional data
362
- trackFeature("some:feature:happened", {
363
- extra: "data",
364
- foo: "bar",
365
- });
366
- ```
367
-
368
- ## 0.1.1
369
-
370
- ### Patch Changes
371
-
372
- - [#3845](https://github.com/equinor/fusion-framework/pull/3845) [`5114ac4`](https://github.com/equinor/fusion-framework/commit/5114ac4f71a60935d0194b9b2766f95adff0ba1e) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - Fix tsconfig references
373
-
374
- - Updated dependencies [[`5114ac4`](https://github.com/equinor/fusion-framework/commit/5114ac4f71a60935d0194b9b2766f95adff0ba1e)]:
375
- - @equinor/fusion-framework-module-app@7.2.1
376
-
377
- ## 0.1.0
378
-
379
- ### Minor Changes
380
-
381
- - [#3842](https://github.com/equinor/fusion-framework/pull/3842) [`d38cd60`](https://github.com/equinor/fusion-framework/commit/d38cd60472380d60282c2a5672dc6e3bba3e7ca9) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - Add module fusion-framework-module-analytics
382
-
383
- ### Patch Changes
384
-
385
- - Updated dependencies [[`d38cd60`](https://github.com/equinor/fusion-framework/commit/d38cd60472380d60282c2a5672dc6e3bba3e7ca9)]:
386
- - @equinor/fusion-framework-module-app@7.2.0
package/docs/adapters.md DELETED
@@ -1,79 +0,0 @@
1
- # Adapters
2
-
3
- Adapters implement `IAnalyticsAdapter` and are responsible for processing and
4
- sending analytics data to their destinations. All adapters support async
5
- initialisation and will be initialised automatically when the provider starts.
6
-
7
- ## ConsoleAnalyticsAdapter
8
-
9
- Logs every analytics event to the browser console. Useful for development and
10
- debugging. No configuration required.
11
-
12
- ```typescript
13
- builder.setAdapter('console', async () => new ConsoleAnalyticsAdapter());
14
- ```
15
-
16
- ## FusionAnalyticsAdapter
17
-
18
- Forwards analytics events to an OpenTelemetry-compatible log endpoint via a
19
- bundled `LoggerProvider`.
20
-
21
- Configuration options:
22
-
23
- | Option | Type | Description |
24
- |---|---|---|
25
- | `portalId` | `string` | Portal identifier included in every log record |
26
- | `logExporter` | `OTLPExporterBase` | OTLP log exporter for transport |
27
-
28
- ### Using `OTLPLogExporter` (direct HTTP)
29
-
30
- ```typescript
31
- import { OTLPLogExporter } from '@equinor/fusion-framework-module-analytics/logExporters';
32
- import { FusionAnalyticsAdapter } from '@equinor/fusion-framework-module-analytics/adapters';
33
-
34
- builder.setAdapter('fusion-log', async () => {
35
- const logExporter = new OTLPLogExporter({
36
- url: 'https://example.com/v1/logs',
37
- headers: { 'Content-Type': 'application/json' },
38
- });
39
- return new FusionAnalyticsAdapter({ portalId: 'my-portal', logExporter });
40
- });
41
- ```
42
-
43
- ### Using `FusionOTLPLogExporter` (service discovery HTTP client)
44
-
45
- ```typescript
46
- import { FusionOTLPLogExporter } from '@equinor/fusion-framework-module-analytics/logExporters';
47
- import { FusionAnalyticsAdapter } from '@equinor/fusion-framework-module-analytics/adapters';
48
-
49
- builder.setAdapter('fusion', async (args) => {
50
- if (args.hasModule('serviceDiscovery')) {
51
- const sd = await args.requireInstance('serviceDiscovery');
52
- const httpClient = await sd.createClient('analytics');
53
- const logExporter = new FusionOTLPLogExporter(httpClient);
54
- return new FusionAnalyticsAdapter({ portalId: 'my-portal', logExporter });
55
- }
56
- console.error('Service discovery unavailable — analytics adapter not created');
57
- });
58
- ```
59
-
60
- ## Creating a Custom Adapter
61
-
62
- Implement `IAnalyticsAdapter` and register it with `setAdapter`:
63
-
64
- ```typescript
65
- import type { IAnalyticsAdapter } from '@equinor/fusion-framework-module-analytics/adapters';
66
- import type { AnalyticsEvent } from '@equinor/fusion-framework-module-analytics';
67
-
68
- class MyRemoteAdapter implements IAnalyticsAdapter {
69
- registerAnalytic(event: AnalyticsEvent): void {
70
- navigator.sendBeacon('/analytics', JSON.stringify(event));
71
- }
72
-
73
- [Symbol.dispose](): void {
74
- // cleanup if needed
75
- }
76
- }
77
-
78
- builder.setAdapter('remote', async () => new MyRemoteAdapter());
79
- ```
@@ -1,91 +0,0 @@
1
- # Collectors
2
-
3
- Collectors implement `IAnalyticsCollector` (or extend `BaseCollector`) and emit
4
- `AnalyticsEvent` objects that are forwarded to all adapters. All collectors
5
- support async initialisation.
6
-
7
- ## ContextSelectedCollector
8
-
9
- Emits an event when the active Fusion context changes. Includes the new context,
10
- the previous context, and the current app key in attributes.
11
-
12
- ```typescript
13
- builder.setCollector('context-selected', async (args) => {
14
- const ctx = await args.requireInstance('context');
15
- const app = await args.requireInstance('app');
16
- return new ContextSelectedCollector(ctx, app);
17
- });
18
- ```
19
-
20
- ## AppSelectedCollector
21
-
22
- Emits an event when the active application changes. Includes the new and
23
- previous app key metadata.
24
-
25
- ```typescript
26
- builder.setCollector('app-selected', async (args) => {
27
- const app = await args.requireInstance('app');
28
- return new AppSelectedCollector(app);
29
- });
30
- ```
31
-
32
- ## AppLoadedCollector
33
-
34
- Emits an event when an application's modules finish loading. Includes app
35
- manifest metadata and the current context (if available).
36
-
37
- ```typescript
38
- builder.setCollector('app-loaded', async (args) => {
39
- const event = await args.requireInstance('event');
40
- const app = await args.requireInstance('app');
41
- return new AppLoadedCollector(event, app);
42
- });
43
- ```
44
-
45
- ## Creating a Custom Collector
46
-
47
- ### Extending `BaseCollector`
48
-
49
- Extend `BaseCollector` with a Zod schema for validation:
50
-
51
- ```typescript
52
- import { BaseCollector, createSchema } from '@equinor/fusion-framework-module-analytics/collectors';
53
- import { z } from 'zod';
54
- import { of } from 'rxjs';
55
-
56
- const schema = createSchema(z.string(), z.object({ page: z.string() }));
57
-
58
- class PageViewCollector extends BaseCollector<string, { page: string }> {
59
- constructor() {
60
- super('page-view', schema);
61
- }
62
-
63
- _initialize() {
64
- return of({ value: window.location.pathname, attributes: { page: document.title } });
65
- }
66
- }
67
- ```
68
-
69
- ### Implementing `IAnalyticsCollector` directly
70
-
71
- For cases that don't need schema validation, implement the `Subscribable` contract directly:
72
-
73
- ```typescript
74
- import { type AnalyticsEvent, enableAnalytics } from '@equinor/fusion-framework-module-analytics';
75
- import { Subject } from 'rxjs';
76
-
77
- const configure = (configurator: IModulesConfigurator<any, any>) => {
78
- enableAnalytics(configurator, (builder) => {
79
- builder.setCollector('click-test', async () => {
80
- const subject = new Subject<AnalyticsEvent>();
81
- window.addEventListener('click', () => {
82
- subject.next({ name: 'window-clicker', value: 42 });
83
- });
84
-
85
- return {
86
- subscribe: (subscriber) => subject.subscribe(subscriber),
87
- };
88
- });
89
- });
90
- };
91
- ```