@salesforce/lds-instrumentation 1.280.0 → 1.281.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.
@@ -984,6 +984,9 @@ function startAdapterActivity(instrumentation, adapterName, requestContext) {
984
984
  }
985
985
  return instrumentation.startActivity(adapterName, apiOptions);
986
986
  }
987
+ const executeAsyncActivityDefaultOptions = {
988
+ LOG_ERROR_ONLY: false,
989
+ };
987
990
  /**
988
991
  * Starts an async o11y Activity using ldsInstrumentation.
989
992
  *
@@ -992,17 +995,31 @@ function startAdapterActivity(instrumentation, adapterName, requestContext) {
992
995
  */
993
996
  async function executeAsyncActivity(name, execute, options) {
994
997
  var _a, _b, _c, _d;
998
+ const normalizedOptions = Object.assign({}, executeAsyncActivityDefaultOptions, options);
995
999
  const act = ldsInstrumentation.startActivity(name, options);
1000
+ let isError = false;
996
1001
  try {
997
1002
  return await execute(act);
998
1003
  }
999
1004
  catch (err) {
1005
+ act.error(err,
1006
+ // eslint-disable-next-line @salesforce/lds/no-optional-chaining
1007
+ (_a = normalizedOptions.errorPayload) === null || _a === void 0 ? void 0 : _a.schema,
1000
1008
  // eslint-disable-next-line @salesforce/lds/no-optional-chaining
1001
- act.error(err, (_a = options === null || options === void 0 ? void 0 : options.errorPayload) === null || _a === void 0 ? void 0 : _a.schema, (_b = options === null || options === void 0 ? void 0 : options.errorPayload) === null || _b === void 0 ? void 0 : _b.payload);
1009
+ (_b = normalizedOptions.errorPayload) === null || _b === void 0 ? void 0 : _b.payload);
1010
+ isError = true;
1002
1011
  }
1003
1012
  finally {
1004
- // eslint-disable-next-line @salesforce/lds/no-optional-chaining
1005
- act.stop((_c = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _c === void 0 ? void 0 : _c.schema, (_d = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _d === void 0 ? void 0 : _d.payload);
1013
+ if (normalizedOptions.LOG_ERROR_ONLY && !isError) {
1014
+ act.discard();
1015
+ }
1016
+ else {
1017
+ act.stop(
1018
+ // eslint-disable-next-line @salesforce/lds/no-optional-chaining
1019
+ (_c = normalizedOptions === null || normalizedOptions === void 0 ? void 0 : normalizedOptions.stopPayload) === null || _c === void 0 ? void 0 : _c.schema,
1020
+ // eslint-disable-next-line @salesforce/lds/no-optional-chaining
1021
+ (_d = normalizedOptions === null || normalizedOptions === void 0 ? void 0 : normalizedOptions.stopPayload) === null || _d === void 0 ? void 0 : _d.payload);
1022
+ }
1006
1023
  }
1007
1024
  }
1008
1025
  function instrumentAdapter(adapter, metadata, adapterInstrumentationOptions) {
@@ -1537,4 +1554,4 @@ function onIdleDetected(callback) {
1537
1554
  const instrumentation = new Instrumentation();
1538
1555
 
1539
1556
  export { Instrumentation, LRUCache, metricKeys as METRIC_KEYS, executeAsyncActivity, handleIngestedNewData, handleOnDataOutOfTtlDurationUpdate, incrementCounterMetric, incrementGetRecordNormalInvokeCount, incrementGetRecordNotifyChangeAllowCount, incrementGetRecordNotifyChangeDropCount, incrementNotifyRecordUpdateAvailableAllowCount, incrementNotifyRecordUpdateAvailableDropCount, instrumentAdapter, instrumentLuvio, instrumentMethods, instrumentStoreMethods, instrumentation, logObjectInfoChanged, onIdleDetected, setInstrumentationHooks, setLdsAdaptersUiapiInstrumentation, setLdsNetworkAdapterInstrumentation, setStoreEventObservers, setupInstrumentation, startAdapterActivity, updatePercentileHistogramMetric };
1540
- // version: 1.280.0-92c104b03
1557
+ // version: 1.281.0-9a56a08f0
@@ -45,13 +45,16 @@ export interface RequestCorrelator {
45
45
  * If an ObservabilityContext is defined, we build an object that conforms to the ApiOptions interface required by the startActivity API
46
46
  */
47
47
  export declare function startAdapterActivity(instrumentation: o11yInstrumentation, adapterName: string, requestContext?: AdapterRequestContext): Activity;
48
+ export type ExecuteAsyncActivityOptions = {
49
+ LOG_ERROR_ONLY?: boolean;
50
+ };
48
51
  /**
49
52
  * Starts an async o11y Activity using ldsInstrumentation.
50
53
  *
51
54
  * Heavily borrowed from o11y asyncActivity, but actually swallows the error instead of rethrowing.
52
55
  *
53
56
  */
54
- export declare function executeAsyncActivity(name: string, execute: (act: Activity) => Promise<unknown>, options?: ActivityApiOptions | undefined): Promise<unknown>;
57
+ export declare function executeAsyncActivity<T>(name: string, execute: (act: Activity) => Promise<T>, options?: ExecuteAsyncActivityOptions & ActivityApiOptions): Promise<T | undefined>;
55
58
  export declare function instrumentAdapter<C, D>(adapter: Adapter<C, D>, metadata: AdapterMetadata, adapterInstrumentationOptions?: AdapterInstrumentationOptions): Adapter<C, D>;
56
59
  /**
57
60
  * Wraps methods to collect runtime performance using o11y's trackValue API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-instrumentation",
3
- "version": "1.280.0",
3
+ "version": "1.281.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "Instrumentation utils for Lightning Data Service",
6
6
  "main": "dist/ldsInstrumentation.js",
@@ -33,22 +33,22 @@
33
33
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-instrumentation"
34
34
  },
35
35
  "dependencies": {
36
- "@salesforce/lds-bindings": "^1.280.0",
37
- "@salesforce/lds-default-luvio": "^1.280.0",
38
- "@salesforce/lds-utils-adapters": "^1.280.0",
36
+ "@salesforce/lds-bindings": "^1.281.0",
37
+ "@salesforce/lds-default-luvio": "^1.281.0",
38
+ "@salesforce/lds-utils-adapters": "^1.281.0",
39
39
  "o11y": "244.0.0",
40
40
  "o11y_schema": "248.40.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-uiapi": "^1.280.0",
44
- "@salesforce/lds-network-adapter": "^1.280.0",
45
- "@salesforce/nimbus-plugin-lds": "^1.280.0"
43
+ "@salesforce/lds-adapters-uiapi": "^1.281.0",
44
+ "@salesforce/lds-network-adapter": "^1.281.0",
45
+ "@salesforce/nimbus-plugin-lds": "^1.281.0"
46
46
  },
47
47
  "luvioBundlesize": [
48
48
  {
49
49
  "path": "./dist/ldsInstrumentation.js",
50
50
  "maxSize": {
51
- "none": "62 kB",
51
+ "none": "64 kB",
52
52
  "min": "27 kB",
53
53
  "compressed": "12 kB"
54
54
  }