@salesforce/lds-store-nimbus 1.354.0-dev2 → 1.354.0-dev21

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DefaultDurableSegment } from '@luvio/environments';
2
- import { idleDetector } from 'o11y/client';
2
+ import { idleDetector, getInstrumentation } from 'o11y/client';
3
3
 
4
4
  const { keys, create, assign, entries, values } = Object;
5
5
  const { stringify, parse } = JSON;
@@ -245,6 +245,9 @@ class LdsInternalDataTable {
245
245
  }
246
246
 
247
247
  const tasker = idleDetector.declareNotifierTaskMulti('NimbusSqliteStore');
248
+ const instrumentation = getInstrumentation('lds-mobile');
249
+ const GRAPHQL_QUERY_ROOT_KEY = 'UiApi::uiapi::Query[uiapi]__uiapi__query';
250
+ const GRAPHQL_QUERY_ROOT_METRIC_NAME = 'gql-query-root-object-size';
248
251
  class NimbusSqliteStore {
249
252
  constructor(plugin, additionalTableMap = {}) {
250
253
  this.plugin = plugin;
@@ -296,6 +299,9 @@ class NimbusSqliteStore {
296
299
  }
297
300
  const table = this.getTable(segment);
298
301
  const upsertOperation = table.entriesToUpsertOperations(entries, segment);
302
+ if (entries[GRAPHQL_QUERY_ROOT_KEY]) {
303
+ this.trackGraphQLQueryRootSize(upsertOperation);
304
+ }
299
305
  return this.batchOperationAsPromise([upsertOperation]);
300
306
  }
301
307
  setMetadata(entries, segment) {
@@ -311,7 +317,11 @@ class NimbusSqliteStore {
311
317
  if (cur.type === 'setEntries') {
312
318
  if (keys(cur.entries).length > 0) {
313
319
  const table = this.getTable(cur.segment);
314
- acc.push(table.entriesToUpsertOperations(cur.entries, cur.segment));
320
+ const upsertOperation = table.entriesToUpsertOperations(cur.entries, cur.segment);
321
+ if (cur.entries[GRAPHQL_QUERY_ROOT_KEY]) {
322
+ this.trackGraphQLQueryRootSize(upsertOperation);
323
+ }
324
+ acc.push(upsertOperation);
315
325
  }
316
326
  }
317
327
  else if (cur.type === 'setMetadata') {
@@ -396,6 +406,19 @@ class NimbusSqliteStore {
396
406
  });
397
407
  }).finally(() => tasker.done());
398
408
  }
409
+ trackGraphQLQueryRootSize(upsertOperation) {
410
+ try {
411
+ if (upsertOperation.type !== 'upsert') {
412
+ return;
413
+ }
414
+ const row = upsertOperation.rows.find((r) => r[0] === GRAPHQL_QUERY_ROOT_KEY);
415
+ if (!(row && row[1] && typeof row[1] === 'string')) {
416
+ return;
417
+ }
418
+ instrumentation.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
419
+ }
420
+ catch { }
421
+ }
399
422
  }
400
423
 
401
424
  // These const values must be in sync with the latest
@@ -1,5 +1,5 @@
1
1
  import type { SqliteResult, SqliteStore, SqliteType } from '@salesforce/lds-store-sql';
2
- import type { SqliteStorePlugin } from '@salesforce/nimbus-plugin-lds';
2
+ import { type SqliteStorePlugin } from '@salesforce/nimbus-plugin-lds';
3
3
  import type { DurableStore, DurableStoreChange, DurableStoreEntries, DurableStoreMetadataEntries, DurableStoreOperation, OnDurableStoreChangedListener } from '@luvio/environments';
4
4
  import type { LdsDataTableBase } from './tables';
5
5
  export type SQLQuery = {
@@ -26,4 +26,5 @@ export declare class NimbusSqliteStore implements SqliteStore, DurableStore {
26
26
  private getTable;
27
27
  private idsToDeleteOperation;
28
28
  private batchOperationAsPromise;
29
+ private trackGraphQLQueryRootSize;
29
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-store-nimbus",
3
- "version": "1.354.0-dev2",
3
+ "version": "1.354.0-dev21",
4
4
  "description": "A nimbus-plugin-based implementation of the Luvio DurableStore and SqliteStore.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "types": "dist/types/index.d.ts",
@@ -28,16 +28,16 @@
28
28
  "o11y": "250.7.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@luvio/environments": "0.156.7",
32
- "@salesforce/lds-store-sql": "^1.354.0-dev2",
33
- "@salesforce/nimbus-plugin-lds": "^1.354.0-dev2"
31
+ "@luvio/environments": "0.157.1-dev5",
32
+ "@salesforce/lds-store-sql": "^1.354.0-dev21",
33
+ "@salesforce/nimbus-plugin-lds": "^1.354.0-dev21"
34
34
  },
35
35
  "luvioBundlesize": [
36
36
  {
37
37
  "path": "./dist/index.js",
38
38
  "maxSize": {
39
- "none": "18 kB",
40
- "min": "8 kB",
39
+ "none": "19 kB",
40
+ "min": "9 kB",
41
41
  "compressed": "3 kB"
42
42
  }
43
43
  }