@kong-ui-public/analytics-config-store 2.0.6 → 2.0.7

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/README.md CHANGED
@@ -30,6 +30,13 @@ The config store uses the host app's Pinia instance, and must only be used after
30
30
 
31
31
  When the store is first instantiated, it makes a call to retrieve the org's analytics config (using the `configFn` from `AnalyticsBridge`). Because the `AnalyticsBridge` is injected using Vue's `provide` / `inject` mechanism, the store must be instantiated either from a component's `setup` block or by using [`app.runWithContext`](https://vuejs.org/api/application.html#app-runwithcontext). Until the call to retrieve analytics config resolves, the store will return `null` for `analyticsConfig` and default values for the various computed properties.
32
32
 
33
+ #### Initialization timing
34
+
35
+ The store calls `configFn` only once, when the store is first created. Pinia keeps the store for the life of the app, so the store never fetches the config again, and a failed fetch is not retried.
36
+
37
+ - Create the store only when the bridge can serve `configFn`. If the bridge's requests need host state that is set later in the app's lifecycle, wait for that state before the first call to `useAnalyticsConfigStore()`. This matters most in early code such as router guards and store setup.
38
+ - `isReady()` resolves when the request succeeds and also when it fails. After a failure, `configError` holds the error, and the computed properties return their defaults (for example, `analytics` and `percentiles` are `false`). Check `configError` when a failed request must not read as "no analytics".
39
+
33
40
  The store exposes several computed properties that attempt to standardize common questions asked of an org's analytics config:
34
41
 
35
42
  - `loading` -- whether the call to retrieve config has resolved
@@ -50,7 +57,10 @@ The datasource config store exposes:
50
57
  - `datasourceConfigMap` -- datasource config keyed by datasource name, with a `fieldsMap` for fast field lookups
51
58
  - `getFieldDataSources` -- a getter that returns all datasource names containing a field
52
59
  - `loading` -- whether the datasource config request is still pending
53
- - `isReady` -- a promise that resolves when datasource config loading succeeds and rejects if datasource config loading fails
60
+ - `datasourceConfigError` -- the error from the datasource config request, or `null`
61
+ - `isReady` -- a promise that resolves when the datasource config request finishes, whether it succeeds or fails. After a failure, `datasourceConfig` is an empty array and `datasourceConfigError` holds the error.
62
+
63
+ Like the analytics config store, this store fetches only once, when it is first created. The [initialization timing](#initialization-timing) notes apply to it as well.
54
64
 
55
65
  ### Using `AnalyticsConfigCheck`
56
66
 
@@ -1,5 +1,13 @@
1
1
  import type { AnalyticsConfigV2 } from '@kong-ui-public/analytics-utilities';
2
2
  export type ConfigStoreState = null | AnalyticsConfigV2;
3
+ /**
4
+ * Caches the org's analytics config, which it gets from the injected `AnalyticsBridge.configFn`.
5
+ *
6
+ * The store calls `configFn` only once, when the store is first created. Pinia keeps the store
7
+ * for the life of the app, so the store never fetches again. Create the store only when the
8
+ * bridge can serve `configFn`: if the bridge's requests need host state that is set later in
9
+ * the app's lifecycle, wait for that state first. A failed fetch is not retried.
10
+ */
3
11
  export declare const useAnalyticsConfigStore: import("pinia").SetupStoreDefinition<"analytics-config", {
4
12
  analyticsConfig: import("vue").Ref<{
5
13
  analytics: {
@@ -1 +1 @@
1
- {"version":3,"file":"analytics-config.d.ts","sourceRoot":"","sources":["../../../src/stores/analytics-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAU7F,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,CAAA;AAEvD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAgDd,OAAO,CAAC,IAAI,CAAC;;EAwCjC,CAAA"}
1
+ {"version":3,"file":"analytics-config.d.ts","sourceRoot":"","sources":["../../../src/stores/analytics-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAU7F,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,CAAA;AAEvD;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAsDd,OAAO,CAAC,IAAI,CAAC;;EAwCjC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kong-ui-public/analytics-config-store",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/vitals-config-store.umd.js",
6
6
  "module": "./dist/vitals-config-store.es.js",