@equinor/fusion-framework-module-analytics 0.2.3 → 1.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.
@@ -1,6 +1,7 @@
1
1
  import { type ObservableInput } from 'rxjs';
2
2
  import type { IAnalyticsCollector } from './AnalyticsCollector.interface.js';
3
3
  import type { IContextProvider } from '@equinor/fusion-framework-module-context';
4
+ import type { AppModuleProvider } from '@equinor/fusion-framework-module-app';
4
5
  import { BaseCollector } from './BaseCollector.js';
5
6
  import { type ContextItemType } from './utils/extractContextMetadata.js';
6
7
  /**
@@ -9,13 +10,15 @@ import { type ContextItemType } from './utils/extractContextMetadata.js';
9
10
  */
10
11
  export declare class ContextSelectedCollector extends BaseCollector<ContextItemType, {
11
12
  previous?: ContextItemType;
13
+ appKey?: string;
12
14
  }> implements IAnalyticsCollector {
13
15
  #private;
14
- constructor(contextProvider: IContextProvider);
16
+ constructor(contextProvider: IContextProvider, appProvider: AppModuleProvider);
15
17
  _initialize(): ObservableInput<{
16
18
  value: ContextItemType;
17
19
  attributes: {
18
20
  previous?: ContextItemType;
21
+ appKey?: string;
19
22
  };
20
23
  }>;
21
24
  }
@@ -1 +1 @@
1
- export declare const version = "0.2.3";
1
+ export declare const version = "1.0.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-analytics",
3
- "version": "0.2.3",
3
+ "version": "1.0.0",
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",
@@ -50,10 +50,10 @@
50
50
  "uuid": "^13.0.0",
51
51
  "zod": "^4.1.11",
52
52
  "@equinor/fusion-framework-module": "5.0.5",
53
- "@equinor/fusion-framework-module-app": "7.4.0",
54
- "@equinor/fusion-framework-module-http": "7.0.7",
55
53
  "@equinor/fusion-framework-module-context": "7.0.2",
56
- "@equinor/fusion-framework-module-event": "5.0.0"
54
+ "@equinor/fusion-framework-module-app": "7.4.0",
55
+ "@equinor/fusion-framework-module-event": "5.0.0",
56
+ "@equinor/fusion-framework-module-http": "7.0.7"
57
57
  },
58
58
  "devDependencies": {
59
59
  "typescript": "^5.8.2",
@@ -3,7 +3,7 @@ import type { AnalyticsEvent } from '../types.js';
3
3
 
4
4
  import {
5
5
  LoggerProvider,
6
- SimpleLogRecordProcessor,
6
+ BatchLogRecordProcessor,
7
7
  type ReadableLogRecord,
8
8
  } from '@opentelemetry/sdk-logs';
9
9
  import type { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';
@@ -34,7 +34,7 @@ export class FusionAnalyticsAdapter<T extends AnalyticsEvent = AnalyticsEvent>
34
34
  this.#logExporter = args.logExporter;
35
35
 
36
36
  this.#loggerProvider = new LoggerProvider({
37
- processors: [new SimpleLogRecordProcessor(this.#logExporter)],
37
+ processors: [new BatchLogRecordProcessor(this.#logExporter)],
38
38
  resource: resourceFromAttributes({
39
39
  'module.version': version,
40
40
  'session.id': uuid(),
@@ -1,6 +1,7 @@
1
1
  import { distinctUntilChanged, map, type ObservableInput, pairwise } from 'rxjs';
2
2
  import type { IAnalyticsCollector } from './AnalyticsCollector.interface.js';
3
3
  import type { IContextProvider } from '@equinor/fusion-framework-module-context';
4
+ import type { AppModuleProvider } from '@equinor/fusion-framework-module-app';
4
5
  import { z } from 'zod';
5
6
  import { BaseCollector, createSchema } from './BaseCollector.js';
6
7
  import {
@@ -12,26 +13,31 @@ import {
12
13
  /**
13
14
  * The schema of the data to be sent.
14
15
  */
15
- const eventSchema = createSchema(contextSchema, z.object({ previous: contextSchema }));
16
+ const eventSchema = createSchema(
17
+ contextSchema,
18
+ z.object({ previous: contextSchema, appKey: z.string().optional() }),
19
+ );
16
20
 
17
21
  /**
18
22
  * Collector to listen for context changes and add values and attributes for
19
23
  * further processing by adapters.
20
24
  */
21
25
  export class ContextSelectedCollector
22
- extends BaseCollector<ContextItemType, { previous?: ContextItemType }>
26
+ extends BaseCollector<ContextItemType, { previous?: ContextItemType; appKey?: string }>
23
27
  implements IAnalyticsCollector
24
28
  {
25
29
  #contextProvider: IContextProvider;
30
+ #appProvider: AppModuleProvider;
26
31
 
27
- constructor(contextProvider: IContextProvider) {
32
+ constructor(contextProvider: IContextProvider, appProvider: AppModuleProvider) {
28
33
  super('context-selected', eventSchema);
29
34
  this.#contextProvider = contextProvider;
35
+ this.#appProvider = appProvider;
30
36
  }
31
37
 
32
38
  _initialize(): ObservableInput<{
33
39
  value: ContextItemType;
34
- attributes: { previous?: ContextItemType };
40
+ attributes: { previous?: ContextItemType; appKey?: string };
35
41
  }> {
36
42
  const contextSelected$ = this.#contextProvider.currentContext$.pipe(
37
43
  // Only emit when an actual change has happened.
@@ -46,6 +52,7 @@ export class ContextSelectedCollector
46
52
  value: next && extractContextMetadata(next),
47
53
  attributes: {
48
54
  previous: prev && extractContextMetadata(prev),
55
+ appKey: this.#appProvider.current?.appKey,
49
56
  },
50
57
  };
51
58
  }),
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '0.2.3';
2
+ export const version = '1.0.0';