@lwrjs/o11y 0.11.0-alpha.4 → 0.11.0-alpha.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.
@@ -1,2 +1,2 @@
1
- import{getInstrumentation as t}from"o11y/client";import{MODULE_DEFINE as e,MODULE_DEFINE_COUNT as r,BOOTSTRAP_END as n,BOOTSTRAP_DURATION as i,MODULE_FETCH as s,MODULE_FETCH_DURATION as a,MAPPINGS_FETCH as o,MAPPINGS_FETCH_DURATION as c,INIT as m,INIT_MODULE as l,ROUTER_NAV as h,ROUTER_VIEW as u,INIT_DURATION as f,INIT_MODULE_DURATION as k,ROUTER_NAV_DURATION as g,ROUTER_VIEW_DURATION as p,BOOTSTRAP_ERROR as b,BOOTSTRAP_ERROR_COUNT as y,INIT_MODULE_COUNT as T,MODULE_FETCH_COUNT as d,MODULE_ERROR as v,MODULE_ERROR_COUNT as E,MAPPINGS_FETCH_COUNT as M,MAPPINGS_ERROR as O,MAPPINGS_ERROR_COUNT as W,ROUTER_NAV_COUNT as w,ROUTER_ERROR as V,ROUTER_ERROR_COUNT as j}from"lwr/metrics";const x=[s,o,m,l,h,u],C={[m]:f,[l]:k,[h]:g,[u]:p},F=Object.keys(C),B={[b]:y,[l]:T,[e]:r,[s]:d,[v]:E,[o]:M,[O]:W,[h]:w,[V]:j},L=Object.keys(B);class P{constructor(t,e){this.config=e||{},this.instrumentation=t}track(){this.trackExistingMarks(),this.setupObserver()}trackExistingMarks(){const t=performance.getEntriesByType("mark").filter((t=>t.name.startsWith(e)));t.length>0&&this.instrumentation.incrementCounter(r,t.length)}setupObserver(){new PerformanceObserver((t=>{t.getEntries().forEach((t=>{const{name:e,duration:r,startTime:m,entryType:l}=t,h=e.split("-")[0];if(e===n&&this.instrumentation.trackValue(i,m),"mark"===l){const e=t.detail||{},r=L.find((t=>t===h));r&&this.instrumentation.incrementCounter(B[r],1,!1,e)}if("measure"===l){const n=t.detail||{};this.config.enableModuleFetchTracking&&e.startsWith(s)&&this.instrumentation.trackValue(a,r,!1,n),this.config.enableMappingFetchTracking&&e.startsWith(o)&&this.instrumentation.trackValue(c,r,!1,n);const i=F.find((t=>t===h));i&&this.instrumentation.trackValue(C[i],r,!1,n)}x.some((t=>e.startsWith(t)))||performance.clearMarks(e)}))})).observe({entryTypes:["mark","measure"]})}}const R=void 0!==globalThis.performance&&"function"==typeof globalThis.performance.mark,q=globalThis.LWR,z={track:()=>{}};function A(e){const r=t("lwrjs"),n=q.metricsConfig||{};(R?new P(r,n):z).track()}export{A as default};
1
+ import{getInstrumentation as t}from"o11y/client";import{MODULE_DEFINE as e,MODULE_DYNAMIC_LOAD as n,MODULE_DEFINE_COUNT as r,MODULE_DYNAMIC_LOAD_COUNT as i,BOOTSTRAP_END as s,BOOTSTRAP_DURATION as a,MODULE_FETCH as o,MODULE_FETCH_DURATION as c,MAPPINGS_FETCH as m,MAPPINGS_FETCH_DURATION as h,INIT as l,INIT_MODULE as u,ROUTER_NAV as f,ROUTER_VIEW as k,INIT_DURATION as g,INIT_MODULE_DURATION as p,ROUTER_NAV_DURATION as y,ROUTER_VIEW_DURATION as b,BOOTSTRAP_ERROR as T,BOOTSTRAP_ERROR_COUNT as d,INIT_MODULE_COUNT as E,MODULE_FETCH_COUNT as W,MODULE_ERROR as v,MODULE_ERROR_COUNT as M,MAPPINGS_FETCH_COUNT as O,MAPPINGS_ERROR as w,MAPPINGS_ERROR_COUNT as C,ROUTER_NAV_COUNT as V,ROUTER_ERROR as j,ROUTER_ERROR_COUNT as x}from"lwr/metrics";const B=[n,o,m,l,u,f,k],F={[l]:g,[u]:p,[f]:y,[k]:b},L=Object.keys(F),P={[T]:d,[u]:E,[e]:r,[o]:W,[v]:M,[n]:i,[m]:O,[w]:C,[f]:V,[j]:x},R=Object.keys(P);class q{constructor(t,e){this.config=e||{},this.instrumentation=t}track(){this.trackExistingMarks(),this.setupObserver()}trackExistingMarks(){const t=performance.getEntriesByType("mark").filter((t=>t.name.startsWith(e))),s=performance.getEntriesByType("mark").filter((t=>t.name.startsWith(n)));t.length>0&&this.instrumentation.incrementCounter(r,t.length),s.length>0&&this.instrumentation.incrementCounter(i,s.length)}setupObserver(){new PerformanceObserver((t=>{t.getEntries().forEach((t=>{const{name:e,duration:n,startTime:r,entryType:i}=t,l=e.split("-")[0];if(e===s&&this.instrumentation.trackValue(a,r),"mark"===i){const e=t.detail||{},n=R.find((t=>t===l));n&&this.instrumentation.incrementCounter(P[n],1,!1,e)}if("measure"===i){const r=t.detail||{};this.config.enableModuleFetchTracking&&e.startsWith(o)&&this.instrumentation.trackValue(c,n,!1,r),this.config.enableMappingFetchTracking&&e.startsWith(m)&&this.instrumentation.trackValue(h,n,!1,r);const i=L.find((t=>t===l));i&&this.instrumentation.trackValue(F[i],n,!1,r)}B.some((t=>e.startsWith(t)))||performance.clearMarks(e)}))})).observe({entryTypes:["mark","measure"]})}}const z=void 0!==globalThis.performance&&"function"==typeof globalThis.performance.mark,A=globalThis.LWR,D={track:()=>{}};function G(e){const n=t("lwrjs"),r=A.metricsConfig||{};(z?new q(n,r):D).track()}export{G as default};
2
2
  //# sourceMappingURL=o11yService.js.map
