@equinor/fusion-framework-module-analytics 0.3.0 → 1.0.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.
- package/CHANGELOG.md +39 -0
- package/README.md +6 -3
- package/dist/esm/collectors/ContextSelectedCollector.js +5 -2
- package/dist/esm/collectors/ContextSelectedCollector.js.map +1 -1
- package/dist/esm/collectors/utils/extractContextMetadata.js +3 -3
- package/dist/esm/collectors/utils/extractContextMetadata.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/collectors/ContextSelectedCollector.d.ts +4 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/collectors/ContextSelectedCollector.ts +11 -4
- package/src/collectors/utils/extractContextMetadata.ts +3 -3
- package/src/version.ts +1 -1
|
@@ -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
|
}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "1.0.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-module-analytics",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.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",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"rxjs": "^7.8.1",
|
|
50
50
|
"uuid": "^13.0.0",
|
|
51
51
|
"zod": "^4.1.11",
|
|
52
|
-
"@equinor/fusion-framework-module": "5.0.5",
|
|
53
52
|
"@equinor/fusion-framework-module-context": "7.0.2",
|
|
54
53
|
"@equinor/fusion-framework-module-event": "5.0.0",
|
|
55
54
|
"@equinor/fusion-framework-module-http": "7.0.7",
|
|
56
|
-
"@equinor/fusion-framework-module-app": "7.4.0"
|
|
55
|
+
"@equinor/fusion-framework-module-app": "7.4.0",
|
|
56
|
+
"@equinor/fusion-framework-module": "5.0.5"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"typescript": "^5.8.2",
|
|
@@ -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(
|
|
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
|
}),
|
|
@@ -19,9 +19,9 @@ export type ContextItemType = z.infer<typeof contextSchema>;
|
|
|
19
19
|
export const extractContextMetadata = (context: ContextItem): z.input<typeof contextSchema> => {
|
|
20
20
|
return {
|
|
21
21
|
id: context.id,
|
|
22
|
-
externalId: context.externalId,
|
|
23
|
-
title: context.title,
|
|
22
|
+
externalId: context.externalId ?? undefined,
|
|
23
|
+
title: context.title ?? undefined,
|
|
24
24
|
type: context.type.id,
|
|
25
|
-
source: context.source,
|
|
25
|
+
source: context.source ?? undefined,
|
|
26
26
|
};
|
|
27
27
|
};
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '0.
|
|
2
|
+
export const version = '1.0.1';
|