@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.
- package/CHANGELOG.md +40 -0
- package/README.md +6 -3
- package/dist/esm/adapters/FusionAnalyticsAdapter.js +2 -2
- package/dist/esm/adapters/FusionAnalyticsAdapter.js.map +1 -1
- package/dist/esm/collectors/ContextSelectedCollector.js +5 -2
- package/dist/esm/collectors/ContextSelectedCollector.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 +4 -4
- package/src/adapters/FusionAnalyticsAdapter.ts +2 -2
- package/src/collectors/ContextSelectedCollector.ts +11 -4
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @equinor/fusion-framework-module-analytics
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
constructor argument and includes the currently active application key
|
|
9
|
+
(`appKey`) in the event attributes.
|
|
10
|
+
|
|
11
|
+
This allows analytics consumers to correlate context-change events with the app
|
|
12
|
+
that was active when the context switch occurred.
|
|
13
|
+
|
|
14
|
+
**Breaking change for direct users of `ContextSelectedCollector`:** the
|
|
15
|
+
constructor now requires a second argument:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// Before
|
|
19
|
+
new ContextSelectedCollector(contextProvider);
|
|
20
|
+
// After
|
|
21
|
+
new ContextSelectedCollector(contextProvider, appProvider);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The emitted event attributes schema is extended accordingly:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// attributes shape
|
|
28
|
+
{
|
|
29
|
+
previous: ContextMetadata | null | undefined;
|
|
30
|
+
appKey?: string; // newly added — the appKey of the active app at the time of the context change
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 0.3.0
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- [#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.
|
|
39
|
+
|
|
40
|
+
This will accumulate all events happening within 5 seconds and send them as a
|
|
41
|
+
batch. This will improve performance.
|
|
42
|
+
|
|
3
43
|
## 0.2.3
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -25,7 +25,8 @@ const configure = (configurator: IModulesConfigurator<any, any>) => {
|
|
|
25
25
|
|
|
26
26
|
builder.setCollector('context-selected', async (args) => {
|
|
27
27
|
const contextProvider = await args.requireInstance('context');
|
|
28
|
-
|
|
28
|
+
const appProvider = await args.requireInstance('app');
|
|
29
|
+
return new ContextSelectedCollector(contextProvider, appProvider);
|
|
29
30
|
});
|
|
30
31
|
});
|
|
31
32
|
}
|
|
@@ -180,7 +181,8 @@ const configure = (configurator: IModulesConfigurator<any, any>) => {
|
|
|
180
181
|
enableAnalytics(configurator, (builder) => {
|
|
181
182
|
builder.setCollector('context-selected', async (args) => {
|
|
182
183
|
const contextProvider = await args.requireInstance('context');
|
|
183
|
-
|
|
184
|
+
const appProvider = await args.requireInstance('app');
|
|
185
|
+
return new ContextSelectedCollector(contextProvider, appProvider);
|
|
184
186
|
});
|
|
185
187
|
});
|
|
186
188
|
}
|
|
@@ -210,7 +212,8 @@ const configure = (configurator: IModulesConfigurator<any, any>) => {
|
|
|
210
212
|
enableAnalytics(configurator, (builder) => {
|
|
211
213
|
builder.setCollector('context-selected', async (args) => {
|
|
212
214
|
const contextProvider = await args.requireInstance('context');
|
|
213
|
-
|
|
215
|
+
const appProvider = await args.requireInstance('app');
|
|
216
|
+
return new ContextSelectedCollector(contextProvider, appProvider);
|
|
214
217
|
});
|
|
215
218
|
});
|
|
216
219
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoggerProvider,
|
|
1
|
+
import { LoggerProvider, BatchLogRecordProcessor, } from '@opentelemetry/sdk-logs';
|
|
2
2
|
import { SeverityNumber, } from '@opentelemetry/api-logs';
|
|
3
3
|
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
4
4
|
import { version } from '../version.js';
|
|
@@ -16,7 +16,7 @@ export class FusionAnalyticsAdapter {
|
|
|
16
16
|
constructor(args) {
|
|
17
17
|
this.#logExporter = args.logExporter;
|
|
18
18
|
this.#loggerProvider = new LoggerProvider({
|
|
19
|
-
processors: [new
|
|
19
|
+
processors: [new BatchLogRecordProcessor(this.#logExporter)],
|
|
20
20
|
resource: resourceFromAttributes({
|
|
21
21
|
'module.version': version,
|
|
22
22
|
'session.id': uuid(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FusionAnalyticsAdapter.js","sourceRoot":"","sources":["../../../src/adapters/FusionAnalyticsAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"FusionAnalyticsAdapter.js","sourceRoot":"","sources":["../../../src/adapters/FusionAnalyticsAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,uBAAuB,GAExB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,cAAc,GAIf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0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
*/
|
|
8
|
-
const eventSchema = createSchema(contextSchema, z.object({ previous: contextSchema }));
|
|
8
|
+
const eventSchema = createSchema(contextSchema, z.object({ previous: contextSchema, appKey: z.string().optional() }));
|
|
9
9
|
/**
|
|
10
10
|
* Collector to listen for context changes and add values and attributes for
|
|
11
11
|
* further processing by adapters.
|
|
12
12
|
*/
|
|
13
13
|
export class ContextSelectedCollector extends BaseCollector {
|
|
14
14
|
#contextProvider;
|
|
15
|
-
|
|
15
|
+
#appProvider;
|
|
16
|
+
constructor(contextProvider, appProvider) {
|
|
16
17
|
super('context-selected', eventSchema);
|
|
17
18
|
this.#contextProvider = contextProvider;
|
|
19
|
+
this.#appProvider = appProvider;
|
|
18
20
|
}
|
|
19
21
|
_initialize() {
|
|
20
22
|
const contextSelected$ = this.#contextProvider.currentContext$.pipe(
|
|
@@ -27,6 +29,7 @@ export class ContextSelectedCollector extends BaseCollector {
|
|
|
27
29
|
value: next && extractContextMetadata(next),
|
|
28
30
|
attributes: {
|
|
29
31
|
previous: prev && extractContextMetadata(prev),
|
|
32
|
+
appKey: this.#appProvider.current?.appKey,
|
|
30
33
|
},
|
|
31
34
|
};
|
|
32
35
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextSelectedCollector.js","sourceRoot":"","sources":["../../../src/collectors/ContextSelectedCollector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,GAAG,EAAwB,QAAQ,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ContextSelectedCollector.js","sourceRoot":"","sources":["../../../src/collectors/ContextSelectedCollector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,GAAG,EAAwB,QAAQ,EAAE,MAAM,MAAM,CAAC;AAIjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAEL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