@equinor/fusion-framework-module-analytics 1.0.2 → 2.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +147 -130
  3. package/dist/esm/AnalyticsConfigurator.js +22 -17
  4. package/dist/esm/AnalyticsConfigurator.js.map +1 -1
  5. package/dist/esm/AnalyticsProvider.js +39 -18
  6. package/dist/esm/AnalyticsProvider.js.map +1 -1
  7. package/dist/esm/adapters/ConsoleAnalyticsAdapter.js +15 -1
  8. package/dist/esm/adapters/ConsoleAnalyticsAdapter.js.map +1 -1
  9. package/dist/esm/adapters/FusionAnalyticsAdapter.js +32 -3
  10. package/dist/esm/adapters/FusionAnalyticsAdapter.js.map +1 -1
  11. package/dist/esm/adapters/index.js.map +1 -1
  12. package/dist/esm/collectors/AppLoadedCollector.js +21 -5
  13. package/dist/esm/collectors/AppLoadedCollector.js.map +1 -1
  14. package/dist/esm/collectors/AppSelectedCollector.js +17 -5
  15. package/dist/esm/collectors/AppSelectedCollector.js.map +1 -1
  16. package/dist/esm/collectors/BaseCollector.js +48 -3
  17. package/dist/esm/collectors/BaseCollector.js.map +1 -1
  18. package/dist/esm/collectors/ContextSelectedCollector.js +20 -5
  19. package/dist/esm/collectors/ContextSelectedCollector.js.map +1 -1
  20. package/dist/esm/collectors/index.js.map +1 -1
  21. package/dist/esm/collectors/utils/extractAppMetadata.js +25 -4
  22. package/dist/esm/collectors/utils/extractAppMetadata.js.map +1 -1
  23. package/dist/esm/collectors/utils/extractContextMetadata.js +13 -2
  24. package/dist/esm/collectors/utils/extractContextMetadata.js.map +1 -1
  25. package/dist/esm/enable-analytics.js +18 -3
  26. package/dist/esm/enable-analytics.js.map +1 -1
  27. package/dist/esm/index.js +18 -0
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/logExporters/fusionOTLPLogExporter/FusionOTLPLogExporter.js +26 -4
  30. package/dist/esm/logExporters/fusionOTLPLogExporter/FusionOTLPLogExporter.js.map +1 -1
  31. package/dist/esm/logExporters/fusionOTLPLogExporter/HttpClientExporterTransport.js +36 -7
  32. package/dist/esm/logExporters/fusionOTLPLogExporter/HttpClientExporterTransport.js.map +1 -1
  33. package/dist/esm/logExporters/index.js +8 -0
  34. package/dist/esm/logExporters/index.js.map +1 -1
  35. package/dist/esm/module.js +8 -8
  36. package/dist/esm/version.js +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/dist/types/AnalyticsConfigurator.d.ts +22 -17
  39. package/dist/types/AnalyticsConfigurator.interface.d.ts +41 -12
  40. package/dist/types/AnalyticsProvider.d.ts +32 -18
  41. package/dist/types/AnalyticsProvider.interface.d.ts +28 -6
  42. package/dist/types/adapters/AnalyticsAdapter.interface.d.ts +15 -2
  43. package/dist/types/adapters/ConsoleAnalyticsAdapter.d.ts +15 -1
  44. package/dist/types/adapters/FusionAnalyticsAdapter.d.ts +32 -3
  45. package/dist/types/adapters/index.d.ts +8 -0
  46. package/dist/types/collectors/AnalyticsCollector.interface.d.ts +11 -2
  47. package/dist/types/collectors/AppLoadedCollector.d.ts +20 -2
  48. package/dist/types/collectors/AppSelectedCollector.d.ts +16 -2
  49. package/dist/types/collectors/BaseCollector.d.ts +58 -3
  50. package/dist/types/collectors/ContextSelectedCollector.d.ts +19 -2
  51. package/dist/types/collectors/index.d.ts +8 -0
  52. package/dist/types/collectors/utils/extractAppMetadata.d.ts +27 -0
  53. package/dist/types/collectors/utils/extractContextMetadata.d.ts +14 -0
  54. package/dist/types/enable-analytics.d.ts +19 -3
  55. package/dist/types/index.d.ts +18 -0
  56. package/dist/types/logExporters/fusionOTLPLogExporter/FusionOTLPLogExporter.d.ts +21 -3
  57. package/dist/types/logExporters/fusionOTLPLogExporter/HttpClientExporterTransport.d.ts +24 -1
  58. package/dist/types/logExporters/index.d.ts +8 -0
  59. package/dist/types/module.d.ts +15 -15
  60. package/dist/types/types.d.ts +38 -7
  61. package/dist/types/version.d.ts +1 -1
  62. package/package.json +11 -11
  63. package/src/AnalyticsConfigurator.interface.ts +41 -12
  64. package/src/AnalyticsConfigurator.ts +22 -17
  65. package/src/AnalyticsProvider.interface.ts +28 -6
  66. package/src/AnalyticsProvider.ts +39 -18
  67. package/src/adapters/AnalyticsAdapter.interface.ts +15 -2
  68. package/src/adapters/ConsoleAnalyticsAdapter.ts +15 -1
  69. package/src/adapters/FusionAnalyticsAdapter.ts +32 -3
  70. package/src/adapters/index.ts +8 -0
  71. package/src/collectors/AnalyticsCollector.interface.ts +11 -2
  72. package/src/collectors/AppLoadedCollector.ts +21 -5
  73. package/src/collectors/AppSelectedCollector.ts +17 -5
  74. package/src/collectors/BaseCollector.ts +58 -3
  75. package/src/collectors/ContextSelectedCollector.ts +20 -5
  76. package/src/collectors/index.ts +8 -0
  77. package/src/collectors/utils/extractAppMetadata.ts +27 -4
  78. package/src/collectors/utils/extractContextMetadata.ts +14 -2
  79. package/src/enable-analytics.ts +19 -3
  80. package/src/index.ts +19 -0
  81. package/src/logExporters/fusionOTLPLogExporter/FusionOTLPLogExporter.ts +26 -4
  82. package/src/logExporters/fusionOTLPLogExporter/HttpClientExporterTransport.ts +36 -7
  83. package/src/logExporters/index.ts +8 -0
  84. package/src/module.ts +15 -15
  85. package/src/types.ts +39 -8
  86. package/src/version.ts +1 -1
