mirror of
https://github.com/MarSeventh/CloudFlare-ImgBed.git
synced 2026-04-29 00:24:57 +00:00
init
This commit is contained in:
110
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getCLS.js
generated
vendored
Normal file
110
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getCLS.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const bindReporter = require('./lib/bindReporter.js');
|
||||
const initMetric = require('./lib/initMetric.js');
|
||||
const observe = require('./lib/observe.js');
|
||||
const onHidden = require('./lib/onHidden.js');
|
||||
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calculates the [CLS](https://web.dev/cls/) value for the current page and
|
||||
* calls the `callback` function once the value is ready to be reported, along
|
||||
* with all `layout-shift` performance entries that were used in the metric
|
||||
* value calculation. The reported value is a `double` (corresponding to a
|
||||
* [layout shift score](https://web.dev/cls/#layout-shift-score)).
|
||||
*
|
||||
* If the `reportAllChanges` configuration option is set to `true`, the
|
||||
* `callback` function will be called as soon as the value is initially
|
||||
* determined as well as any time the value changes throughout the page
|
||||
* lifespan.
|
||||
*
|
||||
* _**Important:** CLS should be continually monitored for changes throughout
|
||||
* the entire lifespan of a page—including if the user returns to the page after
|
||||
* it's been hidden/backgrounded. However, since browsers often [will not fire
|
||||
* additional callbacks once the user has backgrounded a
|
||||
* page](https://developer.chrome.com/blog/page-lifecycle-api/#advice-hidden),
|
||||
* `callback` is always called when the page's visibility state changes to
|
||||
* hidden. As a result, the `callback` function might be called multiple times
|
||||
* during the same page load._
|
||||
*/
|
||||
const onCLS = (
|
||||
onReport,
|
||||
options = {},
|
||||
) => {
|
||||
const metric = initMetric.initMetric('CLS', 0);
|
||||
let report;
|
||||
|
||||
let sessionValue = 0;
|
||||
let sessionEntries = [];
|
||||
|
||||
// const handleEntries = (entries: Metric['entries']) => {
|
||||
const handleEntries = (entries) => {
|
||||
entries.forEach(entry => {
|
||||
// Only count layout shifts without recent user input.
|
||||
if (!entry.hadRecentInput) {
|
||||
const firstSessionEntry = sessionEntries[0];
|
||||
const lastSessionEntry = sessionEntries[sessionEntries.length - 1];
|
||||
|
||||
// If the entry occurred less than 1 second after the previous entry and
|
||||
// less than 5 seconds after the first entry in the session, include the
|
||||
// entry in the current session. Otherwise, start a new session.
|
||||
if (
|
||||
sessionValue &&
|
||||
sessionEntries.length !== 0 &&
|
||||
entry.startTime - lastSessionEntry.startTime < 1000 &&
|
||||
entry.startTime - firstSessionEntry.startTime < 5000
|
||||
) {
|
||||
sessionValue += entry.value;
|
||||
sessionEntries.push(entry);
|
||||
} else {
|
||||
sessionValue = entry.value;
|
||||
sessionEntries = [entry];
|
||||
}
|
||||
|
||||
// If the current session value is larger than the current CLS value,
|
||||
// update CLS and the entries contributing to it.
|
||||
if (sessionValue > metric.value) {
|
||||
metric.value = sessionValue;
|
||||
metric.entries = sessionEntries;
|
||||
if (report) {
|
||||
report();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const po = observe.observe('layout-shift', handleEntries);
|
||||
if (po) {
|
||||
report = bindReporter.bindReporter(onReport, metric, options.reportAllChanges);
|
||||
|
||||
const stopListening = () => {
|
||||
handleEntries(po.takeRecords() );
|
||||
report(true);
|
||||
};
|
||||
|
||||
onHidden.onHidden(stopListening);
|
||||
|
||||
return stopListening;
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
exports.onCLS = onCLS;
|
||||
//# sourceMappingURL=getCLS.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getCLS.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getCLS.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
65
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getFID.js
generated
vendored
Normal file
65
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getFID.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const bindReporter = require('./lib/bindReporter.js');
|
||||
const getVisibilityWatcher = require('./lib/getVisibilityWatcher.js');
|
||||
const initMetric = require('./lib/initMetric.js');
|
||||
const observe = require('./lib/observe.js');
|
||||
const onHidden = require('./lib/onHidden.js');
|
||||
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calculates the [FID](https://web.dev/fid/) value for the current page and
|
||||
* calls the `callback` function once the value is ready, along with the
|
||||
* relevant `first-input` performance entry used to determine the value. The
|
||||
* reported value is a `DOMHighResTimeStamp`.
|
||||
*
|
||||
* _**Important:** since FID is only reported after the user interacts with the
|
||||
* page, it's possible that it will not be reported for some page loads._
|
||||
*/
|
||||
const onFID = (onReport) => {
|
||||
const visibilityWatcher = getVisibilityWatcher.getVisibilityWatcher();
|
||||
const metric = initMetric.initMetric('FID');
|
||||
// eslint-disable-next-line prefer-const
|
||||
let report;
|
||||
|
||||
const handleEntry = (entry) => {
|
||||
// Only report if the page wasn't hidden prior to the first input.
|
||||
if (entry.startTime < visibilityWatcher.firstHiddenTime) {
|
||||
metric.value = entry.processingStart - entry.startTime;
|
||||
metric.entries.push(entry);
|
||||
report(true);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEntries = (entries) => {
|
||||
(entries ).forEach(handleEntry);
|
||||
};
|
||||
|
||||
const po = observe.observe('first-input', handleEntries);
|
||||
report = bindReporter.bindReporter(onReport, metric);
|
||||
|
||||
if (po) {
|
||||
onHidden.onHidden(() => {
|
||||
handleEntries(po.takeRecords() );
|
||||
po.disconnect();
|
||||
}, true);
|
||||
}
|
||||
};
|
||||
|
||||
exports.onFID = onFID;
|
||||
//# sourceMappingURL=getFID.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getFID.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getFID.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getFID.js","sources":["../../../../src/browser/web-vitals/getFID.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { bindReporter } from './lib/bindReporter';\nimport { getVisibilityWatcher } from './lib/getVisibilityWatcher';\nimport { initMetric } from './lib/initMetric';\nimport { observe } from './lib/observe';\nimport { onHidden } from './lib/onHidden';\nimport type { FIDMetric, PerformanceEventTiming, ReportCallback } from './types';\n\n/**\n * Calculates the [FID](https://web.dev/fid/) value for the current page and\n * calls the `callback` function once the value is ready, along with the\n * relevant `first-input` performance entry used to determine the value. The\n * reported value is a `DOMHighResTimeStamp`.\n *\n * _**Important:** since FID is only reported after the user interacts with the\n * page, it's possible that it will not be reported for some page loads._\n */\nexport const onFID = (onReport: ReportCallback): void => {\n const visibilityWatcher = getVisibilityWatcher();\n const metric = initMetric('FID');\n // eslint-disable-next-line prefer-const\n let report: ReturnType<typeof bindReporter>;\n\n const handleEntry = (entry: PerformanceEventTiming): void => {\n // Only report if the page wasn't hidden prior to the first input.\n if (entry.startTime < visibilityWatcher.firstHiddenTime) {\n metric.value = entry.processingStart - entry.startTime;\n metric.entries.push(entry);\n report(true);\n }\n };\n\n const handleEntries = (entries: FIDMetric['entries']): void => {\n (entries as PerformanceEventTiming[]).forEach(handleEntry);\n };\n\n const po = observe('first-input', handleEntries);\n report = bindReporter(onReport, metric);\n\n if (po) {\n onHidden(() => {\n handleEntries(po.takeRecords() as FIDMetric['entries']);\n po.disconnect();\n }, true);\n }\n};\n"],"names":["getVisibilityWatcher","initMetric","observe","bindReporter","onHidden"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACa,MAAA,KAAA,GAAQ,CAAC,QAAQ,KAA2B;AACzD,EAAE,MAAM,iBAAA,GAAoBA,yCAAoB,EAAE,CAAA;AAClD,EAAE,MAAM,MAAO,GAAEC,qBAAU,CAAC,KAAK,CAAC,CAAA;AAClC;AACA,EAAE,IAAI,MAAM,CAAA;AACZ;AACA,EAAE,MAAM,WAAA,GAAc,CAAC,KAAK,KAAmC;AAC/D;AACA,IAAI,IAAI,KAAK,CAAC,YAAY,iBAAiB,CAAC,eAAe,EAAE;AAC7D,MAAM,MAAM,CAAC,KAAA,GAAQ,KAAK,CAAC,eAAgB,GAAE,KAAK,CAAC,SAAS,CAAA;AAC5D,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAChC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;AAClB,KAAI;AACJ,GAAG,CAAA;AACH;AACA,EAAE,MAAM,aAAA,GAAgB,CAAC,OAAO,KAAiC;AACjE,IAAI,CAAC,OAAQ,GAA6B,OAAO,CAAC,WAAW,CAAC,CAAA;AAC9D,GAAG,CAAA;AACH;AACA,EAAE,MAAM,KAAKC,eAAO,CAAC,aAAa,EAAE,aAAa,CAAC,CAAA;AAClD,EAAE,SAASC,yBAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;AACzC;AACA,EAAE,IAAI,EAAE,EAAE;AACV,IAAIC,iBAAQ,CAAC,MAAM;AACnB,MAAM,aAAa,CAAC,EAAE,CAAC,WAAW,IAA2B,CAAA;AAC7D,MAAM,EAAE,CAAC,UAAU,EAAE,CAAA;AACrB,KAAK,EAAE,IAAI,CAAC,CAAA;AACZ,GAAE;AACF;;;;"}
|
||||
212
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getINP.js
generated
vendored
Normal file
212
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getINP.js
generated
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const bindReporter = require('./lib/bindReporter.js');
|
||||
const initMetric = require('./lib/initMetric.js');
|
||||
const observe = require('./lib/observe.js');
|
||||
const onHidden = require('./lib/onHidden.js');
|
||||
const interactionCountPolyfill = require('./lib/polyfills/interactionCountPolyfill.js');
|
||||
|
||||
/*
|
||||
* Copyright 2022 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the interaction count since the last bfcache restore (or for the
|
||||
* full page lifecycle if there were no bfcache restores).
|
||||
*/
|
||||
const getInteractionCountForNavigation = () => {
|
||||
return interactionCountPolyfill.getInteractionCount();
|
||||
};
|
||||
|
||||
// To prevent unnecessary memory usage on pages with lots of interactions,
|
||||
// store at most 10 of the longest interactions to consider as INP candidates.
|
||||
const MAX_INTERACTIONS_TO_CONSIDER = 10;
|
||||
|
||||
// A list of longest interactions on the page (by latency) sorted so the
|
||||
// longest one is first. The list is as most MAX_INTERACTIONS_TO_CONSIDER long.
|
||||
const longestInteractionList = [];
|
||||
|
||||
// A mapping of longest interactions by their interaction ID.
|
||||
// This is used for faster lookup.
|
||||
const longestInteractionMap = {};
|
||||
|
||||
/**
|
||||
* Takes a performance entry and adds it to the list of worst interactions
|
||||
* if its duration is long enough to make it among the worst. If the
|
||||
* entry is part of an existing interaction, it is merged and the latency
|
||||
* and entries list is updated as needed.
|
||||
*/
|
||||
const processEntry = (entry) => {
|
||||
// The least-long of the 10 longest interactions.
|
||||
const minLongestInteraction = longestInteractionList[longestInteractionList.length - 1];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const existingInteraction = longestInteractionMap[entry.interactionId];
|
||||
|
||||
// Only process the entry if it's possibly one of the ten longest,
|
||||
// or if it's part of an existing interaction.
|
||||
if (
|
||||
existingInteraction ||
|
||||
longestInteractionList.length < MAX_INTERACTIONS_TO_CONSIDER ||
|
||||
entry.duration > minLongestInteraction.latency
|
||||
) {
|
||||
// If the interaction already exists, update it. Otherwise create one.
|
||||
if (existingInteraction) {
|
||||
existingInteraction.entries.push(entry);
|
||||
existingInteraction.latency = Math.max(existingInteraction.latency, entry.duration);
|
||||
} else {
|
||||
const interaction = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
id: entry.interactionId,
|
||||
latency: entry.duration,
|
||||
entries: [entry],
|
||||
};
|
||||
longestInteractionMap[interaction.id] = interaction;
|
||||
longestInteractionList.push(interaction);
|
||||
}
|
||||
|
||||
// Sort the entries by latency (descending) and keep only the top ten.
|
||||
longestInteractionList.sort((a, b) => b.latency - a.latency);
|
||||
longestInteractionList.splice(MAX_INTERACTIONS_TO_CONSIDER).forEach(i => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete longestInteractionMap[i.id];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the estimated p98 longest interaction based on the stored
|
||||
* interaction candidates and the interaction count for the current page.
|
||||
*/
|
||||
const estimateP98LongestInteraction = () => {
|
||||
const candidateInteractionIndex = Math.min(
|
||||
longestInteractionList.length - 1,
|
||||
Math.floor(getInteractionCountForNavigation() / 50),
|
||||
);
|
||||
|
||||
return longestInteractionList[candidateInteractionIndex];
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the [INP](https://web.dev/responsiveness/) value for the current
|
||||
* page and calls the `callback` function once the value is ready, along with
|
||||
* the `event` performance entries reported for that interaction. The reported
|
||||
* value is a `DOMHighResTimeStamp`.
|
||||
*
|
||||
* A custom `durationThreshold` configuration option can optionally be passed to
|
||||
* control what `event-timing` entries are considered for INP reporting. The
|
||||
* default threshold is `40`, which means INP scores of less than 40 are
|
||||
* reported as 0. Note that this will not affect your 75th percentile INP value
|
||||
* unless that value is also less than 40 (well below the recommended
|
||||
* [good](https://web.dev/inp/#what-is-a-good-inp-score) threshold).
|
||||
*
|
||||
* If the `reportAllChanges` configuration option is set to `true`, the
|
||||
* `callback` function will be called as soon as the value is initially
|
||||
* determined as well as any time the value changes throughout the page
|
||||
* lifespan.
|
||||
*
|
||||
* _**Important:** INP should be continually monitored for changes throughout
|
||||
* the entire lifespan of a page—including if the user returns to the page after
|
||||
* it's been hidden/backgrounded. However, since browsers often [will not fire
|
||||
* additional callbacks once the user has backgrounded a
|
||||
* page](https://developer.chrome.com/blog/page-lifecycle-api/#advice-hidden),
|
||||
* `callback` is always called when the page's visibility state changes to
|
||||
* hidden. As a result, the `callback` function might be called multiple times
|
||||
* during the same page load._
|
||||
*/
|
||||
const onINP = (onReport, opts) => {
|
||||
// Set defaults
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
opts = opts || {};
|
||||
|
||||
// https://web.dev/inp/#what's-a-%22good%22-inp-value
|
||||
// const thresholds = [200, 500];
|
||||
|
||||
// TODO(philipwalton): remove once the polyfill is no longer needed.
|
||||
interactionCountPolyfill.initInteractionCountPolyfill();
|
||||
|
||||
const metric = initMetric.initMetric('INP');
|
||||
// eslint-disable-next-line prefer-const
|
||||
let report;
|
||||
|
||||
const handleEntries = (entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.interactionId) {
|
||||
processEntry(entry);
|
||||
}
|
||||
|
||||
// Entries of type `first-input` don't currently have an `interactionId`,
|
||||
// so to consider them in INP we have to first check that an existing
|
||||
// entry doesn't match the `duration` and `startTime`.
|
||||
// Note that this logic assumes that `event` entries are dispatched
|
||||
// before `first-input` entries. This is true in Chrome but it is not
|
||||
// true in Firefox; however, Firefox doesn't support interactionId, so
|
||||
// it's not an issue at the moment.
|
||||
// TODO(philipwalton): remove once crbug.com/1325826 is fixed.
|
||||
if (entry.entryType === 'first-input') {
|
||||
const noMatchingEntry = !longestInteractionList.some(interaction => {
|
||||
return interaction.entries.some(prevEntry => {
|
||||
return entry.duration === prevEntry.duration && entry.startTime === prevEntry.startTime;
|
||||
});
|
||||
});
|
||||
if (noMatchingEntry) {
|
||||
processEntry(entry);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const inp = estimateP98LongestInteraction();
|
||||
|
||||
if (inp && inp.latency !== metric.value) {
|
||||
metric.value = inp.latency;
|
||||
metric.entries = inp.entries;
|
||||
report();
|
||||
}
|
||||
};
|
||||
|
||||
const po = observe.observe('event', handleEntries, {
|
||||
// Event Timing entries have their durations rounded to the nearest 8ms,
|
||||
// so a duration of 40ms would be any event that spans 2.5 or more frames
|
||||
// at 60Hz. This threshold is chosen to strike a balance between usefulness
|
||||
// and performance. Running this callback for any interaction that spans
|
||||
// just one or two frames is likely not worth the insight that could be
|
||||
// gained.
|
||||
durationThreshold: opts.durationThreshold || 40,
|
||||
} );
|
||||
|
||||
report = bindReporter.bindReporter(onReport, metric, opts.reportAllChanges);
|
||||
|
||||
if (po) {
|
||||
// Also observe entries of type `first-input`. This is useful in cases
|
||||
// where the first interaction is less than the `durationThreshold`.
|
||||
po.observe({ type: 'first-input', buffered: true });
|
||||
|
||||
onHidden.onHidden(() => {
|
||||
handleEntries(po.takeRecords() );
|
||||
|
||||
// If the interaction count shows that there were interactions but
|
||||
// none were captured by the PerformanceObserver, report a latency of 0.
|
||||
if (metric.value < 0 && getInteractionCountForNavigation() > 0) {
|
||||
metric.value = 0;
|
||||
metric.entries = [];
|
||||
}
|
||||
|
||||
report(true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.onINP = onINP;
|
||||
//# sourceMappingURL=getINP.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getINP.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getINP.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
90
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getLCP.js
generated
vendored
Normal file
90
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getLCP.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const types = require('../types.js');
|
||||
const bindReporter = require('./lib/bindReporter.js');
|
||||
const getActivationStart = require('./lib/getActivationStart.js');
|
||||
const getVisibilityWatcher = require('./lib/getVisibilityWatcher.js');
|
||||
const initMetric = require('./lib/initMetric.js');
|
||||
const observe = require('./lib/observe.js');
|
||||
const onHidden = require('./lib/onHidden.js');
|
||||
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const reportedMetricIDs = {};
|
||||
|
||||
/**
|
||||
* Calculates the [LCP](https://web.dev/lcp/) value for the current page and
|
||||
* calls the `callback` function once the value is ready (along with the
|
||||
* relevant `largest-contentful-paint` performance entry used to determine the
|
||||
* value). The reported value is a `DOMHighResTimeStamp`.
|
||||
*/
|
||||
const onLCP = (onReport) => {
|
||||
const visibilityWatcher = getVisibilityWatcher.getVisibilityWatcher();
|
||||
const metric = initMetric.initMetric('LCP');
|
||||
let report;
|
||||
|
||||
const handleEntries = (entries) => {
|
||||
const lastEntry = entries[entries.length - 1] ;
|
||||
if (lastEntry) {
|
||||
// The startTime attribute returns the value of the renderTime if it is
|
||||
// not 0, and the value of the loadTime otherwise. The activationStart
|
||||
// reference is used because LCP should be relative to page activation
|
||||
// rather than navigation start if the page was prerendered.
|
||||
const value = Math.max(lastEntry.startTime - getActivationStart.getActivationStart(), 0);
|
||||
|
||||
// Only report if the page wasn't hidden prior to LCP.
|
||||
if (value < visibilityWatcher.firstHiddenTime) {
|
||||
metric.value = value;
|
||||
metric.entries = [lastEntry];
|
||||
report();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const po = observe.observe('largest-contentful-paint', handleEntries);
|
||||
|
||||
if (po) {
|
||||
report = bindReporter.bindReporter(onReport, metric);
|
||||
|
||||
const stopListening = () => {
|
||||
if (!reportedMetricIDs[metric.id]) {
|
||||
handleEntries(po.takeRecords() );
|
||||
po.disconnect();
|
||||
reportedMetricIDs[metric.id] = true;
|
||||
report(true);
|
||||
}
|
||||
};
|
||||
|
||||
// Stop listening after input. Note: while scrolling is an input that
|
||||
// stop LCP observation, it's unreliable since it can be programmatically
|
||||
// generated. See: https://github.com/GoogleChrome/web-vitals/issues/75
|
||||
['keydown', 'click'].forEach(type => {
|
||||
if (types.WINDOW.document) {
|
||||
addEventListener(type, stopListening, { once: true, capture: true });
|
||||
}
|
||||
});
|
||||
|
||||
onHidden.onHidden(stopListening, true);
|
||||
|
||||
return stopListening;
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
exports.onLCP = onLCP;
|
||||
//# sourceMappingURL=getLCP.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getLCP.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/getLCP.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
30
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/bindReporter.js
generated
vendored
Normal file
30
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/bindReporter.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const bindReporter = (
|
||||
callback,
|
||||
metric,
|
||||
reportAllChanges,
|
||||
) => {
|
||||
let prevValue;
|
||||
let delta;
|
||||
return (forceReport) => {
|
||||
if (metric.value >= 0) {
|
||||
if (forceReport || reportAllChanges) {
|
||||
delta = metric.value - (prevValue || 0);
|
||||
|
||||
// Report the metric if there's a non-zero delta or if no previous
|
||||
// value exists (which can happen in the case of the document becoming
|
||||
// hidden when the metric value is 0).
|
||||
// See: https://github.com/GoogleChrome/web-vitals/issues/14
|
||||
if (delta || prevValue === undefined) {
|
||||
prevValue = metric.value;
|
||||
metric.delta = delta;
|
||||
callback(metric);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.bindReporter = bindReporter;
|
||||
//# sourceMappingURL=bindReporter.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/bindReporter.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/bindReporter.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bindReporter.js","sources":["../../../../../src/browser/web-vitals/lib/bindReporter.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Metric, ReportCallback } from '../types';\n\nexport const bindReporter = (\n callback: ReportCallback,\n metric: Metric,\n reportAllChanges?: boolean,\n): ((forceReport?: boolean) => void) => {\n let prevValue: number;\n let delta: number;\n return (forceReport?: boolean) => {\n if (metric.value >= 0) {\n if (forceReport || reportAllChanges) {\n delta = metric.value - (prevValue || 0);\n\n // Report the metric if there's a non-zero delta or if no previous\n // value exists (which can happen in the case of the document becoming\n // hidden when the metric value is 0).\n // See: https://github.com/GoogleChrome/web-vitals/issues/14\n if (delta || prevValue === undefined) {\n prevValue = metric.value;\n metric.delta = delta;\n callback(metric);\n }\n }\n }\n };\n};\n"],"names":[],"mappings":";;AAkBO,MAAM,eAAe;AAC5B,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAE,gBAAgB;AAClB,KAAwC;AACxC,EAAE,IAAI,SAAS,CAAA;AACf,EAAE,IAAI,KAAK,CAAA;AACX,EAAE,OAAO,CAAC,WAAW,KAAe;AACpC,IAAI,IAAI,MAAM,CAAC,KAAM,IAAG,CAAC,EAAE;AAC3B,MAAM,IAAI,WAAY,IAAG,gBAAgB,EAAE;AAC3C,QAAQ,KAAA,GAAQ,MAAM,CAAC,KAAA,IAAS,SAAA,IAAa,CAAC,CAAC,CAAA;AAC/C;AACA;AACA;AACA;AACA;AACA,QAAQ,IAAI,KAAA,IAAS,SAAU,KAAI,SAAS,EAAE;AAC9C,UAAU,SAAU,GAAE,MAAM,CAAC,KAAK,CAAA;AAClC,UAAU,MAAM,CAAC,KAAM,GAAE,KAAK,CAAA;AAC9B,UAAU,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC1B,SAAQ;AACR,OAAM;AACN,KAAI;AACJ,GAAG,CAAA;AACH;;;;"}
|
||||
29
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/generateUniqueID.js
generated
vendored
Normal file
29
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/generateUniqueID.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Performantly generate a unique, 30-char string by combining a version
|
||||
* number, the current timestamp with a 13-digit number integer.
|
||||
* @return {string}
|
||||
*/
|
||||
const generateUniqueID = () => {
|
||||
return `v3-${Date.now()}-${Math.floor(Math.random() * (9e12 - 1)) + 1e12}`;
|
||||
};
|
||||
|
||||
exports.generateUniqueID = generateUniqueID;
|
||||
//# sourceMappingURL=generateUniqueID.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/generateUniqueID.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/generateUniqueID.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"generateUniqueID.js","sources":["../../../../../src/browser/web-vitals/lib/generateUniqueID.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Performantly generate a unique, 30-char string by combining a version\n * number, the current timestamp with a 13-digit number integer.\n * @return {string}\n */\nexport const generateUniqueID = (): string => {\n return `v3-${Date.now()}-${Math.floor(Math.random() * (9e12 - 1)) + 1e12}`;\n};\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACa,MAAA,gBAAA,GAAmB,MAAc;AAC9C,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAC,IAAK,IAAA,GAAO,CAAC,CAAC,CAAA,GAAI,IAAI,CAAC,CAAA,CAAA;AACA;;;;"}
|
||||
27
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getActivationStart.js
generated
vendored
Normal file
27
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getActivationStart.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const getNavigationEntry = require('./getNavigationEntry.js');
|
||||
|
||||
/*
|
||||
* Copyright 2022 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const getActivationStart = () => {
|
||||
const navEntry = getNavigationEntry.getNavigationEntry();
|
||||
return (navEntry && navEntry.activationStart) || 0;
|
||||
};
|
||||
|
||||
exports.getActivationStart = getActivationStart;
|
||||
//# sourceMappingURL=getActivationStart.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getActivationStart.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getActivationStart.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getActivationStart.js","sources":["../../../../../src/browser/web-vitals/lib/getActivationStart.ts"],"sourcesContent":["/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getNavigationEntry } from './getNavigationEntry';\n\nexport const getActivationStart = (): number => {\n const navEntry = getNavigationEntry();\n return (navEntry && navEntry.activationStart) || 0;\n};\n"],"names":["getNavigationEntry"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACa,MAAA,kBAAA,GAAqB,MAAc;AAChD,EAAE,MAAM,QAAA,GAAWA,qCAAkB,EAAE,CAAA;AACvC,EAAE,OAAO,CAAC,QAAS,IAAG,QAAQ,CAAC,eAAe,KAAK,CAAC,CAAA;AACpD;;;;"}
|
||||
55
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getNavigationEntry.js
generated
vendored
Normal file
55
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getNavigationEntry.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const types = require('../../types.js');
|
||||
|
||||
/*
|
||||
* Copyright 2022 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const getNavigationEntryFromPerformanceTiming = () => {
|
||||
// eslint-disable-next-line deprecation/deprecation
|
||||
const timing = types.WINDOW.performance.timing;
|
||||
// eslint-disable-next-line deprecation/deprecation
|
||||
const type = types.WINDOW.performance.navigation.type;
|
||||
|
||||
const navigationEntry = {
|
||||
entryType: 'navigation',
|
||||
startTime: 0,
|
||||
type: type == 2 ? 'back_forward' : type === 1 ? 'reload' : 'navigate',
|
||||
};
|
||||
|
||||
for (const key in timing) {
|
||||
if (key !== 'navigationStart' && key !== 'toJSON') {
|
||||
// eslint-disable-next-line deprecation/deprecation
|
||||
navigationEntry[key] = Math.max((timing[key ] ) - timing.navigationStart, 0);
|
||||
}
|
||||
}
|
||||
return navigationEntry ;
|
||||
};
|
||||
|
||||
const getNavigationEntry = () => {
|
||||
if (types.WINDOW.__WEB_VITALS_POLYFILL__) {
|
||||
return (
|
||||
types.WINDOW.performance &&
|
||||
((performance.getEntriesByType && performance.getEntriesByType('navigation')[0]) ||
|
||||
getNavigationEntryFromPerformanceTiming())
|
||||
);
|
||||
} else {
|
||||
return types.WINDOW.performance && performance.getEntriesByType && performance.getEntriesByType('navigation')[0];
|
||||
}
|
||||
};
|
||||
|
||||
exports.getNavigationEntry = getNavigationEntry;
|
||||
//# sourceMappingURL=getNavigationEntry.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getNavigationEntry.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getNavigationEntry.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getNavigationEntry.js","sources":["../../../../../src/browser/web-vitals/lib/getNavigationEntry.ts"],"sourcesContent":["/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../types';\nimport type { NavigationTimingPolyfillEntry } from '../types';\n\nconst getNavigationEntryFromPerformanceTiming = (): NavigationTimingPolyfillEntry => {\n // eslint-disable-next-line deprecation/deprecation\n const timing = WINDOW.performance.timing;\n // eslint-disable-next-line deprecation/deprecation\n const type = WINDOW.performance.navigation.type;\n\n const navigationEntry: { [key: string]: number | string } = {\n entryType: 'navigation',\n startTime: 0,\n type: type == 2 ? 'back_forward' : type === 1 ? 'reload' : 'navigate',\n };\n\n for (const key in timing) {\n if (key !== 'navigationStart' && key !== 'toJSON') {\n // eslint-disable-next-line deprecation/deprecation\n navigationEntry[key] = Math.max((timing[key as keyof PerformanceTiming] as number) - timing.navigationStart, 0);\n }\n }\n return navigationEntry as unknown as NavigationTimingPolyfillEntry;\n};\n\nexport const getNavigationEntry = (): PerformanceNavigationTiming | NavigationTimingPolyfillEntry | undefined => {\n if (WINDOW.__WEB_VITALS_POLYFILL__) {\n return (\n WINDOW.performance &&\n ((performance.getEntriesByType && performance.getEntriesByType('navigation')[0]) ||\n getNavigationEntryFromPerformanceTiming())\n );\n } else {\n return WINDOW.performance && performance.getEntriesByType && performance.getEntriesByType('navigation')[0];\n }\n};\n"],"names":["WINDOW"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,MAAM,uCAAA,GAA0C,MAAqC;AACrF;AACA,EAAE,MAAM,MAAO,GAAEA,YAAM,CAAC,WAAW,CAAC,MAAM,CAAA;AAC1C;AACA,EAAE,MAAM,OAAOA,YAAM,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAA;AACjD;AACA,EAAE,MAAM,eAAe,GAAuC;AAC9D,IAAI,SAAS,EAAE,YAAY;AAC3B,IAAI,SAAS,EAAE,CAAC;AAChB,IAAI,IAAI,EAAE,IAAK,IAAG,IAAI,cAAA,GAAiB,IAAA,KAAS,CAAA,GAAI,QAAA,GAAW,UAAU;AACzE,GAAG,CAAA;AACH;AACA,EAAE,KAAK,MAAM,GAAI,IAAG,MAAM,EAAE;AAC5B,IAAI,IAAI,GAAI,KAAI,qBAAqB,GAAA,KAAQ,QAAQ,EAAE;AACvD;AACA,MAAM,eAAe,CAAC,GAAG,CAAA,GAAI,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,GAAA,OAA6C,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAA;AACrH,KAAI;AACJ,GAAE;AACF,EAAE,OAAO,eAAgB,EAAA;AACzB,CAAC,CAAA;AACD;AACa,MAAA,kBAAA,GAAqB,MAA+E;AACjH,EAAE,IAAIA,YAAM,CAAC,uBAAuB,EAAE;AACtC,IAAI;AACJ,MAAMA,YAAM,CAAC,WAAY;AACzB,OAAO,CAAC,WAAW,CAAC,oBAAoB,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AACrF,QAAQ,uCAAuC,EAAE,CAAA;AACjD,MAAK;AACL,SAAS;AACT,IAAI,OAAOA,YAAM,CAAC,WAAY,IAAG,WAAW,CAAC,gBAAA,IAAoB,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9G,GAAE;AACF;;;;"}
|
||||
58
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getVisibilityWatcher.js
generated
vendored
Normal file
58
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getVisibilityWatcher.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const types = require('../../types.js');
|
||||
const onHidden = require('./onHidden.js');
|
||||
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let firstHiddenTime = -1;
|
||||
|
||||
const initHiddenTime = () => {
|
||||
// If the document is hidden and not prerendering, assume it was always
|
||||
// hidden and the page was loaded in the background.
|
||||
if (types.WINDOW.document && types.WINDOW.document.visibilityState) {
|
||||
firstHiddenTime = types.WINDOW.document.visibilityState === 'hidden' && !types.WINDOW.document.prerendering ? 0 : Infinity;
|
||||
}
|
||||
};
|
||||
|
||||
const trackChanges = () => {
|
||||
// Update the time if/when the document becomes hidden.
|
||||
onHidden.onHidden(({ timeStamp }) => {
|
||||
firstHiddenTime = timeStamp;
|
||||
}, true);
|
||||
};
|
||||
|
||||
const getVisibilityWatcher = (
|
||||
|
||||
) => {
|
||||
if (firstHiddenTime < 0) {
|
||||
// If the document is hidden when this code runs, assume it was hidden
|
||||
// since navigation start. This isn't a perfect heuristic, but it's the
|
||||
// best we can do until an API is available to support querying past
|
||||
// visibilityState.
|
||||
initHiddenTime();
|
||||
trackChanges();
|
||||
}
|
||||
return {
|
||||
get firstHiddenTime() {
|
||||
return firstHiddenTime;
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
exports.getVisibilityWatcher = getVisibilityWatcher;
|
||||
//# sourceMappingURL=getVisibilityWatcher.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getVisibilityWatcher.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/getVisibilityWatcher.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getVisibilityWatcher.js","sources":["../../../../../src/browser/web-vitals/lib/getVisibilityWatcher.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../types';\nimport { onHidden } from './onHidden';\n\nlet firstHiddenTime = -1;\n\nconst initHiddenTime = (): void => {\n // If the document is hidden and not prerendering, assume it was always\n // hidden and the page was loaded in the background.\n if (WINDOW.document && WINDOW.document.visibilityState) {\n firstHiddenTime = WINDOW.document.visibilityState === 'hidden' && !WINDOW.document.prerendering ? 0 : Infinity;\n }\n};\n\nconst trackChanges = (): void => {\n // Update the time if/when the document becomes hidden.\n onHidden(({ timeStamp }) => {\n firstHiddenTime = timeStamp;\n }, true);\n};\n\nexport const getVisibilityWatcher = (): {\n readonly firstHiddenTime: number;\n} => {\n if (firstHiddenTime < 0) {\n // If the document is hidden when this code runs, assume it was hidden\n // since navigation start. This isn't a perfect heuristic, but it's the\n // best we can do until an API is available to support querying past\n // visibilityState.\n initHiddenTime();\n trackChanges();\n }\n return {\n get firstHiddenTime() {\n return firstHiddenTime;\n },\n };\n};\n"],"names":["WINDOW","onHidden"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA,IAAI,eAAA,GAAkB,CAAC,CAAC,CAAA;AACxB;AACA,MAAM,cAAA,GAAiB,MAAY;AACnC;AACA;AACA,EAAE,IAAIA,YAAM,CAAC,QAAA,IAAYA,YAAM,CAAC,QAAQ,CAAC,eAAe,EAAE;AAC1D,IAAI,kBAAkBA,YAAM,CAAC,QAAQ,CAAC,oBAAoB,QAAA,IAAY,CAACA,YAAM,CAAC,QAAQ,CAAC,eAAe,CAAA,GAAI,QAAQ,CAAA;AAClH,GAAE;AACF,CAAC,CAAA;AACD;AACA,MAAM,YAAA,GAAe,MAAY;AACjC;AACA,EAAEC,iBAAQ,CAAC,CAAC,EAAE,SAAU,EAAC,KAAK;AAC9B,IAAI,eAAA,GAAkB,SAAS,CAAA;AAC/B,GAAG,EAAE,IAAI,CAAC,CAAA;AACV,CAAC,CAAA;AACD;AACO,MAAM,oBAAqB,GAAE;AAClC;AACF,KAAK;AACL,EAAE,IAAI,eAAgB,GAAE,CAAC,EAAE;AAC3B;AACA;AACA;AACA;AACA,IAAI,cAAc,EAAE,CAAA;AACpB,IAAI,YAAY,EAAE,CAAA;AAClB,GAAE;AACF,EAAE,OAAO;AACT,IAAI,IAAI,eAAe,GAAG;AAC1B,MAAM,OAAO,eAAe,CAAA;AAC5B,KAAK;AACL,GAAG,CAAA;AACH;;;;"}
|
||||
48
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/initMetric.js
generated
vendored
Normal file
48
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/initMetric.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const types = require('../../types.js');
|
||||
const generateUniqueID = require('./generateUniqueID.js');
|
||||
const getActivationStart = require('./getActivationStart.js');
|
||||
const getNavigationEntry = require('./getNavigationEntry.js');
|
||||
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const initMetric = (name, value) => {
|
||||
const navEntry = getNavigationEntry.getNavigationEntry();
|
||||
let navigationType = 'navigate';
|
||||
|
||||
if (navEntry) {
|
||||
if ((types.WINDOW.document && types.WINDOW.document.prerendering) || getActivationStart.getActivationStart() > 0) {
|
||||
navigationType = 'prerender';
|
||||
} else {
|
||||
navigationType = navEntry.type.replace(/_/g, '-') ;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
value: typeof value === 'undefined' ? -1 : value,
|
||||
rating: 'good', // Will be updated if the value changes.
|
||||
delta: 0,
|
||||
entries: [],
|
||||
id: generateUniqueID.generateUniqueID(),
|
||||
navigationType,
|
||||
};
|
||||
};
|
||||
|
||||
exports.initMetric = initMetric;
|
||||
//# sourceMappingURL=initMetric.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/initMetric.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/initMetric.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"initMetric.js","sources":["../../../../../src/browser/web-vitals/lib/initMetric.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../types';\nimport type { Metric } from '../types';\nimport { generateUniqueID } from './generateUniqueID';\nimport { getActivationStart } from './getActivationStart';\nimport { getNavigationEntry } from './getNavigationEntry';\n\nexport const initMetric = (name: Metric['name'], value?: number): Metric => {\n const navEntry = getNavigationEntry();\n let navigationType: Metric['navigationType'] = 'navigate';\n\n if (navEntry) {\n if ((WINDOW.document && WINDOW.document.prerendering) || getActivationStart() > 0) {\n navigationType = 'prerender';\n } else {\n navigationType = navEntry.type.replace(/_/g, '-') as Metric['navigationType'];\n }\n }\n\n return {\n name,\n value: typeof value === 'undefined' ? -1 : value,\n rating: 'good', // Will be updated if the value changes.\n delta: 0,\n entries: [],\n id: generateUniqueID(),\n navigationType,\n };\n};\n"],"names":["getNavigationEntry","WINDOW","getActivationStart","generateUniqueID"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA;MACa,UAAW,GAAE,CAAC,IAAI,EAAkB,KAAK,KAAsB;AAC5E,EAAE,MAAM,QAAA,GAAWA,qCAAkB,EAAE,CAAA;AACvC,EAAE,IAAI,cAAc,GAA6B,UAAU,CAAA;AAC3D;AACA,EAAE,IAAI,QAAQ,EAAE;AAChB,IAAI,IAAI,CAACC,YAAM,CAAC,QAAA,IAAYA,YAAM,CAAC,QAAQ,CAAC,YAAY,KAAKC,qCAAkB,EAAG,GAAE,CAAC,EAAE;AACvF,MAAM,cAAA,GAAiB,WAAW,CAAA;AAClC,WAAW;AACX,MAAM,cAAA,GAAiB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAE,EAAA;AACxD,KAAI;AACJ,GAAE;AACF;AACA,EAAE,OAAO;AACT,IAAI,IAAI;AACR,IAAI,KAAK,EAAE,OAAO,KAAM,KAAI,cAAc,CAAC,CAAE,GAAE,KAAK;AACpD,IAAI,MAAM,EAAE,MAAM;AAClB,IAAI,KAAK,EAAE,CAAC;AACZ,IAAI,OAAO,EAAE,EAAE;AACf,IAAI,EAAE,EAAEC,iCAAgB,EAAE;AAC1B,IAAI,cAAc;AAClB,GAAG,CAAA;AACH;;;;"}
|
||||
39
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/observe.js
generated
vendored
Normal file
39
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/observe.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/**
|
||||
* Takes a performance entry type and a callback function, and creates a
|
||||
* `PerformanceObserver` instance that will observe the specified entry type
|
||||
* with buffering enabled and call the callback _for each entry_.
|
||||
*
|
||||
* This function also feature-detects entry support and wraps the logic in a
|
||||
* try/catch to avoid errors in unsupporting browsers.
|
||||
*/
|
||||
const observe = (
|
||||
type,
|
||||
callback,
|
||||
opts,
|
||||
) => {
|
||||
try {
|
||||
if (PerformanceObserver.supportedEntryTypes.includes(type)) {
|
||||
const po = new PerformanceObserver(list => {
|
||||
callback(list.getEntries() );
|
||||
});
|
||||
po.observe(
|
||||
Object.assign(
|
||||
{
|
||||
type,
|
||||
buffered: true,
|
||||
},
|
||||
opts || {},
|
||||
) ,
|
||||
);
|
||||
return po;
|
||||
}
|
||||
} catch (e) {
|
||||
// Do nothing.
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
exports.observe = observe;
|
||||
//# sourceMappingURL=observe.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/observe.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/observe.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"observe.js","sources":["../../../../../src/browser/web-vitals/lib/observe.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { FirstInputPolyfillEntry, NavigationTimingPolyfillEntry, PerformancePaintTiming } from '../types';\n\nexport interface PerformanceEntryHandler {\n (entry: PerformanceEntry): void;\n}\n\ninterface PerformanceEntryMap {\n event: PerformanceEventTiming[];\n paint: PerformancePaintTiming[];\n 'layout-shift': LayoutShift[];\n 'largest-contentful-paint': LargestContentfulPaint[];\n 'first-input': PerformanceEventTiming[] | FirstInputPolyfillEntry[];\n navigation: PerformanceNavigationTiming[] | NavigationTimingPolyfillEntry[];\n resource: PerformanceResourceTiming[];\n longtask: PerformanceEntry[];\n}\n\n/**\n * Takes a performance entry type and a callback function, and creates a\n * `PerformanceObserver` instance that will observe the specified entry type\n * with buffering enabled and call the callback _for each entry_.\n *\n * This function also feature-detects entry support and wraps the logic in a\n * try/catch to avoid errors in unsupporting browsers.\n */\nexport const observe = <K extends keyof PerformanceEntryMap>(\n type: K,\n callback: (entries: PerformanceEntryMap[K]) => void,\n opts?: PerformanceObserverInit,\n): PerformanceObserver | undefined => {\n try {\n if (PerformanceObserver.supportedEntryTypes.includes(type)) {\n const po = new PerformanceObserver(list => {\n callback(list.getEntries() as PerformanceEntryMap[K]);\n });\n po.observe(\n Object.assign(\n {\n type,\n buffered: true,\n },\n opts || {},\n ) as PerformanceObserverInit,\n );\n return po;\n }\n } catch (e) {\n // Do nothing.\n }\n return;\n};\n"],"names":[],"mappings":";;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,UAAU;AACvB,EAAE,IAAI;AACN,EAAE,QAAQ;AACV,EAAE,IAAI;AACN,KAAsC;AACtC,EAAE,IAAI;AACN,IAAI,IAAI,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;AAChE,MAAM,MAAM,EAAG,GAAE,IAAI,mBAAmB,CAAC,QAAQ;AACjD,QAAQ,QAAQ,CAAC,IAAI,CAAC,UAAU,IAA6B,CAAA;AAC7D,OAAO,CAAC,CAAA;AACR,MAAM,EAAE,CAAC,OAAO;AAChB,QAAQ,MAAM,CAAC,MAAM;AACrB,UAAU;AACV,YAAY,IAAI;AAChB,YAAY,QAAQ,EAAE,IAAI;AAC1B,WAAW;AACX,UAAU,IAAA,IAAQ,EAAE;AACpB,SAAU;AACV,OAAO,CAAA;AACP,MAAM,OAAO,EAAE,CAAA;AACf,KAAI;AACJ,GAAI,CAAA,OAAO,CAAC,EAAE;AACd;AACA,GAAE;AACF,EAAE,OAAM;AACR;;;;"}
|
||||
41
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/onHidden.js
generated
vendored
Normal file
41
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/onHidden.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const types = require('../../types.js');
|
||||
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const onHidden = (cb, once) => {
|
||||
const onHiddenOrPageHide = (event) => {
|
||||
if (event.type === 'pagehide' || types.WINDOW.document.visibilityState === 'hidden') {
|
||||
cb(event);
|
||||
if (once) {
|
||||
removeEventListener('visibilitychange', onHiddenOrPageHide, true);
|
||||
removeEventListener('pagehide', onHiddenOrPageHide, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (types.WINDOW.document) {
|
||||
addEventListener('visibilitychange', onHiddenOrPageHide, true);
|
||||
// Some browsers have buggy implementations of visibilitychange,
|
||||
// so we use pagehide in addition, just to be safe.
|
||||
addEventListener('pagehide', onHiddenOrPageHide, true);
|
||||
}
|
||||
};
|
||||
|
||||
exports.onHidden = onHidden;
|
||||
//# sourceMappingURL=onHidden.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/onHidden.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/onHidden.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"onHidden.js","sources":["../../../../../src/browser/web-vitals/lib/onHidden.ts"],"sourcesContent":["/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WINDOW } from '../../types';\n\nexport interface OnHiddenCallback {\n (event: Event): void;\n}\n\nexport const onHidden = (cb: OnHiddenCallback, once?: boolean): void => {\n const onHiddenOrPageHide = (event: Event): void => {\n if (event.type === 'pagehide' || WINDOW.document!.visibilityState === 'hidden') {\n cb(event);\n if (once) {\n removeEventListener('visibilitychange', onHiddenOrPageHide, true);\n removeEventListener('pagehide', onHiddenOrPageHide, true);\n }\n }\n };\n\n if (WINDOW.document) {\n addEventListener('visibilitychange', onHiddenOrPageHide, true);\n // Some browsers have buggy implementations of visibilitychange,\n // so we use pagehide in addition, just to be safe.\n addEventListener('pagehide', onHiddenOrPageHide, true);\n }\n};\n"],"names":["WINDOW"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;MAQa,QAAS,GAAE,CAAC,EAAE,EAAoB,IAAI,KAAqB;AACxE,EAAE,MAAM,kBAAA,GAAqB,CAAC,KAAK,KAAkB;AACrD,IAAI,IAAI,KAAK,CAAC,SAAS,UAAA,IAAcA,YAAM,CAAC,QAAQ,CAAE,eAAgB,KAAI,QAAQ,EAAE;AACpF,MAAM,EAAE,CAAC,KAAK,CAAC,CAAA;AACf,MAAM,IAAI,IAAI,EAAE;AAChB,QAAQ,mBAAmB,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAA;AACzE,QAAQ,mBAAmB,CAAC,UAAU,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAA;AACjE,OAAM;AACN,KAAI;AACJ,GAAG,CAAA;AACH;AACA,EAAE,IAAIA,YAAM,CAAC,QAAQ,EAAE;AACvB,IAAI,gBAAgB,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAA;AAClE;AACA;AACA,IAAI,gBAAgB,CAAC,UAAU,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAA;AAC1D,GAAE;AACF;;;;"}
|
||||
45
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/polyfills/interactionCountPolyfill.js
generated
vendored
Normal file
45
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/polyfills/interactionCountPolyfill.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const observe = require('../observe.js');
|
||||
|
||||
let interactionCountEstimate = 0;
|
||||
let minKnownInteractionId = Infinity;
|
||||
let maxKnownInteractionId = 0;
|
||||
|
||||
const updateEstimate = (entries) => {
|
||||
(entries ).forEach(e => {
|
||||
if (e.interactionId) {
|
||||
minKnownInteractionId = Math.min(minKnownInteractionId, e.interactionId);
|
||||
maxKnownInteractionId = Math.max(maxKnownInteractionId, e.interactionId);
|
||||
|
||||
interactionCountEstimate = maxKnownInteractionId ? (maxKnownInteractionId - minKnownInteractionId) / 7 + 1 : 0;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
let po;
|
||||
|
||||
/**
|
||||
* Returns the `interactionCount` value using the native API (if available)
|
||||
* or the polyfill estimate in this module.
|
||||
*/
|
||||
const getInteractionCount = () => {
|
||||
return po ? interactionCountEstimate : performance.interactionCount || 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Feature detects native support or initializes the polyfill if needed.
|
||||
*/
|
||||
const initInteractionCountPolyfill = () => {
|
||||
if ('interactionCount' in performance || po) return;
|
||||
|
||||
po = observe.observe('event', updateEstimate, {
|
||||
type: 'event',
|
||||
buffered: true,
|
||||
durationThreshold: 0,
|
||||
} );
|
||||
};
|
||||
|
||||
exports.getInteractionCount = getInteractionCount;
|
||||
exports.initInteractionCountPolyfill = initInteractionCountPolyfill;
|
||||
//# sourceMappingURL=interactionCountPolyfill.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/polyfills/interactionCountPolyfill.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/lib/polyfills/interactionCountPolyfill.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"interactionCountPolyfill.js","sources":["../../../../../../src/browser/web-vitals/lib/polyfills/interactionCountPolyfill.ts"],"sourcesContent":["/*\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Metric } from '../../types';\nimport { observe } from '../observe';\n\ndeclare global {\n interface Performance {\n interactionCount: number;\n }\n}\n\nlet interactionCountEstimate = 0;\nlet minKnownInteractionId = Infinity;\nlet maxKnownInteractionId = 0;\n\nconst updateEstimate = (entries: Metric['entries']): void => {\n (entries as PerformanceEventTiming[]).forEach(e => {\n if (e.interactionId) {\n minKnownInteractionId = Math.min(minKnownInteractionId, e.interactionId);\n maxKnownInteractionId = Math.max(maxKnownInteractionId, e.interactionId);\n\n interactionCountEstimate = maxKnownInteractionId ? (maxKnownInteractionId - minKnownInteractionId) / 7 + 1 : 0;\n }\n });\n};\n\nlet po: PerformanceObserver | undefined;\n\n/**\n * Returns the `interactionCount` value using the native API (if available)\n * or the polyfill estimate in this module.\n */\nexport const getInteractionCount = (): number => {\n return po ? interactionCountEstimate : performance.interactionCount || 0;\n};\n\n/**\n * Feature detects native support or initializes the polyfill if needed.\n */\nexport const initInteractionCountPolyfill = (): void => {\n if ('interactionCount' in performance || po) return;\n\n po = observe('event', updateEstimate, {\n type: 'event',\n buffered: true,\n durationThreshold: 0,\n } as PerformanceObserverInit);\n};\n"],"names":["observe"],"mappings":";;;;AAyBA,IAAI,wBAAA,GAA2B,CAAC,CAAA;AAChC,IAAI,qBAAA,GAAwB,QAAQ,CAAA;AACpC,IAAI,qBAAA,GAAwB,CAAC,CAAA;AAC7B;AACA,MAAM,cAAe,GAAE,CAAC,OAAO,KAA8B;AAC7D,EAAE,CAAC,OAAQ,GAA6B,OAAO,CAAC,KAAK;AACrD,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE;AACzB,MAAM,qBAAA,GAAwB,IAAI,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC,aAAa,CAAC,CAAA;AAC9E,MAAM,qBAAA,GAAwB,IAAI,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC,aAAa,CAAC,CAAA;AAC9E;AACA,MAAM,wBAAyB,GAAE,qBAAsB,GAAE,CAAC,qBAAsB,GAAE,qBAAqB,IAAI,CAAA,GAAI,CAAA,GAAI,CAAC,CAAA;AACpH,KAAI;AACJ,GAAG,CAAC,CAAA;AACJ,CAAC,CAAA;AACD;AACA,IAAI,EAAE,CAAA;AACN;AACA;AACA;AACA;AACA;AACa,MAAA,mBAAA,GAAsB,MAAc;AACjD,EAAE,OAAO,KAAK,wBAAA,GAA2B,WAAW,CAAC,gBAAiB,IAAG,CAAC,CAAA;AAC1E,EAAC;AACD;AACA;AACA;AACA;AACa,MAAA,4BAAA,GAA+B,MAAY;AACxD,EAAE,IAAI,kBAAmB,IAAG,eAAe,EAAE,EAAE,OAAM;AACrD;AACA,EAAE,KAAKA,eAAO,CAAC,OAAO,EAAE,cAAc,EAAE;AACxC,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,QAAQ,EAAE,IAAI;AAClB,IAAI,iBAAiB,EAAE,CAAC;AACxB,KAA+B,CAAA;AAC/B;;;;;"}
|
||||
94
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/onTTFB.js
generated
vendored
Normal file
94
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/onTTFB.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const types = require('../types.js');
|
||||
const bindReporter = require('./lib/bindReporter.js');
|
||||
const getActivationStart = require('./lib/getActivationStart.js');
|
||||
const getNavigationEntry = require('./lib/getNavigationEntry.js');
|
||||
const initMetric = require('./lib/initMetric.js');
|
||||
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Runs in the next task after the page is done loading and/or prerendering.
|
||||
* @param callback
|
||||
*/
|
||||
const whenReady = (callback) => {
|
||||
if (!types.WINDOW.document) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (types.WINDOW.document.prerendering) {
|
||||
addEventListener('prerenderingchange', () => whenReady(callback), true);
|
||||
} else if (types.WINDOW.document.readyState !== 'complete') {
|
||||
addEventListener('load', () => whenReady(callback), true);
|
||||
} else {
|
||||
// Queue a task so the callback runs after `loadEventEnd`.
|
||||
setTimeout(callback, 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the [TTFB](https://web.dev/time-to-first-byte/) value for the
|
||||
* current page and calls the `callback` function once the page has loaded,
|
||||
* along with the relevant `navigation` performance entry used to determine the
|
||||
* value. The reported value is a `DOMHighResTimeStamp`.
|
||||
*
|
||||
* Note, this function waits until after the page is loaded to call `callback`
|
||||
* in order to ensure all properties of the `navigation` entry are populated.
|
||||
* This is useful if you want to report on other metrics exposed by the
|
||||
* [Navigation Timing API](https://w3c.github.io/navigation-timing/). For
|
||||
* example, the TTFB metric starts from the page's [time
|
||||
* origin](https://www.w3.org/TR/hr-time-2/#sec-time-origin), which means it
|
||||
* includes time spent on DNS lookup, connection negotiation, network latency,
|
||||
* and server processing time.
|
||||
*/
|
||||
const onTTFB = (onReport, opts) => {
|
||||
// Set defaults
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
opts = opts || {};
|
||||
|
||||
// https://web.dev/ttfb/#what-is-a-good-ttfb-score
|
||||
// const thresholds = [800, 1800];
|
||||
|
||||
const metric = initMetric.initMetric('TTFB');
|
||||
const report = bindReporter.bindReporter(onReport, metric, opts.reportAllChanges);
|
||||
|
||||
whenReady(() => {
|
||||
const navEntry = getNavigationEntry.getNavigationEntry() ;
|
||||
|
||||
if (navEntry) {
|
||||
// The activationStart reference is used because TTFB should be
|
||||
// relative to page activation rather than navigation start if the
|
||||
// page was prerendered. But in cases where `activationStart` occurs
|
||||
// after the first byte is received, this time should be clamped at 0.
|
||||
metric.value = Math.max(navEntry.responseStart - getActivationStart.getActivationStart(), 0);
|
||||
|
||||
// In some cases the value reported is negative or is larger
|
||||
// than the current page time. Ignore these cases:
|
||||
// https://github.com/GoogleChrome/web-vitals/issues/137
|
||||
// https://github.com/GoogleChrome/web-vitals/issues/162
|
||||
if (metric.value < 0 || metric.value > performance.now()) return;
|
||||
|
||||
metric.entries = [navEntry];
|
||||
|
||||
report(true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.onTTFB = onTTFB;
|
||||
//# sourceMappingURL=onTTFB.js.map
|
||||
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/onTTFB.js.map
generated
vendored
Normal file
1
node_modules/@sentry-internal/tracing/cjs/browser/web-vitals/onTTFB.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user