@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 CHANGED
@@ -1,5 +1,44 @@
1
1
  # @equinor/fusion-framework-module-analytics
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4149](https://github.com/equinor/fusion-framework/pull/4149) [`c0f86d0`](https://github.com/equinor/fusion-framework/commit/c0f86d00e939e00e08871aa6a7db3b51b7305220) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - Fix `extractContextMetadata` to use nullish coalescing (`?? undefined`) for
8
+ optional fields (`externalId`, `title`, `source`), ensuring `null` values from
9
+ `ContextItem` are coerced to `undefined` to comply with the Zod context schema.
10
+
11
+ ## 1.0.0
12
+
13
+ ### Major Changes
14
+
15
+ - [#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
16
+ constructor argument and includes the currently active application key
17
+ (`appKey`) in the event attributes.
18
+
19
+ This allows analytics consumers to correlate context-change events with the app
20
+ that was active when the context switch occurred.
21
+
22
+ **Breaking change for direct users of `ContextSelectedCollector`:** the
23
+ constructor now requires a second argument:
24
+
25
+ ```typescript
26
+ // Before
27
+ new ContextSelectedCollector(contextProvider);
28
+ // After
29
+ new ContextSelectedCollector(contextProvider, appProvider);
30
+ ```
31
+
32
+ The emitted event attributes schema is extended accordingly:
33
+
34
+ ```typescript
35
+ // attributes shape
36
+ {
37
+ previous: ContextMetadata | null | undefined;
38
+ appKey?: string; // newly added — the appKey of the active app at the time of the context change
39
+ }
40
+ ```
41
+
3
42
  ## 0.3.0
4
43
 
5
44
  ### 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,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAEL,aAAa,EACb,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,GAAG,YAAY,CAAC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;AAEvF;;;GAGG;AACH,MAAM,OAAO,wBACX,SAAQ,aAA8D;IAGtE,gBAAgB,CAAmB;IAEnC,YAAY,eAAiC;QAC3C,KAAK,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC1C,CAAC;IAED,WAAW;QAIT,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,IAAI;QACjE,gDAAgD;QAChD,oBAAoB,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;QAC3D,0CAA0C;QAC1C,QAAQ,EAAE,CACX,CAAC;QAEF,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;YACnB,OAAO;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AAE,EAAE,CAAC;QAC3D,0CAA0C;QAC1C,QAAQ,EAAE,CACX,CAAC;QAEF,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;YACnB,OAAO;gBACL,KAAK,EAAE,IAAI,IAAI,sBAAsB,CAAC,IAAI,CAAC;gBAC3C,UAAU,EAAE;oBACV,QAAQ,EAAE,IAAI,IAAI,sBAAsB,CAAC,IAAI,CAAC;oBAC9C,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM;iBAC1C;aACF,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -14,10 +14,10 @@ export const contextSchema = z
14
14
  export const extractContextMetadata = (context) => {
15
15
  return {
16
16
  id: context.id,
17
- externalId: context.externalId,
18
- title: context.title,
17
+ externalId: context.externalId ?? undefined,
18
+ title: context.title ?? undefined,
19
19
  type: context.type.id,
20
- source: context.source,
20
+ source: context.source ?? undefined,
21
21
  };
22
22
  };
23
23
  //# sourceMappingURL=extractContextMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extractContextMetadata.js","sourceRoot":"","sources":["../../../../src/collectors/utils/extractContextMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,sEAAsE;AACtE,6CAA6C;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC;KAC3B,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QA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AAC;AACJ,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Generated by genversion.
2
- export const version = '0.3.0';
2
+ export const version = '1.0.1';
3
3
  //# sourceMappingURL=version.js.map