package/src/module.ts CHANGED
@@ -5,16 +5,16 @@ import { AnalyticsConfigurator } from './AnalyticsConfigurator.js';
5
5
  import { AnalyticsProvider } from './AnalyticsProvider.js';
6
6
 
7
7
  /**
8
- * Representes the Analytics module within the framework.
8
+ * Represents the Analytics module type within the Fusion Framework module system.
9
9
  *
10
10
  * @remarks
11
- * This type defines a module names `analytics` that integrates with the framwork's module system.
12
- * It specifies the provider and configurator interfaces for analytics functionality, and declares
13
- * its dependencies on itself (`AnalyticsModule`).
11
+ * This type defines a module named `analytics` that integrates with the framework's
12
+ * module system. It specifies the provider and configurator interfaces for analytics
13
+ * functionality, and declares a self-dependency so that child modules can inherit
14
+ * analytics from a parent scope.
14
15
  *
15
- * @typeParam IAnalyticsProvider - The interface for the analytics provider implementation.
16
- * @typeParam IAnalyticsConfigurator - The interface for configuring analytics behavior.
17
- * @typeParam AnalyticsModule - Self-reference to allow for recursive or hierarchical module composition.
16
+ * @see {@link IAnalyticsProvider} for the runtime provider interface.
17
+ * @see {@link IAnalyticsConfigurator} for configuration-time setup.
18
18
  */
19
19
  export type AnalyticsModule = Module<
20
20
  'analytics',
@@ -27,15 +27,15 @@ export type AnalyticsModule = Module<
27
27
  * Analytics module definition for the Fusion Framework.
28
28
  *
29
29
  * @remarks
