UNPKG

@embrace-io/web-sdk

Version:
1 lines 3.37 kB
{"version":3,"file":"constants.cjs","names":["onCLS","onFCP","onLCP","onINP","onTTFB"],"sources":["../../../../src/instrumentations/web-vitals/WebVitalsInstrumentation/constants.ts"],"sourcesContent":["import { onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals/attribution';\n\nexport const WEB_VITAL_EVENT_NAME = 'browser.web_vital';\nexport const MAX_LOAF_SCRIPT_URL_LENGTH = 2048;\nexport const MAX_LOAF_SCRIPT_ENTRIES = 250;\nexport const MAX_CLS_LAYOUT_SHIFTS = 50;\nexport const ALL_WEB_VITALS = ['CLS', 'INP', 'LCP', 'FCP', 'TTFB'] as const;\nexport const WEB_VITALS_ID_TO_LISTENER = {\n /**\n * Cumulative Layout Shift (CLS)\n * https://web.dev/articles/cls\n *\n * Measures _unexpected_ layout shifts throughout the lifespan of a page load. User-initiated shifts, e.g. showing\n * a loading indicator after a user clicked a button that triggered a network request, are excluded since these are\n * expected.\n *\n * onCLS is always called when the page's visibility state changes to hidden and may be called multiple times for\n * a single page load.\n *\n * SPA Note: Since this is cumulative it could be misleading in a SPA, e.g. you might cross the threshold from\n * good -> bad on Page 3 but the largest contributor to your score might have actually occurred on Page 1\n */\n CLS: onCLS,\n\n /**\n * First Contentful Paint (FCP)\n * https://web.dev/articles/fcp\n *\n * Measures from first hard page load to when the first \"content\" (text, image, svg elements, etc.) is rendered\n *\n * Only measured once per page load\n */\n FCP: onFCP,\n\n /**\n * Largest Contentful Paint (LCP)\n * https://web.dev/articles/lcp\n *\n * Uses heuristics to try and measure when the \"main\" content has been rendered on the page. Size is a factor, but\n * certain elements that likely represent backgrounds or splash screens are excluded.\n *\n * As the page loads the element considered the largest could change, once the user interacts with the page these\n * entries stop getting reported and the metric is ready\n *\n * Only measured once per page load\n */\n LCP: onLCP,\n\n /**\n * Interaction to Next Paint (INP)\n * https://web.dev/articles/inp\n *\n * Measures how long it takes from a user interaction until the next paint. The final INP value is the longest\n * interaction observed, ignoring outliers.\n *\n * onINP is always called when the page's visibility state changes to hidden and may be called multiple times for\n * a single page load.\n *\n * Each interaction is not reported even when setting reportAllChanges=true, just when an interaction causes an\n * increase to INP.\n */\n INP: onINP,\n\n /**\n * Time to First Byte (TTFB)\n * https://web.dev/articles/ttfb\n *\n * Measures the time between the request for a resource and when the first byte of a response begins to arrive.\n */\n TTFB: onTTFB,\n\n // Omitting onFID since FID (First Input Delay) has been deprecated\n FID: undefined,\n} as const;\n"],"mappings":";;;AAEA,MAAa,uBAAuB;AACpC,MAAa,6BAA6B;AAC1C,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,iBAAiB;CAAC;CAAO;CAAO;CAAO;CAAO;AAAM;AACjE,MAAa,4BAA4B;;;;;;;;;;;;;;;CAevC,KAAKA,uBAAAA;;;;;;;;;CAUL,KAAKC,uBAAAA;;;;;;;;;;;;;CAcL,KAAKC,uBAAAA;;;;;;;;;;;;;;CAeL,KAAKC,uBAAAA;;;;;;;CAQL,MAAMC,uBAAAA;CAGN,KAAK,KAAA;AACP"}