@equinor/fusion-framework-module-analytics 3.1.0-next.1 → 3.1.1

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/esm/version.js.map +1 -1
  3. package/dist/tsconfig.tsbuildinfo +1 -1
  4. package/dist/types/version.d.ts +1 -1
  5. package/package.json +11 -8
  6. package/CHANGELOG.md +0 -388
  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
@@ -1 +1 @@
1
- export declare const version = "3.1.0-next.1";
1
+ export declare const version = "3.1.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-analytics",
3
- "version": "3.1.0-next.1",
3
+ "version": "3.1.1",
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": "6.1.3-next.0",
57
- "@equinor/fusion-framework-module-context": "9.0.0-next.0",
58
- "@equinor/fusion-framework-module-event": "6.1.0-next.0",
59
- "@equinor/fusion-framework-module-http": "8.1.0-next.0",
60
- "@equinor/fusion-framework-module-app": "8.1.0-next.0"
59
+ "@equinor/fusion-framework-module-app": "8.1.1",
60
+ "@equinor/fusion-framework-module": "6.1.4",
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.1.2-next.1"
68
+ "@equinor/fusion-observable": "^9.2.2"
66
69
  },
67
70
  "peerDependencies": {
68
- "@equinor/fusion-observable": "9.1.2-next.1"
71
+ "@equinor/fusion-observable": "9.2.2"
69
72
  },