30
- * This module provides analytics capabilities by configuring and initializing a analytics provider.
30
+ * This module provides analytics capabilities by configuring and initializing an
31
+ * {@link AnalyticsProvider}. Register it with {@link enableAnalytics} or add it
32
+ * directly to a module configurator.
31
33
  *
32
- * @type {AnalyticsModule}
33
- *
34
- * @property {string} name - The name of the module ('analytics').
35
- * @property {() => AnalyticsConfigurator} configure - Factory function to create a new AnalyticsConfigurator instance.
36
- * @property {(args) => Promise<IAnalyticsProvider>} initialize - Asynchronous initializer that creates and returns a AnalyticsProvider.
37
- * - @param args - Initialization arguments, including configuration and module dependencies.
38
- * - @returns A promise that resolves to an instance of IAnalyticsProvider.
34
+ * - `name` — `'analytics'`
35
+ * - `configure()` — creates a new {@link AnalyticsConfigurator} instance.
36
+ * - `initialize(args)` resolves the configuration, creates an
37
+ * {@link AnalyticsProvider}, calls {@link AnalyticsProvider.initialize},
38
+ * and returns the ready-to-use provider.
39
39
  */
40
40
  export const module = {
41
41
  name: 'analytics',
package/src/types.ts CHANGED
@@ -1,29 +1,60 @@
1
+ /**
2
+ * Scalar analytics attribute value: a string, number, or boolean.
3
+ *
4
+ * @remarks
5
+ * Mirrors the OpenTelemetry `AnyValue` scalar subset used in log record
6
+ * attributes and event bodies.
7
+ */
1
8
  export type AnyValueScalar = string | number | boolean;
9
+
10
+ /** Array of {@link AnyValue} entries, allowing nested attribute structures. */
2
11
  export type AnyValueArray = Array<AnyValue>;
3
12
 
4
13
  /**
5
- * AnyValueMap is a map from string to AnyValue (attribute value or a nested map)
14
+ * A key–value map where each value is an {@link AnyValue}.
15
+ *
16
+ * Used as the attribute bag on {@link AnalyticsEvent} instances and for
17
+ * nested attribute structures.
6
18
  */
7
19
  export interface AnyValueMap {
8
20
  [attributeKey: string]: AnyValue;
9
21
  }
10
22
 
11
23
  /**
12
- * AnyValue can be one of the following:
13
- * - a scalar value
14
- * - a byte array
15
- * - array of any value
16
- * - map from string to any value
17
- * - empty value
24
+ * A flexible value type compatible with OpenTelemetry log record bodies and attributes.
25
+ *
26
+ * Can be one of the following:
27
+ * - a scalar value (`string | number | boolean`)
28
+ * - a byte array (`Uint8Array`)
29
+ * - an array of any value ({@link AnyValueArray})
30
+ * - a map from string to any value ({@link AnyValueMap})
31
+ * - `null` or `undefined`
18
32
  */
19
-
20
33
  export type AnyValue = AnyValueScalar | Uint8Array | AnyValueArray | AnyValueMap | null | undefined;
21
34
 
35
+ /**
36
+ * Represents a single analytics event emitted by a collector and consumed by adapters.
37
+ *
38
+ * @template TValue - The event body type, defaults to {@link AnyValue}.
39
+ * @template TAttr - The attributes map type, defaults to {@link AnyValueMap}.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const event: AnalyticsEvent = {
44
+ * name: 'button-click',
45
+ * value: 'submit',
46
+ * attributes: { section: 'header', count: 1 },
47
+ * };
48
+ * ```
49
+ */
22
50
  export type AnalyticsEvent<
23
51
  TValue extends AnyValue = AnyValue,
24
52
  TAttr extends AnyValueMap = AnyValueMap,
25
53
  > = {
54
+ /** Descriptive event name used to categorise the analytic, e.g. `'context-selected'`. */
26
55
  name: string;
56
+ /** The primary payload of the event. */
27
57
  value: TValue;
58
+ /** Optional metadata attached to the event for filtering and grouping. */
28
59
  attributes?: TAttr;
29
60
  };
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '1.0.2';
2
+ export const version = '2.0.0';