@equinor/fusion-framework-module-analytics 0.3.0 → 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 CHANGED
@@ -1,5 +1,36 @@
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
+
3
34
  ## 0.3.0
4
35
 
5
36
  ### Minor 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
- return new ContextSelectedCollector(contextProvider);
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
- return new ContextSelectedCollector(contextProvider);
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
- return new ContextSelectedCollector(contextProvider);
215
+ const appProvider = await args.requireInstance('app');
216
+ return new ContextSelectedCollector(contextProvider, appProvider);
214
217
  });
215
218
  });
216
219
  }
@@ -5,16 +5,18 @@ import { contextSchema, extractContextMetadata, } from './utils/extractContextMe
5
5
  /**
6
6
  * The schema of the data to be sent.
7
7
  */
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
- constructor(contextProvider) {
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,QA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