@@ -1,5 +1,5 @@
1
- import { BOOTSTRAP_DURATION, BOOTSTRAP_END, BOOTSTRAP_ERROR, BOOTSTRAP_ERROR_COUNT, INIT, INIT_DURATION, INIT_MODULE, INIT_MODULE_DURATION, INIT_MODULE_COUNT, MAPPINGS_ERROR, MAPPINGS_ERROR_COUNT, MAPPINGS_FETCH, MAPPINGS_FETCH_COUNT, MAPPINGS_FETCH_DURATION, MODULE_DEFINE, MODULE_DEFINE_COUNT, MODULE_ERROR, MODULE_ERROR_COUNT, MODULE_FETCH, MODULE_FETCH_COUNT, MODULE_FETCH_DURATION, ROUTER_ERROR, ROUTER_ERROR_COUNT, ROUTER_NAV, ROUTER_NAV_COUNT, ROUTER_NAV_DURATION, ROUTER_VIEW, ROUTER_VIEW_DURATION } from 'lwr/metrics';
2
- const doNotClear = [MODULE_FETCH, MAPPINGS_FETCH, INIT, INIT_MODULE, ROUTER_NAV, ROUTER_VIEW];
1
+ import { BOOTSTRAP_DURATION, BOOTSTRAP_END, BOOTSTRAP_ERROR, BOOTSTRAP_ERROR_COUNT, INIT, INIT_DURATION, INIT_MODULE, INIT_MODULE_DURATION, INIT_MODULE_COUNT, MAPPINGS_ERROR, MAPPINGS_ERROR_COUNT, MAPPINGS_FETCH, MAPPINGS_FETCH_COUNT, MAPPINGS_FETCH_DURATION, MODULE_DEFINE, MODULE_DEFINE_COUNT, MODULE_ERROR, MODULE_ERROR_COUNT, MODULE_DYNAMIC_LOAD, MODULE_DYNAMIC_LOAD_COUNT, MODULE_FETCH, MODULE_FETCH_COUNT, MODULE_FETCH_DURATION, ROUTER_ERROR, ROUTER_ERROR_COUNT, ROUTER_NAV, ROUTER_NAV_COUNT, ROUTER_NAV_DURATION, ROUTER_VIEW, ROUTER_VIEW_DURATION } from 'lwr/metrics';
2
+ const doNotClear = [MODULE_DYNAMIC_LOAD, MODULE_FETCH, MAPPINGS_FETCH, INIT, INIT_MODULE, ROUTER_NAV, ROUTER_VIEW];
3
3
  const durationMap = {
4
4
  [INIT]: INIT_DURATION,
5
5
  [INIT_MODULE]: INIT_MODULE_DURATION,
@@ -13,6 +13,7 @@ const countMap = {
13
13
  [MODULE_DEFINE]: MODULE_DEFINE_COUNT,
14
14
  [MODULE_FETCH]: MODULE_FETCH_COUNT,
15
15
  [MODULE_ERROR]: MODULE_ERROR_COUNT,
16
+ [MODULE_DYNAMIC_LOAD]: MODULE_DYNAMIC_LOAD_COUNT,
16
17
  [MAPPINGS_FETCH]: MAPPINGS_FETCH_COUNT,
17
18
  [MAPPINGS_ERROR]: MAPPINGS_ERROR_COUNT,
18
19
  [ROUTER_NAV]: ROUTER_NAV_COUNT,
@@ -32,6 +33,7 @@ export class PerformanceApiSink {
32
33
  // Retrieve existing loader define metrics to this point
33
34
  trackExistingMarks() {
34
35
  const defineMarks = performance.getEntriesByType('mark').filter(e => e.name.startsWith(MODULE_DEFINE));
36
+ const dynamicLoadMarks = performance.getEntriesByType('mark').filter(e => e.name.startsWith(MODULE_DYNAMIC_LOAD));
35
37
 
36
38
  // Initialize the module define count
37
39
  // At this point in time, the count will include modules NOT fetched by the loader:
@@ -42,6 +44,9 @@ export class PerformanceApiSink {
42
44
  if (defineMarks.length > 0) {
43
45
  this.instrumentation.incrementCounter(MODULE_DEFINE_COUNT, defineMarks.length);
44
46
  }
47
+ if (dynamicLoadMarks.length > 0) {
48
+ this.instrumentation.incrementCounter(MODULE_DYNAMIC_LOAD_COUNT, dynamicLoadMarks.length);
49
+ }
45
50
  }
46
51
 
47
52
  // Add observer to log future metrics
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.11.0-alpha.4",
7
+ "version": "0.11.0-alpha.7",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "build:bundle": "rollup --config scripts/rollup.moduleBundle.config.cjs"
25
25
  },
26
26
  "dependencies": {
27
- "@lwrjs/shared-utils": "0.11.0-alpha.4"
27
+ "@lwrjs/shared-utils": "0.11.0-alpha.7"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@rollup/plugin-sucrase": "^5.0.1",
@@ -32,7 +32,7 @@
32
32
  "rollup": "^2.78.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "o11y": "246.x"
35
+ "o11y": "248.x"
36
36
  },
37
37
  "lwc": {
38
38
  "modules": [
@@ -50,5 +50,5 @@
50
50
  "engines": {
51
51
  "node": ">=16.0.0"
52
52
  },
53
- "gitHead": "89a7e9815e0e381d9fd67212f0471d9a11f73985"
53
+ "gitHead": "872180fbd00df214ab91971d7ec80ba138a73756"
54
54
  }