70
73
  "scripts": {
71
74
  "build": "tsc -b",
package/CHANGELOG.md DELETED
@@ -1,388 +0,0 @@
1
- # @equinor/fusion-framework-module-analytics
2
-
3
- ## 3.1.0-next.1
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [6639e6e]
8
- - @equinor/fusion-observable@9.1.2-next.1
9
-
10
- ## 3.1.0-next.0
11
-
12
- ### Minor Changes
13
-
14
- - 2836e0b: Add `MockAnalyticsAdapter` and `./mock` subpath for asserting on tracked analytics events in tests.
15
-
16
- ```ts
17
- import { enableAnalytics } from "@equinor/fusion-framework-module-analytics";
18
- import { MockAnalyticsAdapter } from "@equinor/fusion-framework-module-analytics/mock";
19
-
20
- const recorder = new MockAnalyticsAdapter();
21
-
22
- enableAnalytics(configurator, (builder) => {
23
- builder.setAdapter("mock", async () => recorder);
24
- });
25
-
26
- // ... exercise the app under test, then assert:
27
- const event = await recorder.waitForAnalytic("button-click");
28
- expect(event.attributes?.section).toBe("header");
29
- ```
30
-
31
- ### `getAnalytics(matcher?)`
32
-
33
- Returns recorded events synchronously, filtered by an event name, an array of names, or a predicate. Omit the matcher to get every recorded event.
34
-
35
- ### `waitForAnalytic(matcher, options?)`
36
-
37
- 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.
38
-
39
- ### Patch Changes
40
-
41
- - e8aae1f: Internal: publish every package on the `next` pre-release tag so the whole framework can be installed as a coherent set.
42
-
43
- Packages without their own changes are bumped only to receive a `-next.N` version and the `next` dist-tag on npm. Install with:
44
-
45
- ```bash
46
- pnpm add @equinor/fusion-framework-react-app@next
47
- ```
48
-
49
- - Updated dependencies [e8aae1f]
50
- - Updated dependencies [2836e0b]
51
- - Updated dependencies [2836e0b]
52
- - Updated dependencies [2836e0b]
53
- - Updated dependencies [2836e0b]
54
- - Updated dependencies [2836e0b]
55
- - Updated dependencies [2836e0b]
56
- - Updated dependencies [2836e0b]
57
- - Updated dependencies [2836e0b]
58
- - Updated dependencies [2836e0b]
59
- - Updated dependencies [2836e0b]
60
- - Updated dependencies [2836e0b]
61
- - Updated dependencies [2836e0b]
62
- - Updated dependencies [2836e0b]
63
- - Updated dependencies [2836e0b]
64
- - @equinor/fusion-framework-module@6.1.3-next.0
65
- - @equinor/fusion-framework-module-app@8.1.0-next.0
66
- - @equinor/fusion-framework-module-context@9.0.0-next.0
67
- - @equinor/fusion-framework-module-event@6.1.0-next.0
68
- - @equinor/fusion-framework-module-http@8.1.0-next.0
69
- - @equinor/fusion-observable@9.1.2-next.0
70
-
71
- ## 3.0.6
72
-
73
- ### Patch Changes
74
-
75
- - Updated dependencies [73bfe52]
76
- - @equinor/fusion-framework-module-context@8.0.3
77
-
78
- ## 3.0.5
79
-
80
- ### Patch Changes
81
-
82
- - Updated dependencies [1b9d026]
83
- - Updated dependencies [b92698d]
84
- - @equinor/fusion-framework-module-context@8.0.2
85
- - @equinor/fusion-framework-module@6.1.2
86
-
87
- ## 3.0.4
88
-
89
- ### Patch Changes
90
-
91
- - de2b4fb: Added missing TSDoc comments on class fields flagged by the new `require-property-tsdoc` fusion-lint rule.
92
- - Updated dependencies [de2b4fb]
93
- - @equinor/fusion-framework-module-app@8.0.4
94
- - @equinor/fusion-framework-module-http@8.0.5
95
-
96
- ## 3.0.3
97
-
98
- ### Patch Changes
99
-
100
- - 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`.
101
-
102
- `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.
103
-
104
- ## 3.0.2
105
-
106
- ### Patch Changes
107
-
108
- - 80c3e4a: Internal: resolve fusion-lint warnings across the analytics module.
109
- - Added intent comments above control-flow and RxJS `.pipe()` chains that were missing them.
110
- - Added missing constructor and method TSDoc (including `@param`/`@returns` tags).
111
- - 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.
112
- - Replaced ad-hoc `@TODO` comments in `AnalyticsProvider` with references to [#5098](https://github.com/equinor/fusion-framework/issues/5098).
113
-
114
- No public API changes.
115
-
116
- - 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.
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
- - Updated dependencies [80c3e4a]
138
- - Updated dependencies [80c3e4a]
139
- - @equinor/fusion-framework-module-app@8.0.3
140
- - @equinor/fusion-framework-module-context@8.0.1
141
- - @equinor/fusion-framework-module-event@6.0.1
142
- - @equinor/fusion-framework-module-http@8.0.4
143
- - @equinor/fusion-framework-module@6.1.1
144
- - @equinor/fusion-observable@9.1.1
145
-
146
- ## 3.0.1
147
-
148
- ### Patch Changes
149
-
150
- - 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`.
151
-
152
- ## 3.0.0
153
-
154
- ### Patch Changes
155
-
156
- - Updated dependencies [658af0e]
157
- - @equinor/fusion-observable@9.1.0
158
- - @equinor/fusion-framework-module-app@8.0.2
159
- - @equinor/fusion-framework-module-http@8.0.3
160
-
161
- ## 2.0.7
162
-
163
- ### Patch Changes
164
-
165
- - Updated dependencies [418c14d]
166
- - @equinor/fusion-observable@9.0.3
167
-
168
- ## 2.0.6
169
-
170
- ### Patch Changes
171
-
172
- - Updated dependencies [b7b1d9a]
173
- - Updated dependencies [b7b1d9a]
174
- - Updated dependencies [b7b1d9a]
175
- - Updated dependencies [8dd9b9a]
176
- - @equinor/fusion-framework-module@6.1.0
177
- - @equinor/fusion-observable@9.0.2
178
- - @equinor/fusion-framework-module-app@8.0.2
179
- - @equinor/fusion-framework-module-http@8.0.2
180
-
181
- ## 2.0.5
182
-
183
- ### Patch Changes
184
-
185
- - 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.
186
-
187
- ## 2.0.4
188
-
189
- ### Patch Changes
190
-
191
- - f045ac0: Internal: upgrade `zod` from 4.3.6 to 4.4.3 to resolve validation issues; no public API changes.
192
- - Updated dependencies [f045ac0]
193
- - @equinor/fusion-framework-module-app@8.0.2
194
- - @equinor/fusion-framework-module-http@8.0.1
195
-
196
- ## 2.0.3
197
-
198
- ### Patch Changes
199
-
200
- - a6355fe: Internal: bump `uuid` from `13.0.0` to `14.0.0`.
201
- - Updated dependencies [a6355fe]
202
- - @equinor/fusion-framework-module-app@8.0.1
203
- - @equinor/fusion-observable@9.0.1
204
-
205
- ## 2.0.2
206
-
207
- ### Patch Changes
208
-
209
- - 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.
210
-
211
- ## 2.0.1
212
-
213
- ### Patch Changes
214
-
215
- - 3198879: Internal: update OpenTelemetry dependencies (0.213.x → 0.214.x, resources 2.6.0 → 2.6.1).
216
-
217
- 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.
218
-
219
- ## 2.0.0
220
-
221
- ### Major Changes
222
-
223
- - abffa53: Major version bump for Fusion Framework React 19 release.
224
-
225
- 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.
226
-
227
- **Breaking changes:**
228
- - Peer dependencies now require React 18 or 19 (`^18.0.0 || ^19.0.0`)
229
- - React Router upgraded from v6 to v7
230
- - Navigation module refactored with new history API
231
- - `renderComponent` and `renderApp` now use `createRoot` API
232
-
233
- **Migration:**
234
- - Update your React version to 18.0.0 or higher before upgrading
235
- - Replace `NavigationProvider.createRouter()` with `@equinor/fusion-framework-react-router`
236
- - See individual package changelogs for package-specific migration steps
237
-
238
- ### Patch Changes
239
-
240
- - Updated dependencies [abffa53]
241
- - Updated dependencies [abffa53]
242
- - Updated dependencies [abffa53]
243
- - Updated dependencies [abffa53]
244
- - Updated dependencies [abffa53]
245
- - Updated dependencies [abffa53]
246
- - @equinor/fusion-framework-module@6.0.0
247
- - @equinor/fusion-framework-module-app@8.0.0
248
- - @equinor/fusion-framework-module-context@8.0.0
249
- - @equinor/fusion-framework-module-event@6.0.0
250
- - @equinor/fusion-framework-module-http@8.0.0
251
- - @equinor/fusion-observable@9.0.0
252
-
253
- ## 1.0.2
254
-
255
- ### Patch Changes
256
-
257
- - [#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.
258
-
259
- - [#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.
260
-
261
- - Updated dependencies [[`6aa8e1f`](https://github.com/equinor/fusion-framework/commit/6aa8e1f5c9d852b25e97aa7d98a63008c64d4581)]:
262
- - @equinor/fusion-framework-module-app@7.4.1
263
- - @equinor/fusion-framework-module-context@7.0.3
264
- - @equinor/fusion-framework-module-event@5.0.1
265
- - @equinor/fusion-framework-module-http@7.0.8
266
- - @equinor/fusion-framework-module@5.0.6
267
- - @equinor/fusion-observable@8.5.8
268
-
269
- ## 1.0.1
270
-
271
- ### Patch Changes
272
-
273
- - [#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
274
- optional fields (`externalId`, `title`, `source`), ensuring `null` values from
275
- `ContextItem` are coerced to `undefined` to comply with the Zod context schema.
276
-
277
- ## 1.0.0
278
-
279
- ### Major Changes
280
-
281
- - [#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
282
- constructor argument and includes the currently active application key
283
- (`appKey`) in the event attributes.
284
-
285
- This allows analytics consumers to correlate context-change events with the app
286
- that was active when the context switch occurred.
287
-
288
- **Breaking change for direct users of `ContextSelectedCollector`:** the
289
- constructor now requires a second argument:
290
-
291
- ```typescript
292
- // Before
293
- new ContextSelectedCollector(contextProvider);
294
- // After
295
- new ContextSelectedCollector(contextProvider, appProvider);
296
- ```
297
-
298
- The emitted event attributes schema is extended accordingly:
299
-
300
- ```typescript
301
- // attributes shape
302
- {
303
- previous: ContextMetadata | null | undefined;
304
- appKey?: string; // newly added — the appKey of the active app at the time of the context change
305
- }
306
- ```
307
-
308
- ## 0.3.0
309
-
310
- ### Minor Changes
311
-
312
- - [#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.
313
-
314
- This will accumulate all events happening within 5 seconds and send them as a
315
- batch. This will improve performance.
316
-
317
- ## 0.2.3
318
-
319
- ### Patch Changes
320
-
321
- - Updated dependencies [[`1f5a8e4`](https://github.com/equinor/fusion-framework/commit/1f5a8e475ea30fa1e0f32c7dab885a5a42c50bba)]:
322
- - @equinor/fusion-framework-module-event@5.0.0
323
- - @equinor/fusion-framework-module-app@7.4.0
324
- - @equinor/fusion-framework-module-context@7.0.2
325
-
326
- ## 0.2.2
327
-
328
- ### Patch Changes
329
-
330
- - [#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.
331
-
332
- - Updated dependencies [[`343f5f9`](https://github.com/equinor/fusion-framework/commit/343f5f9cc0acbd8e69b62cc73dda577c9015a620), [`122752b`](https://github.com/equinor/fusion-framework/commit/122752b075113b206583ec2c46240997162329b8)]:
333
- - @equinor/fusion-framework-module-app@7.3.0
334
- - @equinor/fusion-framework-module-event@4.4.1
335
-
336
- ## 0.2.1
337
-
338
- ### Patch Changes
339
-
340
- - [#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
341
-
342
- 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.
343
-
344
- - Updated dependencies [[`f70d66f`](https://github.com/equinor/fusion-framework/commit/f70d66f1bc826e614140adb2c6ee052f98e3b3da)]:
345
- - @equinor/fusion-framework-module-app@7.2.2
346
- - @equinor/fusion-framework-module-http@7.0.6
347
-
348
- ## 0.2.0
349
-
350
- ### Minor Changes
351
-
352
- - [#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
353
- data.
354
-
355
- Example
356
-
357
- ```typescript
358
- const trackFeature = useTrackFeature();
359
-
360
- // Without extra data
361
- trackFeature("SomeComponent:loaded");
362
-
363
- // Send additional data
364
- trackFeature("some:feature:happened", {
365
- extra: "data",
366
- foo: "bar",
367
- });
368
- ```
369
-
370
- ## 0.1.1
371
-
372
- ### Patch Changes
373
-
374
- - [#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
375
-
376
- - Updated dependencies [[`5114ac4`](https://github.com/equinor/fusion-framework/commit/5114ac4f71a60935d0194b9b2766f95adff0ba1e)]:
377
- - @equinor/fusion-framework-module-app@7.2.1
378
-
379
- ## 0.1.0
380
-
381
- ### Minor Changes
382
-
383
- - [#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
384
-
385
- ### Patch Changes
386
-
387
- - Updated dependencies [[`d38cd60`](https://github.com/equinor/fusion-framework/commit/d38cd60472380d60282c2a5672dc6e3bba3e7ca9)]:
388
- - @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
- ```