diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
| commit | 8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch) | |
| tree | 05534d1a720ddc3691d346c69b4972555820a061 /frontend-old/node_modules/@firebase/performance | |
pain
Diffstat (limited to 'frontend-old/node_modules/@firebase/performance')
52 files changed, 5060 insertions, 0 deletions
diff --git a/frontend-old/node_modules/@firebase/performance/README.md b/frontend-old/node_modules/@firebase/performance/README.md new file mode 100644 index 0000000..5c83dbc --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/README.md @@ -0,0 +1,5 @@ +# @firebase/performance + +This is the Firebase Performance component of the Firebase JS SDK. + +**This package is not intended for direct usage, and should only be used via the officially supported [firebase](https://www.npmjs.com/package/firebase) package.** diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/index.esm.js b/frontend-old/node_modules/@firebase/performance/dist/esm/index.esm.js new file mode 100644 index 0000000..ac11e83 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/index.esm.js @@ -0,0 +1,1614 @@ +import { ErrorFactory, areCookiesEnabled, isIndexedDBAvailable, validateIndexedDBOpenable, getModularInstance, deepEqual } from '@firebase/util'; +import { Logger, LogLevel } from '@firebase/logger'; +import { onLCP, onINP, onCLS } from 'web-vitals/attribution'; +import { _getProvider, getApp, _registerComponent, registerVersion } from '@firebase/app'; +import { Component } from '@firebase/component'; +import '@firebase/installations'; + +const name = "@firebase/performance"; +const version = "0.7.9"; + +/** + * @license + * 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 + * + * http://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 SDK_VERSION = version; +/** The prefix for start User Timing marks used for creating Traces. */ +const TRACE_START_MARK_PREFIX = 'FB-PERF-TRACE-START'; +/** The prefix for stop User Timing marks used for creating Traces. */ +const TRACE_STOP_MARK_PREFIX = 'FB-PERF-TRACE-STOP'; +/** The prefix for User Timing measure used for creating Traces. */ +const TRACE_MEASURE_PREFIX = 'FB-PERF-TRACE-MEASURE'; +/** The prefix for out of the box page load Trace name. */ +const OOB_TRACE_PAGE_LOAD_PREFIX = '_wt_'; +const FIRST_PAINT_COUNTER_NAME = '_fp'; +const FIRST_CONTENTFUL_PAINT_COUNTER_NAME = '_fcp'; +const FIRST_INPUT_DELAY_COUNTER_NAME = '_fid'; +const LARGEST_CONTENTFUL_PAINT_METRIC_NAME = '_lcp'; +const LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME = 'lcp_element'; +const INTERACTION_TO_NEXT_PAINT_METRIC_NAME = '_inp'; +const INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME = 'inp_interactionTarget'; +const CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME = '_cls'; +const CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME = 'cls_largestShiftTarget'; +const CONFIG_LOCAL_STORAGE_KEY = '@firebase/performance/config'; +const CONFIG_EXPIRY_LOCAL_STORAGE_KEY = '@firebase/performance/configexpire'; +const SERVICE = 'performance'; +const SERVICE_NAME = 'Performance'; + +/** + * @license + * 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 + * + * http://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 ERROR_DESCRIPTION_MAP = { + ["trace started" /* ErrorCode.TRACE_STARTED_BEFORE */]: 'Trace {$traceName} was started before.', + ["trace stopped" /* ErrorCode.TRACE_STOPPED_BEFORE */]: 'Trace {$traceName} is not running.', + ["nonpositive trace startTime" /* ErrorCode.NONPOSITIVE_TRACE_START_TIME */]: 'Trace {$traceName} startTime should be positive.', + ["nonpositive trace duration" /* ErrorCode.NONPOSITIVE_TRACE_DURATION */]: 'Trace {$traceName} duration should be positive.', + ["no window" /* ErrorCode.NO_WINDOW */]: 'Window is not available.', + ["no app id" /* ErrorCode.NO_APP_ID */]: 'App id is not available.', + ["no project id" /* ErrorCode.NO_PROJECT_ID */]: 'Project id is not available.', + ["no api key" /* ErrorCode.NO_API_KEY */]: 'Api key is not available.', + ["invalid cc log" /* ErrorCode.INVALID_CC_LOG */]: 'Attempted to queue invalid cc event', + ["FB not default" /* ErrorCode.FB_NOT_DEFAULT */]: 'Performance can only start when Firebase app instance is the default one.', + ["RC response not ok" /* ErrorCode.RC_NOT_OK */]: 'RC response is not ok', + ["invalid attribute name" /* ErrorCode.INVALID_ATTRIBUTE_NAME */]: 'Attribute name {$attributeName} is invalid.', + ["invalid attribute value" /* ErrorCode.INVALID_ATTRIBUTE_VALUE */]: 'Attribute value {$attributeValue} is invalid.', + ["invalid custom metric name" /* ErrorCode.INVALID_CUSTOM_METRIC_NAME */]: 'Custom metric name {$customMetricName} is invalid', + ["invalid String merger input" /* ErrorCode.INVALID_STRING_MERGER_PARAMETER */]: 'Input for String merger is invalid, contact support team to resolve.', + ["already initialized" /* ErrorCode.ALREADY_INITIALIZED */]: 'initializePerformance() has already been called with ' + + 'different options. To avoid this error, call initializePerformance() with the ' + + 'same options as when it was originally called, or call getPerformance() to return the' + + ' already initialized instance.' +}; +const ERROR_FACTORY = new ErrorFactory(SERVICE, SERVICE_NAME, ERROR_DESCRIPTION_MAP); + +/** + * @license + * 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 + * + * http://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 consoleLogger = new Logger(SERVICE_NAME); +consoleLogger.logLevel = LogLevel.INFO; + +/** + * @license + * 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 + * + * http://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 apiInstance; +let windowInstance; +/** + * This class holds a reference to various browser related objects injected by + * set methods. + */ +class Api { + constructor(window) { + this.window = window; + if (!window) { + throw ERROR_FACTORY.create("no window" /* ErrorCode.NO_WINDOW */); + } + this.performance = window.performance; + this.PerformanceObserver = window.PerformanceObserver; + this.windowLocation = window.location; + this.navigator = window.navigator; + this.document = window.document; + if (this.navigator && this.navigator.cookieEnabled) { + // If user blocks cookies on the browser, accessing localStorage will + // throw an exception. + this.localStorage = window.localStorage; + } + if (window.perfMetrics && window.perfMetrics.onFirstInputDelay) { + this.onFirstInputDelay = window.perfMetrics.onFirstInputDelay; + } + this.onLCP = onLCP; + this.onINP = onINP; + this.onCLS = onCLS; + } + getUrl() { + // Do not capture the string query part of url. + return this.windowLocation.href.split('?')[0]; + } + mark(name) { + if (!this.performance || !this.performance.mark) { + return; + } + this.performance.mark(name); + } + measure(measureName, mark1, mark2) { + if (!this.performance || !this.performance.measure) { + return; + } + this.performance.measure(measureName, mark1, mark2); + } + getEntriesByType(type) { + if (!this.performance || !this.performance.getEntriesByType) { + return []; + } + return this.performance.getEntriesByType(type); + } + getEntriesByName(name) { + if (!this.performance || !this.performance.getEntriesByName) { + return []; + } + return this.performance.getEntriesByName(name); + } + getTimeOrigin() { + // Polyfill the time origin with performance.timing.navigationStart. + return (this.performance && + (this.performance.timeOrigin || this.performance.timing.navigationStart)); + } + requiredApisAvailable() { + if (!fetch || !Promise || !areCookiesEnabled()) { + consoleLogger.info('Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled.'); + return false; + } + if (!isIndexedDBAvailable()) { + consoleLogger.info('IndexedDB is not supported by current browser'); + return false; + } + return true; + } + setupObserver(entryType, callback) { + if (!this.PerformanceObserver) { + return; + } + const observer = new this.PerformanceObserver(list => { + for (const entry of list.getEntries()) { + // `entry` is a PerformanceEntry instance. + callback(entry); + } + }); + // Start observing the entry types you care about. + observer.observe({ entryTypes: [entryType] }); + } + static getInstance() { + if (apiInstance === undefined) { + apiInstance = new Api(windowInstance); + } + return apiInstance; + } +} +function setupApi(window) { + windowInstance = window; +} + +/** + * @license + * 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 + * + * http://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 iid; +function getIidPromise(installationsService) { + const iidPromise = installationsService.getId(); + // eslint-disable-next-line @typescript-eslint/no-floating-promises + iidPromise.then((iidVal) => { + iid = iidVal; + }); + return iidPromise; +} +// This method should be used after the iid is retrieved by getIidPromise method. +function getIid() { + return iid; +} +function getAuthTokenPromise(installationsService) { + const authTokenPromise = installationsService.getToken(); + // eslint-disable-next-line @typescript-eslint/no-floating-promises + authTokenPromise.then((authTokenVal) => { + }); + return authTokenPromise; +} + +/** + * @license + * 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 + * + * http://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. + */ +function mergeStrings(part1, part2) { + const sizeDiff = part1.length - part2.length; + if (sizeDiff < 0 || sizeDiff > 1) { + throw ERROR_FACTORY.create("invalid String merger input" /* ErrorCode.INVALID_STRING_MERGER_PARAMETER */); + } + const resultArray = []; + for (let i = 0; i < part1.length; i++) { + resultArray.push(part1.charAt(i)); + if (part2.length > i) { + resultArray.push(part2.charAt(i)); + } + } + return resultArray.join(''); +} + +/** + * @license + * Copyright 2019 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 + * + * http://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 settingsServiceInstance; +class SettingsService { + constructor() { + // The variable which controls logging of automatic traces and HTTP/S network monitoring. + this.instrumentationEnabled = true; + // The variable which controls logging of custom traces. + this.dataCollectionEnabled = true; + // Configuration flags set through remote config. + this.loggingEnabled = false; + // Sampling rate between 0 and 1. + this.tracesSamplingRate = 1; + this.networkRequestsSamplingRate = 1; + // Address of logging service. + this.logEndPointUrl = 'https://firebaselogging.googleapis.com/v0cc/log?format=json_proto'; + // Performance event transport endpoint URL which should be compatible with proto3. + // New Address for transport service, not configurable via Remote Config. + this.flTransportEndpointUrl = mergeStrings('hts/frbslgigp.ogepscmv/ieo/eaylg', 'tp:/ieaeogn-agolai.o/1frlglgc/o'); + this.transportKey = mergeStrings('AzSC8r6ReiGqFMyfvgow', 'Iayx0u-XT3vksVM-pIV'); + // Source type for performance event logs. + this.logSource = 462; + // Flags which control per session logging of traces and network requests. + this.logTraceAfterSampling = false; + this.logNetworkAfterSampling = false; + // TTL of config retrieved from remote config in hours. + this.configTimeToLive = 12; + // The max number of events to send during a flush. This number is kept low to since Chrome has a + // shared payload limit for all sendBeacon calls in the same nav context. + this.logMaxFlushSize = 40; + } + getFlTransportFullUrl() { + return this.flTransportEndpointUrl.concat('?key=', this.transportKey); + } + static getInstance() { + if (settingsServiceInstance === undefined) { + settingsServiceInstance = new SettingsService(); + } + return settingsServiceInstance; + } +} + +/** + * @license + * 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 + * + * http://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. + */ +var VisibilityState; +(function (VisibilityState) { + VisibilityState[VisibilityState["UNKNOWN"] = 0] = "UNKNOWN"; + VisibilityState[VisibilityState["VISIBLE"] = 1] = "VISIBLE"; + VisibilityState[VisibilityState["HIDDEN"] = 2] = "HIDDEN"; +})(VisibilityState || (VisibilityState = {})); +const RESERVED_ATTRIBUTE_PREFIXES = ['firebase_', 'google_', 'ga_']; +const ATTRIBUTE_FORMAT_REGEX = new RegExp('^[a-zA-Z]\\w*$'); +const MAX_ATTRIBUTE_NAME_LENGTH = 40; +const MAX_ATTRIBUTE_VALUE_LENGTH = 100; +function getServiceWorkerStatus() { + const navigator = Api.getInstance().navigator; + if (navigator?.serviceWorker) { + if (navigator.serviceWorker.controller) { + return 2 /* ServiceWorkerStatus.CONTROLLED */; + } + else { + return 3 /* ServiceWorkerStatus.UNCONTROLLED */; + } + } + else { + return 1 /* ServiceWorkerStatus.UNSUPPORTED */; + } +} +function getVisibilityState() { + const document = Api.getInstance().document; + const visibilityState = document.visibilityState; + switch (visibilityState) { + case 'visible': + return VisibilityState.VISIBLE; + case 'hidden': + return VisibilityState.HIDDEN; + default: + return VisibilityState.UNKNOWN; + } +} +function getEffectiveConnectionType() { + const navigator = Api.getInstance().navigator; + const navigatorConnection = navigator.connection; + const effectiveType = navigatorConnection && navigatorConnection.effectiveType; + switch (effectiveType) { + case 'slow-2g': + return 1 /* EffectiveConnectionType.CONNECTION_SLOW_2G */; + case '2g': + return 2 /* EffectiveConnectionType.CONNECTION_2G */; + case '3g': + return 3 /* EffectiveConnectionType.CONNECTION_3G */; + case '4g': + return 4 /* EffectiveConnectionType.CONNECTION_4G */; + default: + return 0 /* EffectiveConnectionType.UNKNOWN */; + } +} +function isValidCustomAttributeName(name) { + if (name.length === 0 || name.length > MAX_ATTRIBUTE_NAME_LENGTH) { + return false; + } + const matchesReservedPrefix = RESERVED_ATTRIBUTE_PREFIXES.some(prefix => name.startsWith(prefix)); + return !matchesReservedPrefix && !!name.match(ATTRIBUTE_FORMAT_REGEX); +} +function isValidCustomAttributeValue(value) { + return value.length !== 0 && value.length <= MAX_ATTRIBUTE_VALUE_LENGTH; +} + +/** + * @license + * 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 + * + * http://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. + */ +function getAppId(firebaseApp) { + const appId = firebaseApp.options?.appId; + if (!appId) { + throw ERROR_FACTORY.create("no app id" /* ErrorCode.NO_APP_ID */); + } + return appId; +} +function getProjectId(firebaseApp) { + const projectId = firebaseApp.options?.projectId; + if (!projectId) { + throw ERROR_FACTORY.create("no project id" /* ErrorCode.NO_PROJECT_ID */); + } + return projectId; +} +function getApiKey(firebaseApp) { + const apiKey = firebaseApp.options?.apiKey; + if (!apiKey) { + throw ERROR_FACTORY.create("no api key" /* ErrorCode.NO_API_KEY */); + } + return apiKey; +} + +/** + * @license + * 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 + * + * http://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 REMOTE_CONFIG_SDK_VERSION = '0.0.1'; +// These values will be used if the remote config object is successfully +// retrieved, but the template does not have these fields. +const DEFAULT_CONFIGS = { + loggingEnabled: true +}; +const FIS_AUTH_PREFIX = 'FIREBASE_INSTALLATIONS_AUTH'; +function getConfig(performanceController, iid) { + const config = getStoredConfig(); + if (config) { + processConfig(config); + return Promise.resolve(); + } + return getRemoteConfig(performanceController, iid) + .then(processConfig) + .then(config => storeConfig(config), + /** Do nothing for error, use defaults set in settings service. */ + () => { }); +} +function getStoredConfig() { + const localStorage = Api.getInstance().localStorage; + if (!localStorage) { + return; + } + const expiryString = localStorage.getItem(CONFIG_EXPIRY_LOCAL_STORAGE_KEY); + if (!expiryString || !configValid(expiryString)) { + return; + } + const configStringified = localStorage.getItem(CONFIG_LOCAL_STORAGE_KEY); + if (!configStringified) { + return; + } + try { + const configResponse = JSON.parse(configStringified); + return configResponse; + } + catch { + return; + } +} +function storeConfig(config) { + const localStorage = Api.getInstance().localStorage; + if (!config || !localStorage) { + return; + } + localStorage.setItem(CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config)); + localStorage.setItem(CONFIG_EXPIRY_LOCAL_STORAGE_KEY, String(Date.now() + + SettingsService.getInstance().configTimeToLive * 60 * 60 * 1000)); +} +const COULD_NOT_GET_CONFIG_MSG = 'Could not fetch config, will use default configs'; +function getRemoteConfig(performanceController, iid) { + // Perf needs auth token only to retrieve remote config. + return getAuthTokenPromise(performanceController.installations) + .then(authToken => { + const projectId = getProjectId(performanceController.app); + const apiKey = getApiKey(performanceController.app); + const configEndPoint = `https://firebaseremoteconfig.googleapis.com/v1/projects/${projectId}/namespaces/fireperf:fetch?key=${apiKey}`; + const request = new Request(configEndPoint, { + method: 'POST', + headers: { Authorization: `${FIS_AUTH_PREFIX} ${authToken}` }, + /* eslint-disable camelcase */ + body: JSON.stringify({ + app_instance_id: iid, + app_instance_id_token: authToken, + app_id: getAppId(performanceController.app), + app_version: SDK_VERSION, + sdk_version: REMOTE_CONFIG_SDK_VERSION + }) + /* eslint-enable camelcase */ + }); + return fetch(request).then(response => { + if (response.ok) { + return response.json(); + } + // In case response is not ok. This will be caught by catch. + throw ERROR_FACTORY.create("RC response not ok" /* ErrorCode.RC_NOT_OK */); + }); + }) + .catch(() => { + consoleLogger.info(COULD_NOT_GET_CONFIG_MSG); + return undefined; + }); +} +/** + * Processes config coming either from calling RC or from local storage. + * This method only runs if call is successful or config in storage + * is valid. + */ +function processConfig(config) { + if (!config) { + return config; + } + const settingsServiceInstance = SettingsService.getInstance(); + const entries = config.entries || {}; + if (entries.fpr_enabled !== undefined) { + // TODO: Change the assignment of loggingEnabled once the received type is + // known. + settingsServiceInstance.loggingEnabled = + String(entries.fpr_enabled) === 'true'; + } + else { + // Config retrieved successfully, but there is no fpr_enabled in template. + // Use secondary configs value. + settingsServiceInstance.loggingEnabled = DEFAULT_CONFIGS.loggingEnabled; + } + if (entries.fpr_log_source) { + settingsServiceInstance.logSource = Number(entries.fpr_log_source); + } + else if (DEFAULT_CONFIGS.logSource) { + settingsServiceInstance.logSource = DEFAULT_CONFIGS.logSource; + } + if (entries.fpr_log_endpoint_url) { + settingsServiceInstance.logEndPointUrl = entries.fpr_log_endpoint_url; + } + else if (DEFAULT_CONFIGS.logEndPointUrl) { + settingsServiceInstance.logEndPointUrl = DEFAULT_CONFIGS.logEndPointUrl; + } + // Key from Remote Config has to be non-empty string, otherwise use local value. + if (entries.fpr_log_transport_key) { + settingsServiceInstance.transportKey = entries.fpr_log_transport_key; + } + else if (DEFAULT_CONFIGS.transportKey) { + settingsServiceInstance.transportKey = DEFAULT_CONFIGS.transportKey; + } + if (entries.fpr_vc_network_request_sampling_rate !== undefined) { + settingsServiceInstance.networkRequestsSamplingRate = Number(entries.fpr_vc_network_request_sampling_rate); + } + else if (DEFAULT_CONFIGS.networkRequestsSamplingRate !== undefined) { + settingsServiceInstance.networkRequestsSamplingRate = + DEFAULT_CONFIGS.networkRequestsSamplingRate; + } + if (entries.fpr_vc_trace_sampling_rate !== undefined) { + settingsServiceInstance.tracesSamplingRate = Number(entries.fpr_vc_trace_sampling_rate); + } + else if (DEFAULT_CONFIGS.tracesSamplingRate !== undefined) { + settingsServiceInstance.tracesSamplingRate = + DEFAULT_CONFIGS.tracesSamplingRate; + } + if (entries.fpr_log_max_flush_size) { + settingsServiceInstance.logMaxFlushSize = Number(entries.fpr_log_max_flush_size); + } + else if (DEFAULT_CONFIGS.logMaxFlushSize) { + settingsServiceInstance.logMaxFlushSize = DEFAULT_CONFIGS.logMaxFlushSize; + } + // Set the per session trace and network logging flags. + settingsServiceInstance.logTraceAfterSampling = shouldLogAfterSampling(settingsServiceInstance.tracesSamplingRate); + settingsServiceInstance.logNetworkAfterSampling = shouldLogAfterSampling(settingsServiceInstance.networkRequestsSamplingRate); + return config; +} +function configValid(expiry) { + return Number(expiry) > Date.now(); +} +function shouldLogAfterSampling(samplingRate) { + return Math.random() <= samplingRate; +} + +/** + * @license + * 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 + * + * http://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 initializationStatus = 1 /* InitializationStatus.notInitialized */; +let initializationPromise; +function getInitializationPromise(performanceController) { + initializationStatus = 2 /* InitializationStatus.initializationPending */; + initializationPromise = + initializationPromise || initializePerf(performanceController); + return initializationPromise; +} +function isPerfInitialized() { + return initializationStatus === 3 /* InitializationStatus.initialized */; +} +function initializePerf(performanceController) { + return getDocumentReadyComplete() + .then(() => getIidPromise(performanceController.installations)) + .then(iid => getConfig(performanceController, iid)) + .then(() => changeInitializationStatus(), () => changeInitializationStatus()); +} +/** + * Returns a promise which resolves whenever the document readystate is complete or + * immediately if it is called after page load complete. + */ +function getDocumentReadyComplete() { + const document = Api.getInstance().document; + return new Promise(resolve => { + if (document && document.readyState !== 'complete') { + const handler = () => { + if (document.readyState === 'complete') { + document.removeEventListener('readystatechange', handler); + resolve(); + } + }; + document.addEventListener('readystatechange', handler); + } + else { + resolve(); + } + }); +} +function changeInitializationStatus() { + initializationStatus = 3 /* InitializationStatus.initialized */; +} + +/** + * @license + * 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 + * + * http://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 DEFAULT_SEND_INTERVAL_MS = 10 * 1000; +const INITIAL_SEND_TIME_DELAY_MS = 5.5 * 1000; +const MAX_EVENT_COUNT_PER_REQUEST = 1000; +const DEFAULT_REMAINING_TRIES = 3; +// Most browsers have a max payload of 64KB for sendbeacon/keep alive payload. +const MAX_SEND_BEACON_PAYLOAD_SIZE = 65536; +const TEXT_ENCODER = new TextEncoder(); +let remainingTries = DEFAULT_REMAINING_TRIES; +/* eslint-enable camelcase */ +let queue = []; +let isTransportSetup = false; +function setupTransportService() { + if (!isTransportSetup) { + processQueue(INITIAL_SEND_TIME_DELAY_MS); + isTransportSetup = true; + } +} +function processQueue(timeOffset) { + setTimeout(() => { + // If there is no remainingTries left, stop retrying. + if (remainingTries <= 0) { + return; + } + if (queue.length > 0) { + dispatchQueueEvents(); + } + processQueue(DEFAULT_SEND_INTERVAL_MS); + }, timeOffset); +} +function dispatchQueueEvents() { + // Extract events up to the maximum cap of single logRequest from top of "official queue". + // The staged events will be used for current logRequest attempt, remaining events will be kept + // for next attempt. + const staged = queue.splice(0, MAX_EVENT_COUNT_PER_REQUEST); + const data = buildPayload(staged); + postToFlEndpoint(data) + .then(() => { + remainingTries = DEFAULT_REMAINING_TRIES; + }) + .catch(() => { + // If the request fails for some reason, add the events that were attempted + // back to the primary queue to retry later. + queue = [...staged, ...queue]; + remainingTries--; + consoleLogger.info(`Tries left: ${remainingTries}.`); + processQueue(DEFAULT_SEND_INTERVAL_MS); + }); +} +function buildPayload(events) { + /* eslint-disable camelcase */ + // We will pass the JSON serialized event to the backend. + const log_event = events.map(evt => ({ + source_extension_json_proto3: evt.message, + event_time_ms: String(evt.eventTime) + })); + const transportBatchLog = { + request_time_ms: String(Date.now()), + client_info: { + client_type: 1, // 1 is JS + js_client_info: {} + }, + log_source: SettingsService.getInstance().logSource, + log_event + }; + /* eslint-enable camelcase */ + return JSON.stringify(transportBatchLog); +} +/** Sends to Firelog. Atempts to use sendBeacon otherwsise uses fetch. */ +function postToFlEndpoint(body) { + const flTransportFullUrl = SettingsService.getInstance().getFlTransportFullUrl(); + const size = TEXT_ENCODER.encode(body).length; + if (size <= MAX_SEND_BEACON_PAYLOAD_SIZE && + navigator.sendBeacon && + navigator.sendBeacon(flTransportFullUrl, body)) { + return Promise.resolve(); + } + else { + return fetch(flTransportFullUrl, { + method: 'POST', + body + }); + } +} +function addToQueue(evt) { + if (!evt.eventTime || !evt.message) { + throw ERROR_FACTORY.create("invalid cc log" /* ErrorCode.INVALID_CC_LOG */); + } + // Add the new event to the queue. + queue = [...queue, evt]; +} +/** Log handler for cc service to send the performance logs to the server. */ +function transportHandler( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +serializer) { + return (...args) => { + const message = serializer(...args); + addToQueue({ + message, + eventTime: Date.now() + }); + }; +} +/** + * Force flush the queued events. Useful at page unload time to ensure all events are uploaded. + * Flush will attempt to use sendBeacon to send events async and defaults back to fetch as soon as a + * sendBeacon fails. Firefox + */ +function flushQueuedEvents() { + const flTransportFullUrl = SettingsService.getInstance().getFlTransportFullUrl(); + while (queue.length > 0) { + // Send the last events first to prioritize page load traces + const staged = queue.splice(-SettingsService.getInstance().logMaxFlushSize); + const body = buildPayload(staged); + if (navigator.sendBeacon && + navigator.sendBeacon(flTransportFullUrl, body)) { + continue; + } + else { + queue = [...queue, ...staged]; + break; + } + } + if (queue.length > 0) { + const body = buildPayload(queue); + fetch(flTransportFullUrl, { + method: 'POST', + body + }).catch(() => { + consoleLogger.info(`Failed flushing queued events.`); + }); + } +} + +/** + * @license + * 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 + * + * http://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 logger; +// +// This method is not called before initialization. +function sendLog(resource, resourceType) { + if (!logger) { + logger = { + send: transportHandler(serializer), + flush: flushQueuedEvents + }; + } + logger.send(resource, resourceType); +} +function logTrace(trace) { + const settingsService = SettingsService.getInstance(); + // Do not log if trace is auto generated and instrumentation is disabled. + if (!settingsService.instrumentationEnabled && trace.isAuto) { + return; + } + // Do not log if trace is custom and data collection is disabled. + if (!settingsService.dataCollectionEnabled && !trace.isAuto) { + return; + } + // Do not log if required apis are not available. + if (!Api.getInstance().requiredApisAvailable()) { + return; + } + if (isPerfInitialized()) { + sendTraceLog(trace); + } + else { + // Custom traces can be used before the initialization but logging + // should wait until after. + getInitializationPromise(trace.performanceController).then(() => sendTraceLog(trace), () => sendTraceLog(trace)); + } +} +function flushLogs() { + if (logger) { + logger.flush(); + } +} +function sendTraceLog(trace) { + if (!getIid()) { + return; + } + const settingsService = SettingsService.getInstance(); + if (!settingsService.loggingEnabled || + !settingsService.logTraceAfterSampling) { + return; + } + sendLog(trace, 1 /* ResourceType.Trace */); +} +function logNetworkRequest(networkRequest) { + const settingsService = SettingsService.getInstance(); + // Do not log network requests if instrumentation is disabled. + if (!settingsService.instrumentationEnabled) { + return; + } + // Do not log the js sdk's call to transport service domain to avoid unnecessary cycle. + // Need to blacklist both old and new endpoints to avoid migration gap. + const networkRequestUrl = networkRequest.url; + // Blacklist old log endpoint and new transport endpoint. + // Because Performance SDK doesn't instrument requests sent from SDK itself. + const logEndpointUrl = settingsService.logEndPointUrl.split('?')[0]; + const flEndpointUrl = settingsService.flTransportEndpointUrl.split('?')[0]; + if (networkRequestUrl === logEndpointUrl || + networkRequestUrl === flEndpointUrl) { + return; + } + if (!settingsService.loggingEnabled || + !settingsService.logNetworkAfterSampling) { + return; + } + sendLog(networkRequest, 0 /* ResourceType.NetworkRequest */); +} +function serializer(resource, resourceType) { + if (resourceType === 0 /* ResourceType.NetworkRequest */) { + return serializeNetworkRequest(resource); + } + return serializeTrace(resource); +} +function serializeNetworkRequest(networkRequest) { + const networkRequestMetric = { + url: networkRequest.url, + http_method: networkRequest.httpMethod || 0, + http_response_code: 200, + response_payload_bytes: networkRequest.responsePayloadBytes, + client_start_time_us: networkRequest.startTimeUs, + time_to_response_initiated_us: networkRequest.timeToResponseInitiatedUs, + time_to_response_completed_us: networkRequest.timeToResponseCompletedUs + }; + const perfMetric = { + application_info: getApplicationInfo(networkRequest.performanceController.app), + network_request_metric: networkRequestMetric + }; + return JSON.stringify(perfMetric); +} +function serializeTrace(trace) { + const traceMetric = { + name: trace.name, + is_auto: trace.isAuto, + client_start_time_us: trace.startTimeUs, + duration_us: trace.durationUs + }; + if (Object.keys(trace.counters).length !== 0) { + traceMetric.counters = trace.counters; + } + const customAttributes = trace.getAttributes(); + if (Object.keys(customAttributes).length !== 0) { + traceMetric.custom_attributes = customAttributes; + } + const perfMetric = { + application_info: getApplicationInfo(trace.performanceController.app), + trace_metric: traceMetric + }; + return JSON.stringify(perfMetric); +} +function getApplicationInfo(firebaseApp) { + return { + google_app_id: getAppId(firebaseApp), + app_instance_id: getIid(), + web_app_info: { + sdk_version: SDK_VERSION, + page_url: Api.getInstance().getUrl(), + service_worker_status: getServiceWorkerStatus(), + visibility_state: getVisibilityState(), + effective_connection_type: getEffectiveConnectionType() + }, + application_process_state: 0 + }; +} +/* eslint-enable camelcase */ + +/** + * @license + * 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 + * + * http://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. + */ +function createNetworkRequestEntry(performanceController, entry) { + const performanceEntry = entry; + if (!performanceEntry || performanceEntry.responseStart === undefined) { + return; + } + const timeOrigin = Api.getInstance().getTimeOrigin(); + const startTimeUs = Math.floor((performanceEntry.startTime + timeOrigin) * 1000); + const timeToResponseInitiatedUs = performanceEntry.responseStart + ? Math.floor((performanceEntry.responseStart - performanceEntry.startTime) * 1000) + : undefined; + const timeToResponseCompletedUs = Math.floor((performanceEntry.responseEnd - performanceEntry.startTime) * 1000); + // Remove the query params from logged network request url. + const url = performanceEntry.name && performanceEntry.name.split('?')[0]; + const networkRequest = { + performanceController, + url, + responsePayloadBytes: performanceEntry.transferSize, + startTimeUs, + timeToResponseInitiatedUs, + timeToResponseCompletedUs + }; + logNetworkRequest(networkRequest); +} + +/** + * @license + * 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 + * + * http://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 MAX_METRIC_NAME_LENGTH = 100; +const RESERVED_AUTO_PREFIX = '_'; +const oobMetrics = [ + FIRST_PAINT_COUNTER_NAME, + FIRST_CONTENTFUL_PAINT_COUNTER_NAME, + FIRST_INPUT_DELAY_COUNTER_NAME, + LARGEST_CONTENTFUL_PAINT_METRIC_NAME, + CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME, + INTERACTION_TO_NEXT_PAINT_METRIC_NAME +]; +/** + * Returns true if the metric is custom and does not start with reserved prefix, or if + * the metric is one of out of the box page load trace metrics. + */ +function isValidMetricName(name, traceName) { + if (name.length === 0 || name.length > MAX_METRIC_NAME_LENGTH) { + return false; + } + return ((traceName && + traceName.startsWith(OOB_TRACE_PAGE_LOAD_PREFIX) && + oobMetrics.indexOf(name) > -1) || + !name.startsWith(RESERVED_AUTO_PREFIX)); +} +/** + * Converts the provided value to an integer value to be used in case of a metric. + * @param providedValue Provided number value of the metric that needs to be converted to an integer. + * + * @returns Converted integer number to be set for the metric. + */ +function convertMetricValueToInteger(providedValue) { + const valueAsInteger = Math.floor(providedValue); + if (valueAsInteger < providedValue) { + consoleLogger.info(`Metric value should be an Integer, setting the value as : ${valueAsInteger}.`); + } + return valueAsInteger; +} + +/** + * @license + * 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 + * + * http://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. + */ +class Trace { + /** + * @param performanceController The performance controller running. + * @param name The name of the trace. + * @param isAuto If the trace is auto-instrumented. + * @param traceMeasureName The name of the measure marker in user timing specification. This field + * is only set when the trace is built for logging when the user directly uses the user timing + * api (performance.mark and performance.measure). + */ + constructor(performanceController, name, isAuto = false, traceMeasureName) { + this.performanceController = performanceController; + this.name = name; + this.isAuto = isAuto; + this.state = 1 /* TraceState.UNINITIALIZED */; + this.customAttributes = {}; + this.counters = {}; + this.api = Api.getInstance(); + this.randomId = Math.floor(Math.random() * 1000000); + if (!this.isAuto) { + this.traceStartMark = `${TRACE_START_MARK_PREFIX}-${this.randomId}-${this.name}`; + this.traceStopMark = `${TRACE_STOP_MARK_PREFIX}-${this.randomId}-${this.name}`; + this.traceMeasure = + traceMeasureName || + `${TRACE_MEASURE_PREFIX}-${this.randomId}-${this.name}`; + if (traceMeasureName) { + // For the case of direct user timing traces, no start stop will happen. The measure object + // is already available. + this.calculateTraceMetrics(); + } + } + } + /** + * Starts a trace. The measurement of the duration starts at this point. + */ + start() { + if (this.state !== 1 /* TraceState.UNINITIALIZED */) { + throw ERROR_FACTORY.create("trace started" /* ErrorCode.TRACE_STARTED_BEFORE */, { + traceName: this.name + }); + } + this.api.mark(this.traceStartMark); + this.state = 2 /* TraceState.RUNNING */; + } + /** + * Stops the trace. The measurement of the duration of the trace stops at this point and trace + * is logged. + */ + stop() { + if (this.state !== 2 /* TraceState.RUNNING */) { + throw ERROR_FACTORY.create("trace stopped" /* ErrorCode.TRACE_STOPPED_BEFORE */, { + traceName: this.name + }); + } + this.state = 3 /* TraceState.TERMINATED */; + this.api.mark(this.traceStopMark); + this.api.measure(this.traceMeasure, this.traceStartMark, this.traceStopMark); + this.calculateTraceMetrics(); + logTrace(this); + } + /** + * Records a trace with predetermined values. If this method is used a trace is created and logged + * directly. No need to use start and stop methods. + * @param startTime Trace start time since epoch in millisec + * @param duration The duration of the trace in millisec + * @param options An object which can optionally hold maps of custom metrics and custom attributes + */ + record(startTime, duration, options) { + if (startTime <= 0) { + throw ERROR_FACTORY.create("nonpositive trace startTime" /* ErrorCode.NONPOSITIVE_TRACE_START_TIME */, { + traceName: this.name + }); + } + if (duration <= 0) { + throw ERROR_FACTORY.create("nonpositive trace duration" /* ErrorCode.NONPOSITIVE_TRACE_DURATION */, { + traceName: this.name + }); + } + this.durationUs = Math.floor(duration * 1000); + this.startTimeUs = Math.floor(startTime * 1000); + if (options && options.attributes) { + this.customAttributes = { ...options.attributes }; + } + if (options && options.metrics) { + for (const metricName of Object.keys(options.metrics)) { + if (!isNaN(Number(options.metrics[metricName]))) { + this.counters[metricName] = Math.floor(Number(options.metrics[metricName])); + } + } + } + logTrace(this); + } + /** + * Increments a custom metric by a certain number or 1 if number not specified. Will create a new + * custom metric if one with the given name does not exist. The value will be floored down to an + * integer. + * @param counter Name of the custom metric + * @param numAsInteger Increment by value + */ + incrementMetric(counter, numAsInteger = 1) { + if (this.counters[counter] === undefined) { + this.putMetric(counter, numAsInteger); + } + else { + this.putMetric(counter, this.counters[counter] + numAsInteger); + } + } + /** + * Sets a custom metric to a specified value. Will create a new custom metric if one with the + * given name does not exist. The value will be floored down to an integer. + * @param counter Name of the custom metric + * @param numAsInteger Set custom metric to this value + */ + putMetric(counter, numAsInteger) { + if (isValidMetricName(counter, this.name)) { + this.counters[counter] = convertMetricValueToInteger(numAsInteger ?? 0); + } + else { + throw ERROR_FACTORY.create("invalid custom metric name" /* ErrorCode.INVALID_CUSTOM_METRIC_NAME */, { + customMetricName: counter + }); + } + } + /** + * Returns the value of the custom metric by that name. If a custom metric with that name does + * not exist will return zero. + * @param counter + */ + getMetric(counter) { + return this.counters[counter] || 0; + } + /** + * Sets a custom attribute of a trace to a certain value. + * @param attr + * @param value + */ + putAttribute(attr, value) { + const isValidName = isValidCustomAttributeName(attr); + const isValidValue = isValidCustomAttributeValue(value); + if (isValidName && isValidValue) { + this.customAttributes[attr] = value; + return; + } + // Throw appropriate error when the attribute name or value is invalid. + if (!isValidName) { + throw ERROR_FACTORY.create("invalid attribute name" /* ErrorCode.INVALID_ATTRIBUTE_NAME */, { + attributeName: attr + }); + } + if (!isValidValue) { + throw ERROR_FACTORY.create("invalid attribute value" /* ErrorCode.INVALID_ATTRIBUTE_VALUE */, { + attributeValue: value + }); + } + } + /** + * Retrieves the value a custom attribute of a trace is set to. + * @param attr + */ + getAttribute(attr) { + return this.customAttributes[attr]; + } + removeAttribute(attr) { + if (this.customAttributes[attr] === undefined) { + return; + } + delete this.customAttributes[attr]; + } + getAttributes() { + return { ...this.customAttributes }; + } + setStartTime(startTime) { + this.startTimeUs = startTime; + } + setDuration(duration) { + this.durationUs = duration; + } + /** + * Calculates and assigns the duration and start time of the trace using the measure performance + * entry. + */ + calculateTraceMetrics() { + const perfMeasureEntries = this.api.getEntriesByName(this.traceMeasure); + const perfMeasureEntry = perfMeasureEntries && perfMeasureEntries[0]; + if (perfMeasureEntry) { + this.durationUs = Math.floor(perfMeasureEntry.duration * 1000); + this.startTimeUs = Math.floor((perfMeasureEntry.startTime + this.api.getTimeOrigin()) * 1000); + } + } + /** + * @param navigationTimings A single element array which contains the navigationTIming object of + * the page load + * @param paintTimings A array which contains paintTiming object of the page load + * @param firstInputDelay First input delay in millisec + */ + static createOobTrace(performanceController, navigationTimings, paintTimings, webVitalMetrics, firstInputDelay) { + const route = Api.getInstance().getUrl(); + if (!route) { + return; + } + const trace = new Trace(performanceController, OOB_TRACE_PAGE_LOAD_PREFIX + route, true); + const timeOriginUs = Math.floor(Api.getInstance().getTimeOrigin() * 1000); + trace.setStartTime(timeOriginUs); + // navigationTimings includes only one element. + if (navigationTimings && navigationTimings[0]) { + trace.setDuration(Math.floor(navigationTimings[0].duration * 1000)); + trace.putMetric('domInteractive', Math.floor(navigationTimings[0].domInteractive * 1000)); + trace.putMetric('domContentLoadedEventEnd', Math.floor(navigationTimings[0].domContentLoadedEventEnd * 1000)); + trace.putMetric('loadEventEnd', Math.floor(navigationTimings[0].loadEventEnd * 1000)); + } + const FIRST_PAINT = 'first-paint'; + const FIRST_CONTENTFUL_PAINT = 'first-contentful-paint'; + if (paintTimings) { + const firstPaint = paintTimings.find(paintObject => paintObject.name === FIRST_PAINT); + if (firstPaint && firstPaint.startTime) { + trace.putMetric(FIRST_PAINT_COUNTER_NAME, Math.floor(firstPaint.startTime * 1000)); + } + const firstContentfulPaint = paintTimings.find(paintObject => paintObject.name === FIRST_CONTENTFUL_PAINT); + if (firstContentfulPaint && firstContentfulPaint.startTime) { + trace.putMetric(FIRST_CONTENTFUL_PAINT_COUNTER_NAME, Math.floor(firstContentfulPaint.startTime * 1000)); + } + if (firstInputDelay) { + trace.putMetric(FIRST_INPUT_DELAY_COUNTER_NAME, Math.floor(firstInputDelay * 1000)); + } + } + this.addWebVitalMetric(trace, LARGEST_CONTENTFUL_PAINT_METRIC_NAME, LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME, webVitalMetrics.lcp); + this.addWebVitalMetric(trace, CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME, CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME, webVitalMetrics.cls); + this.addWebVitalMetric(trace, INTERACTION_TO_NEXT_PAINT_METRIC_NAME, INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME, webVitalMetrics.inp); + // Page load logs are sent at unload time and so should be logged and + // flushed immediately. + logTrace(trace); + flushLogs(); + } + static addWebVitalMetric(trace, metricKey, attributeKey, metric) { + if (metric) { + trace.putMetric(metricKey, Math.floor(metric.value * 1000)); + if (metric.elementAttribution) { + if (metric.elementAttribution.length > MAX_ATTRIBUTE_VALUE_LENGTH) { + trace.putAttribute(attributeKey, metric.elementAttribution.substring(0, MAX_ATTRIBUTE_VALUE_LENGTH)); + } + else { + trace.putAttribute(attributeKey, metric.elementAttribution); + } + } + } + } + static createUserTimingTrace(performanceController, measureName) { + const trace = new Trace(performanceController, measureName, false, measureName); + logTrace(trace); + } +} + +/** + * @license + * 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 + * + * http://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 webVitalMetrics = {}; +let sentPageLoadTrace = false; +let firstInputDelay; +function setupOobResources(performanceController) { + // Do not initialize unless iid is available. + if (!getIid()) { + return; + } + // The load event might not have fired yet, and that means performance + // navigation timing object has a duration of 0. The setup should run after + // all current tasks in js queue. + setTimeout(() => setupOobTraces(performanceController), 0); + setTimeout(() => setupNetworkRequests(performanceController), 0); + setTimeout(() => setupUserTimingTraces(performanceController), 0); +} +function setupNetworkRequests(performanceController) { + const api = Api.getInstance(); + const resources = api.getEntriesByType('resource'); + for (const resource of resources) { + createNetworkRequestEntry(performanceController, resource); + } + api.setupObserver('resource', entry => createNetworkRequestEntry(performanceController, entry)); +} +function setupOobTraces(performanceController) { + const api = Api.getInstance(); + // Better support for Safari + if ('onpagehide' in window) { + api.document.addEventListener('pagehide', () => sendOobTrace(performanceController)); + } + else { + api.document.addEventListener('unload', () => sendOobTrace(performanceController)); + } + api.document.addEventListener('visibilitychange', () => { + if (api.document.visibilityState === 'hidden') { + sendOobTrace(performanceController); + } + }); + if (api.onFirstInputDelay) { + api.onFirstInputDelay((fid) => { + firstInputDelay = fid; + }); + } + api.onLCP((metric) => { + webVitalMetrics.lcp = { + value: metric.value, + elementAttribution: metric.attribution?.element + }; + }); + api.onCLS((metric) => { + webVitalMetrics.cls = { + value: metric.value, + elementAttribution: metric.attribution?.largestShiftTarget + }; + }); + api.onINP((metric) => { + webVitalMetrics.inp = { + value: metric.value, + elementAttribution: metric.attribution?.interactionTarget + }; + }); +} +function setupUserTimingTraces(performanceController) { + const api = Api.getInstance(); + // Run through the measure performance entries collected up to this point. + const measures = api.getEntriesByType('measure'); + for (const measure of measures) { + createUserTimingTrace(performanceController, measure); + } + // Setup an observer to capture the measures from this point on. + api.setupObserver('measure', entry => createUserTimingTrace(performanceController, entry)); +} +function createUserTimingTrace(performanceController, measure) { + const measureName = measure.name; + // Do not create a trace, if the user timing marks and measures are created by + // the sdk itself. + if (measureName.substring(0, TRACE_MEASURE_PREFIX.length) === + TRACE_MEASURE_PREFIX) { + return; + } + Trace.createUserTimingTrace(performanceController, measureName); +} +function sendOobTrace(performanceController) { + if (!sentPageLoadTrace) { + sentPageLoadTrace = true; + const api = Api.getInstance(); + const navigationTimings = api.getEntriesByType('navigation'); + const paintTimings = api.getEntriesByType('paint'); + // On page unload web vitals may be updated so queue the oob trace creation + // so that these updates have time to be included. + setTimeout(() => { + Trace.createOobTrace(performanceController, navigationTimings, paintTimings, webVitalMetrics, firstInputDelay); + }, 0); + } +} + +/** + * @license + * 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 + * + * http://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. + */ +class PerformanceController { + constructor(app, installations) { + this.app = app; + this.installations = installations; + this.initialized = false; + } + /** + * This method *must* be called internally as part of creating a + * PerformanceController instance. + * + * Currently it's not possible to pass the settings object through the + * constructor using Components, so this method exists to be called with the + * desired settings, to ensure nothing is collected without the user's + * consent. + */ + _init(settings) { + if (this.initialized) { + return; + } + if (settings?.dataCollectionEnabled !== undefined) { + this.dataCollectionEnabled = settings.dataCollectionEnabled; + } + if (settings?.instrumentationEnabled !== undefined) { + this.instrumentationEnabled = settings.instrumentationEnabled; + } + if (Api.getInstance().requiredApisAvailable()) { + validateIndexedDBOpenable() + .then(isAvailable => { + if (isAvailable) { + setupTransportService(); + getInitializationPromise(this).then(() => setupOobResources(this), () => setupOobResources(this)); + this.initialized = true; + } + }) + .catch(error => { + consoleLogger.info(`Environment doesn't support IndexedDB: ${error}`); + }); + } + else { + consoleLogger.info('Firebase Performance cannot start if the browser does not support ' + + '"Fetch" and "Promise", or cookies are disabled.'); + } + } + set instrumentationEnabled(val) { + SettingsService.getInstance().instrumentationEnabled = val; + } + get instrumentationEnabled() { + return SettingsService.getInstance().instrumentationEnabled; + } + set dataCollectionEnabled(val) { + SettingsService.getInstance().dataCollectionEnabled = val; + } + get dataCollectionEnabled() { + return SettingsService.getInstance().dataCollectionEnabled; + } +} + +/** + * The Firebase Performance Monitoring Web SDK. + * This SDK does not work in a Node.js environment. + * + * @packageDocumentation + */ +const DEFAULT_ENTRY_NAME = '[DEFAULT]'; +/** + * Returns a {@link FirebasePerformance} instance for the given app. + * @param app - The {@link @firebase/app#FirebaseApp} to use. + * @public + */ +function getPerformance(app = getApp()) { + app = getModularInstance(app); + const provider = _getProvider(app, 'performance'); + const perfInstance = provider.getImmediate(); + return perfInstance; +} +/** + * Returns a {@link FirebasePerformance} instance for the given app. Can only be called once. + * @param app - The {@link @firebase/app#FirebaseApp} to use. + * @param settings - Optional settings for the {@link FirebasePerformance} instance. + * @public + */ +function initializePerformance(app, settings) { + app = getModularInstance(app); + const provider = _getProvider(app, 'performance'); + // throw if an instance was already created. + // It could happen if initializePerformance() is called more than once, or getPerformance() is called first. + if (provider.isInitialized()) { + const existingInstance = provider.getImmediate(); + const initialSettings = provider.getOptions(); + if (deepEqual(initialSettings, settings ?? {})) { + return existingInstance; + } + else { + throw ERROR_FACTORY.create("already initialized" /* ErrorCode.ALREADY_INITIALIZED */); + } + } + const perfInstance = provider.initialize({ + options: settings + }); + return perfInstance; +} +/** + * Returns a new `PerformanceTrace` instance. + * @param performance - The {@link FirebasePerformance} instance to use. + * @param name - The name of the trace. + * @public + */ +function trace(performance, name) { + performance = getModularInstance(performance); + return new Trace(performance, name); +} +const factory = (container, { options: settings }) => { + // Dependencies + const app = container.getProvider('app').getImmediate(); + const installations = container + .getProvider('installations-internal') + .getImmediate(); + if (app.name !== DEFAULT_ENTRY_NAME) { + throw ERROR_FACTORY.create("FB not default" /* ErrorCode.FB_NOT_DEFAULT */); + } + if (typeof window === 'undefined') { + throw ERROR_FACTORY.create("no window" /* ErrorCode.NO_WINDOW */); + } + setupApi(window); + const perfInstance = new PerformanceController(app, installations); + perfInstance._init(settings); + return perfInstance; +}; +function registerPerformance() { + _registerComponent(new Component('performance', factory, "PUBLIC" /* ComponentType.PUBLIC */)); + registerVersion(name, version); + // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation + registerVersion(name, version, 'esm2020'); +} +registerPerformance(); + +export { getPerformance, initializePerformance, trace }; +//# sourceMappingURL=index.esm.js.map diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/index.esm.js.map b/frontend-old/node_modules/@firebase/performance/dist/esm/index.esm.js.map new file mode 100644 index 0000000..9593993 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/index.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.esm.js","sources":["../../src/constants.ts","../../src/utils/errors.ts","../../src/utils/console_logger.ts","../../src/services/api_service.ts","../../src/services/iid_service.ts","../../src/utils/string_merger.ts","../../src/services/settings_service.ts","../../src/utils/attributes_utils.ts","../../src/utils/app_utils.ts","../../src/services/remote_config_service.ts","../../src/services/initialization_service.ts","../../src/services/transport_service.ts","../../src/services/perf_logger.ts","../../src/resources/network_request.ts","../../src/utils/metric_utils.ts","../../src/resources/trace.ts","../../src/services/oob_resources_service.ts","../../src/controllers/perf.ts","../../src/index.ts"],"sourcesContent":["/**\n * @license\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 * http://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 { version } from '../package.json';\n\nexport const SDK_VERSION = version;\n/** The prefix for start User Timing marks used for creating Traces. */\nexport const TRACE_START_MARK_PREFIX = 'FB-PERF-TRACE-START';\n/** The prefix for stop User Timing marks used for creating Traces. */\nexport const TRACE_STOP_MARK_PREFIX = 'FB-PERF-TRACE-STOP';\n/** The prefix for User Timing measure used for creating Traces. */\nexport const TRACE_MEASURE_PREFIX = 'FB-PERF-TRACE-MEASURE';\n/** The prefix for out of the box page load Trace name. */\nexport const OOB_TRACE_PAGE_LOAD_PREFIX = '_wt_';\n\nexport const FIRST_PAINT_COUNTER_NAME = '_fp';\n\nexport const FIRST_CONTENTFUL_PAINT_COUNTER_NAME = '_fcp';\n\nexport const FIRST_INPUT_DELAY_COUNTER_NAME = '_fid';\n\nexport const LARGEST_CONTENTFUL_PAINT_METRIC_NAME = '_lcp';\nexport const LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME = 'lcp_element';\n\nexport const INTERACTION_TO_NEXT_PAINT_METRIC_NAME = '_inp';\nexport const INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME = 'inp_interactionTarget';\n\nexport const CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME = '_cls';\nexport const CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME = 'cls_largestShiftTarget';\n\nexport const CONFIG_LOCAL_STORAGE_KEY = '@firebase/performance/config';\n\nexport const CONFIG_EXPIRY_LOCAL_STORAGE_KEY =\n '@firebase/performance/configexpire';\n\nexport const SERVICE = 'performance';\nexport const SERVICE_NAME = 'Performance';\n","/**\n * @license\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 * http://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 { ErrorFactory } from '@firebase/util';\nimport { SERVICE, SERVICE_NAME } from '../constants';\n\nexport const enum ErrorCode {\n TRACE_STARTED_BEFORE = 'trace started',\n TRACE_STOPPED_BEFORE = 'trace stopped',\n NONPOSITIVE_TRACE_START_TIME = 'nonpositive trace startTime',\n NONPOSITIVE_TRACE_DURATION = 'nonpositive trace duration',\n NO_WINDOW = 'no window',\n NO_APP_ID = 'no app id',\n NO_PROJECT_ID = 'no project id',\n NO_API_KEY = 'no api key',\n INVALID_CC_LOG = 'invalid cc log',\n FB_NOT_DEFAULT = 'FB not default',\n RC_NOT_OK = 'RC response not ok',\n INVALID_ATTRIBUTE_NAME = 'invalid attribute name',\n INVALID_ATTRIBUTE_VALUE = 'invalid attribute value',\n INVALID_CUSTOM_METRIC_NAME = 'invalid custom metric name',\n INVALID_STRING_MERGER_PARAMETER = 'invalid String merger input',\n ALREADY_INITIALIZED = 'already initialized'\n}\n\nconst ERROR_DESCRIPTION_MAP: { readonly [key in ErrorCode]: string } = {\n [ErrorCode.TRACE_STARTED_BEFORE]: 'Trace {$traceName} was started before.',\n [ErrorCode.TRACE_STOPPED_BEFORE]: 'Trace {$traceName} is not running.',\n [ErrorCode.NONPOSITIVE_TRACE_START_TIME]:\n 'Trace {$traceName} startTime should be positive.',\n [ErrorCode.NONPOSITIVE_TRACE_DURATION]:\n 'Trace {$traceName} duration should be positive.',\n [ErrorCode.NO_WINDOW]: 'Window is not available.',\n [ErrorCode.NO_APP_ID]: 'App id is not available.',\n [ErrorCode.NO_PROJECT_ID]: 'Project id is not available.',\n [ErrorCode.NO_API_KEY]: 'Api key is not available.',\n [ErrorCode.INVALID_CC_LOG]: 'Attempted to queue invalid cc event',\n [ErrorCode.FB_NOT_DEFAULT]:\n 'Performance can only start when Firebase app instance is the default one.',\n [ErrorCode.RC_NOT_OK]: 'RC response is not ok',\n [ErrorCode.INVALID_ATTRIBUTE_NAME]:\n 'Attribute name {$attributeName} is invalid.',\n [ErrorCode.INVALID_ATTRIBUTE_VALUE]:\n 'Attribute value {$attributeValue} is invalid.',\n [ErrorCode.INVALID_CUSTOM_METRIC_NAME]:\n 'Custom metric name {$customMetricName} is invalid',\n [ErrorCode.INVALID_STRING_MERGER_PARAMETER]:\n 'Input for String merger is invalid, contact support team to resolve.',\n [ErrorCode.ALREADY_INITIALIZED]:\n 'initializePerformance() has already been called with ' +\n 'different options. To avoid this error, call initializePerformance() with the ' +\n 'same options as when it was originally called, or call getPerformance() to return the' +\n ' already initialized instance.'\n};\n\ninterface ErrorParams {\n [ErrorCode.TRACE_STARTED_BEFORE]: { traceName: string };\n [ErrorCode.TRACE_STOPPED_BEFORE]: { traceName: string };\n [ErrorCode.NONPOSITIVE_TRACE_START_TIME]: { traceName: string };\n [ErrorCode.NONPOSITIVE_TRACE_DURATION]: { traceName: string };\n [ErrorCode.INVALID_ATTRIBUTE_NAME]: { attributeName: string };\n [ErrorCode.INVALID_ATTRIBUTE_VALUE]: { attributeValue: string };\n [ErrorCode.INVALID_CUSTOM_METRIC_NAME]: { customMetricName: string };\n}\n\nexport const ERROR_FACTORY = new ErrorFactory<ErrorCode, ErrorParams>(\n SERVICE,\n SERVICE_NAME,\n ERROR_DESCRIPTION_MAP\n);\n","/**\n * @license\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 * http://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 { Logger, LogLevel } from '@firebase/logger';\nimport { SERVICE_NAME } from '../constants';\n\nexport const consoleLogger = new Logger(SERVICE_NAME);\nconsoleLogger.logLevel = LogLevel.INFO;\n","/**\n * @license\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 * http://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 { ERROR_FACTORY, ErrorCode } from '../utils/errors';\nimport { isIndexedDBAvailable, areCookiesEnabled } from '@firebase/util';\nimport { consoleLogger } from '../utils/console_logger';\nimport {\n CLSMetricWithAttribution,\n INPMetricWithAttribution,\n LCPMetricWithAttribution,\n onCLS as vitalsOnCLS,\n onINP as vitalsOnINP,\n onLCP as vitalsOnLCP\n} from 'web-vitals/attribution';\n\ndeclare global {\n interface Window {\n PerformanceObserver: typeof PerformanceObserver;\n perfMetrics?: { onFirstInputDelay(fn: (fid: number) => void): void };\n }\n}\n\nlet apiInstance: Api | undefined;\nlet windowInstance: Window | undefined;\n\nexport type EntryType =\n | 'mark'\n | 'measure'\n | 'paint'\n | 'resource'\n | 'frame'\n | 'navigation';\n\n/**\n * This class holds a reference to various browser related objects injected by\n * set methods.\n */\nexport class Api {\n private readonly performance: Performance;\n /** PerformanceObserver constructor function. */\n private readonly PerformanceObserver: typeof PerformanceObserver;\n private readonly windowLocation: Location;\n readonly onFirstInputDelay?: (fn: (fid: number) => void) => void;\n readonly onLCP: (fn: (metric: LCPMetricWithAttribution) => void) => void;\n readonly onINP: (fn: (metric: INPMetricWithAttribution) => void) => void;\n readonly onCLS: (fn: (metric: CLSMetricWithAttribution) => void) => void;\n readonly localStorage?: Storage;\n readonly document: Document;\n readonly navigator: Navigator;\n\n constructor(readonly window?: Window) {\n if (!window) {\n throw ERROR_FACTORY.create(ErrorCode.NO_WINDOW);\n }\n this.performance = window.performance;\n this.PerformanceObserver = window.PerformanceObserver;\n this.windowLocation = window.location;\n this.navigator = window.navigator;\n this.document = window.document;\n if (this.navigator && this.navigator.cookieEnabled) {\n // If user blocks cookies on the browser, accessing localStorage will\n // throw an exception.\n this.localStorage = window.localStorage;\n }\n if (window.perfMetrics && window.perfMetrics.onFirstInputDelay) {\n this.onFirstInputDelay = window.perfMetrics.onFirstInputDelay;\n }\n this.onLCP = vitalsOnLCP;\n this.onINP = vitalsOnINP;\n this.onCLS = vitalsOnCLS;\n }\n\n getUrl(): string {\n // Do not capture the string query part of url.\n return this.windowLocation.href.split('?')[0];\n }\n\n mark(name: string): void {\n if (!this.performance || !this.performance.mark) {\n return;\n }\n this.performance.mark(name);\n }\n\n measure(measureName: string, mark1: string, mark2: string): void {\n if (!this.performance || !this.performance.measure) {\n return;\n }\n this.performance.measure(measureName, mark1, mark2);\n }\n\n getEntriesByType(type: EntryType): PerformanceEntry[] {\n if (!this.performance || !this.performance.getEntriesByType) {\n return [];\n }\n return this.performance.getEntriesByType(type);\n }\n\n getEntriesByName(name: string): PerformanceEntry[] {\n if (!this.performance || !this.performance.getEntriesByName) {\n return [];\n }\n return this.performance.getEntriesByName(name);\n }\n\n getTimeOrigin(): number {\n // Polyfill the time origin with performance.timing.navigationStart.\n return (\n this.performance &&\n (this.performance.timeOrigin || this.performance.timing.navigationStart)\n );\n }\n\n requiredApisAvailable(): boolean {\n if (!fetch || !Promise || !areCookiesEnabled()) {\n consoleLogger.info(\n 'Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled.'\n );\n return false;\n }\n\n if (!isIndexedDBAvailable()) {\n consoleLogger.info('IndexedDB is not supported by current browser');\n return false;\n }\n return true;\n }\n\n setupObserver(\n entryType: EntryType,\n callback: (entry: PerformanceEntry) => void\n ): void {\n if (!this.PerformanceObserver) {\n return;\n }\n const observer = new this.PerformanceObserver(list => {\n for (const entry of list.getEntries()) {\n // `entry` is a PerformanceEntry instance.\n callback(entry);\n }\n });\n\n // Start observing the entry types you care about.\n observer.observe({ entryTypes: [entryType] });\n }\n\n static getInstance(): Api {\n if (apiInstance === undefined) {\n apiInstance = new Api(windowInstance);\n }\n return apiInstance;\n }\n}\n\nexport function setupApi(window: Window): void {\n windowInstance = window;\n}\n","/**\n * @license\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 * http://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 { _FirebaseInstallationsInternal } from '@firebase/installations';\n\nlet iid: string | undefined;\nlet authToken: string | undefined;\n\nexport function getIidPromise(\n installationsService: _FirebaseInstallationsInternal\n): Promise<string> {\n const iidPromise = installationsService.getId();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n iidPromise.then((iidVal: string) => {\n iid = iidVal;\n });\n return iidPromise;\n}\n\n// This method should be used after the iid is retrieved by getIidPromise method.\nexport function getIid(): string | undefined {\n return iid;\n}\n\nexport function getAuthTokenPromise(\n installationsService: _FirebaseInstallationsInternal\n): Promise<string> {\n const authTokenPromise = installationsService.getToken();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n authTokenPromise.then((authTokenVal: string) => {\n authToken = authTokenVal;\n });\n return authTokenPromise;\n}\n\nexport function getAuthenticationToken(): string | undefined {\n return authToken;\n}\n","/**\n * @license\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 * http://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 { ERROR_FACTORY, ErrorCode } from './errors';\n\nexport function mergeStrings(part1: string, part2: string): string {\n const sizeDiff = part1.length - part2.length;\n if (sizeDiff < 0 || sizeDiff > 1) {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_STRING_MERGER_PARAMETER);\n }\n\n const resultArray = [];\n for (let i = 0; i < part1.length; i++) {\n resultArray.push(part1.charAt(i));\n if (part2.length > i) {\n resultArray.push(part2.charAt(i));\n }\n }\n\n return resultArray.join('');\n}\n","/**\n * @license\n * Copyright 2019 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 * http://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 { mergeStrings } from '../utils/string_merger';\n\nlet settingsServiceInstance: SettingsService | undefined;\n\nexport class SettingsService {\n // The variable which controls logging of automatic traces and HTTP/S network monitoring.\n instrumentationEnabled = true;\n\n // The variable which controls logging of custom traces.\n dataCollectionEnabled = true;\n\n // Configuration flags set through remote config.\n loggingEnabled = false;\n // Sampling rate between 0 and 1.\n tracesSamplingRate = 1;\n networkRequestsSamplingRate = 1;\n\n // Address of logging service.\n logEndPointUrl =\n 'https://firebaselogging.googleapis.com/v0cc/log?format=json_proto';\n // Performance event transport endpoint URL which should be compatible with proto3.\n // New Address for transport service, not configurable via Remote Config.\n flTransportEndpointUrl = mergeStrings(\n 'hts/frbslgigp.ogepscmv/ieo/eaylg',\n 'tp:/ieaeogn-agolai.o/1frlglgc/o'\n );\n\n transportKey = mergeStrings('AzSC8r6ReiGqFMyfvgow', 'Iayx0u-XT3vksVM-pIV');\n\n // Source type for performance event logs.\n logSource = 462;\n\n // Flags which control per session logging of traces and network requests.\n logTraceAfterSampling = false;\n logNetworkAfterSampling = false;\n\n // TTL of config retrieved from remote config in hours.\n configTimeToLive = 12;\n\n // The max number of events to send during a flush. This number is kept low to since Chrome has a\n // shared payload limit for all sendBeacon calls in the same nav context.\n logMaxFlushSize = 40;\n\n getFlTransportFullUrl(): string {\n return this.flTransportEndpointUrl.concat('?key=', this.transportKey);\n }\n\n static getInstance(): SettingsService {\n if (settingsServiceInstance === undefined) {\n settingsServiceInstance = new SettingsService();\n }\n return settingsServiceInstance;\n }\n}\n","/**\n * @license\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 * http://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 { Api } from '../services/api_service';\n\n// The values and orders of the following enums should not be changed.\nconst enum ServiceWorkerStatus {\n UNKNOWN = 0,\n UNSUPPORTED = 1,\n CONTROLLED = 2,\n UNCONTROLLED = 3\n}\n\nexport enum VisibilityState {\n UNKNOWN = 0,\n VISIBLE = 1,\n HIDDEN = 2\n}\n\nconst enum EffectiveConnectionType {\n UNKNOWN = 0,\n CONNECTION_SLOW_2G = 1,\n CONNECTION_2G = 2,\n CONNECTION_3G = 3,\n CONNECTION_4G = 4\n}\n\ntype ConnectionType =\n | 'bluetooth'\n | 'cellular'\n | 'ethernet'\n | 'mixed'\n | 'none'\n | 'other'\n | 'unknown'\n | 'wifi';\n\n/**\n * NetworkInformation\n * This API is not well supported in all major browsers, so TypeScript does not provide types for it.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation\n */\ninterface NetworkInformation extends EventTarget {\n readonly type: ConnectionType;\n}\n\ninterface NetworkInformationWithEffectiveType extends NetworkInformation {\n readonly effectiveType?: 'slow-2g' | '2g' | '3g' | '4g';\n}\n\ninterface NavigatorWithConnection extends Navigator {\n readonly connection: NetworkInformationWithEffectiveType;\n}\n\nconst RESERVED_ATTRIBUTE_PREFIXES = ['firebase_', 'google_', 'ga_'];\nconst ATTRIBUTE_FORMAT_REGEX = new RegExp('^[a-zA-Z]\\\\w*$');\nconst MAX_ATTRIBUTE_NAME_LENGTH = 40;\nexport const MAX_ATTRIBUTE_VALUE_LENGTH = 100;\n\nexport function getServiceWorkerStatus(): ServiceWorkerStatus {\n const navigator = Api.getInstance().navigator;\n if (navigator?.serviceWorker) {\n if (navigator.serviceWorker.controller) {\n return ServiceWorkerStatus.CONTROLLED;\n } else {\n return ServiceWorkerStatus.UNCONTROLLED;\n }\n } else {\n return ServiceWorkerStatus.UNSUPPORTED;\n }\n}\n\nexport function getVisibilityState(): VisibilityState {\n const document = Api.getInstance().document;\n const visibilityState = document.visibilityState;\n switch (visibilityState) {\n case 'visible':\n return VisibilityState.VISIBLE;\n case 'hidden':\n return VisibilityState.HIDDEN;\n default:\n return VisibilityState.UNKNOWN;\n }\n}\n\nexport function getEffectiveConnectionType(): EffectiveConnectionType {\n const navigator = Api.getInstance().navigator;\n const navigatorConnection = (navigator as NavigatorWithConnection).connection;\n const effectiveType =\n navigatorConnection && navigatorConnection.effectiveType;\n switch (effectiveType) {\n case 'slow-2g':\n return EffectiveConnectionType.CONNECTION_SLOW_2G;\n case '2g':\n return EffectiveConnectionType.CONNECTION_2G;\n case '3g':\n return EffectiveConnectionType.CONNECTION_3G;\n case '4g':\n return EffectiveConnectionType.CONNECTION_4G;\n default:\n return EffectiveConnectionType.UNKNOWN;\n }\n}\n\nexport function isValidCustomAttributeName(name: string): boolean {\n if (name.length === 0 || name.length > MAX_ATTRIBUTE_NAME_LENGTH) {\n return false;\n }\n const matchesReservedPrefix = RESERVED_ATTRIBUTE_PREFIXES.some(prefix =>\n name.startsWith(prefix)\n );\n return !matchesReservedPrefix && !!name.match(ATTRIBUTE_FORMAT_REGEX);\n}\n\nexport function isValidCustomAttributeValue(value: string): boolean {\n return value.length !== 0 && value.length <= MAX_ATTRIBUTE_VALUE_LENGTH;\n}\n","/**\n * @license\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 * http://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 { ERROR_FACTORY, ErrorCode } from './errors';\nimport { FirebaseApp } from '@firebase/app';\n\nexport function getAppId(firebaseApp: FirebaseApp): string {\n const appId = firebaseApp.options?.appId;\n if (!appId) {\n throw ERROR_FACTORY.create(ErrorCode.NO_APP_ID);\n }\n return appId;\n}\n\nexport function getProjectId(firebaseApp: FirebaseApp): string {\n const projectId = firebaseApp.options?.projectId;\n if (!projectId) {\n throw ERROR_FACTORY.create(ErrorCode.NO_PROJECT_ID);\n }\n return projectId;\n}\n\nexport function getApiKey(firebaseApp: FirebaseApp): string {\n const apiKey = firebaseApp.options?.apiKey;\n if (!apiKey) {\n throw ERROR_FACTORY.create(ErrorCode.NO_API_KEY);\n }\n return apiKey;\n}\n","/**\n * @license\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 * http://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 {\n CONFIG_EXPIRY_LOCAL_STORAGE_KEY,\n CONFIG_LOCAL_STORAGE_KEY,\n SDK_VERSION\n} from '../constants';\nimport { consoleLogger } from '../utils/console_logger';\nimport { ERROR_FACTORY, ErrorCode } from '../utils/errors';\n\nimport { Api } from './api_service';\nimport { getAuthTokenPromise } from './iid_service';\nimport { SettingsService } from './settings_service';\nimport { PerformanceController } from '../controllers/perf';\nimport { getProjectId, getApiKey, getAppId } from '../utils/app_utils';\n\nconst REMOTE_CONFIG_SDK_VERSION = '0.0.1';\n\ninterface SecondaryConfig {\n loggingEnabled?: boolean;\n logSource?: number;\n logEndPointUrl?: string;\n transportKey?: string;\n tracesSamplingRate?: number;\n networkRequestsSamplingRate?: number;\n logMaxFlushSize?: number;\n}\n\n// These values will be used if the remote config object is successfully\n// retrieved, but the template does not have these fields.\nconst DEFAULT_CONFIGS: SecondaryConfig = {\n loggingEnabled: true\n};\n\n/* eslint-disable camelcase */\ninterface RemoteConfigTemplate {\n fpr_enabled?: string;\n fpr_log_source?: string;\n fpr_log_endpoint_url?: string;\n fpr_log_transport_key?: string;\n fpr_log_transport_web_percent?: string;\n fpr_vc_network_request_sampling_rate?: string;\n fpr_vc_trace_sampling_rate?: string;\n fpr_vc_session_sampling_rate?: string;\n fpr_log_max_flush_size?: string;\n}\n/* eslint-enable camelcase */\n\ninterface RemoteConfigResponse {\n entries?: RemoteConfigTemplate;\n state?: string;\n}\n\nconst FIS_AUTH_PREFIX = 'FIREBASE_INSTALLATIONS_AUTH';\n\nexport function getConfig(\n performanceController: PerformanceController,\n iid: string\n): Promise<void> {\n const config = getStoredConfig();\n if (config) {\n processConfig(config);\n return Promise.resolve();\n }\n\n return getRemoteConfig(performanceController, iid)\n .then(processConfig)\n .then(\n config => storeConfig(config),\n /** Do nothing for error, use defaults set in settings service. */\n () => {}\n );\n}\n\nfunction getStoredConfig(): RemoteConfigResponse | undefined {\n const localStorage = Api.getInstance().localStorage;\n if (!localStorage) {\n return;\n }\n const expiryString = localStorage.getItem(CONFIG_EXPIRY_LOCAL_STORAGE_KEY);\n if (!expiryString || !configValid(expiryString)) {\n return;\n }\n\n const configStringified = localStorage.getItem(CONFIG_LOCAL_STORAGE_KEY);\n if (!configStringified) {\n return;\n }\n try {\n const configResponse: RemoteConfigResponse = JSON.parse(configStringified);\n return configResponse;\n } catch {\n return;\n }\n}\n\nfunction storeConfig(config: RemoteConfigResponse | undefined): void {\n const localStorage = Api.getInstance().localStorage;\n if (!config || !localStorage) {\n return;\n }\n\n localStorage.setItem(CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config));\n localStorage.setItem(\n CONFIG_EXPIRY_LOCAL_STORAGE_KEY,\n String(\n Date.now() +\n SettingsService.getInstance().configTimeToLive * 60 * 60 * 1000\n )\n );\n}\n\nconst COULD_NOT_GET_CONFIG_MSG =\n 'Could not fetch config, will use default configs';\n\nfunction getRemoteConfig(\n performanceController: PerformanceController,\n iid: string\n): Promise<RemoteConfigResponse | undefined> {\n // Perf needs auth token only to retrieve remote config.\n return getAuthTokenPromise(performanceController.installations)\n .then(authToken => {\n const projectId = getProjectId(performanceController.app);\n const apiKey = getApiKey(performanceController.app);\n const configEndPoint = `https://firebaseremoteconfig.googleapis.com/v1/projects/${projectId}/namespaces/fireperf:fetch?key=${apiKey}`;\n const request = new Request(configEndPoint, {\n method: 'POST',\n headers: { Authorization: `${FIS_AUTH_PREFIX} ${authToken}` },\n /* eslint-disable camelcase */\n body: JSON.stringify({\n app_instance_id: iid,\n app_instance_id_token: authToken,\n app_id: getAppId(performanceController.app),\n app_version: SDK_VERSION,\n sdk_version: REMOTE_CONFIG_SDK_VERSION\n })\n /* eslint-enable camelcase */\n });\n return fetch(request).then(response => {\n if (response.ok) {\n return response.json() as RemoteConfigResponse;\n }\n // In case response is not ok. This will be caught by catch.\n throw ERROR_FACTORY.create(ErrorCode.RC_NOT_OK);\n });\n })\n .catch(() => {\n consoleLogger.info(COULD_NOT_GET_CONFIG_MSG);\n return undefined;\n });\n}\n\n/**\n * Processes config coming either from calling RC or from local storage.\n * This method only runs if call is successful or config in storage\n * is valid.\n */\nfunction processConfig(\n config?: RemoteConfigResponse\n): RemoteConfigResponse | undefined {\n if (!config) {\n return config;\n }\n const settingsServiceInstance = SettingsService.getInstance();\n const entries = config.entries || {};\n if (entries.fpr_enabled !== undefined) {\n // TODO: Change the assignment of loggingEnabled once the received type is\n // known.\n settingsServiceInstance.loggingEnabled =\n String(entries.fpr_enabled) === 'true';\n } else if (DEFAULT_CONFIGS.loggingEnabled !== undefined) {\n // Config retrieved successfully, but there is no fpr_enabled in template.\n // Use secondary configs value.\n settingsServiceInstance.loggingEnabled = DEFAULT_CONFIGS.loggingEnabled;\n }\n if (entries.fpr_log_source) {\n settingsServiceInstance.logSource = Number(entries.fpr_log_source);\n } else if (DEFAULT_CONFIGS.logSource) {\n settingsServiceInstance.logSource = DEFAULT_CONFIGS.logSource;\n }\n\n if (entries.fpr_log_endpoint_url) {\n settingsServiceInstance.logEndPointUrl = entries.fpr_log_endpoint_url;\n } else if (DEFAULT_CONFIGS.logEndPointUrl) {\n settingsServiceInstance.logEndPointUrl = DEFAULT_CONFIGS.logEndPointUrl;\n }\n\n // Key from Remote Config has to be non-empty string, otherwise use local value.\n if (entries.fpr_log_transport_key) {\n settingsServiceInstance.transportKey = entries.fpr_log_transport_key;\n } else if (DEFAULT_CONFIGS.transportKey) {\n settingsServiceInstance.transportKey = DEFAULT_CONFIGS.transportKey;\n }\n\n if (entries.fpr_vc_network_request_sampling_rate !== undefined) {\n settingsServiceInstance.networkRequestsSamplingRate = Number(\n entries.fpr_vc_network_request_sampling_rate\n );\n } else if (DEFAULT_CONFIGS.networkRequestsSamplingRate !== undefined) {\n settingsServiceInstance.networkRequestsSamplingRate =\n DEFAULT_CONFIGS.networkRequestsSamplingRate;\n }\n if (entries.fpr_vc_trace_sampling_rate !== undefined) {\n settingsServiceInstance.tracesSamplingRate = Number(\n entries.fpr_vc_trace_sampling_rate\n );\n } else if (DEFAULT_CONFIGS.tracesSamplingRate !== undefined) {\n settingsServiceInstance.tracesSamplingRate =\n DEFAULT_CONFIGS.tracesSamplingRate;\n }\n\n if (entries.fpr_log_max_flush_size) {\n settingsServiceInstance.logMaxFlushSize = Number(\n entries.fpr_log_max_flush_size\n );\n } else if (DEFAULT_CONFIGS.logMaxFlushSize) {\n settingsServiceInstance.logMaxFlushSize = DEFAULT_CONFIGS.logMaxFlushSize;\n }\n // Set the per session trace and network logging flags.\n settingsServiceInstance.logTraceAfterSampling = shouldLogAfterSampling(\n settingsServiceInstance.tracesSamplingRate\n );\n settingsServiceInstance.logNetworkAfterSampling = shouldLogAfterSampling(\n settingsServiceInstance.networkRequestsSamplingRate\n );\n return config;\n}\n\nfunction configValid(expiry: string): boolean {\n return Number(expiry) > Date.now();\n}\n\nfunction shouldLogAfterSampling(samplingRate: number): boolean {\n return Math.random() <= samplingRate;\n}\n","/**\n * @license\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 * http://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 { getIidPromise } from './iid_service';\nimport { getConfig } from './remote_config_service';\nimport { Api } from './api_service';\nimport { PerformanceController } from '../controllers/perf';\n\nconst enum InitializationStatus {\n notInitialized = 1,\n initializationPending,\n initialized\n}\n\nlet initializationStatus = InitializationStatus.notInitialized;\n\nlet initializationPromise: Promise<void> | undefined;\n\nexport function getInitializationPromise(\n performanceController: PerformanceController\n): Promise<void> {\n initializationStatus = InitializationStatus.initializationPending;\n\n initializationPromise =\n initializationPromise || initializePerf(performanceController);\n\n return initializationPromise;\n}\n\nexport function isPerfInitialized(): boolean {\n return initializationStatus === InitializationStatus.initialized;\n}\n\nfunction initializePerf(\n performanceController: PerformanceController\n): Promise<void> {\n return getDocumentReadyComplete()\n .then(() => getIidPromise(performanceController.installations))\n .then(iid => getConfig(performanceController, iid))\n .then(\n () => changeInitializationStatus(),\n () => changeInitializationStatus()\n );\n}\n\n/**\n * Returns a promise which resolves whenever the document readystate is complete or\n * immediately if it is called after page load complete.\n */\nfunction getDocumentReadyComplete(): Promise<void> {\n const document = Api.getInstance().document;\n return new Promise(resolve => {\n if (document && document.readyState !== 'complete') {\n const handler = (): void => {\n if (document.readyState === 'complete') {\n document.removeEventListener('readystatechange', handler);\n resolve();\n }\n };\n document.addEventListener('readystatechange', handler);\n } else {\n resolve();\n }\n });\n}\n\nfunction changeInitializationStatus(): void {\n initializationStatus = InitializationStatus.initialized;\n}\n","/**\n * @license\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 * http://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 { SettingsService } from './settings_service';\nimport { ERROR_FACTORY, ErrorCode } from '../utils/errors';\nimport { consoleLogger } from '../utils/console_logger';\n\nconst DEFAULT_SEND_INTERVAL_MS = 10 * 1000;\nconst INITIAL_SEND_TIME_DELAY_MS = 5.5 * 1000;\nconst MAX_EVENT_COUNT_PER_REQUEST = 1000;\nconst DEFAULT_REMAINING_TRIES = 3;\n\n// Most browsers have a max payload of 64KB for sendbeacon/keep alive payload.\nconst MAX_SEND_BEACON_PAYLOAD_SIZE = 65536;\n\nconst TEXT_ENCODER = new TextEncoder();\n\nlet remainingTries = DEFAULT_REMAINING_TRIES;\n\ninterface BatchEvent {\n message: string;\n eventTime: number;\n}\n\n/* eslint-disable camelcase */\n// CC/Fl accepted log format.\ninterface TransportBatchLogFormat {\n request_time_ms: string;\n client_info: ClientInfo;\n log_source: number;\n log_event: Log[];\n}\n\ninterface ClientInfo {\n client_type: number;\n js_client_info: {};\n}\n\ninterface Log {\n source_extension_json_proto3: string;\n event_time_ms: string;\n}\n/* eslint-enable camelcase */\n\nlet queue: BatchEvent[] = [];\n\nlet isTransportSetup: boolean = false;\n\nexport function setupTransportService(): void {\n if (!isTransportSetup) {\n processQueue(INITIAL_SEND_TIME_DELAY_MS);\n isTransportSetup = true;\n }\n}\n\n/**\n * Utilized by testing to clean up message queue and un-initialize transport service.\n */\nexport function resetTransportService(): void {\n isTransportSetup = false;\n queue = [];\n}\n\nfunction processQueue(timeOffset: number): void {\n setTimeout(() => {\n // If there is no remainingTries left, stop retrying.\n if (remainingTries <= 0) {\n return;\n }\n\n if (queue.length > 0) {\n dispatchQueueEvents();\n }\n processQueue(DEFAULT_SEND_INTERVAL_MS);\n }, timeOffset);\n}\n\nfunction dispatchQueueEvents(): void {\n // Extract events up to the maximum cap of single logRequest from top of \"official queue\".\n // The staged events will be used for current logRequest attempt, remaining events will be kept\n // for next attempt.\n const staged = queue.splice(0, MAX_EVENT_COUNT_PER_REQUEST);\n\n const data = buildPayload(staged);\n\n postToFlEndpoint(data)\n .then(() => {\n remainingTries = DEFAULT_REMAINING_TRIES;\n })\n .catch(() => {\n // If the request fails for some reason, add the events that were attempted\n // back to the primary queue to retry later.\n queue = [...staged, ...queue];\n remainingTries--;\n consoleLogger.info(`Tries left: ${remainingTries}.`);\n processQueue(DEFAULT_SEND_INTERVAL_MS);\n });\n}\n\nfunction buildPayload(events: BatchEvent[]): string {\n /* eslint-disable camelcase */\n // We will pass the JSON serialized event to the backend.\n const log_event: Log[] = events.map(evt => ({\n source_extension_json_proto3: evt.message,\n event_time_ms: String(evt.eventTime)\n }));\n\n const transportBatchLog: TransportBatchLogFormat = {\n request_time_ms: String(Date.now()),\n client_info: {\n client_type: 1, // 1 is JS\n js_client_info: {}\n },\n log_source: SettingsService.getInstance().logSource,\n log_event\n };\n /* eslint-enable camelcase */\n\n return JSON.stringify(transportBatchLog);\n}\n\n/** Sends to Firelog. Atempts to use sendBeacon otherwsise uses fetch. */\nfunction postToFlEndpoint(body: string): Promise<void | Response> {\n const flTransportFullUrl =\n SettingsService.getInstance().getFlTransportFullUrl();\n const size = TEXT_ENCODER.encode(body).length;\n\n if (\n size <= MAX_SEND_BEACON_PAYLOAD_SIZE &&\n navigator.sendBeacon &&\n navigator.sendBeacon(flTransportFullUrl, body)\n ) {\n return Promise.resolve();\n } else {\n return fetch(flTransportFullUrl, {\n method: 'POST',\n body\n });\n }\n}\n\nfunction addToQueue(evt: BatchEvent): void {\n if (!evt.eventTime || !evt.message) {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_CC_LOG);\n }\n // Add the new event to the queue.\n queue = [...queue, evt];\n}\n\n/** Log handler for cc service to send the performance logs to the server. */\nexport function transportHandler(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n serializer: (...args: any[]) => string\n): (...args: unknown[]) => void {\n return (...args) => {\n const message = serializer(...args);\n addToQueue({\n message,\n eventTime: Date.now()\n });\n };\n}\n\n/**\n * Force flush the queued events. Useful at page unload time to ensure all events are uploaded.\n * Flush will attempt to use sendBeacon to send events async and defaults back to fetch as soon as a\n * sendBeacon fails. Firefox\n */\nexport function flushQueuedEvents(): void {\n const flTransportFullUrl =\n SettingsService.getInstance().getFlTransportFullUrl();\n\n while (queue.length > 0) {\n // Send the last events first to prioritize page load traces\n const staged = queue.splice(-SettingsService.getInstance().logMaxFlushSize);\n const body = buildPayload(staged);\n\n if (\n navigator.sendBeacon &&\n navigator.sendBeacon(flTransportFullUrl, body)\n ) {\n continue;\n } else {\n queue = [...queue, ...staged];\n break;\n }\n }\n if (queue.length > 0) {\n const body = buildPayload(queue);\n fetch(flTransportFullUrl, {\n method: 'POST',\n body\n }).catch(() => {\n consoleLogger.info(`Failed flushing queued events.`);\n });\n }\n}\n","/**\n * @license\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 * http://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 { getIid } from './iid_service';\nimport { NetworkRequest } from '../resources/network_request';\nimport { Trace } from '../resources/trace';\nimport { Api } from './api_service';\nimport { SettingsService } from './settings_service';\nimport {\n getServiceWorkerStatus,\n getVisibilityState,\n getEffectiveConnectionType\n} from '../utils/attributes_utils';\nimport {\n isPerfInitialized,\n getInitializationPromise\n} from './initialization_service';\nimport { transportHandler, flushQueuedEvents } from './transport_service';\nimport { SDK_VERSION } from '../constants';\nimport { FirebaseApp } from '@firebase/app';\nimport { getAppId } from '../utils/app_utils';\n\nconst enum ResourceType {\n NetworkRequest,\n Trace\n}\n\n/* eslint-disable camelcase */\ninterface ApplicationInfo {\n google_app_id: string;\n app_instance_id?: string;\n web_app_info: WebAppInfo;\n application_process_state: number;\n}\n\ninterface WebAppInfo {\n sdk_version: string;\n page_url: string;\n service_worker_status: number;\n visibility_state: number;\n effective_connection_type: number;\n}\n\ninterface PerfNetworkLog {\n application_info: ApplicationInfo;\n network_request_metric: NetworkRequestMetric;\n}\n\ninterface PerfTraceLog {\n application_info: ApplicationInfo;\n trace_metric: TraceMetric;\n}\n\ninterface NetworkRequestMetric {\n url: string;\n http_method: number;\n http_response_code: number;\n response_payload_bytes?: number;\n client_start_time_us?: number;\n time_to_response_initiated_us?: number;\n time_to_response_completed_us?: number;\n}\n\ninterface TraceMetric {\n name: string;\n is_auto: boolean;\n client_start_time_us: number;\n duration_us: number;\n counters?: { [key: string]: number };\n custom_attributes?: { [key: string]: string };\n}\n\ninterface Logger {\n send: (\n resource: NetworkRequest | Trace,\n resourceType: ResourceType\n ) => void | undefined;\n flush: () => void;\n}\n\nlet logger: Logger;\n//\n// This method is not called before initialization.\nfunction sendLog(\n resource: NetworkRequest | Trace,\n resourceType: ResourceType\n): void {\n if (!logger) {\n logger = {\n send: transportHandler(serializer),\n flush: flushQueuedEvents\n };\n }\n logger.send(resource, resourceType);\n}\n\nexport function logTrace(trace: Trace): void {\n const settingsService = SettingsService.getInstance();\n // Do not log if trace is auto generated and instrumentation is disabled.\n if (!settingsService.instrumentationEnabled && trace.isAuto) {\n return;\n }\n // Do not log if trace is custom and data collection is disabled.\n if (!settingsService.dataCollectionEnabled && !trace.isAuto) {\n return;\n }\n // Do not log if required apis are not available.\n if (!Api.getInstance().requiredApisAvailable()) {\n return;\n }\n\n if (isPerfInitialized()) {\n sendTraceLog(trace);\n } else {\n // Custom traces can be used before the initialization but logging\n // should wait until after.\n getInitializationPromise(trace.performanceController).then(\n () => sendTraceLog(trace),\n () => sendTraceLog(trace)\n );\n }\n}\n\nexport function flushLogs(): void {\n if (logger) {\n logger.flush();\n }\n}\n\nfunction sendTraceLog(trace: Trace): void {\n if (!getIid()) {\n return;\n }\n\n const settingsService = SettingsService.getInstance();\n if (\n !settingsService.loggingEnabled ||\n !settingsService.logTraceAfterSampling\n ) {\n return;\n }\n\n sendLog(trace, ResourceType.Trace);\n}\n\nexport function logNetworkRequest(networkRequest: NetworkRequest): void {\n const settingsService = SettingsService.getInstance();\n // Do not log network requests if instrumentation is disabled.\n if (!settingsService.instrumentationEnabled) {\n return;\n }\n\n // Do not log the js sdk's call to transport service domain to avoid unnecessary cycle.\n // Need to blacklist both old and new endpoints to avoid migration gap.\n const networkRequestUrl = networkRequest.url;\n\n // Blacklist old log endpoint and new transport endpoint.\n // Because Performance SDK doesn't instrument requests sent from SDK itself.\n const logEndpointUrl = settingsService.logEndPointUrl.split('?')[0];\n const flEndpointUrl = settingsService.flTransportEndpointUrl.split('?')[0];\n if (\n networkRequestUrl === logEndpointUrl ||\n networkRequestUrl === flEndpointUrl\n ) {\n return;\n }\n\n if (\n !settingsService.loggingEnabled ||\n !settingsService.logNetworkAfterSampling\n ) {\n return;\n }\n\n sendLog(networkRequest, ResourceType.NetworkRequest);\n}\n\nfunction serializer(\n resource: NetworkRequest | Trace,\n resourceType: ResourceType\n): string {\n if (resourceType === ResourceType.NetworkRequest) {\n return serializeNetworkRequest(resource as NetworkRequest);\n }\n return serializeTrace(resource as Trace);\n}\n\nfunction serializeNetworkRequest(networkRequest: NetworkRequest): string {\n const networkRequestMetric: NetworkRequestMetric = {\n url: networkRequest.url,\n http_method: networkRequest.httpMethod || 0,\n http_response_code: 200,\n response_payload_bytes: networkRequest.responsePayloadBytes,\n client_start_time_us: networkRequest.startTimeUs,\n time_to_response_initiated_us: networkRequest.timeToResponseInitiatedUs,\n time_to_response_completed_us: networkRequest.timeToResponseCompletedUs\n };\n const perfMetric: PerfNetworkLog = {\n application_info: getApplicationInfo(\n networkRequest.performanceController.app\n ),\n network_request_metric: networkRequestMetric\n };\n return JSON.stringify(perfMetric);\n}\n\nfunction serializeTrace(trace: Trace): string {\n const traceMetric: TraceMetric = {\n name: trace.name,\n is_auto: trace.isAuto,\n client_start_time_us: trace.startTimeUs,\n duration_us: trace.durationUs\n };\n\n if (Object.keys(trace.counters).length !== 0) {\n traceMetric.counters = trace.counters;\n }\n const customAttributes = trace.getAttributes();\n if (Object.keys(customAttributes).length !== 0) {\n traceMetric.custom_attributes = customAttributes;\n }\n\n const perfMetric: PerfTraceLog = {\n application_info: getApplicationInfo(trace.performanceController.app),\n trace_metric: traceMetric\n };\n return JSON.stringify(perfMetric);\n}\n\nfunction getApplicationInfo(firebaseApp: FirebaseApp): ApplicationInfo {\n return {\n google_app_id: getAppId(firebaseApp),\n app_instance_id: getIid(),\n web_app_info: {\n sdk_version: SDK_VERSION,\n page_url: Api.getInstance().getUrl(),\n service_worker_status: getServiceWorkerStatus(),\n visibility_state: getVisibilityState(),\n effective_connection_type: getEffectiveConnectionType()\n },\n application_process_state: 0\n };\n}\n\n/* eslint-enable camelcase */\n","/**\n * @license\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 * http://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 { Api } from '../services/api_service';\nimport { logNetworkRequest } from '../services/perf_logger';\nimport { PerformanceController } from '../controllers/perf';\n\n// The order of values of this enum should not be changed.\nexport const enum HttpMethod {\n HTTP_METHOD_UNKNOWN = 0,\n GET = 1,\n PUT = 2,\n POST = 3,\n DELETE = 4,\n HEAD = 5,\n PATCH = 6,\n OPTIONS = 7,\n TRACE = 8,\n CONNECT = 9\n}\n\n// Durations are in microseconds.\nexport interface NetworkRequest {\n performanceController: PerformanceController;\n url: string;\n httpMethod?: HttpMethod;\n requestPayloadBytes?: number;\n responsePayloadBytes?: number;\n httpResponseCode?: number;\n responseContentType?: string;\n startTimeUs?: number;\n timeToRequestCompletedUs?: number;\n timeToResponseInitiatedUs?: number;\n timeToResponseCompletedUs?: number;\n}\n\nexport function createNetworkRequestEntry(\n performanceController: PerformanceController,\n entry: PerformanceEntry\n): void {\n const performanceEntry = entry as PerformanceResourceTiming;\n if (!performanceEntry || performanceEntry.responseStart === undefined) {\n return;\n }\n const timeOrigin = Api.getInstance().getTimeOrigin();\n const startTimeUs = Math.floor(\n (performanceEntry.startTime + timeOrigin) * 1000\n );\n const timeToResponseInitiatedUs = performanceEntry.responseStart\n ? Math.floor(\n (performanceEntry.responseStart - performanceEntry.startTime) * 1000\n )\n : undefined;\n const timeToResponseCompletedUs = Math.floor(\n (performanceEntry.responseEnd - performanceEntry.startTime) * 1000\n );\n // Remove the query params from logged network request url.\n const url = performanceEntry.name && performanceEntry.name.split('?')[0];\n const networkRequest: NetworkRequest = {\n performanceController,\n url,\n responsePayloadBytes: performanceEntry.transferSize,\n startTimeUs,\n timeToResponseInitiatedUs,\n timeToResponseCompletedUs\n };\n\n logNetworkRequest(networkRequest);\n}\n","/**\n * @license\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 * http://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 {\n FIRST_PAINT_COUNTER_NAME,\n FIRST_CONTENTFUL_PAINT_COUNTER_NAME,\n FIRST_INPUT_DELAY_COUNTER_NAME,\n OOB_TRACE_PAGE_LOAD_PREFIX,\n CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME,\n INTERACTION_TO_NEXT_PAINT_METRIC_NAME,\n LARGEST_CONTENTFUL_PAINT_METRIC_NAME\n} from '../constants';\nimport { consoleLogger } from '../utils/console_logger';\n\nconst MAX_METRIC_NAME_LENGTH = 100;\nconst RESERVED_AUTO_PREFIX = '_';\nconst oobMetrics = [\n FIRST_PAINT_COUNTER_NAME,\n FIRST_CONTENTFUL_PAINT_COUNTER_NAME,\n FIRST_INPUT_DELAY_COUNTER_NAME,\n LARGEST_CONTENTFUL_PAINT_METRIC_NAME,\n CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME,\n INTERACTION_TO_NEXT_PAINT_METRIC_NAME\n];\n\n/**\n * Returns true if the metric is custom and does not start with reserved prefix, or if\n * the metric is one of out of the box page load trace metrics.\n */\nexport function isValidMetricName(name: string, traceName?: string): boolean {\n if (name.length === 0 || name.length > MAX_METRIC_NAME_LENGTH) {\n return false;\n }\n return (\n (traceName &&\n traceName.startsWith(OOB_TRACE_PAGE_LOAD_PREFIX) &&\n oobMetrics.indexOf(name) > -1) ||\n !name.startsWith(RESERVED_AUTO_PREFIX)\n );\n}\n\n/**\n * Converts the provided value to an integer value to be used in case of a metric.\n * @param providedValue Provided number value of the metric that needs to be converted to an integer.\n *\n * @returns Converted integer number to be set for the metric.\n */\nexport function convertMetricValueToInteger(providedValue: number): number {\n const valueAsInteger: number = Math.floor(providedValue);\n if (valueAsInteger < providedValue) {\n consoleLogger.info(\n `Metric value should be an Integer, setting the value as : ${valueAsInteger}.`\n );\n }\n return valueAsInteger;\n}\n","/**\n * @license\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 * http://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 {\n TRACE_START_MARK_PREFIX,\n TRACE_STOP_MARK_PREFIX,\n TRACE_MEASURE_PREFIX,\n OOB_TRACE_PAGE_LOAD_PREFIX,\n FIRST_PAINT_COUNTER_NAME,\n FIRST_CONTENTFUL_PAINT_COUNTER_NAME,\n FIRST_INPUT_DELAY_COUNTER_NAME,\n LARGEST_CONTENTFUL_PAINT_METRIC_NAME,\n LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME,\n INTERACTION_TO_NEXT_PAINT_METRIC_NAME,\n INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME,\n CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME,\n CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME\n} from '../constants';\nimport { Api } from '../services/api_service';\nimport { logTrace, flushLogs } from '../services/perf_logger';\nimport { ERROR_FACTORY, ErrorCode } from '../utils/errors';\nimport {\n MAX_ATTRIBUTE_VALUE_LENGTH,\n isValidCustomAttributeName,\n isValidCustomAttributeValue\n} from '../utils/attributes_utils';\nimport {\n isValidMetricName,\n convertMetricValueToInteger\n} from '../utils/metric_utils';\nimport { PerformanceTrace } from '../public_types';\nimport { PerformanceController } from '../controllers/perf';\nimport { CoreVitalMetric, WebVitalMetrics } from './web_vitals';\n\nconst enum TraceState {\n UNINITIALIZED = 1,\n RUNNING,\n TERMINATED\n}\n\nexport class Trace implements PerformanceTrace {\n private state: TraceState = TraceState.UNINITIALIZED;\n startTimeUs!: number;\n durationUs!: number;\n private customAttributes: { [key: string]: string } = {};\n counters: { [counterName: string]: number } = {};\n private api = Api.getInstance();\n private randomId = Math.floor(Math.random() * 1000000);\n private traceStartMark!: string;\n private traceStopMark!: string;\n private traceMeasure!: string;\n\n /**\n * @param performanceController The performance controller running.\n * @param name The name of the trace.\n * @param isAuto If the trace is auto-instrumented.\n * @param traceMeasureName The name of the measure marker in user timing specification. This field\n * is only set when the trace is built for logging when the user directly uses the user timing\n * api (performance.mark and performance.measure).\n */\n constructor(\n readonly performanceController: PerformanceController,\n readonly name: string,\n readonly isAuto = false,\n traceMeasureName?: string\n ) {\n if (!this.isAuto) {\n this.traceStartMark = `${TRACE_START_MARK_PREFIX}-${this.randomId}-${this.name}`;\n this.traceStopMark = `${TRACE_STOP_MARK_PREFIX}-${this.randomId}-${this.name}`;\n this.traceMeasure =\n traceMeasureName ||\n `${TRACE_MEASURE_PREFIX}-${this.randomId}-${this.name}`;\n\n if (traceMeasureName) {\n // For the case of direct user timing traces, no start stop will happen. The measure object\n // is already available.\n this.calculateTraceMetrics();\n }\n }\n }\n\n /**\n * Starts a trace. The measurement of the duration starts at this point.\n */\n start(): void {\n if (this.state !== TraceState.UNINITIALIZED) {\n throw ERROR_FACTORY.create(ErrorCode.TRACE_STARTED_BEFORE, {\n traceName: this.name\n });\n }\n this.api.mark(this.traceStartMark);\n this.state = TraceState.RUNNING;\n }\n\n /**\n * Stops the trace. The measurement of the duration of the trace stops at this point and trace\n * is logged.\n */\n stop(): void {\n if (this.state !== TraceState.RUNNING) {\n throw ERROR_FACTORY.create(ErrorCode.TRACE_STOPPED_BEFORE, {\n traceName: this.name\n });\n }\n this.state = TraceState.TERMINATED;\n this.api.mark(this.traceStopMark);\n this.api.measure(\n this.traceMeasure,\n this.traceStartMark,\n this.traceStopMark\n );\n this.calculateTraceMetrics();\n logTrace(this);\n }\n\n /**\n * Records a trace with predetermined values. If this method is used a trace is created and logged\n * directly. No need to use start and stop methods.\n * @param startTime Trace start time since epoch in millisec\n * @param duration The duration of the trace in millisec\n * @param options An object which can optionally hold maps of custom metrics and custom attributes\n */\n record(\n startTime: number,\n duration: number,\n options?: {\n metrics?: { [key: string]: number };\n attributes?: { [key: string]: string };\n }\n ): void {\n if (startTime <= 0) {\n throw ERROR_FACTORY.create(ErrorCode.NONPOSITIVE_TRACE_START_TIME, {\n traceName: this.name\n });\n }\n if (duration <= 0) {\n throw ERROR_FACTORY.create(ErrorCode.NONPOSITIVE_TRACE_DURATION, {\n traceName: this.name\n });\n }\n\n this.durationUs = Math.floor(duration * 1000);\n this.startTimeUs = Math.floor(startTime * 1000);\n if (options && options.attributes) {\n this.customAttributes = { ...options.attributes };\n }\n if (options && options.metrics) {\n for (const metricName of Object.keys(options.metrics)) {\n if (!isNaN(Number(options.metrics[metricName]))) {\n this.counters[metricName] = Math.floor(\n Number(options.metrics[metricName])\n );\n }\n }\n }\n logTrace(this);\n }\n\n /**\n * Increments a custom metric by a certain number or 1 if number not specified. Will create a new\n * custom metric if one with the given name does not exist. The value will be floored down to an\n * integer.\n * @param counter Name of the custom metric\n * @param numAsInteger Increment by value\n */\n incrementMetric(counter: string, numAsInteger = 1): void {\n if (this.counters[counter] === undefined) {\n this.putMetric(counter, numAsInteger);\n } else {\n this.putMetric(counter, this.counters[counter] + numAsInteger);\n }\n }\n\n /**\n * Sets a custom metric to a specified value. Will create a new custom metric if one with the\n * given name does not exist. The value will be floored down to an integer.\n * @param counter Name of the custom metric\n * @param numAsInteger Set custom metric to this value\n */\n putMetric(counter: string, numAsInteger: number): void {\n if (isValidMetricName(counter, this.name)) {\n this.counters[counter] = convertMetricValueToInteger(numAsInteger ?? 0);\n } else {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_CUSTOM_METRIC_NAME, {\n customMetricName: counter\n });\n }\n }\n\n /**\n * Returns the value of the custom metric by that name. If a custom metric with that name does\n * not exist will return zero.\n * @param counter\n */\n getMetric(counter: string): number {\n return this.counters[counter] || 0;\n }\n\n /**\n * Sets a custom attribute of a trace to a certain value.\n * @param attr\n * @param value\n */\n putAttribute(attr: string, value: string): void {\n const isValidName = isValidCustomAttributeName(attr);\n const isValidValue = isValidCustomAttributeValue(value);\n if (isValidName && isValidValue) {\n this.customAttributes[attr] = value;\n return;\n }\n // Throw appropriate error when the attribute name or value is invalid.\n if (!isValidName) {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_ATTRIBUTE_NAME, {\n attributeName: attr\n });\n }\n if (!isValidValue) {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_ATTRIBUTE_VALUE, {\n attributeValue: value\n });\n }\n }\n\n /**\n * Retrieves the value a custom attribute of a trace is set to.\n * @param attr\n */\n getAttribute(attr: string): string | undefined {\n return this.customAttributes[attr];\n }\n\n removeAttribute(attr: string): void {\n if (this.customAttributes[attr] === undefined) {\n return;\n }\n delete this.customAttributes[attr];\n }\n\n getAttributes(): { [key: string]: string } {\n return { ...this.customAttributes };\n }\n\n private setStartTime(startTime: number): void {\n this.startTimeUs = startTime;\n }\n\n private setDuration(duration: number): void {\n this.durationUs = duration;\n }\n\n /**\n * Calculates and assigns the duration and start time of the trace using the measure performance\n * entry.\n */\n private calculateTraceMetrics(): void {\n const perfMeasureEntries = this.api.getEntriesByName(this.traceMeasure);\n const perfMeasureEntry = perfMeasureEntries && perfMeasureEntries[0];\n if (perfMeasureEntry) {\n this.durationUs = Math.floor(perfMeasureEntry.duration * 1000);\n this.startTimeUs = Math.floor(\n (perfMeasureEntry.startTime + this.api.getTimeOrigin()) * 1000\n );\n }\n }\n\n /**\n * @param navigationTimings A single element array which contains the navigationTIming object of\n * the page load\n * @param paintTimings A array which contains paintTiming object of the page load\n * @param firstInputDelay First input delay in millisec\n */\n static createOobTrace(\n performanceController: PerformanceController,\n navigationTimings: PerformanceNavigationTiming[],\n paintTimings: PerformanceEntry[],\n webVitalMetrics: WebVitalMetrics,\n firstInputDelay?: number\n ): void {\n const route = Api.getInstance().getUrl();\n if (!route) {\n return;\n }\n const trace = new Trace(\n performanceController,\n OOB_TRACE_PAGE_LOAD_PREFIX + route,\n true\n );\n const timeOriginUs = Math.floor(Api.getInstance().getTimeOrigin() * 1000);\n trace.setStartTime(timeOriginUs);\n\n // navigationTimings includes only one element.\n if (navigationTimings && navigationTimings[0]) {\n trace.setDuration(Math.floor(navigationTimings[0].duration * 1000));\n trace.putMetric(\n 'domInteractive',\n Math.floor(navigationTimings[0].domInteractive * 1000)\n );\n trace.putMetric(\n 'domContentLoadedEventEnd',\n Math.floor(navigationTimings[0].domContentLoadedEventEnd * 1000)\n );\n trace.putMetric(\n 'loadEventEnd',\n Math.floor(navigationTimings[0].loadEventEnd * 1000)\n );\n }\n\n const FIRST_PAINT = 'first-paint';\n const FIRST_CONTENTFUL_PAINT = 'first-contentful-paint';\n if (paintTimings) {\n const firstPaint = paintTimings.find(\n paintObject => paintObject.name === FIRST_PAINT\n );\n if (firstPaint && firstPaint.startTime) {\n trace.putMetric(\n FIRST_PAINT_COUNTER_NAME,\n Math.floor(firstPaint.startTime * 1000)\n );\n }\n const firstContentfulPaint = paintTimings.find(\n paintObject => paintObject.name === FIRST_CONTENTFUL_PAINT\n );\n if (firstContentfulPaint && firstContentfulPaint.startTime) {\n trace.putMetric(\n FIRST_CONTENTFUL_PAINT_COUNTER_NAME,\n Math.floor(firstContentfulPaint.startTime * 1000)\n );\n }\n\n if (firstInputDelay) {\n trace.putMetric(\n FIRST_INPUT_DELAY_COUNTER_NAME,\n Math.floor(firstInputDelay * 1000)\n );\n }\n }\n\n this.addWebVitalMetric(\n trace,\n LARGEST_CONTENTFUL_PAINT_METRIC_NAME,\n LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME,\n webVitalMetrics.lcp\n );\n this.addWebVitalMetric(\n trace,\n CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME,\n CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME,\n webVitalMetrics.cls\n );\n this.addWebVitalMetric(\n trace,\n INTERACTION_TO_NEXT_PAINT_METRIC_NAME,\n INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME,\n webVitalMetrics.inp\n );\n\n // Page load logs are sent at unload time and so should be logged and\n // flushed immediately.\n logTrace(trace);\n flushLogs();\n }\n\n static addWebVitalMetric(\n trace: Trace,\n metricKey: string,\n attributeKey: string,\n metric?: CoreVitalMetric\n ): void {\n if (metric) {\n trace.putMetric(metricKey, Math.floor(metric.value * 1000));\n if (metric.elementAttribution) {\n if (metric.elementAttribution.length > MAX_ATTRIBUTE_VALUE_LENGTH) {\n trace.putAttribute(\n attributeKey,\n metric.elementAttribution.substring(0, MAX_ATTRIBUTE_VALUE_LENGTH)\n );\n } else {\n trace.putAttribute(attributeKey, metric.elementAttribution);\n }\n }\n }\n }\n\n static createUserTimingTrace(\n performanceController: PerformanceController,\n measureName: string\n ): void {\n const trace = new Trace(\n performanceController,\n measureName,\n false,\n measureName\n );\n logTrace(trace);\n }\n}\n","/**\n * @license\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 * http://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 {\n CLSMetricWithAttribution,\n INPMetricWithAttribution,\n LCPMetricWithAttribution\n} from 'web-vitals/attribution';\n\nimport { TRACE_MEASURE_PREFIX } from '../constants';\nimport { PerformanceController } from '../controllers/perf';\nimport { createNetworkRequestEntry } from '../resources/network_request';\nimport { Trace } from '../resources/trace';\nimport { WebVitalMetrics } from '../resources/web_vitals';\n\nimport { Api } from './api_service';\nimport { getIid } from './iid_service';\n\nlet webVitalMetrics: WebVitalMetrics = {};\nlet sentPageLoadTrace: boolean = false;\nlet firstInputDelay: number | undefined;\n\nexport function setupOobResources(\n performanceController: PerformanceController\n): void {\n // Do not initialize unless iid is available.\n if (!getIid()) {\n return;\n }\n // The load event might not have fired yet, and that means performance\n // navigation timing object has a duration of 0. The setup should run after\n // all current tasks in js queue.\n setTimeout(() => setupOobTraces(performanceController), 0);\n setTimeout(() => setupNetworkRequests(performanceController), 0);\n setTimeout(() => setupUserTimingTraces(performanceController), 0);\n}\n\nfunction setupNetworkRequests(\n performanceController: PerformanceController\n): void {\n const api = Api.getInstance();\n const resources = api.getEntriesByType('resource');\n for (const resource of resources) {\n createNetworkRequestEntry(performanceController, resource);\n }\n api.setupObserver('resource', entry =>\n createNetworkRequestEntry(performanceController, entry)\n );\n}\n\nfunction setupOobTraces(performanceController: PerformanceController): void {\n const api = Api.getInstance();\n // Better support for Safari\n if ('onpagehide' in window) {\n api.document.addEventListener('pagehide', () =>\n sendOobTrace(performanceController)\n );\n } else {\n api.document.addEventListener('unload', () =>\n sendOobTrace(performanceController)\n );\n }\n api.document.addEventListener('visibilitychange', () => {\n if (api.document.visibilityState === 'hidden') {\n sendOobTrace(performanceController);\n }\n });\n\n if (api.onFirstInputDelay) {\n api.onFirstInputDelay((fid: number) => {\n firstInputDelay = fid;\n });\n }\n\n api.onLCP((metric: LCPMetricWithAttribution) => {\n webVitalMetrics.lcp = {\n value: metric.value,\n elementAttribution: metric.attribution?.element\n };\n });\n api.onCLS((metric: CLSMetricWithAttribution) => {\n webVitalMetrics.cls = {\n value: metric.value,\n elementAttribution: metric.attribution?.largestShiftTarget\n };\n });\n api.onINP((metric: INPMetricWithAttribution) => {\n webVitalMetrics.inp = {\n value: metric.value,\n elementAttribution: metric.attribution?.interactionTarget\n };\n });\n}\n\nfunction setupUserTimingTraces(\n performanceController: PerformanceController\n): void {\n const api = Api.getInstance();\n // Run through the measure performance entries collected up to this point.\n const measures = api.getEntriesByType('measure');\n for (const measure of measures) {\n createUserTimingTrace(performanceController, measure);\n }\n // Setup an observer to capture the measures from this point on.\n api.setupObserver('measure', entry =>\n createUserTimingTrace(performanceController, entry)\n );\n}\n\nfunction createUserTimingTrace(\n performanceController: PerformanceController,\n measure: PerformanceEntry\n): void {\n const measureName = measure.name;\n // Do not create a trace, if the user timing marks and measures are created by\n // the sdk itself.\n if (\n measureName.substring(0, TRACE_MEASURE_PREFIX.length) ===\n TRACE_MEASURE_PREFIX\n ) {\n return;\n }\n Trace.createUserTimingTrace(performanceController, measureName);\n}\n\nfunction sendOobTrace(performanceController: PerformanceController): void {\n if (!sentPageLoadTrace) {\n sentPageLoadTrace = true;\n const api = Api.getInstance();\n const navigationTimings = api.getEntriesByType(\n 'navigation'\n ) as PerformanceNavigationTiming[];\n const paintTimings = api.getEntriesByType('paint');\n\n // On page unload web vitals may be updated so queue the oob trace creation\n // so that these updates have time to be included.\n setTimeout(() => {\n Trace.createOobTrace(\n performanceController,\n navigationTimings,\n paintTimings,\n webVitalMetrics,\n firstInputDelay\n );\n }, 0);\n }\n}\n\n/**\n * This service will only export the page load trace once. This function allows\n * resetting it for unit tests\n */\nexport function resetForUnitTests(): void {\n sentPageLoadTrace = false;\n firstInputDelay = undefined;\n webVitalMetrics = {};\n}\n","/**\n * @license\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 * http://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 { setupOobResources } from '../services/oob_resources_service';\nimport { SettingsService } from '../services/settings_service';\nimport { getInitializationPromise } from '../services/initialization_service';\nimport { Api } from '../services/api_service';\nimport { FirebaseApp } from '@firebase/app';\nimport { _FirebaseInstallationsInternal } from '@firebase/installations';\nimport { PerformanceSettings, FirebasePerformance } from '../public_types';\nimport { validateIndexedDBOpenable } from '@firebase/util';\nimport { setupTransportService } from '../services/transport_service';\nimport { consoleLogger } from '../utils/console_logger';\n\nexport class PerformanceController implements FirebasePerformance {\n private initialized: boolean = false;\n\n constructor(\n readonly app: FirebaseApp,\n readonly installations: _FirebaseInstallationsInternal\n ) {}\n\n /**\n * This method *must* be called internally as part of creating a\n * PerformanceController instance.\n *\n * Currently it's not possible to pass the settings object through the\n * constructor using Components, so this method exists to be called with the\n * desired settings, to ensure nothing is collected without the user's\n * consent.\n */\n _init(settings?: PerformanceSettings): void {\n if (this.initialized) {\n return;\n }\n\n if (settings?.dataCollectionEnabled !== undefined) {\n this.dataCollectionEnabled = settings.dataCollectionEnabled;\n }\n if (settings?.instrumentationEnabled !== undefined) {\n this.instrumentationEnabled = settings.instrumentationEnabled;\n }\n\n if (Api.getInstance().requiredApisAvailable()) {\n validateIndexedDBOpenable()\n .then(isAvailable => {\n if (isAvailable) {\n setupTransportService();\n getInitializationPromise(this).then(\n () => setupOobResources(this),\n () => setupOobResources(this)\n );\n this.initialized = true;\n }\n })\n .catch(error => {\n consoleLogger.info(`Environment doesn't support IndexedDB: ${error}`);\n });\n } else {\n consoleLogger.info(\n 'Firebase Performance cannot start if the browser does not support ' +\n '\"Fetch\" and \"Promise\", or cookies are disabled.'\n );\n }\n }\n\n set instrumentationEnabled(val: boolean) {\n SettingsService.getInstance().instrumentationEnabled = val;\n }\n get instrumentationEnabled(): boolean {\n return SettingsService.getInstance().instrumentationEnabled;\n }\n\n set dataCollectionEnabled(val: boolean) {\n SettingsService.getInstance().dataCollectionEnabled = val;\n }\n get dataCollectionEnabled(): boolean {\n return SettingsService.getInstance().dataCollectionEnabled;\n }\n}\n","/**\n * The Firebase Performance Monitoring Web SDK.\n * This SDK does not work in a Node.js environment.\n *\n * @packageDocumentation\n */\n\n/**\n * @license\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 * http://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 {\n FirebasePerformance,\n PerformanceSettings,\n PerformanceTrace\n} from './public_types';\nimport { ERROR_FACTORY, ErrorCode } from './utils/errors';\nimport { setupApi } from './services/api_service';\nimport { PerformanceController } from './controllers/perf';\nimport {\n _registerComponent,\n _getProvider,\n registerVersion,\n FirebaseApp,\n getApp\n} from '@firebase/app';\nimport {\n InstanceFactory,\n ComponentContainer,\n Component,\n ComponentType\n} from '@firebase/component';\nimport { name, version } from '../package.json';\nimport { Trace } from './resources/trace';\nimport '@firebase/installations';\nimport { deepEqual, getModularInstance } from '@firebase/util';\n\nconst DEFAULT_ENTRY_NAME = '[DEFAULT]';\n\n/**\n * Returns a {@link FirebasePerformance} instance for the given app.\n * @param app - The {@link @firebase/app#FirebaseApp} to use.\n * @public\n */\nexport function getPerformance(\n app: FirebaseApp = getApp()\n): FirebasePerformance {\n app = getModularInstance(app);\n const provider = _getProvider(app, 'performance');\n const perfInstance = provider.getImmediate() as PerformanceController;\n return perfInstance;\n}\n\n/**\n * Returns a {@link FirebasePerformance} instance for the given app. Can only be called once.\n * @param app - The {@link @firebase/app#FirebaseApp} to use.\n * @param settings - Optional settings for the {@link FirebasePerformance} instance.\n * @public\n */\nexport function initializePerformance(\n app: FirebaseApp,\n settings?: PerformanceSettings\n): FirebasePerformance {\n app = getModularInstance(app);\n const provider = _getProvider(app, 'performance');\n\n // throw if an instance was already created.\n // It could happen if initializePerformance() is called more than once, or getPerformance() is called first.\n if (provider.isInitialized()) {\n const existingInstance = provider.getImmediate();\n const initialSettings = provider.getOptions() as PerformanceSettings;\n if (deepEqual(initialSettings, settings ?? {})) {\n return existingInstance;\n } else {\n throw ERROR_FACTORY.create(ErrorCode.ALREADY_INITIALIZED);\n }\n }\n\n const perfInstance = provider.initialize({\n options: settings\n }) as PerformanceController;\n return perfInstance;\n}\n\n/**\n * Returns a new `PerformanceTrace` instance.\n * @param performance - The {@link FirebasePerformance} instance to use.\n * @param name - The name of the trace.\n * @public\n */\nexport function trace(\n performance: FirebasePerformance,\n name: string\n): PerformanceTrace {\n performance = getModularInstance(performance);\n return new Trace(performance as PerformanceController, name);\n}\n\nconst factory: InstanceFactory<'performance'> = (\n container: ComponentContainer,\n { options: settings }: { options?: PerformanceSettings }\n) => {\n // Dependencies\n const app = container.getProvider('app').getImmediate();\n const installations = container\n .getProvider('installations-internal')\n .getImmediate();\n\n if (app.name !== DEFAULT_ENTRY_NAME) {\n throw ERROR_FACTORY.create(ErrorCode.FB_NOT_DEFAULT);\n }\n if (typeof window === 'undefined') {\n throw ERROR_FACTORY.create(ErrorCode.NO_WINDOW);\n }\n setupApi(window);\n const perfInstance = new PerformanceController(app, installations);\n perfInstance._init(settings);\n\n return perfInstance;\n};\n\nfunction registerPerformance(): void {\n _registerComponent(\n new Component('performance', factory, ComponentType.PUBLIC)\n );\n registerVersion(name, version);\n // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\n}\n\nregisterPerformance();\n\nexport { FirebasePerformance, PerformanceSettings, PerformanceTrace };\n"],"names":["vitalsOnLCP","vitalsOnINP","vitalsOnCLS"],"mappings":";;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAII,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC;AACO,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAC7D;AACO,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D;AACO,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAC5D;AACO,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAE1C,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAEvC,MAAM,mCAAm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IAAY,EAAA;AAEZ,IAAA,WAAW,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;AAC9C,IAAA,OAAO,IAAI,KAAK,CAAC,WAAoC,EAAE,IAAI,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,OAAO,GAAmC,CAC9C,SAA6B,EAC7B,EAAE,OAAO,EAAE,QAAQ,EAAqC,KACtD;;IAEF,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;IACxD,MAAM,aAAa,GAAG,SAAS;SAC5B,WAAW,CAAC,wBAAwB,CAAC;AACrC,SAAA,YAAY,EAAE,CAAC;AAElB,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB,EAAE;AACnC,QAAA,MAAM,aAAa,CAAC,MAAM,CAAA,gBAAA,gCAA0B,CAAC;KACtD;AACD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,QAAA,MAAM,aAAa,CAAC,MAAM,CAAA,WAAA,2BAAqB,CAAC;KACjD;IACD,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,YAAY,GAAG,IAAI,qBAAqB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;AACnE,IAAA,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAE7B,IAAA,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,SAAS,mBAAmB,GAAA;IAC1B,kBAAkB,CAChB,IAAI,SAAS,CAAC,aAAa,EAAE,OAAO,EAAuB,QAAA,4BAAA,CAC5D,CAAC;AACF,IAAA,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;AAE/B,IAAA,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,SAAkB,CAAC,CAAC;AACrD,CAAC;AAED,mBAAmB,EAAE;;;;"}
\ No newline at end of file diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/package.json b/frontend-old/node_modules/@firebase/performance/dist/esm/package.json new file mode 100644 index 0000000..7c34deb --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/package.json @@ -0,0 +1 @@ +{"type":"module"}
\ No newline at end of file diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/constants.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/constants.d.ts new file mode 100644 index 0000000..dbb2159 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/constants.d.ts @@ -0,0 +1,38 @@ +/** + * @license + * 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 + * + * http://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. + */ +export declare const SDK_VERSION: string; +/** The prefix for start User Timing marks used for creating Traces. */ +export declare const TRACE_START_MARK_PREFIX = "FB-PERF-TRACE-START"; +/** The prefix for stop User Timing marks used for creating Traces. */ +export declare const TRACE_STOP_MARK_PREFIX = "FB-PERF-TRACE-STOP"; +/** The prefix for User Timing measure used for creating Traces. */ +export declare const TRACE_MEASURE_PREFIX = "FB-PERF-TRACE-MEASURE"; +/** The prefix for out of the box page load Trace name. */ +export declare const OOB_TRACE_PAGE_LOAD_PREFIX = "_wt_"; +export declare const FIRST_PAINT_COUNTER_NAME = "_fp"; +export declare const FIRST_CONTENTFUL_PAINT_COUNTER_NAME = "_fcp"; +export declare const FIRST_INPUT_DELAY_COUNTER_NAME = "_fid"; +export declare const LARGEST_CONTENTFUL_PAINT_METRIC_NAME = "_lcp"; +export declare const LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME = "lcp_element"; +export declare const INTERACTION_TO_NEXT_PAINT_METRIC_NAME = "_inp"; +export declare const INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME = "inp_interactionTarget"; +export declare const CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME = "_cls"; +export declare const CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME = "cls_largestShiftTarget"; +export declare const CONFIG_LOCAL_STORAGE_KEY = "@firebase/performance/config"; +export declare const CONFIG_EXPIRY_LOCAL_STORAGE_KEY = "@firebase/performance/configexpire"; +export declare const SERVICE = "performance"; +export declare const SERVICE_NAME = "Performance"; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/controllers/perf.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/controllers/perf.d.ts new file mode 100644 index 0000000..bfb45a5 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/controllers/perf.d.ts @@ -0,0 +1,39 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { FirebaseApp } from '@firebase/app'; +import { _FirebaseInstallationsInternal } from '@firebase/installations'; +import { PerformanceSettings, FirebasePerformance } from '../public_types'; +export declare class PerformanceController implements FirebasePerformance { + readonly app: FirebaseApp; + readonly installations: _FirebaseInstallationsInternal; + private initialized; + constructor(app: FirebaseApp, installations: _FirebaseInstallationsInternal); + /** + * This method *must* be called internally as part of creating a + * PerformanceController instance. + * + * Currently it's not possible to pass the settings object through the + * constructor using Components, so this method exists to be called with the + * desired settings, to ensure nothing is collected without the user's + * consent. + */ + _init(settings?: PerformanceSettings): void; + set instrumentationEnabled(val: boolean); + get instrumentationEnabled(): boolean; + set dataCollectionEnabled(val: boolean); + get dataCollectionEnabled(): boolean; +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/index.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/index.d.ts new file mode 100644 index 0000000..eb2968e --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/index.d.ts @@ -0,0 +1,46 @@ +/** + * The Firebase Performance Monitoring Web SDK. + * This SDK does not work in a Node.js environment. + * + * @packageDocumentation + */ +/** + * @license + * 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 + * + * http://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. + */ +import { FirebasePerformance, PerformanceSettings, PerformanceTrace } from './public_types'; +import { FirebaseApp } from '@firebase/app'; +import '@firebase/installations'; +/** + * Returns a {@link FirebasePerformance} instance for the given app. + * @param app - The {@link @firebase/app#FirebaseApp} to use. + * @public + */ +export declare function getPerformance(app?: FirebaseApp): FirebasePerformance; +/** + * Returns a {@link FirebasePerformance} instance for the given app. Can only be called once. + * @param app - The {@link @firebase/app#FirebaseApp} to use. + * @param settings - Optional settings for the {@link FirebasePerformance} instance. + * @public + */ +export declare function initializePerformance(app: FirebaseApp, settings?: PerformanceSettings): FirebasePerformance; +/** + * Returns a new `PerformanceTrace` instance. + * @param performance - The {@link FirebasePerformance} instance to use. + * @param name - The name of the trace. + * @public + */ +export declare function trace(performance: FirebasePerformance, name: string): PerformanceTrace; +export { FirebasePerformance, PerformanceSettings, PerformanceTrace }; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/public_types.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/public_types.d.ts new file mode 100644 index 0000000..5f37697 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/public_types.d.ts @@ -0,0 +1,136 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { FirebaseApp } from '@firebase/app'; +/** + * Defines configuration options for the Performance Monitoring SDK. + * + * @public + */ +export interface PerformanceSettings { + /** Whether to collect custom events. */ + dataCollectionEnabled?: boolean; + /** Whether to collect out of the box events. */ + instrumentationEnabled?: boolean; +} +/** + * The Firebase Performance Monitoring service interface. + * + * @public + */ +export interface FirebasePerformance { + /** + * The {@link @firebase/app#FirebaseApp} this `FirebasePerformance` instance is associated with. + */ + app: FirebaseApp; + /** + * Controls the logging of automatic traces and HTTP/S network monitoring. + */ + instrumentationEnabled: boolean; + /** + * Controls the logging of custom traces. + */ + dataCollectionEnabled: boolean; +} +/** + * The interface representing a `Trace`. + * + * @public + */ +export interface PerformanceTrace { + /** + * Starts the timing for the trace instance. + */ + start(): void; + /** + * Stops the timing of the trace instance and logs the data of the instance. + */ + stop(): void; + /** + * Records a trace from given parameters. This provides a direct way to use trace without a need to + * start/stop. This is useful for use cases in which the trace cannot directly be used + * (e.g. if the duration was captured before the Performance SDK was loaded). + * + * @param startTime - trace start time since epoch in millisec. + * @param duration - The duration of the trace in millisec. + * @param options - An object which can optionally hold maps of custom metrics and + * custom attributes. + */ + record(startTime: number, duration: number, options?: { + metrics?: { + [key: string]: number; + }; + attributes?: { + [key: string]: string; + }; + }): void; + /** + * Adds to the value of a custom metric. If a custom metric with the provided name does not + * exist, it creates one with that name and the value equal to the given number. The value will be floored down to an + * integer. + * + * @param metricName - The name of the custom metric. + * @param num - The number to be added to the value of the custom metric. If not provided, it + * uses a default value of one. + */ + incrementMetric(metricName: string, num?: number): void; + /** + * Sets the value of the specified custom metric to the given number regardless of whether + * a metric with that name already exists on the trace instance or not. The value will be floored down to an + * integer. + * + * @param metricName - Name of the custom metric. + * @param num - Value to of the custom metric. + */ + putMetric(metricName: string, num: number): void; + /** + * Returns the value of the custom metric by that name. If a custom metric with that name does + * not exist will return zero. + * + * @param metricName - Name of the custom metric. + */ + getMetric(metricName: string): number; + /** + * Set a custom attribute of a trace to a certain value. + * + * @param attr - Name of the custom attribute. + * @param value - Value of the custom attribute. + */ + putAttribute(attr: string, value: string): void; + /** + * Retrieves the value which a custom attribute is set to. + * + * @param attr - Name of the custom attribute. + */ + getAttribute(attr: string): string | undefined; + /** + * Removes the specified custom attribute from a trace instance. + * + * @param attr - Name of the custom attribute. + */ + removeAttribute(attr: string): void; + /** + * Returns a map of all custom attributes of a trace instance. + */ + getAttributes(): { + [key: string]: string; + }; +} +declare module '@firebase/component' { + interface NameServiceMapping { + 'performance': FirebasePerformance; + } +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/resources/network_request.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/resources/network_request.d.ts new file mode 100644 index 0000000..cf7f15d --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/resources/network_request.d.ts @@ -0,0 +1,43 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceController } from '../controllers/perf'; +export declare const enum HttpMethod { + HTTP_METHOD_UNKNOWN = 0, + GET = 1, + PUT = 2, + POST = 3, + DELETE = 4, + HEAD = 5, + PATCH = 6, + OPTIONS = 7, + TRACE = 8, + CONNECT = 9 +} +export interface NetworkRequest { + performanceController: PerformanceController; + url: string; + httpMethod?: HttpMethod; + requestPayloadBytes?: number; + responsePayloadBytes?: number; + httpResponseCode?: number; + responseContentType?: string; + startTimeUs?: number; + timeToRequestCompletedUs?: number; + timeToResponseInitiatedUs?: number; + timeToResponseCompletedUs?: number; +} +export declare function createNetworkRequestEntry(performanceController: PerformanceController, entry: PerformanceEntry): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/resources/trace.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/resources/trace.d.ts new file mode 100644 index 0000000..65d9ca4 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/resources/trace.d.ts @@ -0,0 +1,121 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceTrace } from '../public_types'; +import { PerformanceController } from '../controllers/perf'; +import { CoreVitalMetric, WebVitalMetrics } from './web_vitals'; +export declare class Trace implements PerformanceTrace { + readonly performanceController: PerformanceController; + readonly name: string; + readonly isAuto: boolean; + private state; + startTimeUs: number; + durationUs: number; + private customAttributes; + counters: { + [counterName: string]: number; + }; + private api; + private randomId; + private traceStartMark; + private traceStopMark; + private traceMeasure; + /** + * @param performanceController The performance controller running. + * @param name The name of the trace. + * @param isAuto If the trace is auto-instrumented. + * @param traceMeasureName The name of the measure marker in user timing specification. This field + * is only set when the trace is built for logging when the user directly uses the user timing + * api (performance.mark and performance.measure). + */ + constructor(performanceController: PerformanceController, name: string, isAuto?: boolean, traceMeasureName?: string); + /** + * Starts a trace. The measurement of the duration starts at this point. + */ + start(): void; + /** + * Stops the trace. The measurement of the duration of the trace stops at this point and trace + * is logged. + */ + stop(): void; + /** + * Records a trace with predetermined values. If this method is used a trace is created and logged + * directly. No need to use start and stop methods. + * @param startTime Trace start time since epoch in millisec + * @param duration The duration of the trace in millisec + * @param options An object which can optionally hold maps of custom metrics and custom attributes + */ + record(startTime: number, duration: number, options?: { + metrics?: { + [key: string]: number; + }; + attributes?: { + [key: string]: string; + }; + }): void; + /** + * Increments a custom metric by a certain number or 1 if number not specified. Will create a new + * custom metric if one with the given name does not exist. The value will be floored down to an + * integer. + * @param counter Name of the custom metric + * @param numAsInteger Increment by value + */ + incrementMetric(counter: string, numAsInteger?: number): void; + /** + * Sets a custom metric to a specified value. Will create a new custom metric if one with the + * given name does not exist. The value will be floored down to an integer. + * @param counter Name of the custom metric + * @param numAsInteger Set custom metric to this value + */ + putMetric(counter: string, numAsInteger: number): void; + /** + * Returns the value of the custom metric by that name. If a custom metric with that name does + * not exist will return zero. + * @param counter + */ + getMetric(counter: string): number; + /** + * Sets a custom attribute of a trace to a certain value. + * @param attr + * @param value + */ + putAttribute(attr: string, value: string): void; + /** + * Retrieves the value a custom attribute of a trace is set to. + * @param attr + */ + getAttribute(attr: string): string | undefined; + removeAttribute(attr: string): void; + getAttributes(): { + [key: string]: string; + }; + private setStartTime; + private setDuration; + /** + * Calculates and assigns the duration and start time of the trace using the measure performance + * entry. + */ + private calculateTraceMetrics; + /** + * @param navigationTimings A single element array which contains the navigationTIming object of + * the page load + * @param paintTimings A array which contains paintTiming object of the page load + * @param firstInputDelay First input delay in millisec + */ + static createOobTrace(performanceController: PerformanceController, navigationTimings: PerformanceNavigationTiming[], paintTimings: PerformanceEntry[], webVitalMetrics: WebVitalMetrics, firstInputDelay?: number): void; + static addWebVitalMetric(trace: Trace, metricKey: string, attributeKey: string, metric?: CoreVitalMetric): void; + static createUserTimingTrace(performanceController: PerformanceController, measureName: string): void; +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/resources/web_vitals.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/resources/web_vitals.d.ts new file mode 100644 index 0000000..1d9f7a1 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/resources/web_vitals.d.ts @@ -0,0 +1,25 @@ +/** + * @license + * Copyright 2024 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 + * + * http://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. + */ +export interface CoreVitalMetric { + value: number; + elementAttribution?: string; +} +export interface WebVitalMetrics { + cls?: CoreVitalMetric; + inp?: CoreVitalMetric; + lcp?: CoreVitalMetric; +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/api_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/api_service.d.ts new file mode 100644 index 0000000..e576c29 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/api_service.d.ts @@ -0,0 +1,55 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { CLSMetricWithAttribution, INPMetricWithAttribution, LCPMetricWithAttribution } from 'web-vitals/attribution'; +declare global { + interface Window { + PerformanceObserver: typeof PerformanceObserver; + perfMetrics?: { + onFirstInputDelay(fn: (fid: number) => void): void; + }; + } +} +export type EntryType = 'mark' | 'measure' | 'paint' | 'resource' | 'frame' | 'navigation'; +/** + * This class holds a reference to various browser related objects injected by + * set methods. + */ +export declare class Api { + readonly window?: Window | undefined; + private readonly performance; + /** PerformanceObserver constructor function. */ + private readonly PerformanceObserver; + private readonly windowLocation; + readonly onFirstInputDelay?: (fn: (fid: number) => void) => void; + readonly onLCP: (fn: (metric: LCPMetricWithAttribution) => void) => void; + readonly onINP: (fn: (metric: INPMetricWithAttribution) => void) => void; + readonly onCLS: (fn: (metric: CLSMetricWithAttribution) => void) => void; + readonly localStorage?: Storage; + readonly document: Document; + readonly navigator: Navigator; + constructor(window?: Window | undefined); + getUrl(): string; + mark(name: string): void; + measure(measureName: string, mark1: string, mark2: string): void; + getEntriesByType(type: EntryType): PerformanceEntry[]; + getEntriesByName(name: string): PerformanceEntry[]; + getTimeOrigin(): number; + requiredApisAvailable(): boolean; + setupObserver(entryType: EntryType, callback: (entry: PerformanceEntry) => void): void; + static getInstance(): Api; +} +export declare function setupApi(window: Window): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/iid_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/iid_service.d.ts new file mode 100644 index 0000000..c3387d7 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/iid_service.d.ts @@ -0,0 +1,21 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { _FirebaseInstallationsInternal } from '@firebase/installations'; +export declare function getIidPromise(installationsService: _FirebaseInstallationsInternal): Promise<string>; +export declare function getIid(): string | undefined; +export declare function getAuthTokenPromise(installationsService: _FirebaseInstallationsInternal): Promise<string>; +export declare function getAuthenticationToken(): string | undefined; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/initialization_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/initialization_service.d.ts new file mode 100644 index 0000000..3e16a52 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/initialization_service.d.ts @@ -0,0 +1,19 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceController } from '../controllers/perf'; +export declare function getInitializationPromise(performanceController: PerformanceController): Promise<void>; +export declare function isPerfInitialized(): boolean; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/oob_resources_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/oob_resources_service.d.ts new file mode 100644 index 0000000..2109a59 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/oob_resources_service.d.ts @@ -0,0 +1,23 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceController } from '../controllers/perf'; +export declare function setupOobResources(performanceController: PerformanceController): void; +/** + * This service will only export the page load trace once. This function allows + * resetting it for unit tests + */ +export declare function resetForUnitTests(): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/perf_logger.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/perf_logger.d.ts new file mode 100644 index 0000000..f9dc083 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/perf_logger.d.ts @@ -0,0 +1,21 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { NetworkRequest } from '../resources/network_request'; +import { Trace } from '../resources/trace'; +export declare function logTrace(trace: Trace): void; +export declare function flushLogs(): void; +export declare function logNetworkRequest(networkRequest: NetworkRequest): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/remote_config_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/remote_config_service.d.ts new file mode 100644 index 0000000..22aeb58 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/remote_config_service.d.ts @@ -0,0 +1,18 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceController } from '../controllers/perf'; +export declare function getConfig(performanceController: PerformanceController, iid: string): Promise<void>; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/settings_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/settings_service.d.ts new file mode 100644 index 0000000..c343189 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/settings_service.d.ts @@ -0,0 +1,33 @@ +/** + * @license + * Copyright 2019 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 + * + * http://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. + */ +export declare class SettingsService { + instrumentationEnabled: boolean; + dataCollectionEnabled: boolean; + loggingEnabled: boolean; + tracesSamplingRate: number; + networkRequestsSamplingRate: number; + logEndPointUrl: string; + flTransportEndpointUrl: string; + transportKey: string; + logSource: number; + logTraceAfterSampling: boolean; + logNetworkAfterSampling: boolean; + configTimeToLive: number; + logMaxFlushSize: number; + getFlTransportFullUrl(): string; + static getInstance(): SettingsService; +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/transport_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/transport_service.d.ts new file mode 100644 index 0000000..d204a91 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/services/transport_service.d.ts @@ -0,0 +1,29 @@ +/** + * @license + * 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 + * + * http://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. + */ +export declare function setupTransportService(): void; +/** + * Utilized by testing to clean up message queue and un-initialize transport service. + */ +export declare function resetTransportService(): void; +/** Log handler for cc service to send the performance logs to the server. */ +export declare function transportHandler(serializer: (...args: any[]) => string): (...args: unknown[]) => void; +/** + * Force flush the queued events. Useful at page unload time to ensure all events are uploaded. + * Flush will attempt to use sendBeacon to send events async and defaults back to fetch as soon as a + * sendBeacon fails. Firefox + */ +export declare function flushQueuedEvents(): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/app_utils.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/app_utils.d.ts new file mode 100644 index 0000000..3c86d5a --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/app_utils.d.ts @@ -0,0 +1,20 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { FirebaseApp } from '@firebase/app'; +export declare function getAppId(firebaseApp: FirebaseApp): string; +export declare function getProjectId(firebaseApp: FirebaseApp): string; +export declare function getApiKey(firebaseApp: FirebaseApp): string; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/attributes_utils.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/attributes_utils.d.ts new file mode 100644 index 0000000..bbdcd52 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/attributes_utils.d.ts @@ -0,0 +1,41 @@ +/** + * @license + * 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 + * + * http://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. + */ +declare const enum ServiceWorkerStatus { + UNKNOWN = 0, + UNSUPPORTED = 1, + CONTROLLED = 2, + UNCONTROLLED = 3 +} +export declare enum VisibilityState { + UNKNOWN = 0, + VISIBLE = 1, + HIDDEN = 2 +} +declare const enum EffectiveConnectionType { + UNKNOWN = 0, + CONNECTION_SLOW_2G = 1, + CONNECTION_2G = 2, + CONNECTION_3G = 3, + CONNECTION_4G = 4 +} +export declare const MAX_ATTRIBUTE_VALUE_LENGTH = 100; +export declare function getServiceWorkerStatus(): ServiceWorkerStatus; +export declare function getVisibilityState(): VisibilityState; +export declare function getEffectiveConnectionType(): EffectiveConnectionType; +export declare function isValidCustomAttributeName(name: string): boolean; +export declare function isValidCustomAttributeValue(value: string): boolean; +export {}; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/console_logger.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/console_logger.d.ts new file mode 100644 index 0000000..3049fb6 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/console_logger.d.ts @@ -0,0 +1,18 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { Logger } from '@firebase/logger'; +export declare const consoleLogger: Logger; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/errors.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/errors.d.ts new file mode 100644 index 0000000..8db0240 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/errors.d.ts @@ -0,0 +1,60 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { ErrorFactory } from '@firebase/util'; +export declare const enum ErrorCode { + TRACE_STARTED_BEFORE = "trace started", + TRACE_STOPPED_BEFORE = "trace stopped", + NONPOSITIVE_TRACE_START_TIME = "nonpositive trace startTime", + NONPOSITIVE_TRACE_DURATION = "nonpositive trace duration", + NO_WINDOW = "no window", + NO_APP_ID = "no app id", + NO_PROJECT_ID = "no project id", + NO_API_KEY = "no api key", + INVALID_CC_LOG = "invalid cc log", + FB_NOT_DEFAULT = "FB not default", + RC_NOT_OK = "RC response not ok", + INVALID_ATTRIBUTE_NAME = "invalid attribute name", + INVALID_ATTRIBUTE_VALUE = "invalid attribute value", + INVALID_CUSTOM_METRIC_NAME = "invalid custom metric name", + INVALID_STRING_MERGER_PARAMETER = "invalid String merger input", + ALREADY_INITIALIZED = "already initialized" +} +interface ErrorParams { + [ErrorCode.TRACE_STARTED_BEFORE]: { + traceName: string; + }; + [ErrorCode.TRACE_STOPPED_BEFORE]: { + traceName: string; + }; + [ErrorCode.NONPOSITIVE_TRACE_START_TIME]: { + traceName: string; + }; + [ErrorCode.NONPOSITIVE_TRACE_DURATION]: { + traceName: string; + }; + [ErrorCode.INVALID_ATTRIBUTE_NAME]: { + attributeName: string; + }; + [ErrorCode.INVALID_ATTRIBUTE_VALUE]: { + attributeValue: string; + }; + [ErrorCode.INVALID_CUSTOM_METRIC_NAME]: { + customMetricName: string; + }; +} +export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>; +export {}; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/metric_utils.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/metric_utils.d.ts new file mode 100644 index 0000000..9639f76 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/metric_utils.d.ts @@ -0,0 +1,28 @@ +/** + * @license + * 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 + * + * http://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 true if the metric is custom and does not start with reserved prefix, or if + * the metric is one of out of the box page load trace metrics. + */ +export declare function isValidMetricName(name: string, traceName?: string): boolean; +/** + * Converts the provided value to an integer value to be used in case of a metric. + * @param providedValue Provided number value of the metric that needs to be converted to an integer. + * + * @returns Converted integer number to be set for the metric. + */ +export declare function convertMetricValueToInteger(providedValue: number): number; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/string_merger.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/string_merger.d.ts new file mode 100644 index 0000000..4bdb19e --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/src/utils/string_merger.d.ts @@ -0,0 +1,17 @@ +/** + * @license + * 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 + * + * http://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. + */ +export declare function mergeStrings(part1: string, part2: string): string; diff --git a/frontend-old/node_modules/@firebase/performance/dist/esm/test/setup.d.ts b/frontend-old/node_modules/@firebase/performance/dist/esm/test/setup.d.ts new file mode 100644 index 0000000..731d2d9 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/esm/test/setup.d.ts @@ -0,0 +1,17 @@ +/** + * @license + * 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 + * + * http://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. + */ +export {}; diff --git a/frontend-old/node_modules/@firebase/performance/dist/index.cjs.js b/frontend-old/node_modules/@firebase/performance/dist/index.cjs.js new file mode 100644 index 0000000..38e4e0e --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/index.cjs.js @@ -0,0 +1,1620 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var util = require('@firebase/util'); +var logger$1 = require('@firebase/logger'); +var attribution = require('web-vitals/attribution'); +var app = require('@firebase/app'); +var component = require('@firebase/component'); +require('@firebase/installations'); + +const name = "@firebase/performance"; +const version = "0.7.9"; + +/** + * @license + * 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 + * + * http://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 SDK_VERSION = version; +/** The prefix for start User Timing marks used for creating Traces. */ +const TRACE_START_MARK_PREFIX = 'FB-PERF-TRACE-START'; +/** The prefix for stop User Timing marks used for creating Traces. */ +const TRACE_STOP_MARK_PREFIX = 'FB-PERF-TRACE-STOP'; +/** The prefix for User Timing measure used for creating Traces. */ +const TRACE_MEASURE_PREFIX = 'FB-PERF-TRACE-MEASURE'; +/** The prefix for out of the box page load Trace name. */ +const OOB_TRACE_PAGE_LOAD_PREFIX = '_wt_'; +const FIRST_PAINT_COUNTER_NAME = '_fp'; +const FIRST_CONTENTFUL_PAINT_COUNTER_NAME = '_fcp'; +const FIRST_INPUT_DELAY_COUNTER_NAME = '_fid'; +const LARGEST_CONTENTFUL_PAINT_METRIC_NAME = '_lcp'; +const LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME = 'lcp_element'; +const INTERACTION_TO_NEXT_PAINT_METRIC_NAME = '_inp'; +const INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME = 'inp_interactionTarget'; +const CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME = '_cls'; +const CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME = 'cls_largestShiftTarget'; +const CONFIG_LOCAL_STORAGE_KEY = '@firebase/performance/config'; +const CONFIG_EXPIRY_LOCAL_STORAGE_KEY = '@firebase/performance/configexpire'; +const SERVICE = 'performance'; +const SERVICE_NAME = 'Performance'; + +/** + * @license + * 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 + * + * http://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 ERROR_DESCRIPTION_MAP = { + ["trace started" /* ErrorCode.TRACE_STARTED_BEFORE */]: 'Trace {$traceName} was started before.', + ["trace stopped" /* ErrorCode.TRACE_STOPPED_BEFORE */]: 'Trace {$traceName} is not running.', + ["nonpositive trace startTime" /* ErrorCode.NONPOSITIVE_TRACE_START_TIME */]: 'Trace {$traceName} startTime should be positive.', + ["nonpositive trace duration" /* ErrorCode.NONPOSITIVE_TRACE_DURATION */]: 'Trace {$traceName} duration should be positive.', + ["no window" /* ErrorCode.NO_WINDOW */]: 'Window is not available.', + ["no app id" /* ErrorCode.NO_APP_ID */]: 'App id is not available.', + ["no project id" /* ErrorCode.NO_PROJECT_ID */]: 'Project id is not available.', + ["no api key" /* ErrorCode.NO_API_KEY */]: 'Api key is not available.', + ["invalid cc log" /* ErrorCode.INVALID_CC_LOG */]: 'Attempted to queue invalid cc event', + ["FB not default" /* ErrorCode.FB_NOT_DEFAULT */]: 'Performance can only start when Firebase app instance is the default one.', + ["RC response not ok" /* ErrorCode.RC_NOT_OK */]: 'RC response is not ok', + ["invalid attribute name" /* ErrorCode.INVALID_ATTRIBUTE_NAME */]: 'Attribute name {$attributeName} is invalid.', + ["invalid attribute value" /* ErrorCode.INVALID_ATTRIBUTE_VALUE */]: 'Attribute value {$attributeValue} is invalid.', + ["invalid custom metric name" /* ErrorCode.INVALID_CUSTOM_METRIC_NAME */]: 'Custom metric name {$customMetricName} is invalid', + ["invalid String merger input" /* ErrorCode.INVALID_STRING_MERGER_PARAMETER */]: 'Input for String merger is invalid, contact support team to resolve.', + ["already initialized" /* ErrorCode.ALREADY_INITIALIZED */]: 'initializePerformance() has already been called with ' + + 'different options. To avoid this error, call initializePerformance() with the ' + + 'same options as when it was originally called, or call getPerformance() to return the' + + ' already initialized instance.' +}; +const ERROR_FACTORY = new util.ErrorFactory(SERVICE, SERVICE_NAME, ERROR_DESCRIPTION_MAP); + +/** + * @license + * 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 + * + * http://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 consoleLogger = new logger$1.Logger(SERVICE_NAME); +consoleLogger.logLevel = logger$1.LogLevel.INFO; + +/** + * @license + * 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 + * + * http://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 apiInstance; +let windowInstance; +/** + * This class holds a reference to various browser related objects injected by + * set methods. + */ +class Api { + constructor(window) { + this.window = window; + if (!window) { + throw ERROR_FACTORY.create("no window" /* ErrorCode.NO_WINDOW */); + } + this.performance = window.performance; + this.PerformanceObserver = window.PerformanceObserver; + this.windowLocation = window.location; + this.navigator = window.navigator; + this.document = window.document; + if (this.navigator && this.navigator.cookieEnabled) { + // If user blocks cookies on the browser, accessing localStorage will + // throw an exception. + this.localStorage = window.localStorage; + } + if (window.perfMetrics && window.perfMetrics.onFirstInputDelay) { + this.onFirstInputDelay = window.perfMetrics.onFirstInputDelay; + } + this.onLCP = attribution.onLCP; + this.onINP = attribution.onINP; + this.onCLS = attribution.onCLS; + } + getUrl() { + // Do not capture the string query part of url. + return this.windowLocation.href.split('?')[0]; + } + mark(name) { + if (!this.performance || !this.performance.mark) { + return; + } + this.performance.mark(name); + } + measure(measureName, mark1, mark2) { + if (!this.performance || !this.performance.measure) { + return; + } + this.performance.measure(measureName, mark1, mark2); + } + getEntriesByType(type) { + if (!this.performance || !this.performance.getEntriesByType) { + return []; + } + return this.performance.getEntriesByType(type); + } + getEntriesByName(name) { + if (!this.performance || !this.performance.getEntriesByName) { + return []; + } + return this.performance.getEntriesByName(name); + } + getTimeOrigin() { + // Polyfill the time origin with performance.timing.navigationStart. + return (this.performance && + (this.performance.timeOrigin || this.performance.timing.navigationStart)); + } + requiredApisAvailable() { + if (!fetch || !Promise || !util.areCookiesEnabled()) { + consoleLogger.info('Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled.'); + return false; + } + if (!util.isIndexedDBAvailable()) { + consoleLogger.info('IndexedDB is not supported by current browser'); + return false; + } + return true; + } + setupObserver(entryType, callback) { + if (!this.PerformanceObserver) { + return; + } + const observer = new this.PerformanceObserver(list => { + for (const entry of list.getEntries()) { + // `entry` is a PerformanceEntry instance. + callback(entry); + } + }); + // Start observing the entry types you care about. + observer.observe({ entryTypes: [entryType] }); + } + static getInstance() { + if (apiInstance === undefined) { + apiInstance = new Api(windowInstance); + } + return apiInstance; + } +} +function setupApi(window) { + windowInstance = window; +} + +/** + * @license + * 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 + * + * http://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 iid; +function getIidPromise(installationsService) { + const iidPromise = installationsService.getId(); + // eslint-disable-next-line @typescript-eslint/no-floating-promises + iidPromise.then((iidVal) => { + iid = iidVal; + }); + return iidPromise; +} +// This method should be used after the iid is retrieved by getIidPromise method. +function getIid() { + return iid; +} +function getAuthTokenPromise(installationsService) { + const authTokenPromise = installationsService.getToken(); + // eslint-disable-next-line @typescript-eslint/no-floating-promises + authTokenPromise.then((authTokenVal) => { + }); + return authTokenPromise; +} + +/** + * @license + * 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 + * + * http://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. + */ +function mergeStrings(part1, part2) { + const sizeDiff = part1.length - part2.length; + if (sizeDiff < 0 || sizeDiff > 1) { + throw ERROR_FACTORY.create("invalid String merger input" /* ErrorCode.INVALID_STRING_MERGER_PARAMETER */); + } + const resultArray = []; + for (let i = 0; i < part1.length; i++) { + resultArray.push(part1.charAt(i)); + if (part2.length > i) { + resultArray.push(part2.charAt(i)); + } + } + return resultArray.join(''); +} + +/** + * @license + * Copyright 2019 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 + * + * http://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 settingsServiceInstance; +class SettingsService { + constructor() { + // The variable which controls logging of automatic traces and HTTP/S network monitoring. + this.instrumentationEnabled = true; + // The variable which controls logging of custom traces. + this.dataCollectionEnabled = true; + // Configuration flags set through remote config. + this.loggingEnabled = false; + // Sampling rate between 0 and 1. + this.tracesSamplingRate = 1; + this.networkRequestsSamplingRate = 1; + // Address of logging service. + this.logEndPointUrl = 'https://firebaselogging.googleapis.com/v0cc/log?format=json_proto'; + // Performance event transport endpoint URL which should be compatible with proto3. + // New Address for transport service, not configurable via Remote Config. + this.flTransportEndpointUrl = mergeStrings('hts/frbslgigp.ogepscmv/ieo/eaylg', 'tp:/ieaeogn-agolai.o/1frlglgc/o'); + this.transportKey = mergeStrings('AzSC8r6ReiGqFMyfvgow', 'Iayx0u-XT3vksVM-pIV'); + // Source type for performance event logs. + this.logSource = 462; + // Flags which control per session logging of traces and network requests. + this.logTraceAfterSampling = false; + this.logNetworkAfterSampling = false; + // TTL of config retrieved from remote config in hours. + this.configTimeToLive = 12; + // The max number of events to send during a flush. This number is kept low to since Chrome has a + // shared payload limit for all sendBeacon calls in the same nav context. + this.logMaxFlushSize = 40; + } + getFlTransportFullUrl() { + return this.flTransportEndpointUrl.concat('?key=', this.transportKey); + } + static getInstance() { + if (settingsServiceInstance === undefined) { + settingsServiceInstance = new SettingsService(); + } + return settingsServiceInstance; + } +} + +/** + * @license + * 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 + * + * http://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. + */ +var VisibilityState; +(function (VisibilityState) { + VisibilityState[VisibilityState["UNKNOWN"] = 0] = "UNKNOWN"; + VisibilityState[VisibilityState["VISIBLE"] = 1] = "VISIBLE"; + VisibilityState[VisibilityState["HIDDEN"] = 2] = "HIDDEN"; +})(VisibilityState || (VisibilityState = {})); +const RESERVED_ATTRIBUTE_PREFIXES = ['firebase_', 'google_', 'ga_']; +const ATTRIBUTE_FORMAT_REGEX = new RegExp('^[a-zA-Z]\\w*$'); +const MAX_ATTRIBUTE_NAME_LENGTH = 40; +const MAX_ATTRIBUTE_VALUE_LENGTH = 100; +function getServiceWorkerStatus() { + const navigator = Api.getInstance().navigator; + if (navigator?.serviceWorker) { + if (navigator.serviceWorker.controller) { + return 2 /* ServiceWorkerStatus.CONTROLLED */; + } + else { + return 3 /* ServiceWorkerStatus.UNCONTROLLED */; + } + } + else { + return 1 /* ServiceWorkerStatus.UNSUPPORTED */; + } +} +function getVisibilityState() { + const document = Api.getInstance().document; + const visibilityState = document.visibilityState; + switch (visibilityState) { + case 'visible': + return VisibilityState.VISIBLE; + case 'hidden': + return VisibilityState.HIDDEN; + default: + return VisibilityState.UNKNOWN; + } +} +function getEffectiveConnectionType() { + const navigator = Api.getInstance().navigator; + const navigatorConnection = navigator.connection; + const effectiveType = navigatorConnection && navigatorConnection.effectiveType; + switch (effectiveType) { + case 'slow-2g': + return 1 /* EffectiveConnectionType.CONNECTION_SLOW_2G */; + case '2g': + return 2 /* EffectiveConnectionType.CONNECTION_2G */; + case '3g': + return 3 /* EffectiveConnectionType.CONNECTION_3G */; + case '4g': + return 4 /* EffectiveConnectionType.CONNECTION_4G */; + default: + return 0 /* EffectiveConnectionType.UNKNOWN */; + } +} +function isValidCustomAttributeName(name) { + if (name.length === 0 || name.length > MAX_ATTRIBUTE_NAME_LENGTH) { + return false; + } + const matchesReservedPrefix = RESERVED_ATTRIBUTE_PREFIXES.some(prefix => name.startsWith(prefix)); + return !matchesReservedPrefix && !!name.match(ATTRIBUTE_FORMAT_REGEX); +} +function isValidCustomAttributeValue(value) { + return value.length !== 0 && value.length <= MAX_ATTRIBUTE_VALUE_LENGTH; +} + +/** + * @license + * 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 + * + * http://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. + */ +function getAppId(firebaseApp) { + const appId = firebaseApp.options?.appId; + if (!appId) { + throw ERROR_FACTORY.create("no app id" /* ErrorCode.NO_APP_ID */); + } + return appId; +} +function getProjectId(firebaseApp) { + const projectId = firebaseApp.options?.projectId; + if (!projectId) { + throw ERROR_FACTORY.create("no project id" /* ErrorCode.NO_PROJECT_ID */); + } + return projectId; +} +function getApiKey(firebaseApp) { + const apiKey = firebaseApp.options?.apiKey; + if (!apiKey) { + throw ERROR_FACTORY.create("no api key" /* ErrorCode.NO_API_KEY */); + } + return apiKey; +} + +/** + * @license + * 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 + * + * http://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 REMOTE_CONFIG_SDK_VERSION = '0.0.1'; +// These values will be used if the remote config object is successfully +// retrieved, but the template does not have these fields. +const DEFAULT_CONFIGS = { + loggingEnabled: true +}; +const FIS_AUTH_PREFIX = 'FIREBASE_INSTALLATIONS_AUTH'; +function getConfig(performanceController, iid) { + const config = getStoredConfig(); + if (config) { + processConfig(config); + return Promise.resolve(); + } + return getRemoteConfig(performanceController, iid) + .then(processConfig) + .then(config => storeConfig(config), + /** Do nothing for error, use defaults set in settings service. */ + () => { }); +} +function getStoredConfig() { + const localStorage = Api.getInstance().localStorage; + if (!localStorage) { + return; + } + const expiryString = localStorage.getItem(CONFIG_EXPIRY_LOCAL_STORAGE_KEY); + if (!expiryString || !configValid(expiryString)) { + return; + } + const configStringified = localStorage.getItem(CONFIG_LOCAL_STORAGE_KEY); + if (!configStringified) { + return; + } + try { + const configResponse = JSON.parse(configStringified); + return configResponse; + } + catch { + return; + } +} +function storeConfig(config) { + const localStorage = Api.getInstance().localStorage; + if (!config || !localStorage) { + return; + } + localStorage.setItem(CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config)); + localStorage.setItem(CONFIG_EXPIRY_LOCAL_STORAGE_KEY, String(Date.now() + + SettingsService.getInstance().configTimeToLive * 60 * 60 * 1000)); +} +const COULD_NOT_GET_CONFIG_MSG = 'Could not fetch config, will use default configs'; +function getRemoteConfig(performanceController, iid) { + // Perf needs auth token only to retrieve remote config. + return getAuthTokenPromise(performanceController.installations) + .then(authToken => { + const projectId = getProjectId(performanceController.app); + const apiKey = getApiKey(performanceController.app); + const configEndPoint = `https://firebaseremoteconfig.googleapis.com/v1/projects/${projectId}/namespaces/fireperf:fetch?key=${apiKey}`; + const request = new Request(configEndPoint, { + method: 'POST', + headers: { Authorization: `${FIS_AUTH_PREFIX} ${authToken}` }, + /* eslint-disable camelcase */ + body: JSON.stringify({ + app_instance_id: iid, + app_instance_id_token: authToken, + app_id: getAppId(performanceController.app), + app_version: SDK_VERSION, + sdk_version: REMOTE_CONFIG_SDK_VERSION + }) + /* eslint-enable camelcase */ + }); + return fetch(request).then(response => { + if (response.ok) { + return response.json(); + } + // In case response is not ok. This will be caught by catch. + throw ERROR_FACTORY.create("RC response not ok" /* ErrorCode.RC_NOT_OK */); + }); + }) + .catch(() => { + consoleLogger.info(COULD_NOT_GET_CONFIG_MSG); + return undefined; + }); +} +/** + * Processes config coming either from calling RC or from local storage. + * This method only runs if call is successful or config in storage + * is valid. + */ +function processConfig(config) { + if (!config) { + return config; + } + const settingsServiceInstance = SettingsService.getInstance(); + const entries = config.entries || {}; + if (entries.fpr_enabled !== undefined) { + // TODO: Change the assignment of loggingEnabled once the received type is + // known. + settingsServiceInstance.loggingEnabled = + String(entries.fpr_enabled) === 'true'; + } + else { + // Config retrieved successfully, but there is no fpr_enabled in template. + // Use secondary configs value. + settingsServiceInstance.loggingEnabled = DEFAULT_CONFIGS.loggingEnabled; + } + if (entries.fpr_log_source) { + settingsServiceInstance.logSource = Number(entries.fpr_log_source); + } + else if (DEFAULT_CONFIGS.logSource) { + settingsServiceInstance.logSource = DEFAULT_CONFIGS.logSource; + } + if (entries.fpr_log_endpoint_url) { + settingsServiceInstance.logEndPointUrl = entries.fpr_log_endpoint_url; + } + else if (DEFAULT_CONFIGS.logEndPointUrl) { + settingsServiceInstance.logEndPointUrl = DEFAULT_CONFIGS.logEndPointUrl; + } + // Key from Remote Config has to be non-empty string, otherwise use local value. + if (entries.fpr_log_transport_key) { + settingsServiceInstance.transportKey = entries.fpr_log_transport_key; + } + else if (DEFAULT_CONFIGS.transportKey) { + settingsServiceInstance.transportKey = DEFAULT_CONFIGS.transportKey; + } + if (entries.fpr_vc_network_request_sampling_rate !== undefined) { + settingsServiceInstance.networkRequestsSamplingRate = Number(entries.fpr_vc_network_request_sampling_rate); + } + else if (DEFAULT_CONFIGS.networkRequestsSamplingRate !== undefined) { + settingsServiceInstance.networkRequestsSamplingRate = + DEFAULT_CONFIGS.networkRequestsSamplingRate; + } + if (entries.fpr_vc_trace_sampling_rate !== undefined) { + settingsServiceInstance.tracesSamplingRate = Number(entries.fpr_vc_trace_sampling_rate); + } + else if (DEFAULT_CONFIGS.tracesSamplingRate !== undefined) { + settingsServiceInstance.tracesSamplingRate = + DEFAULT_CONFIGS.tracesSamplingRate; + } + if (entries.fpr_log_max_flush_size) { + settingsServiceInstance.logMaxFlushSize = Number(entries.fpr_log_max_flush_size); + } + else if (DEFAULT_CONFIGS.logMaxFlushSize) { + settingsServiceInstance.logMaxFlushSize = DEFAULT_CONFIGS.logMaxFlushSize; + } + // Set the per session trace and network logging flags. + settingsServiceInstance.logTraceAfterSampling = shouldLogAfterSampling(settingsServiceInstance.tracesSamplingRate); + settingsServiceInstance.logNetworkAfterSampling = shouldLogAfterSampling(settingsServiceInstance.networkRequestsSamplingRate); + return config; +} +function configValid(expiry) { + return Number(expiry) > Date.now(); +} +function shouldLogAfterSampling(samplingRate) { + return Math.random() <= samplingRate; +} + +/** + * @license + * 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 + * + * http://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 initializationStatus = 1 /* InitializationStatus.notInitialized */; +let initializationPromise; +function getInitializationPromise(performanceController) { + initializationStatus = 2 /* InitializationStatus.initializationPending */; + initializationPromise = + initializationPromise || initializePerf(performanceController); + return initializationPromise; +} +function isPerfInitialized() { + return initializationStatus === 3 /* InitializationStatus.initialized */; +} +function initializePerf(performanceController) { + return getDocumentReadyComplete() + .then(() => getIidPromise(performanceController.installations)) + .then(iid => getConfig(performanceController, iid)) + .then(() => changeInitializationStatus(), () => changeInitializationStatus()); +} +/** + * Returns a promise which resolves whenever the document readystate is complete or + * immediately if it is called after page load complete. + */ +function getDocumentReadyComplete() { + const document = Api.getInstance().document; + return new Promise(resolve => { + if (document && document.readyState !== 'complete') { + const handler = () => { + if (document.readyState === 'complete') { + document.removeEventListener('readystatechange', handler); + resolve(); + } + }; + document.addEventListener('readystatechange', handler); + } + else { + resolve(); + } + }); +} +function changeInitializationStatus() { + initializationStatus = 3 /* InitializationStatus.initialized */; +} + +/** + * @license + * 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 + * + * http://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 DEFAULT_SEND_INTERVAL_MS = 10 * 1000; +const INITIAL_SEND_TIME_DELAY_MS = 5.5 * 1000; +const MAX_EVENT_COUNT_PER_REQUEST = 1000; +const DEFAULT_REMAINING_TRIES = 3; +// Most browsers have a max payload of 64KB for sendbeacon/keep alive payload. +const MAX_SEND_BEACON_PAYLOAD_SIZE = 65536; +const TEXT_ENCODER = new TextEncoder(); +let remainingTries = DEFAULT_REMAINING_TRIES; +/* eslint-enable camelcase */ +let queue = []; +let isTransportSetup = false; +function setupTransportService() { + if (!isTransportSetup) { + processQueue(INITIAL_SEND_TIME_DELAY_MS); + isTransportSetup = true; + } +} +function processQueue(timeOffset) { + setTimeout(() => { + // If there is no remainingTries left, stop retrying. + if (remainingTries <= 0) { + return; + } + if (queue.length > 0) { + dispatchQueueEvents(); + } + processQueue(DEFAULT_SEND_INTERVAL_MS); + }, timeOffset); +} +function dispatchQueueEvents() { + // Extract events up to the maximum cap of single logRequest from top of "official queue". + // The staged events will be used for current logRequest attempt, remaining events will be kept + // for next attempt. + const staged = queue.splice(0, MAX_EVENT_COUNT_PER_REQUEST); + const data = buildPayload(staged); + postToFlEndpoint(data) + .then(() => { + remainingTries = DEFAULT_REMAINING_TRIES; + }) + .catch(() => { + // If the request fails for some reason, add the events that were attempted + // back to the primary queue to retry later. + queue = [...staged, ...queue]; + remainingTries--; + consoleLogger.info(`Tries left: ${remainingTries}.`); + processQueue(DEFAULT_SEND_INTERVAL_MS); + }); +} +function buildPayload(events) { + /* eslint-disable camelcase */ + // We will pass the JSON serialized event to the backend. + const log_event = events.map(evt => ({ + source_extension_json_proto3: evt.message, + event_time_ms: String(evt.eventTime) + })); + const transportBatchLog = { + request_time_ms: String(Date.now()), + client_info: { + client_type: 1, // 1 is JS + js_client_info: {} + }, + log_source: SettingsService.getInstance().logSource, + log_event + }; + /* eslint-enable camelcase */ + return JSON.stringify(transportBatchLog); +} +/** Sends to Firelog. Atempts to use sendBeacon otherwsise uses fetch. */ +function postToFlEndpoint(body) { + const flTransportFullUrl = SettingsService.getInstance().getFlTransportFullUrl(); + const size = TEXT_ENCODER.encode(body).length; + if (size <= MAX_SEND_BEACON_PAYLOAD_SIZE && + navigator.sendBeacon && + navigator.sendBeacon(flTransportFullUrl, body)) { + return Promise.resolve(); + } + else { + return fetch(flTransportFullUrl, { + method: 'POST', + body + }); + } +} +function addToQueue(evt) { + if (!evt.eventTime || !evt.message) { + throw ERROR_FACTORY.create("invalid cc log" /* ErrorCode.INVALID_CC_LOG */); + } + // Add the new event to the queue. + queue = [...queue, evt]; +} +/** Log handler for cc service to send the performance logs to the server. */ +function transportHandler( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +serializer) { + return (...args) => { + const message = serializer(...args); + addToQueue({ + message, + eventTime: Date.now() + }); + }; +} +/** + * Force flush the queued events. Useful at page unload time to ensure all events are uploaded. + * Flush will attempt to use sendBeacon to send events async and defaults back to fetch as soon as a + * sendBeacon fails. Firefox + */ +function flushQueuedEvents() { + const flTransportFullUrl = SettingsService.getInstance().getFlTransportFullUrl(); + while (queue.length > 0) { + // Send the last events first to prioritize page load traces + const staged = queue.splice(-SettingsService.getInstance().logMaxFlushSize); + const body = buildPayload(staged); + if (navigator.sendBeacon && + navigator.sendBeacon(flTransportFullUrl, body)) { + continue; + } + else { + queue = [...queue, ...staged]; + break; + } + } + if (queue.length > 0) { + const body = buildPayload(queue); + fetch(flTransportFullUrl, { + method: 'POST', + body + }).catch(() => { + consoleLogger.info(`Failed flushing queued events.`); + }); + } +} + +/** + * @license + * 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 + * + * http://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 logger; +// +// This method is not called before initialization. +function sendLog(resource, resourceType) { + if (!logger) { + logger = { + send: transportHandler(serializer), + flush: flushQueuedEvents + }; + } + logger.send(resource, resourceType); +} +function logTrace(trace) { + const settingsService = SettingsService.getInstance(); + // Do not log if trace is auto generated and instrumentation is disabled. + if (!settingsService.instrumentationEnabled && trace.isAuto) { + return; + } + // Do not log if trace is custom and data collection is disabled. + if (!settingsService.dataCollectionEnabled && !trace.isAuto) { + return; + } + // Do not log if required apis are not available. + if (!Api.getInstance().requiredApisAvailable()) { + return; + } + if (isPerfInitialized()) { + sendTraceLog(trace); + } + else { + // Custom traces can be used before the initialization but logging + // should wait until after. + getInitializationPromise(trace.performanceController).then(() => sendTraceLog(trace), () => sendTraceLog(trace)); + } +} +function flushLogs() { + if (logger) { + logger.flush(); + } +} +function sendTraceLog(trace) { + if (!getIid()) { + return; + } + const settingsService = SettingsService.getInstance(); + if (!settingsService.loggingEnabled || + !settingsService.logTraceAfterSampling) { + return; + } + sendLog(trace, 1 /* ResourceType.Trace */); +} +function logNetworkRequest(networkRequest) { + const settingsService = SettingsService.getInstance(); + // Do not log network requests if instrumentation is disabled. + if (!settingsService.instrumentationEnabled) { + return; + } + // Do not log the js sdk's call to transport service domain to avoid unnecessary cycle. + // Need to blacklist both old and new endpoints to avoid migration gap. + const networkRequestUrl = networkRequest.url; + // Blacklist old log endpoint and new transport endpoint. + // Because Performance SDK doesn't instrument requests sent from SDK itself. + const logEndpointUrl = settingsService.logEndPointUrl.split('?')[0]; + const flEndpointUrl = settingsService.flTransportEndpointUrl.split('?')[0]; + if (networkRequestUrl === logEndpointUrl || + networkRequestUrl === flEndpointUrl) { + return; + } + if (!settingsService.loggingEnabled || + !settingsService.logNetworkAfterSampling) { + return; + } + sendLog(networkRequest, 0 /* ResourceType.NetworkRequest */); +} +function serializer(resource, resourceType) { + if (resourceType === 0 /* ResourceType.NetworkRequest */) { + return serializeNetworkRequest(resource); + } + return serializeTrace(resource); +} +function serializeNetworkRequest(networkRequest) { + const networkRequestMetric = { + url: networkRequest.url, + http_method: networkRequest.httpMethod || 0, + http_response_code: 200, + response_payload_bytes: networkRequest.responsePayloadBytes, + client_start_time_us: networkRequest.startTimeUs, + time_to_response_initiated_us: networkRequest.timeToResponseInitiatedUs, + time_to_response_completed_us: networkRequest.timeToResponseCompletedUs + }; + const perfMetric = { + application_info: getApplicationInfo(networkRequest.performanceController.app), + network_request_metric: networkRequestMetric + }; + return JSON.stringify(perfMetric); +} +function serializeTrace(trace) { + const traceMetric = { + name: trace.name, + is_auto: trace.isAuto, + client_start_time_us: trace.startTimeUs, + duration_us: trace.durationUs + }; + if (Object.keys(trace.counters).length !== 0) { + traceMetric.counters = trace.counters; + } + const customAttributes = trace.getAttributes(); + if (Object.keys(customAttributes).length !== 0) { + traceMetric.custom_attributes = customAttributes; + } + const perfMetric = { + application_info: getApplicationInfo(trace.performanceController.app), + trace_metric: traceMetric + }; + return JSON.stringify(perfMetric); +} +function getApplicationInfo(firebaseApp) { + return { + google_app_id: getAppId(firebaseApp), + app_instance_id: getIid(), + web_app_info: { + sdk_version: SDK_VERSION, + page_url: Api.getInstance().getUrl(), + service_worker_status: getServiceWorkerStatus(), + visibility_state: getVisibilityState(), + effective_connection_type: getEffectiveConnectionType() + }, + application_process_state: 0 + }; +} +/* eslint-enable camelcase */ + +/** + * @license + * 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 + * + * http://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. + */ +function createNetworkRequestEntry(performanceController, entry) { + const performanceEntry = entry; + if (!performanceEntry || performanceEntry.responseStart === undefined) { + return; + } + const timeOrigin = Api.getInstance().getTimeOrigin(); + const startTimeUs = Math.floor((performanceEntry.startTime + timeOrigin) * 1000); + const timeToResponseInitiatedUs = performanceEntry.responseStart + ? Math.floor((performanceEntry.responseStart - performanceEntry.startTime) * 1000) + : undefined; + const timeToResponseCompletedUs = Math.floor((performanceEntry.responseEnd - performanceEntry.startTime) * 1000); + // Remove the query params from logged network request url. + const url = performanceEntry.name && performanceEntry.name.split('?')[0]; + const networkRequest = { + performanceController, + url, + responsePayloadBytes: performanceEntry.transferSize, + startTimeUs, + timeToResponseInitiatedUs, + timeToResponseCompletedUs + }; + logNetworkRequest(networkRequest); +} + +/** + * @license + * 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 + * + * http://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 MAX_METRIC_NAME_LENGTH = 100; +const RESERVED_AUTO_PREFIX = '_'; +const oobMetrics = [ + FIRST_PAINT_COUNTER_NAME, + FIRST_CONTENTFUL_PAINT_COUNTER_NAME, + FIRST_INPUT_DELAY_COUNTER_NAME, + LARGEST_CONTENTFUL_PAINT_METRIC_NAME, + CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME, + INTERACTION_TO_NEXT_PAINT_METRIC_NAME +]; +/** + * Returns true if the metric is custom and does not start with reserved prefix, or if + * the metric is one of out of the box page load trace metrics. + */ +function isValidMetricName(name, traceName) { + if (name.length === 0 || name.length > MAX_METRIC_NAME_LENGTH) { + return false; + } + return ((traceName && + traceName.startsWith(OOB_TRACE_PAGE_LOAD_PREFIX) && + oobMetrics.indexOf(name) > -1) || + !name.startsWith(RESERVED_AUTO_PREFIX)); +} +/** + * Converts the provided value to an integer value to be used in case of a metric. + * @param providedValue Provided number value of the metric that needs to be converted to an integer. + * + * @returns Converted integer number to be set for the metric. + */ +function convertMetricValueToInteger(providedValue) { + const valueAsInteger = Math.floor(providedValue); + if (valueAsInteger < providedValue) { + consoleLogger.info(`Metric value should be an Integer, setting the value as : ${valueAsInteger}.`); + } + return valueAsInteger; +} + +/** + * @license + * 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 + * + * http://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. + */ +class Trace { + /** + * @param performanceController The performance controller running. + * @param name The name of the trace. + * @param isAuto If the trace is auto-instrumented. + * @param traceMeasureName The name of the measure marker in user timing specification. This field + * is only set when the trace is built for logging when the user directly uses the user timing + * api (performance.mark and performance.measure). + */ + constructor(performanceController, name, isAuto = false, traceMeasureName) { + this.performanceController = performanceController; + this.name = name; + this.isAuto = isAuto; + this.state = 1 /* TraceState.UNINITIALIZED */; + this.customAttributes = {}; + this.counters = {}; + this.api = Api.getInstance(); + this.randomId = Math.floor(Math.random() * 1000000); + if (!this.isAuto) { + this.traceStartMark = `${TRACE_START_MARK_PREFIX}-${this.randomId}-${this.name}`; + this.traceStopMark = `${TRACE_STOP_MARK_PREFIX}-${this.randomId}-${this.name}`; + this.traceMeasure = + traceMeasureName || + `${TRACE_MEASURE_PREFIX}-${this.randomId}-${this.name}`; + if (traceMeasureName) { + // For the case of direct user timing traces, no start stop will happen. The measure object + // is already available. + this.calculateTraceMetrics(); + } + } + } + /** + * Starts a trace. The measurement of the duration starts at this point. + */ + start() { + if (this.state !== 1 /* TraceState.UNINITIALIZED */) { + throw ERROR_FACTORY.create("trace started" /* ErrorCode.TRACE_STARTED_BEFORE */, { + traceName: this.name + }); + } + this.api.mark(this.traceStartMark); + this.state = 2 /* TraceState.RUNNING */; + } + /** + * Stops the trace. The measurement of the duration of the trace stops at this point and trace + * is logged. + */ + stop() { + if (this.state !== 2 /* TraceState.RUNNING */) { + throw ERROR_FACTORY.create("trace stopped" /* ErrorCode.TRACE_STOPPED_BEFORE */, { + traceName: this.name + }); + } + this.state = 3 /* TraceState.TERMINATED */; + this.api.mark(this.traceStopMark); + this.api.measure(this.traceMeasure, this.traceStartMark, this.traceStopMark); + this.calculateTraceMetrics(); + logTrace(this); + } + /** + * Records a trace with predetermined values. If this method is used a trace is created and logged + * directly. No need to use start and stop methods. + * @param startTime Trace start time since epoch in millisec + * @param duration The duration of the trace in millisec + * @param options An object which can optionally hold maps of custom metrics and custom attributes + */ + record(startTime, duration, options) { + if (startTime <= 0) { + throw ERROR_FACTORY.create("nonpositive trace startTime" /* ErrorCode.NONPOSITIVE_TRACE_START_TIME */, { + traceName: this.name + }); + } + if (duration <= 0) { + throw ERROR_FACTORY.create("nonpositive trace duration" /* ErrorCode.NONPOSITIVE_TRACE_DURATION */, { + traceName: this.name + }); + } + this.durationUs = Math.floor(duration * 1000); + this.startTimeUs = Math.floor(startTime * 1000); + if (options && options.attributes) { + this.customAttributes = { ...options.attributes }; + } + if (options && options.metrics) { + for (const metricName of Object.keys(options.metrics)) { + if (!isNaN(Number(options.metrics[metricName]))) { + this.counters[metricName] = Math.floor(Number(options.metrics[metricName])); + } + } + } + logTrace(this); + } + /** + * Increments a custom metric by a certain number or 1 if number not specified. Will create a new + * custom metric if one with the given name does not exist. The value will be floored down to an + * integer. + * @param counter Name of the custom metric + * @param numAsInteger Increment by value + */ + incrementMetric(counter, numAsInteger = 1) { + if (this.counters[counter] === undefined) { + this.putMetric(counter, numAsInteger); + } + else { + this.putMetric(counter, this.counters[counter] + numAsInteger); + } + } + /** + * Sets a custom metric to a specified value. Will create a new custom metric if one with the + * given name does not exist. The value will be floored down to an integer. + * @param counter Name of the custom metric + * @param numAsInteger Set custom metric to this value + */ + putMetric(counter, numAsInteger) { + if (isValidMetricName(counter, this.name)) { + this.counters[counter] = convertMetricValueToInteger(numAsInteger ?? 0); + } + else { + throw ERROR_FACTORY.create("invalid custom metric name" /* ErrorCode.INVALID_CUSTOM_METRIC_NAME */, { + customMetricName: counter + }); + } + } + /** + * Returns the value of the custom metric by that name. If a custom metric with that name does + * not exist will return zero. + * @param counter + */ + getMetric(counter) { + return this.counters[counter] || 0; + } + /** + * Sets a custom attribute of a trace to a certain value. + * @param attr + * @param value + */ + putAttribute(attr, value) { + const isValidName = isValidCustomAttributeName(attr); + const isValidValue = isValidCustomAttributeValue(value); + if (isValidName && isValidValue) { + this.customAttributes[attr] = value; + return; + } + // Throw appropriate error when the attribute name or value is invalid. + if (!isValidName) { + throw ERROR_FACTORY.create("invalid attribute name" /* ErrorCode.INVALID_ATTRIBUTE_NAME */, { + attributeName: attr + }); + } + if (!isValidValue) { + throw ERROR_FACTORY.create("invalid attribute value" /* ErrorCode.INVALID_ATTRIBUTE_VALUE */, { + attributeValue: value + }); + } + } + /** + * Retrieves the value a custom attribute of a trace is set to. + * @param attr + */ + getAttribute(attr) { + return this.customAttributes[attr]; + } + removeAttribute(attr) { + if (this.customAttributes[attr] === undefined) { + return; + } + delete this.customAttributes[attr]; + } + getAttributes() { + return { ...this.customAttributes }; + } + setStartTime(startTime) { + this.startTimeUs = startTime; + } + setDuration(duration) { + this.durationUs = duration; + } + /** + * Calculates and assigns the duration and start time of the trace using the measure performance + * entry. + */ + calculateTraceMetrics() { + const perfMeasureEntries = this.api.getEntriesByName(this.traceMeasure); + const perfMeasureEntry = perfMeasureEntries && perfMeasureEntries[0]; + if (perfMeasureEntry) { + this.durationUs = Math.floor(perfMeasureEntry.duration * 1000); + this.startTimeUs = Math.floor((perfMeasureEntry.startTime + this.api.getTimeOrigin()) * 1000); + } + } + /** + * @param navigationTimings A single element array which contains the navigationTIming object of + * the page load + * @param paintTimings A array which contains paintTiming object of the page load + * @param firstInputDelay First input delay in millisec + */ + static createOobTrace(performanceController, navigationTimings, paintTimings, webVitalMetrics, firstInputDelay) { + const route = Api.getInstance().getUrl(); + if (!route) { + return; + } + const trace = new Trace(performanceController, OOB_TRACE_PAGE_LOAD_PREFIX + route, true); + const timeOriginUs = Math.floor(Api.getInstance().getTimeOrigin() * 1000); + trace.setStartTime(timeOriginUs); + // navigationTimings includes only one element. + if (navigationTimings && navigationTimings[0]) { + trace.setDuration(Math.floor(navigationTimings[0].duration * 1000)); + trace.putMetric('domInteractive', Math.floor(navigationTimings[0].domInteractive * 1000)); + trace.putMetric('domContentLoadedEventEnd', Math.floor(navigationTimings[0].domContentLoadedEventEnd * 1000)); + trace.putMetric('loadEventEnd', Math.floor(navigationTimings[0].loadEventEnd * 1000)); + } + const FIRST_PAINT = 'first-paint'; + const FIRST_CONTENTFUL_PAINT = 'first-contentful-paint'; + if (paintTimings) { + const firstPaint = paintTimings.find(paintObject => paintObject.name === FIRST_PAINT); + if (firstPaint && firstPaint.startTime) { + trace.putMetric(FIRST_PAINT_COUNTER_NAME, Math.floor(firstPaint.startTime * 1000)); + } + const firstContentfulPaint = paintTimings.find(paintObject => paintObject.name === FIRST_CONTENTFUL_PAINT); + if (firstContentfulPaint && firstContentfulPaint.startTime) { + trace.putMetric(FIRST_CONTENTFUL_PAINT_COUNTER_NAME, Math.floor(firstContentfulPaint.startTime * 1000)); + } + if (firstInputDelay) { + trace.putMetric(FIRST_INPUT_DELAY_COUNTER_NAME, Math.floor(firstInputDelay * 1000)); + } + } + this.addWebVitalMetric(trace, LARGEST_CONTENTFUL_PAINT_METRIC_NAME, LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME, webVitalMetrics.lcp); + this.addWebVitalMetric(trace, CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME, CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME, webVitalMetrics.cls); + this.addWebVitalMetric(trace, INTERACTION_TO_NEXT_PAINT_METRIC_NAME, INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME, webVitalMetrics.inp); + // Page load logs are sent at unload time and so should be logged and + // flushed immediately. + logTrace(trace); + flushLogs(); + } + static addWebVitalMetric(trace, metricKey, attributeKey, metric) { + if (metric) { + trace.putMetric(metricKey, Math.floor(metric.value * 1000)); + if (metric.elementAttribution) { + if (metric.elementAttribution.length > MAX_ATTRIBUTE_VALUE_LENGTH) { + trace.putAttribute(attributeKey, metric.elementAttribution.substring(0, MAX_ATTRIBUTE_VALUE_LENGTH)); + } + else { + trace.putAttribute(attributeKey, metric.elementAttribution); + } + } + } + } + static createUserTimingTrace(performanceController, measureName) { + const trace = new Trace(performanceController, measureName, false, measureName); + logTrace(trace); + } +} + +/** + * @license + * 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 + * + * http://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 webVitalMetrics = {}; +let sentPageLoadTrace = false; +let firstInputDelay; +function setupOobResources(performanceController) { + // Do not initialize unless iid is available. + if (!getIid()) { + return; + } + // The load event might not have fired yet, and that means performance + // navigation timing object has a duration of 0. The setup should run after + // all current tasks in js queue. + setTimeout(() => setupOobTraces(performanceController), 0); + setTimeout(() => setupNetworkRequests(performanceController), 0); + setTimeout(() => setupUserTimingTraces(performanceController), 0); +} +function setupNetworkRequests(performanceController) { + const api = Api.getInstance(); + const resources = api.getEntriesByType('resource'); + for (const resource of resources) { + createNetworkRequestEntry(performanceController, resource); + } + api.setupObserver('resource', entry => createNetworkRequestEntry(performanceController, entry)); +} +function setupOobTraces(performanceController) { + const api = Api.getInstance(); + // Better support for Safari + if ('onpagehide' in window) { + api.document.addEventListener('pagehide', () => sendOobTrace(performanceController)); + } + else { + api.document.addEventListener('unload', () => sendOobTrace(performanceController)); + } + api.document.addEventListener('visibilitychange', () => { + if (api.document.visibilityState === 'hidden') { + sendOobTrace(performanceController); + } + }); + if (api.onFirstInputDelay) { + api.onFirstInputDelay((fid) => { + firstInputDelay = fid; + }); + } + api.onLCP((metric) => { + webVitalMetrics.lcp = { + value: metric.value, + elementAttribution: metric.attribution?.element + }; + }); + api.onCLS((metric) => { + webVitalMetrics.cls = { + value: metric.value, + elementAttribution: metric.attribution?.largestShiftTarget + }; + }); + api.onINP((metric) => { + webVitalMetrics.inp = { + value: metric.value, + elementAttribution: metric.attribution?.interactionTarget + }; + }); +} +function setupUserTimingTraces(performanceController) { + const api = Api.getInstance(); + // Run through the measure performance entries collected up to this point. + const measures = api.getEntriesByType('measure'); + for (const measure of measures) { + createUserTimingTrace(performanceController, measure); + } + // Setup an observer to capture the measures from this point on. + api.setupObserver('measure', entry => createUserTimingTrace(performanceController, entry)); +} +function createUserTimingTrace(performanceController, measure) { + const measureName = measure.name; + // Do not create a trace, if the user timing marks and measures are created by + // the sdk itself. + if (measureName.substring(0, TRACE_MEASURE_PREFIX.length) === + TRACE_MEASURE_PREFIX) { + return; + } + Trace.createUserTimingTrace(performanceController, measureName); +} +function sendOobTrace(performanceController) { + if (!sentPageLoadTrace) { + sentPageLoadTrace = true; + const api = Api.getInstance(); + const navigationTimings = api.getEntriesByType('navigation'); + const paintTimings = api.getEntriesByType('paint'); + // On page unload web vitals may be updated so queue the oob trace creation + // so that these updates have time to be included. + setTimeout(() => { + Trace.createOobTrace(performanceController, navigationTimings, paintTimings, webVitalMetrics, firstInputDelay); + }, 0); + } +} + +/** + * @license + * 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 + * + * http://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. + */ +class PerformanceController { + constructor(app, installations) { + this.app = app; + this.installations = installations; + this.initialized = false; + } + /** + * This method *must* be called internally as part of creating a + * PerformanceController instance. + * + * Currently it's not possible to pass the settings object through the + * constructor using Components, so this method exists to be called with the + * desired settings, to ensure nothing is collected without the user's + * consent. + */ + _init(settings) { + if (this.initialized) { + return; + } + if (settings?.dataCollectionEnabled !== undefined) { + this.dataCollectionEnabled = settings.dataCollectionEnabled; + } + if (settings?.instrumentationEnabled !== undefined) { + this.instrumentationEnabled = settings.instrumentationEnabled; + } + if (Api.getInstance().requiredApisAvailable()) { + util.validateIndexedDBOpenable() + .then(isAvailable => { + if (isAvailable) { + setupTransportService(); + getInitializationPromise(this).then(() => setupOobResources(this), () => setupOobResources(this)); + this.initialized = true; + } + }) + .catch(error => { + consoleLogger.info(`Environment doesn't support IndexedDB: ${error}`); + }); + } + else { + consoleLogger.info('Firebase Performance cannot start if the browser does not support ' + + '"Fetch" and "Promise", or cookies are disabled.'); + } + } + set instrumentationEnabled(val) { + SettingsService.getInstance().instrumentationEnabled = val; + } + get instrumentationEnabled() { + return SettingsService.getInstance().instrumentationEnabled; + } + set dataCollectionEnabled(val) { + SettingsService.getInstance().dataCollectionEnabled = val; + } + get dataCollectionEnabled() { + return SettingsService.getInstance().dataCollectionEnabled; + } +} + +/** + * The Firebase Performance Monitoring Web SDK. + * This SDK does not work in a Node.js environment. + * + * @packageDocumentation + */ +const DEFAULT_ENTRY_NAME = '[DEFAULT]'; +/** + * Returns a {@link FirebasePerformance} instance for the given app. + * @param app - The {@link @firebase/app#FirebaseApp} to use. + * @public + */ +function getPerformance(app$1 = app.getApp()) { + app$1 = util.getModularInstance(app$1); + const provider = app._getProvider(app$1, 'performance'); + const perfInstance = provider.getImmediate(); + return perfInstance; +} +/** + * Returns a {@link FirebasePerformance} instance for the given app. Can only be called once. + * @param app - The {@link @firebase/app#FirebaseApp} to use. + * @param settings - Optional settings for the {@link FirebasePerformance} instance. + * @public + */ +function initializePerformance(app$1, settings) { + app$1 = util.getModularInstance(app$1); + const provider = app._getProvider(app$1, 'performance'); + // throw if an instance was already created. + // It could happen if initializePerformance() is called more than once, or getPerformance() is called first. + if (provider.isInitialized()) { + const existingInstance = provider.getImmediate(); + const initialSettings = provider.getOptions(); + if (util.deepEqual(initialSettings, settings ?? {})) { + return existingInstance; + } + else { + throw ERROR_FACTORY.create("already initialized" /* ErrorCode.ALREADY_INITIALIZED */); + } + } + const perfInstance = provider.initialize({ + options: settings + }); + return perfInstance; +} +/** + * Returns a new `PerformanceTrace` instance. + * @param performance - The {@link FirebasePerformance} instance to use. + * @param name - The name of the trace. + * @public + */ +function trace(performance, name) { + performance = util.getModularInstance(performance); + return new Trace(performance, name); +} +const factory = (container, { options: settings }) => { + // Dependencies + const app = container.getProvider('app').getImmediate(); + const installations = container + .getProvider('installations-internal') + .getImmediate(); + if (app.name !== DEFAULT_ENTRY_NAME) { + throw ERROR_FACTORY.create("FB not default" /* ErrorCode.FB_NOT_DEFAULT */); + } + if (typeof window === 'undefined') { + throw ERROR_FACTORY.create("no window" /* ErrorCode.NO_WINDOW */); + } + setupApi(window); + const perfInstance = new PerformanceController(app, installations); + perfInstance._init(settings); + return perfInstance; +}; +function registerPerformance() { + app._registerComponent(new component.Component('performance', factory, "PUBLIC" /* ComponentType.PUBLIC */)); + app.registerVersion(name, version); + // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation + app.registerVersion(name, version, 'cjs2020'); +} +registerPerformance(); + +exports.getPerformance = getPerformance; +exports.initializePerformance = initializePerformance; +exports.trace = trace; +//# sourceMappingURL=index.cjs.js.map diff --git a/frontend-old/node_modules/@firebase/performance/dist/index.cjs.js.map b/frontend-old/node_modules/@firebase/performance/dist/index.cjs.js.map new file mode 100644 index 0000000..1844044 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/index.cjs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.cjs.js","sources":["../src/constants.ts","../src/utils/errors.ts","../src/utils/console_logger.ts","../src/services/api_service.ts","../src/services/iid_service.ts","../src/utils/string_merger.ts","../src/services/settings_service.ts","../src/utils/attributes_utils.ts","../src/utils/app_utils.ts","../src/services/remote_config_service.ts","../src/services/initialization_service.ts","../src/services/transport_service.ts","../src/services/perf_logger.ts","../src/resources/network_request.ts","../src/utils/metric_utils.ts","../src/resources/trace.ts","../src/services/oob_resources_service.ts","../src/controllers/perf.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\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 * http://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 { version } from '../package.json';\n\nexport const SDK_VERSION = version;\n/** The prefix for start User Timing marks used for creating Traces. */\nexport const TRACE_START_MARK_PREFIX = 'FB-PERF-TRACE-START';\n/** The prefix for stop User Timing marks used for creating Traces. */\nexport const TRACE_STOP_MARK_PREFIX = 'FB-PERF-TRACE-STOP';\n/** The prefix for User Timing measure used for creating Traces. */\nexport const TRACE_MEASURE_PREFIX = 'FB-PERF-TRACE-MEASURE';\n/** The prefix for out of the box page load Trace name. */\nexport const OOB_TRACE_PAGE_LOAD_PREFIX = '_wt_';\n\nexport const FIRST_PAINT_COUNTER_NAME = '_fp';\n\nexport const FIRST_CONTENTFUL_PAINT_COUNTER_NAME = '_fcp';\n\nexport const FIRST_INPUT_DELAY_COUNTER_NAME = '_fid';\n\nexport const LARGEST_CONTENTFUL_PAINT_METRIC_NAME = '_lcp';\nexport const LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME = 'lcp_element';\n\nexport const INTERACTION_TO_NEXT_PAINT_METRIC_NAME = '_inp';\nexport const INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME = 'inp_interactionTarget';\n\nexport const CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME = '_cls';\nexport const CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME = 'cls_largestShiftTarget';\n\nexport const CONFIG_LOCAL_STORAGE_KEY = '@firebase/performance/config';\n\nexport const CONFIG_EXPIRY_LOCAL_STORAGE_KEY =\n '@firebase/performance/configexpire';\n\nexport const SERVICE = 'performance';\nexport const SERVICE_NAME = 'Performance';\n","/**\n * @license\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 * http://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 { ErrorFactory } from '@firebase/util';\nimport { SERVICE, SERVICE_NAME } from '../constants';\n\nexport const enum ErrorCode {\n TRACE_STARTED_BEFORE = 'trace started',\n TRACE_STOPPED_BEFORE = 'trace stopped',\n NONPOSITIVE_TRACE_START_TIME = 'nonpositive trace startTime',\n NONPOSITIVE_TRACE_DURATION = 'nonpositive trace duration',\n NO_WINDOW = 'no window',\n NO_APP_ID = 'no app id',\n NO_PROJECT_ID = 'no project id',\n NO_API_KEY = 'no api key',\n INVALID_CC_LOG = 'invalid cc log',\n FB_NOT_DEFAULT = 'FB not default',\n RC_NOT_OK = 'RC response not ok',\n INVALID_ATTRIBUTE_NAME = 'invalid attribute name',\n INVALID_ATTRIBUTE_VALUE = 'invalid attribute value',\n INVALID_CUSTOM_METRIC_NAME = 'invalid custom metric name',\n INVALID_STRING_MERGER_PARAMETER = 'invalid String merger input',\n ALREADY_INITIALIZED = 'already initialized'\n}\n\nconst ERROR_DESCRIPTION_MAP: { readonly [key in ErrorCode]: string } = {\n [ErrorCode.TRACE_STARTED_BEFORE]: 'Trace {$traceName} was started before.',\n [ErrorCode.TRACE_STOPPED_BEFORE]: 'Trace {$traceName} is not running.',\n [ErrorCode.NONPOSITIVE_TRACE_START_TIME]:\n 'Trace {$traceName} startTime should be positive.',\n [ErrorCode.NONPOSITIVE_TRACE_DURATION]:\n 'Trace {$traceName} duration should be positive.',\n [ErrorCode.NO_WINDOW]: 'Window is not available.',\n [ErrorCode.NO_APP_ID]: 'App id is not available.',\n [ErrorCode.NO_PROJECT_ID]: 'Project id is not available.',\n [ErrorCode.NO_API_KEY]: 'Api key is not available.',\n [ErrorCode.INVALID_CC_LOG]: 'Attempted to queue invalid cc event',\n [ErrorCode.FB_NOT_DEFAULT]:\n 'Performance can only start when Firebase app instance is the default one.',\n [ErrorCode.RC_NOT_OK]: 'RC response is not ok',\n [ErrorCode.INVALID_ATTRIBUTE_NAME]:\n 'Attribute name {$attributeName} is invalid.',\n [ErrorCode.INVALID_ATTRIBUTE_VALUE]:\n 'Attribute value {$attributeValue} is invalid.',\n [ErrorCode.INVALID_CUSTOM_METRIC_NAME]:\n 'Custom metric name {$customMetricName} is invalid',\n [ErrorCode.INVALID_STRING_MERGER_PARAMETER]:\n 'Input for String merger is invalid, contact support team to resolve.',\n [ErrorCode.ALREADY_INITIALIZED]:\n 'initializePerformance() has already been called with ' +\n 'different options. To avoid this error, call initializePerformance() with the ' +\n 'same options as when it was originally called, or call getPerformance() to return the' +\n ' already initialized instance.'\n};\n\ninterface ErrorParams {\n [ErrorCode.TRACE_STARTED_BEFORE]: { traceName: string };\n [ErrorCode.TRACE_STOPPED_BEFORE]: { traceName: string };\n [ErrorCode.NONPOSITIVE_TRACE_START_TIME]: { traceName: string };\n [ErrorCode.NONPOSITIVE_TRACE_DURATION]: { traceName: string };\n [ErrorCode.INVALID_ATTRIBUTE_NAME]: { attributeName: string };\n [ErrorCode.INVALID_ATTRIBUTE_VALUE]: { attributeValue: string };\n [ErrorCode.INVALID_CUSTOM_METRIC_NAME]: { customMetricName: string };\n}\n\nexport const ERROR_FACTORY = new ErrorFactory<ErrorCode, ErrorParams>(\n SERVICE,\n SERVICE_NAME,\n ERROR_DESCRIPTION_MAP\n);\n","/**\n * @license\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 * http://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 { Logger, LogLevel } from '@firebase/logger';\nimport { SERVICE_NAME } from '../constants';\n\nexport const consoleLogger = new Logger(SERVICE_NAME);\nconsoleLogger.logLevel = LogLevel.INFO;\n","/**\n * @license\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 * http://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 { ERROR_FACTORY, ErrorCode } from '../utils/errors';\nimport { isIndexedDBAvailable, areCookiesEnabled } from '@firebase/util';\nimport { consoleLogger } from '../utils/console_logger';\nimport {\n CLSMetricWithAttribution,\n INPMetricWithAttribution,\n LCPMetricWithAttribution,\n onCLS as vitalsOnCLS,\n onINP as vitalsOnINP,\n onLCP as vitalsOnLCP\n} from 'web-vitals/attribution';\n\ndeclare global {\n interface Window {\n PerformanceObserver: typeof PerformanceObserver;\n perfMetrics?: { onFirstInputDelay(fn: (fid: number) => void): void };\n }\n}\n\nlet apiInstance: Api | undefined;\nlet windowInstance: Window | undefined;\n\nexport type EntryType =\n | 'mark'\n | 'measure'\n | 'paint'\n | 'resource'\n | 'frame'\n | 'navigation';\n\n/**\n * This class holds a reference to various browser related objects injected by\n * set methods.\n */\nexport class Api {\n private readonly performance: Performance;\n /** PerformanceObserver constructor function. */\n private readonly PerformanceObserver: typeof PerformanceObserver;\n private readonly windowLocation: Location;\n readonly onFirstInputDelay?: (fn: (fid: number) => void) => void;\n readonly onLCP: (fn: (metric: LCPMetricWithAttribution) => void) => void;\n readonly onINP: (fn: (metric: INPMetricWithAttribution) => void) => void;\n readonly onCLS: (fn: (metric: CLSMetricWithAttribution) => void) => void;\n readonly localStorage?: Storage;\n readonly document: Document;\n readonly navigator: Navigator;\n\n constructor(readonly window?: Window) {\n if (!window) {\n throw ERROR_FACTORY.create(ErrorCode.NO_WINDOW);\n }\n this.performance = window.performance;\n this.PerformanceObserver = window.PerformanceObserver;\n this.windowLocation = window.location;\n this.navigator = window.navigator;\n this.document = window.document;\n if (this.navigator && this.navigator.cookieEnabled) {\n // If user blocks cookies on the browser, accessing localStorage will\n // throw an exception.\n this.localStorage = window.localStorage;\n }\n if (window.perfMetrics && window.perfMetrics.onFirstInputDelay) {\n this.onFirstInputDelay = window.perfMetrics.onFirstInputDelay;\n }\n this.onLCP = vitalsOnLCP;\n this.onINP = vitalsOnINP;\n this.onCLS = vitalsOnCLS;\n }\n\n getUrl(): string {\n // Do not capture the string query part of url.\n return this.windowLocation.href.split('?')[0];\n }\n\n mark(name: string): void {\n if (!this.performance || !this.performance.mark) {\n return;\n }\n this.performance.mark(name);\n }\n\n measure(measureName: string, mark1: string, mark2: string): void {\n if (!this.performance || !this.performance.measure) {\n return;\n }\n this.performance.measure(measureName, mark1, mark2);\n }\n\n getEntriesByType(type: EntryType): PerformanceEntry[] {\n if (!this.performance || !this.performance.getEntriesByType) {\n return [];\n }\n return this.performance.getEntriesByType(type);\n }\n\n getEntriesByName(name: string): PerformanceEntry[] {\n if (!this.performance || !this.performance.getEntriesByName) {\n return [];\n }\n return this.performance.getEntriesByName(name);\n }\n\n getTimeOrigin(): number {\n // Polyfill the time origin with performance.timing.navigationStart.\n return (\n this.performance &&\n (this.performance.timeOrigin || this.performance.timing.navigationStart)\n );\n }\n\n requiredApisAvailable(): boolean {\n if (!fetch || !Promise || !areCookiesEnabled()) {\n consoleLogger.info(\n 'Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled.'\n );\n return false;\n }\n\n if (!isIndexedDBAvailable()) {\n consoleLogger.info('IndexedDB is not supported by current browser');\n return false;\n }\n return true;\n }\n\n setupObserver(\n entryType: EntryType,\n callback: (entry: PerformanceEntry) => void\n ): void {\n if (!this.PerformanceObserver) {\n return;\n }\n const observer = new this.PerformanceObserver(list => {\n for (const entry of list.getEntries()) {\n // `entry` is a PerformanceEntry instance.\n callback(entry);\n }\n });\n\n // Start observing the entry types you care about.\n observer.observe({ entryTypes: [entryType] });\n }\n\n static getInstance(): Api {\n if (apiInstance === undefined) {\n apiInstance = new Api(windowInstance);\n }\n return apiInstance;\n }\n}\n\nexport function setupApi(window: Window): void {\n windowInstance = window;\n}\n","/**\n * @license\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 * http://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 { _FirebaseInstallationsInternal } from '@firebase/installations';\n\nlet iid: string | undefined;\nlet authToken: string | undefined;\n\nexport function getIidPromise(\n installationsService: _FirebaseInstallationsInternal\n): Promise<string> {\n const iidPromise = installationsService.getId();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n iidPromise.then((iidVal: string) => {\n iid = iidVal;\n });\n return iidPromise;\n}\n\n// This method should be used after the iid is retrieved by getIidPromise method.\nexport function getIid(): string | undefined {\n return iid;\n}\n\nexport function getAuthTokenPromise(\n installationsService: _FirebaseInstallationsInternal\n): Promise<string> {\n const authTokenPromise = installationsService.getToken();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n authTokenPromise.then((authTokenVal: string) => {\n authToken = authTokenVal;\n });\n return authTokenPromise;\n}\n\nexport function getAuthenticationToken(): string | undefined {\n return authToken;\n}\n","/**\n * @license\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 * http://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 { ERROR_FACTORY, ErrorCode } from './errors';\n\nexport function mergeStrings(part1: string, part2: string): string {\n const sizeDiff = part1.length - part2.length;\n if (sizeDiff < 0 || sizeDiff > 1) {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_STRING_MERGER_PARAMETER);\n }\n\n const resultArray = [];\n for (let i = 0; i < part1.length; i++) {\n resultArray.push(part1.charAt(i));\n if (part2.length > i) {\n resultArray.push(part2.charAt(i));\n }\n }\n\n return resultArray.join('');\n}\n","/**\n * @license\n * Copyright 2019 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 * http://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 { mergeStrings } from '../utils/string_merger';\n\nlet settingsServiceInstance: SettingsService | undefined;\n\nexport class SettingsService {\n // The variable which controls logging of automatic traces and HTTP/S network monitoring.\n instrumentationEnabled = true;\n\n // The variable which controls logging of custom traces.\n dataCollectionEnabled = true;\n\n // Configuration flags set through remote config.\n loggingEnabled = false;\n // Sampling rate between 0 and 1.\n tracesSamplingRate = 1;\n networkRequestsSamplingRate = 1;\n\n // Address of logging service.\n logEndPointUrl =\n 'https://firebaselogging.googleapis.com/v0cc/log?format=json_proto';\n // Performance event transport endpoint URL which should be compatible with proto3.\n // New Address for transport service, not configurable via Remote Config.\n flTransportEndpointUrl = mergeStrings(\n 'hts/frbslgigp.ogepscmv/ieo/eaylg',\n 'tp:/ieaeogn-agolai.o/1frlglgc/o'\n );\n\n transportKey = mergeStrings('AzSC8r6ReiGqFMyfvgow', 'Iayx0u-XT3vksVM-pIV');\n\n // Source type for performance event logs.\n logSource = 462;\n\n // Flags which control per session logging of traces and network requests.\n logTraceAfterSampling = false;\n logNetworkAfterSampling = false;\n\n // TTL of config retrieved from remote config in hours.\n configTimeToLive = 12;\n\n // The max number of events to send during a flush. This number is kept low to since Chrome has a\n // shared payload limit for all sendBeacon calls in the same nav context.\n logMaxFlushSize = 40;\n\n getFlTransportFullUrl(): string {\n return this.flTransportEndpointUrl.concat('?key=', this.transportKey);\n }\n\n static getInstance(): SettingsService {\n if (settingsServiceInstance === undefined) {\n settingsServiceInstance = new SettingsService();\n }\n return settingsServiceInstance;\n }\n}\n","/**\n * @license\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 * http://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 { Api } from '../services/api_service';\n\n// The values and orders of the following enums should not be changed.\nconst enum ServiceWorkerStatus {\n UNKNOWN = 0,\n UNSUPPORTED = 1,\n CONTROLLED = 2,\n UNCONTROLLED = 3\n}\n\nexport enum VisibilityState {\n UNKNOWN = 0,\n VISIBLE = 1,\n HIDDEN = 2\n}\n\nconst enum EffectiveConnectionType {\n UNKNOWN = 0,\n CONNECTION_SLOW_2G = 1,\n CONNECTION_2G = 2,\n CONNECTION_3G = 3,\n CONNECTION_4G = 4\n}\n\ntype ConnectionType =\n | 'bluetooth'\n | 'cellular'\n | 'ethernet'\n | 'mixed'\n | 'none'\n | 'other'\n | 'unknown'\n | 'wifi';\n\n/**\n * NetworkInformation\n * This API is not well supported in all major browsers, so TypeScript does not provide types for it.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation\n */\ninterface NetworkInformation extends EventTarget {\n readonly type: ConnectionType;\n}\n\ninterface NetworkInformationWithEffectiveType extends NetworkInformation {\n readonly effectiveType?: 'slow-2g' | '2g' | '3g' | '4g';\n}\n\ninterface NavigatorWithConnection extends Navigator {\n readonly connection: NetworkInformationWithEffectiveType;\n}\n\nconst RESERVED_ATTRIBUTE_PREFIXES = ['firebase_', 'google_', 'ga_'];\nconst ATTRIBUTE_FORMAT_REGEX = new RegExp('^[a-zA-Z]\\\\w*$');\nconst MAX_ATTRIBUTE_NAME_LENGTH = 40;\nexport const MAX_ATTRIBUTE_VALUE_LENGTH = 100;\n\nexport function getServiceWorkerStatus(): ServiceWorkerStatus {\n const navigator = Api.getInstance().navigator;\n if (navigator?.serviceWorker) {\n if (navigator.serviceWorker.controller) {\n return ServiceWorkerStatus.CONTROLLED;\n } else {\n return ServiceWorkerStatus.UNCONTROLLED;\n }\n } else {\n return ServiceWorkerStatus.UNSUPPORTED;\n }\n}\n\nexport function getVisibilityState(): VisibilityState {\n const document = Api.getInstance().document;\n const visibilityState = document.visibilityState;\n switch (visibilityState) {\n case 'visible':\n return VisibilityState.VISIBLE;\n case 'hidden':\n return VisibilityState.HIDDEN;\n default:\n return VisibilityState.UNKNOWN;\n }\n}\n\nexport function getEffectiveConnectionType(): EffectiveConnectionType {\n const navigator = Api.getInstance().navigator;\n const navigatorConnection = (navigator as NavigatorWithConnection).connection;\n const effectiveType =\n navigatorConnection && navigatorConnection.effectiveType;\n switch (effectiveType) {\n case 'slow-2g':\n return EffectiveConnectionType.CONNECTION_SLOW_2G;\n case '2g':\n return EffectiveConnectionType.CONNECTION_2G;\n case '3g':\n return EffectiveConnectionType.CONNECTION_3G;\n case '4g':\n return EffectiveConnectionType.CONNECTION_4G;\n default:\n return EffectiveConnectionType.UNKNOWN;\n }\n}\n\nexport function isValidCustomAttributeName(name: string): boolean {\n if (name.length === 0 || name.length > MAX_ATTRIBUTE_NAME_LENGTH) {\n return false;\n }\n const matchesReservedPrefix = RESERVED_ATTRIBUTE_PREFIXES.some(prefix =>\n name.startsWith(prefix)\n );\n return !matchesReservedPrefix && !!name.match(ATTRIBUTE_FORMAT_REGEX);\n}\n\nexport function isValidCustomAttributeValue(value: string): boolean {\n return value.length !== 0 && value.length <= MAX_ATTRIBUTE_VALUE_LENGTH;\n}\n","/**\n * @license\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 * http://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 { ERROR_FACTORY, ErrorCode } from './errors';\nimport { FirebaseApp } from '@firebase/app';\n\nexport function getAppId(firebaseApp: FirebaseApp): string {\n const appId = firebaseApp.options?.appId;\n if (!appId) {\n throw ERROR_FACTORY.create(ErrorCode.NO_APP_ID);\n }\n return appId;\n}\n\nexport function getProjectId(firebaseApp: FirebaseApp): string {\n const projectId = firebaseApp.options?.projectId;\n if (!projectId) {\n throw ERROR_FACTORY.create(ErrorCode.NO_PROJECT_ID);\n }\n return projectId;\n}\n\nexport function getApiKey(firebaseApp: FirebaseApp): string {\n const apiKey = firebaseApp.options?.apiKey;\n if (!apiKey) {\n throw ERROR_FACTORY.create(ErrorCode.NO_API_KEY);\n }\n return apiKey;\n}\n","/**\n * @license\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 * http://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 {\n CONFIG_EXPIRY_LOCAL_STORAGE_KEY,\n CONFIG_LOCAL_STORAGE_KEY,\n SDK_VERSION\n} from '../constants';\nimport { consoleLogger } from '../utils/console_logger';\nimport { ERROR_FACTORY, ErrorCode } from '../utils/errors';\n\nimport { Api } from './api_service';\nimport { getAuthTokenPromise } from './iid_service';\nimport { SettingsService } from './settings_service';\nimport { PerformanceController } from '../controllers/perf';\nimport { getProjectId, getApiKey, getAppId } from '../utils/app_utils';\n\nconst REMOTE_CONFIG_SDK_VERSION = '0.0.1';\n\ninterface SecondaryConfig {\n loggingEnabled?: boolean;\n logSource?: number;\n logEndPointUrl?: string;\n transportKey?: string;\n tracesSamplingRate?: number;\n networkRequestsSamplingRate?: number;\n logMaxFlushSize?: number;\n}\n\n// These values will be used if the remote config object is successfully\n// retrieved, but the template does not have these fields.\nconst DEFAULT_CONFIGS: SecondaryConfig = {\n loggingEnabled: true\n};\n\n/* eslint-disable camelcase */\ninterface RemoteConfigTemplate {\n fpr_enabled?: string;\n fpr_log_source?: string;\n fpr_log_endpoint_url?: string;\n fpr_log_transport_key?: string;\n fpr_log_transport_web_percent?: string;\n fpr_vc_network_request_sampling_rate?: string;\n fpr_vc_trace_sampling_rate?: string;\n fpr_vc_session_sampling_rate?: string;\n fpr_log_max_flush_size?: string;\n}\n/* eslint-enable camelcase */\n\ninterface RemoteConfigResponse {\n entries?: RemoteConfigTemplate;\n state?: string;\n}\n\nconst FIS_AUTH_PREFIX = 'FIREBASE_INSTALLATIONS_AUTH';\n\nexport function getConfig(\n performanceController: PerformanceController,\n iid: string\n): Promise<void> {\n const config = getStoredConfig();\n if (config) {\n processConfig(config);\n return Promise.resolve();\n }\n\n return getRemoteConfig(performanceController, iid)\n .then(processConfig)\n .then(\n config => storeConfig(config),\n /** Do nothing for error, use defaults set in settings service. */\n () => {}\n );\n}\n\nfunction getStoredConfig(): RemoteConfigResponse | undefined {\n const localStorage = Api.getInstance().localStorage;\n if (!localStorage) {\n return;\n }\n const expiryString = localStorage.getItem(CONFIG_EXPIRY_LOCAL_STORAGE_KEY);\n if (!expiryString || !configValid(expiryString)) {\n return;\n }\n\n const configStringified = localStorage.getItem(CONFIG_LOCAL_STORAGE_KEY);\n if (!configStringified) {\n return;\n }\n try {\n const configResponse: RemoteConfigResponse = JSON.parse(configStringified);\n return configResponse;\n } catch {\n return;\n }\n}\n\nfunction storeConfig(config: RemoteConfigResponse | undefined): void {\n const localStorage = Api.getInstance().localStorage;\n if (!config || !localStorage) {\n return;\n }\n\n localStorage.setItem(CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config));\n localStorage.setItem(\n CONFIG_EXPIRY_LOCAL_STORAGE_KEY,\n String(\n Date.now() +\n SettingsService.getInstance().configTimeToLive * 60 * 60 * 1000\n )\n );\n}\n\nconst COULD_NOT_GET_CONFIG_MSG =\n 'Could not fetch config, will use default configs';\n\nfunction getRemoteConfig(\n performanceController: PerformanceController,\n iid: string\n): Promise<RemoteConfigResponse | undefined> {\n // Perf needs auth token only to retrieve remote config.\n return getAuthTokenPromise(performanceController.installations)\n .then(authToken => {\n const projectId = getProjectId(performanceController.app);\n const apiKey = getApiKey(performanceController.app);\n const configEndPoint = `https://firebaseremoteconfig.googleapis.com/v1/projects/${projectId}/namespaces/fireperf:fetch?key=${apiKey}`;\n const request = new Request(configEndPoint, {\n method: 'POST',\n headers: { Authorization: `${FIS_AUTH_PREFIX} ${authToken}` },\n /* eslint-disable camelcase */\n body: JSON.stringify({\n app_instance_id: iid,\n app_instance_id_token: authToken,\n app_id: getAppId(performanceController.app),\n app_version: SDK_VERSION,\n sdk_version: REMOTE_CONFIG_SDK_VERSION\n })\n /* eslint-enable camelcase */\n });\n return fetch(request).then(response => {\n if (response.ok) {\n return response.json() as RemoteConfigResponse;\n }\n // In case response is not ok. This will be caught by catch.\n throw ERROR_FACTORY.create(ErrorCode.RC_NOT_OK);\n });\n })\n .catch(() => {\n consoleLogger.info(COULD_NOT_GET_CONFIG_MSG);\n return undefined;\n });\n}\n\n/**\n * Processes config coming either from calling RC or from local storage.\n * This method only runs if call is successful or config in storage\n * is valid.\n */\nfunction processConfig(\n config?: RemoteConfigResponse\n): RemoteConfigResponse | undefined {\n if (!config) {\n return config;\n }\n const settingsServiceInstance = SettingsService.getInstance();\n const entries = config.entries || {};\n if (entries.fpr_enabled !== undefined) {\n // TODO: Change the assignment of loggingEnabled once the received type is\n // known.\n settingsServiceInstance.loggingEnabled =\n String(entries.fpr_enabled) === 'true';\n } else if (DEFAULT_CONFIGS.loggingEnabled !== undefined) {\n // Config retrieved successfully, but there is no fpr_enabled in template.\n // Use secondary configs value.\n settingsServiceInstance.loggingEnabled = DEFAULT_CONFIGS.loggingEnabled;\n }\n if (entries.fpr_log_source) {\n settingsServiceInstance.logSource = Number(entries.fpr_log_source);\n } else if (DEFAULT_CONFIGS.logSource) {\n settingsServiceInstance.logSource = DEFAULT_CONFIGS.logSource;\n }\n\n if (entries.fpr_log_endpoint_url) {\n settingsServiceInstance.logEndPointUrl = entries.fpr_log_endpoint_url;\n } else if (DEFAULT_CONFIGS.logEndPointUrl) {\n settingsServiceInstance.logEndPointUrl = DEFAULT_CONFIGS.logEndPointUrl;\n }\n\n // Key from Remote Config has to be non-empty string, otherwise use local value.\n if (entries.fpr_log_transport_key) {\n settingsServiceInstance.transportKey = entries.fpr_log_transport_key;\n } else if (DEFAULT_CONFIGS.transportKey) {\n settingsServiceInstance.transportKey = DEFAULT_CONFIGS.transportKey;\n }\n\n if (entries.fpr_vc_network_request_sampling_rate !== undefined) {\n settingsServiceInstance.networkRequestsSamplingRate = Number(\n entries.fpr_vc_network_request_sampling_rate\n );\n } else if (DEFAULT_CONFIGS.networkRequestsSamplingRate !== undefined) {\n settingsServiceInstance.networkRequestsSamplingRate =\n DEFAULT_CONFIGS.networkRequestsSamplingRate;\n }\n if (entries.fpr_vc_trace_sampling_rate !== undefined) {\n settingsServiceInstance.tracesSamplingRate = Number(\n entries.fpr_vc_trace_sampling_rate\n );\n } else if (DEFAULT_CONFIGS.tracesSamplingRate !== undefined) {\n settingsServiceInstance.tracesSamplingRate =\n DEFAULT_CONFIGS.tracesSamplingRate;\n }\n\n if (entries.fpr_log_max_flush_size) {\n settingsServiceInstance.logMaxFlushSize = Number(\n entries.fpr_log_max_flush_size\n );\n } else if (DEFAULT_CONFIGS.logMaxFlushSize) {\n settingsServiceInstance.logMaxFlushSize = DEFAULT_CONFIGS.logMaxFlushSize;\n }\n // Set the per session trace and network logging flags.\n settingsServiceInstance.logTraceAfterSampling = shouldLogAfterSampling(\n settingsServiceInstance.tracesSamplingRate\n );\n settingsServiceInstance.logNetworkAfterSampling = shouldLogAfterSampling(\n settingsServiceInstance.networkRequestsSamplingRate\n );\n return config;\n}\n\nfunction configValid(expiry: string): boolean {\n return Number(expiry) > Date.now();\n}\n\nfunction shouldLogAfterSampling(samplingRate: number): boolean {\n return Math.random() <= samplingRate;\n}\n","/**\n * @license\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 * http://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 { getIidPromise } from './iid_service';\nimport { getConfig } from './remote_config_service';\nimport { Api } from './api_service';\nimport { PerformanceController } from '../controllers/perf';\n\nconst enum InitializationStatus {\n notInitialized = 1,\n initializationPending,\n initialized\n}\n\nlet initializationStatus = InitializationStatus.notInitialized;\n\nlet initializationPromise: Promise<void> | undefined;\n\nexport function getInitializationPromise(\n performanceController: PerformanceController\n): Promise<void> {\n initializationStatus = InitializationStatus.initializationPending;\n\n initializationPromise =\n initializationPromise || initializePerf(performanceController);\n\n return initializationPromise;\n}\n\nexport function isPerfInitialized(): boolean {\n return initializationStatus === InitializationStatus.initialized;\n}\n\nfunction initializePerf(\n performanceController: PerformanceController\n): Promise<void> {\n return getDocumentReadyComplete()\n .then(() => getIidPromise(performanceController.installations))\n .then(iid => getConfig(performanceController, iid))\n .then(\n () => changeInitializationStatus(),\n () => changeInitializationStatus()\n );\n}\n\n/**\n * Returns a promise which resolves whenever the document readystate is complete or\n * immediately if it is called after page load complete.\n */\nfunction getDocumentReadyComplete(): Promise<void> {\n const document = Api.getInstance().document;\n return new Promise(resolve => {\n if (document && document.readyState !== 'complete') {\n const handler = (): void => {\n if (document.readyState === 'complete') {\n document.removeEventListener('readystatechange', handler);\n resolve();\n }\n };\n document.addEventListener('readystatechange', handler);\n } else {\n resolve();\n }\n });\n}\n\nfunction changeInitializationStatus(): void {\n initializationStatus = InitializationStatus.initialized;\n}\n","/**\n * @license\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 * http://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 { SettingsService } from './settings_service';\nimport { ERROR_FACTORY, ErrorCode } from '../utils/errors';\nimport { consoleLogger } from '../utils/console_logger';\n\nconst DEFAULT_SEND_INTERVAL_MS = 10 * 1000;\nconst INITIAL_SEND_TIME_DELAY_MS = 5.5 * 1000;\nconst MAX_EVENT_COUNT_PER_REQUEST = 1000;\nconst DEFAULT_REMAINING_TRIES = 3;\n\n// Most browsers have a max payload of 64KB for sendbeacon/keep alive payload.\nconst MAX_SEND_BEACON_PAYLOAD_SIZE = 65536;\n\nconst TEXT_ENCODER = new TextEncoder();\n\nlet remainingTries = DEFAULT_REMAINING_TRIES;\n\ninterface BatchEvent {\n message: string;\n eventTime: number;\n}\n\n/* eslint-disable camelcase */\n// CC/Fl accepted log format.\ninterface TransportBatchLogFormat {\n request_time_ms: string;\n client_info: ClientInfo;\n log_source: number;\n log_event: Log[];\n}\n\ninterface ClientInfo {\n client_type: number;\n js_client_info: {};\n}\n\ninterface Log {\n source_extension_json_proto3: string;\n event_time_ms: string;\n}\n/* eslint-enable camelcase */\n\nlet queue: BatchEvent[] = [];\n\nlet isTransportSetup: boolean = false;\n\nexport function setupTransportService(): void {\n if (!isTransportSetup) {\n processQueue(INITIAL_SEND_TIME_DELAY_MS);\n isTransportSetup = true;\n }\n}\n\n/**\n * Utilized by testing to clean up message queue and un-initialize transport service.\n */\nexport function resetTransportService(): void {\n isTransportSetup = false;\n queue = [];\n}\n\nfunction processQueue(timeOffset: number): void {\n setTimeout(() => {\n // If there is no remainingTries left, stop retrying.\n if (remainingTries <= 0) {\n return;\n }\n\n if (queue.length > 0) {\n dispatchQueueEvents();\n }\n processQueue(DEFAULT_SEND_INTERVAL_MS);\n }, timeOffset);\n}\n\nfunction dispatchQueueEvents(): void {\n // Extract events up to the maximum cap of single logRequest from top of \"official queue\".\n // The staged events will be used for current logRequest attempt, remaining events will be kept\n // for next attempt.\n const staged = queue.splice(0, MAX_EVENT_COUNT_PER_REQUEST);\n\n const data = buildPayload(staged);\n\n postToFlEndpoint(data)\n .then(() => {\n remainingTries = DEFAULT_REMAINING_TRIES;\n })\n .catch(() => {\n // If the request fails for some reason, add the events that were attempted\n // back to the primary queue to retry later.\n queue = [...staged, ...queue];\n remainingTries--;\n consoleLogger.info(`Tries left: ${remainingTries}.`);\n processQueue(DEFAULT_SEND_INTERVAL_MS);\n });\n}\n\nfunction buildPayload(events: BatchEvent[]): string {\n /* eslint-disable camelcase */\n // We will pass the JSON serialized event to the backend.\n const log_event: Log[] = events.map(evt => ({\n source_extension_json_proto3: evt.message,\n event_time_ms: String(evt.eventTime)\n }));\n\n const transportBatchLog: TransportBatchLogFormat = {\n request_time_ms: String(Date.now()),\n client_info: {\n client_type: 1, // 1 is JS\n js_client_info: {}\n },\n log_source: SettingsService.getInstance().logSource,\n log_event\n };\n /* eslint-enable camelcase */\n\n return JSON.stringify(transportBatchLog);\n}\n\n/** Sends to Firelog. Atempts to use sendBeacon otherwsise uses fetch. */\nfunction postToFlEndpoint(body: string): Promise<void | Response> {\n const flTransportFullUrl =\n SettingsService.getInstance().getFlTransportFullUrl();\n const size = TEXT_ENCODER.encode(body).length;\n\n if (\n size <= MAX_SEND_BEACON_PAYLOAD_SIZE &&\n navigator.sendBeacon &&\n navigator.sendBeacon(flTransportFullUrl, body)\n ) {\n return Promise.resolve();\n } else {\n return fetch(flTransportFullUrl, {\n method: 'POST',\n body\n });\n }\n}\n\nfunction addToQueue(evt: BatchEvent): void {\n if (!evt.eventTime || !evt.message) {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_CC_LOG);\n }\n // Add the new event to the queue.\n queue = [...queue, evt];\n}\n\n/** Log handler for cc service to send the performance logs to the server. */\nexport function transportHandler(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n serializer: (...args: any[]) => string\n): (...args: unknown[]) => void {\n return (...args) => {\n const message = serializer(...args);\n addToQueue({\n message,\n eventTime: Date.now()\n });\n };\n}\n\n/**\n * Force flush the queued events. Useful at page unload time to ensure all events are uploaded.\n * Flush will attempt to use sendBeacon to send events async and defaults back to fetch as soon as a\n * sendBeacon fails. Firefox\n */\nexport function flushQueuedEvents(): void {\n const flTransportFullUrl =\n SettingsService.getInstance().getFlTransportFullUrl();\n\n while (queue.length > 0) {\n // Send the last events first to prioritize page load traces\n const staged = queue.splice(-SettingsService.getInstance().logMaxFlushSize);\n const body = buildPayload(staged);\n\n if (\n navigator.sendBeacon &&\n navigator.sendBeacon(flTransportFullUrl, body)\n ) {\n continue;\n } else {\n queue = [...queue, ...staged];\n break;\n }\n }\n if (queue.length > 0) {\n const body = buildPayload(queue);\n fetch(flTransportFullUrl, {\n method: 'POST',\n body\n }).catch(() => {\n consoleLogger.info(`Failed flushing queued events.`);\n });\n }\n}\n","/**\n * @license\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 * http://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 { getIid } from './iid_service';\nimport { NetworkRequest } from '../resources/network_request';\nimport { Trace } from '../resources/trace';\nimport { Api } from './api_service';\nimport { SettingsService } from './settings_service';\nimport {\n getServiceWorkerStatus,\n getVisibilityState,\n getEffectiveConnectionType\n} from '../utils/attributes_utils';\nimport {\n isPerfInitialized,\n getInitializationPromise\n} from './initialization_service';\nimport { transportHandler, flushQueuedEvents } from './transport_service';\nimport { SDK_VERSION } from '../constants';\nimport { FirebaseApp } from '@firebase/app';\nimport { getAppId } from '../utils/app_utils';\n\nconst enum ResourceType {\n NetworkRequest,\n Trace\n}\n\n/* eslint-disable camelcase */\ninterface ApplicationInfo {\n google_app_id: string;\n app_instance_id?: string;\n web_app_info: WebAppInfo;\n application_process_state: number;\n}\n\ninterface WebAppInfo {\n sdk_version: string;\n page_url: string;\n service_worker_status: number;\n visibility_state: number;\n effective_connection_type: number;\n}\n\ninterface PerfNetworkLog {\n application_info: ApplicationInfo;\n network_request_metric: NetworkRequestMetric;\n}\n\ninterface PerfTraceLog {\n application_info: ApplicationInfo;\n trace_metric: TraceMetric;\n}\n\ninterface NetworkRequestMetric {\n url: string;\n http_method: number;\n http_response_code: number;\n response_payload_bytes?: number;\n client_start_time_us?: number;\n time_to_response_initiated_us?: number;\n time_to_response_completed_us?: number;\n}\n\ninterface TraceMetric {\n name: string;\n is_auto: boolean;\n client_start_time_us: number;\n duration_us: number;\n counters?: { [key: string]: number };\n custom_attributes?: { [key: string]: string };\n}\n\ninterface Logger {\n send: (\n resource: NetworkRequest | Trace,\n resourceType: ResourceType\n ) => void | undefined;\n flush: () => void;\n}\n\nlet logger: Logger;\n//\n// This method is not called before initialization.\nfunction sendLog(\n resource: NetworkRequest | Trace,\n resourceType: ResourceType\n): void {\n if (!logger) {\n logger = {\n send: transportHandler(serializer),\n flush: flushQueuedEvents\n };\n }\n logger.send(resource, resourceType);\n}\n\nexport function logTrace(trace: Trace): void {\n const settingsService = SettingsService.getInstance();\n // Do not log if trace is auto generated and instrumentation is disabled.\n if (!settingsService.instrumentationEnabled && trace.isAuto) {\n return;\n }\n // Do not log if trace is custom and data collection is disabled.\n if (!settingsService.dataCollectionEnabled && !trace.isAuto) {\n return;\n }\n // Do not log if required apis are not available.\n if (!Api.getInstance().requiredApisAvailable()) {\n return;\n }\n\n if (isPerfInitialized()) {\n sendTraceLog(trace);\n } else {\n // Custom traces can be used before the initialization but logging\n // should wait until after.\n getInitializationPromise(trace.performanceController).then(\n () => sendTraceLog(trace),\n () => sendTraceLog(trace)\n );\n }\n}\n\nexport function flushLogs(): void {\n if (logger) {\n logger.flush();\n }\n}\n\nfunction sendTraceLog(trace: Trace): void {\n if (!getIid()) {\n return;\n }\n\n const settingsService = SettingsService.getInstance();\n if (\n !settingsService.loggingEnabled ||\n !settingsService.logTraceAfterSampling\n ) {\n return;\n }\n\n sendLog(trace, ResourceType.Trace);\n}\n\nexport function logNetworkRequest(networkRequest: NetworkRequest): void {\n const settingsService = SettingsService.getInstance();\n // Do not log network requests if instrumentation is disabled.\n if (!settingsService.instrumentationEnabled) {\n return;\n }\n\n // Do not log the js sdk's call to transport service domain to avoid unnecessary cycle.\n // Need to blacklist both old and new endpoints to avoid migration gap.\n const networkRequestUrl = networkRequest.url;\n\n // Blacklist old log endpoint and new transport endpoint.\n // Because Performance SDK doesn't instrument requests sent from SDK itself.\n const logEndpointUrl = settingsService.logEndPointUrl.split('?')[0];\n const flEndpointUrl = settingsService.flTransportEndpointUrl.split('?')[0];\n if (\n networkRequestUrl === logEndpointUrl ||\n networkRequestUrl === flEndpointUrl\n ) {\n return;\n }\n\n if (\n !settingsService.loggingEnabled ||\n !settingsService.logNetworkAfterSampling\n ) {\n return;\n }\n\n sendLog(networkRequest, ResourceType.NetworkRequest);\n}\n\nfunction serializer(\n resource: NetworkRequest | Trace,\n resourceType: ResourceType\n): string {\n if (resourceType === ResourceType.NetworkRequest) {\n return serializeNetworkRequest(resource as NetworkRequest);\n }\n return serializeTrace(resource as Trace);\n}\n\nfunction serializeNetworkRequest(networkRequest: NetworkRequest): string {\n const networkRequestMetric: NetworkRequestMetric = {\n url: networkRequest.url,\n http_method: networkRequest.httpMethod || 0,\n http_response_code: 200,\n response_payload_bytes: networkRequest.responsePayloadBytes,\n client_start_time_us: networkRequest.startTimeUs,\n time_to_response_initiated_us: networkRequest.timeToResponseInitiatedUs,\n time_to_response_completed_us: networkRequest.timeToResponseCompletedUs\n };\n const perfMetric: PerfNetworkLog = {\n application_info: getApplicationInfo(\n networkRequest.performanceController.app\n ),\n network_request_metric: networkRequestMetric\n };\n return JSON.stringify(perfMetric);\n}\n\nfunction serializeTrace(trace: Trace): string {\n const traceMetric: TraceMetric = {\n name: trace.name,\n is_auto: trace.isAuto,\n client_start_time_us: trace.startTimeUs,\n duration_us: trace.durationUs\n };\n\n if (Object.keys(trace.counters).length !== 0) {\n traceMetric.counters = trace.counters;\n }\n const customAttributes = trace.getAttributes();\n if (Object.keys(customAttributes).length !== 0) {\n traceMetric.custom_attributes = customAttributes;\n }\n\n const perfMetric: PerfTraceLog = {\n application_info: getApplicationInfo(trace.performanceController.app),\n trace_metric: traceMetric\n };\n return JSON.stringify(perfMetric);\n}\n\nfunction getApplicationInfo(firebaseApp: FirebaseApp): ApplicationInfo {\n return {\n google_app_id: getAppId(firebaseApp),\n app_instance_id: getIid(),\n web_app_info: {\n sdk_version: SDK_VERSION,\n page_url: Api.getInstance().getUrl(),\n service_worker_status: getServiceWorkerStatus(),\n visibility_state: getVisibilityState(),\n effective_connection_type: getEffectiveConnectionType()\n },\n application_process_state: 0\n };\n}\n\n/* eslint-enable camelcase */\n","/**\n * @license\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 * http://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 { Api } from '../services/api_service';\nimport { logNetworkRequest } from '../services/perf_logger';\nimport { PerformanceController } from '../controllers/perf';\n\n// The order of values of this enum should not be changed.\nexport const enum HttpMethod {\n HTTP_METHOD_UNKNOWN = 0,\n GET = 1,\n PUT = 2,\n POST = 3,\n DELETE = 4,\n HEAD = 5,\n PATCH = 6,\n OPTIONS = 7,\n TRACE = 8,\n CONNECT = 9\n}\n\n// Durations are in microseconds.\nexport interface NetworkRequest {\n performanceController: PerformanceController;\n url: string;\n httpMethod?: HttpMethod;\n requestPayloadBytes?: number;\n responsePayloadBytes?: number;\n httpResponseCode?: number;\n responseContentType?: string;\n startTimeUs?: number;\n timeToRequestCompletedUs?: number;\n timeToResponseInitiatedUs?: number;\n timeToResponseCompletedUs?: number;\n}\n\nexport function createNetworkRequestEntry(\n performanceController: PerformanceController,\n entry: PerformanceEntry\n): void {\n const performanceEntry = entry as PerformanceResourceTiming;\n if (!performanceEntry || performanceEntry.responseStart === undefined) {\n return;\n }\n const timeOrigin = Api.getInstance().getTimeOrigin();\n const startTimeUs = Math.floor(\n (performanceEntry.startTime + timeOrigin) * 1000\n );\n const timeToResponseInitiatedUs = performanceEntry.responseStart\n ? Math.floor(\n (performanceEntry.responseStart - performanceEntry.startTime) * 1000\n )\n : undefined;\n const timeToResponseCompletedUs = Math.floor(\n (performanceEntry.responseEnd - performanceEntry.startTime) * 1000\n );\n // Remove the query params from logged network request url.\n const url = performanceEntry.name && performanceEntry.name.split('?')[0];\n const networkRequest: NetworkRequest = {\n performanceController,\n url,\n responsePayloadBytes: performanceEntry.transferSize,\n startTimeUs,\n timeToResponseInitiatedUs,\n timeToResponseCompletedUs\n };\n\n logNetworkRequest(networkRequest);\n}\n","/**\n * @license\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 * http://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 {\n FIRST_PAINT_COUNTER_NAME,\n FIRST_CONTENTFUL_PAINT_COUNTER_NAME,\n FIRST_INPUT_DELAY_COUNTER_NAME,\n OOB_TRACE_PAGE_LOAD_PREFIX,\n CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME,\n INTERACTION_TO_NEXT_PAINT_METRIC_NAME,\n LARGEST_CONTENTFUL_PAINT_METRIC_NAME\n} from '../constants';\nimport { consoleLogger } from '../utils/console_logger';\n\nconst MAX_METRIC_NAME_LENGTH = 100;\nconst RESERVED_AUTO_PREFIX = '_';\nconst oobMetrics = [\n FIRST_PAINT_COUNTER_NAME,\n FIRST_CONTENTFUL_PAINT_COUNTER_NAME,\n FIRST_INPUT_DELAY_COUNTER_NAME,\n LARGEST_CONTENTFUL_PAINT_METRIC_NAME,\n CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME,\n INTERACTION_TO_NEXT_PAINT_METRIC_NAME\n];\n\n/**\n * Returns true if the metric is custom and does not start with reserved prefix, or if\n * the metric is one of out of the box page load trace metrics.\n */\nexport function isValidMetricName(name: string, traceName?: string): boolean {\n if (name.length === 0 || name.length > MAX_METRIC_NAME_LENGTH) {\n return false;\n }\n return (\n (traceName &&\n traceName.startsWith(OOB_TRACE_PAGE_LOAD_PREFIX) &&\n oobMetrics.indexOf(name) > -1) ||\n !name.startsWith(RESERVED_AUTO_PREFIX)\n );\n}\n\n/**\n * Converts the provided value to an integer value to be used in case of a metric.\n * @param providedValue Provided number value of the metric that needs to be converted to an integer.\n *\n * @returns Converted integer number to be set for the metric.\n */\nexport function convertMetricValueToInteger(providedValue: number): number {\n const valueAsInteger: number = Math.floor(providedValue);\n if (valueAsInteger < providedValue) {\n consoleLogger.info(\n `Metric value should be an Integer, setting the value as : ${valueAsInteger}.`\n );\n }\n return valueAsInteger;\n}\n","/**\n * @license\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 * http://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 {\n TRACE_START_MARK_PREFIX,\n TRACE_STOP_MARK_PREFIX,\n TRACE_MEASURE_PREFIX,\n OOB_TRACE_PAGE_LOAD_PREFIX,\n FIRST_PAINT_COUNTER_NAME,\n FIRST_CONTENTFUL_PAINT_COUNTER_NAME,\n FIRST_INPUT_DELAY_COUNTER_NAME,\n LARGEST_CONTENTFUL_PAINT_METRIC_NAME,\n LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME,\n INTERACTION_TO_NEXT_PAINT_METRIC_NAME,\n INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME,\n CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME,\n CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME\n} from '../constants';\nimport { Api } from '../services/api_service';\nimport { logTrace, flushLogs } from '../services/perf_logger';\nimport { ERROR_FACTORY, ErrorCode } from '../utils/errors';\nimport {\n MAX_ATTRIBUTE_VALUE_LENGTH,\n isValidCustomAttributeName,\n isValidCustomAttributeValue\n} from '../utils/attributes_utils';\nimport {\n isValidMetricName,\n convertMetricValueToInteger\n} from '../utils/metric_utils';\nimport { PerformanceTrace } from '../public_types';\nimport { PerformanceController } from '../controllers/perf';\nimport { CoreVitalMetric, WebVitalMetrics } from './web_vitals';\n\nconst enum TraceState {\n UNINITIALIZED = 1,\n RUNNING,\n TERMINATED\n}\n\nexport class Trace implements PerformanceTrace {\n private state: TraceState = TraceState.UNINITIALIZED;\n startTimeUs!: number;\n durationUs!: number;\n private customAttributes: { [key: string]: string } = {};\n counters: { [counterName: string]: number } = {};\n private api = Api.getInstance();\n private randomId = Math.floor(Math.random() * 1000000);\n private traceStartMark!: string;\n private traceStopMark!: string;\n private traceMeasure!: string;\n\n /**\n * @param performanceController The performance controller running.\n * @param name The name of the trace.\n * @param isAuto If the trace is auto-instrumented.\n * @param traceMeasureName The name of the measure marker in user timing specification. This field\n * is only set when the trace is built for logging when the user directly uses the user timing\n * api (performance.mark and performance.measure).\n */\n constructor(\n readonly performanceController: PerformanceController,\n readonly name: string,\n readonly isAuto = false,\n traceMeasureName?: string\n ) {\n if (!this.isAuto) {\n this.traceStartMark = `${TRACE_START_MARK_PREFIX}-${this.randomId}-${this.name}`;\n this.traceStopMark = `${TRACE_STOP_MARK_PREFIX}-${this.randomId}-${this.name}`;\n this.traceMeasure =\n traceMeasureName ||\n `${TRACE_MEASURE_PREFIX}-${this.randomId}-${this.name}`;\n\n if (traceMeasureName) {\n // For the case of direct user timing traces, no start stop will happen. The measure object\n // is already available.\n this.calculateTraceMetrics();\n }\n }\n }\n\n /**\n * Starts a trace. The measurement of the duration starts at this point.\n */\n start(): void {\n if (this.state !== TraceState.UNINITIALIZED) {\n throw ERROR_FACTORY.create(ErrorCode.TRACE_STARTED_BEFORE, {\n traceName: this.name\n });\n }\n this.api.mark(this.traceStartMark);\n this.state = TraceState.RUNNING;\n }\n\n /**\n * Stops the trace. The measurement of the duration of the trace stops at this point and trace\n * is logged.\n */\n stop(): void {\n if (this.state !== TraceState.RUNNING) {\n throw ERROR_FACTORY.create(ErrorCode.TRACE_STOPPED_BEFORE, {\n traceName: this.name\n });\n }\n this.state = TraceState.TERMINATED;\n this.api.mark(this.traceStopMark);\n this.api.measure(\n this.traceMeasure,\n this.traceStartMark,\n this.traceStopMark\n );\n this.calculateTraceMetrics();\n logTrace(this);\n }\n\n /**\n * Records a trace with predetermined values. If this method is used a trace is created and logged\n * directly. No need to use start and stop methods.\n * @param startTime Trace start time since epoch in millisec\n * @param duration The duration of the trace in millisec\n * @param options An object which can optionally hold maps of custom metrics and custom attributes\n */\n record(\n startTime: number,\n duration: number,\n options?: {\n metrics?: { [key: string]: number };\n attributes?: { [key: string]: string };\n }\n ): void {\n if (startTime <= 0) {\n throw ERROR_FACTORY.create(ErrorCode.NONPOSITIVE_TRACE_START_TIME, {\n traceName: this.name\n });\n }\n if (duration <= 0) {\n throw ERROR_FACTORY.create(ErrorCode.NONPOSITIVE_TRACE_DURATION, {\n traceName: this.name\n });\n }\n\n this.durationUs = Math.floor(duration * 1000);\n this.startTimeUs = Math.floor(startTime * 1000);\n if (options && options.attributes) {\n this.customAttributes = { ...options.attributes };\n }\n if (options && options.metrics) {\n for (const metricName of Object.keys(options.metrics)) {\n if (!isNaN(Number(options.metrics[metricName]))) {\n this.counters[metricName] = Math.floor(\n Number(options.metrics[metricName])\n );\n }\n }\n }\n logTrace(this);\n }\n\n /**\n * Increments a custom metric by a certain number or 1 if number not specified. Will create a new\n * custom metric if one with the given name does not exist. The value will be floored down to an\n * integer.\n * @param counter Name of the custom metric\n * @param numAsInteger Increment by value\n */\n incrementMetric(counter: string, numAsInteger = 1): void {\n if (this.counters[counter] === undefined) {\n this.putMetric(counter, numAsInteger);\n } else {\n this.putMetric(counter, this.counters[counter] + numAsInteger);\n }\n }\n\n /**\n * Sets a custom metric to a specified value. Will create a new custom metric if one with the\n * given name does not exist. The value will be floored down to an integer.\n * @param counter Name of the custom metric\n * @param numAsInteger Set custom metric to this value\n */\n putMetric(counter: string, numAsInteger: number): void {\n if (isValidMetricName(counter, this.name)) {\n this.counters[counter] = convertMetricValueToInteger(numAsInteger ?? 0);\n } else {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_CUSTOM_METRIC_NAME, {\n customMetricName: counter\n });\n }\n }\n\n /**\n * Returns the value of the custom metric by that name. If a custom metric with that name does\n * not exist will return zero.\n * @param counter\n */\n getMetric(counter: string): number {\n return this.counters[counter] || 0;\n }\n\n /**\n * Sets a custom attribute of a trace to a certain value.\n * @param attr\n * @param value\n */\n putAttribute(attr: string, value: string): void {\n const isValidName = isValidCustomAttributeName(attr);\n const isValidValue = isValidCustomAttributeValue(value);\n if (isValidName && isValidValue) {\n this.customAttributes[attr] = value;\n return;\n }\n // Throw appropriate error when the attribute name or value is invalid.\n if (!isValidName) {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_ATTRIBUTE_NAME, {\n attributeName: attr\n });\n }\n if (!isValidValue) {\n throw ERROR_FACTORY.create(ErrorCode.INVALID_ATTRIBUTE_VALUE, {\n attributeValue: value\n });\n }\n }\n\n /**\n * Retrieves the value a custom attribute of a trace is set to.\n * @param attr\n */\n getAttribute(attr: string): string | undefined {\n return this.customAttributes[attr];\n }\n\n removeAttribute(attr: string): void {\n if (this.customAttributes[attr] === undefined) {\n return;\n }\n delete this.customAttributes[attr];\n }\n\n getAttributes(): { [key: string]: string } {\n return { ...this.customAttributes };\n }\n\n private setStartTime(startTime: number): void {\n this.startTimeUs = startTime;\n }\n\n private setDuration(duration: number): void {\n this.durationUs = duration;\n }\n\n /**\n * Calculates and assigns the duration and start time of the trace using the measure performance\n * entry.\n */\n private calculateTraceMetrics(): void {\n const perfMeasureEntries = this.api.getEntriesByName(this.traceMeasure);\n const perfMeasureEntry = perfMeasureEntries && perfMeasureEntries[0];\n if (perfMeasureEntry) {\n this.durationUs = Math.floor(perfMeasureEntry.duration * 1000);\n this.startTimeUs = Math.floor(\n (perfMeasureEntry.startTime + this.api.getTimeOrigin()) * 1000\n );\n }\n }\n\n /**\n * @param navigationTimings A single element array which contains the navigationTIming object of\n * the page load\n * @param paintTimings A array which contains paintTiming object of the page load\n * @param firstInputDelay First input delay in millisec\n */\n static createOobTrace(\n performanceController: PerformanceController,\n navigationTimings: PerformanceNavigationTiming[],\n paintTimings: PerformanceEntry[],\n webVitalMetrics: WebVitalMetrics,\n firstInputDelay?: number\n ): void {\n const route = Api.getInstance().getUrl();\n if (!route) {\n return;\n }\n const trace = new Trace(\n performanceController,\n OOB_TRACE_PAGE_LOAD_PREFIX + route,\n true\n );\n const timeOriginUs = Math.floor(Api.getInstance().getTimeOrigin() * 1000);\n trace.setStartTime(timeOriginUs);\n\n // navigationTimings includes only one element.\n if (navigationTimings && navigationTimings[0]) {\n trace.setDuration(Math.floor(navigationTimings[0].duration * 1000));\n trace.putMetric(\n 'domInteractive',\n Math.floor(navigationTimings[0].domInteractive * 1000)\n );\n trace.putMetric(\n 'domContentLoadedEventEnd',\n Math.floor(navigationTimings[0].domContentLoadedEventEnd * 1000)\n );\n trace.putMetric(\n 'loadEventEnd',\n Math.floor(navigationTimings[0].loadEventEnd * 1000)\n );\n }\n\n const FIRST_PAINT = 'first-paint';\n const FIRST_CONTENTFUL_PAINT = 'first-contentful-paint';\n if (paintTimings) {\n const firstPaint = paintTimings.find(\n paintObject => paintObject.name === FIRST_PAINT\n );\n if (firstPaint && firstPaint.startTime) {\n trace.putMetric(\n FIRST_PAINT_COUNTER_NAME,\n Math.floor(firstPaint.startTime * 1000)\n );\n }\n const firstContentfulPaint = paintTimings.find(\n paintObject => paintObject.name === FIRST_CONTENTFUL_PAINT\n );\n if (firstContentfulPaint && firstContentfulPaint.startTime) {\n trace.putMetric(\n FIRST_CONTENTFUL_PAINT_COUNTER_NAME,\n Math.floor(firstContentfulPaint.startTime * 1000)\n );\n }\n\n if (firstInputDelay) {\n trace.putMetric(\n FIRST_INPUT_DELAY_COUNTER_NAME,\n Math.floor(firstInputDelay * 1000)\n );\n }\n }\n\n this.addWebVitalMetric(\n trace,\n LARGEST_CONTENTFUL_PAINT_METRIC_NAME,\n LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME,\n webVitalMetrics.lcp\n );\n this.addWebVitalMetric(\n trace,\n CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME,\n CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME,\n webVitalMetrics.cls\n );\n this.addWebVitalMetric(\n trace,\n INTERACTION_TO_NEXT_PAINT_METRIC_NAME,\n INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME,\n webVitalMetrics.inp\n );\n\n // Page load logs are sent at unload time and so should be logged and\n // flushed immediately.\n logTrace(trace);\n flushLogs();\n }\n\n static addWebVitalMetric(\n trace: Trace,\n metricKey: string,\n attributeKey: string,\n metric?: CoreVitalMetric\n ): void {\n if (metric) {\n trace.putMetric(metricKey, Math.floor(metric.value * 1000));\n if (metric.elementAttribution) {\n if (metric.elementAttribution.length > MAX_ATTRIBUTE_VALUE_LENGTH) {\n trace.putAttribute(\n attributeKey,\n metric.elementAttribution.substring(0, MAX_ATTRIBUTE_VALUE_LENGTH)\n );\n } else {\n trace.putAttribute(attributeKey, metric.elementAttribution);\n }\n }\n }\n }\n\n static createUserTimingTrace(\n performanceController: PerformanceController,\n measureName: string\n ): void {\n const trace = new Trace(\n performanceController,\n measureName,\n false,\n measureName\n );\n logTrace(trace);\n }\n}\n","/**\n * @license\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 * http://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 {\n CLSMetricWithAttribution,\n INPMetricWithAttribution,\n LCPMetricWithAttribution\n} from 'web-vitals/attribution';\n\nimport { TRACE_MEASURE_PREFIX } from '../constants';\nimport { PerformanceController } from '../controllers/perf';\nimport { createNetworkRequestEntry } from '../resources/network_request';\nimport { Trace } from '../resources/trace';\nimport { WebVitalMetrics } from '../resources/web_vitals';\n\nimport { Api } from './api_service';\nimport { getIid } from './iid_service';\n\nlet webVitalMetrics: WebVitalMetrics = {};\nlet sentPageLoadTrace: boolean = false;\nlet firstInputDelay: number | undefined;\n\nexport function setupOobResources(\n performanceController: PerformanceController\n): void {\n // Do not initialize unless iid is available.\n if (!getIid()) {\n return;\n }\n // The load event might not have fired yet, and that means performance\n // navigation timing object has a duration of 0. The setup should run after\n // all current tasks in js queue.\n setTimeout(() => setupOobTraces(performanceController), 0);\n setTimeout(() => setupNetworkRequests(performanceController), 0);\n setTimeout(() => setupUserTimingTraces(performanceController), 0);\n}\n\nfunction setupNetworkRequests(\n performanceController: PerformanceController\n): void {\n const api = Api.getInstance();\n const resources = api.getEntriesByType('resource');\n for (const resource of resources) {\n createNetworkRequestEntry(performanceController, resource);\n }\n api.setupObserver('resource', entry =>\n createNetworkRequestEntry(performanceController, entry)\n );\n}\n\nfunction setupOobTraces(performanceController: PerformanceController): void {\n const api = Api.getInstance();\n // Better support for Safari\n if ('onpagehide' in window) {\n api.document.addEventListener('pagehide', () =>\n sendOobTrace(performanceController)\n );\n } else {\n api.document.addEventListener('unload', () =>\n sendOobTrace(performanceController)\n );\n }\n api.document.addEventListener('visibilitychange', () => {\n if (api.document.visibilityState === 'hidden') {\n sendOobTrace(performanceController);\n }\n });\n\n if (api.onFirstInputDelay) {\n api.onFirstInputDelay((fid: number) => {\n firstInputDelay = fid;\n });\n }\n\n api.onLCP((metric: LCPMetricWithAttribution) => {\n webVitalMetrics.lcp = {\n value: metric.value,\n elementAttribution: metric.attribution?.element\n };\n });\n api.onCLS((metric: CLSMetricWithAttribution) => {\n webVitalMetrics.cls = {\n value: metric.value,\n elementAttribution: metric.attribution?.largestShiftTarget\n };\n });\n api.onINP((metric: INPMetricWithAttribution) => {\n webVitalMetrics.inp = {\n value: metric.value,\n elementAttribution: metric.attribution?.interactionTarget\n };\n });\n}\n\nfunction setupUserTimingTraces(\n performanceController: PerformanceController\n): void {\n const api = Api.getInstance();\n // Run through the measure performance entries collected up to this point.\n const measures = api.getEntriesByType('measure');\n for (const measure of measures) {\n createUserTimingTrace(performanceController, measure);\n }\n // Setup an observer to capture the measures from this point on.\n api.setupObserver('measure', entry =>\n createUserTimingTrace(performanceController, entry)\n );\n}\n\nfunction createUserTimingTrace(\n performanceController: PerformanceController,\n measure: PerformanceEntry\n): void {\n const measureName = measure.name;\n // Do not create a trace, if the user timing marks and measures are created by\n // the sdk itself.\n if (\n measureName.substring(0, TRACE_MEASURE_PREFIX.length) ===\n TRACE_MEASURE_PREFIX\n ) {\n return;\n }\n Trace.createUserTimingTrace(performanceController, measureName);\n}\n\nfunction sendOobTrace(performanceController: PerformanceController): void {\n if (!sentPageLoadTrace) {\n sentPageLoadTrace = true;\n const api = Api.getInstance();\n const navigationTimings = api.getEntriesByType(\n 'navigation'\n ) as PerformanceNavigationTiming[];\n const paintTimings = api.getEntriesByType('paint');\n\n // On page unload web vitals may be updated so queue the oob trace creation\n // so that these updates have time to be included.\n setTimeout(() => {\n Trace.createOobTrace(\n performanceController,\n navigationTimings,\n paintTimings,\n webVitalMetrics,\n firstInputDelay\n );\n }, 0);\n }\n}\n\n/**\n * This service will only export the page load trace once. This function allows\n * resetting it for unit tests\n */\nexport function resetForUnitTests(): void {\n sentPageLoadTrace = false;\n firstInputDelay = undefined;\n webVitalMetrics = {};\n}\n","/**\n * @license\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 * http://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 { setupOobResources } from '../services/oob_resources_service';\nimport { SettingsService } from '../services/settings_service';\nimport { getInitializationPromise } from '../services/initialization_service';\nimport { Api } from '../services/api_service';\nimport { FirebaseApp } from '@firebase/app';\nimport { _FirebaseInstallationsInternal } from '@firebase/installations';\nimport { PerformanceSettings, FirebasePerformance } from '../public_types';\nimport { validateIndexedDBOpenable } from '@firebase/util';\nimport { setupTransportService } from '../services/transport_service';\nimport { consoleLogger } from '../utils/console_logger';\n\nexport class PerformanceController implements FirebasePerformance {\n private initialized: boolean = false;\n\n constructor(\n readonly app: FirebaseApp,\n readonly installations: _FirebaseInstallationsInternal\n ) {}\n\n /**\n * This method *must* be called internally as part of creating a\n * PerformanceController instance.\n *\n * Currently it's not possible to pass the settings object through the\n * constructor using Components, so this method exists to be called with the\n * desired settings, to ensure nothing is collected without the user's\n * consent.\n */\n _init(settings?: PerformanceSettings): void {\n if (this.initialized) {\n return;\n }\n\n if (settings?.dataCollectionEnabled !== undefined) {\n this.dataCollectionEnabled = settings.dataCollectionEnabled;\n }\n if (settings?.instrumentationEnabled !== undefined) {\n this.instrumentationEnabled = settings.instrumentationEnabled;\n }\n\n if (Api.getInstance().requiredApisAvailable()) {\n validateIndexedDBOpenable()\n .then(isAvailable => {\n if (isAvailable) {\n setupTransportService();\n getInitializationPromise(this).then(\n () => setupOobResources(this),\n () => setupOobResources(this)\n );\n this.initialized = true;\n }\n })\n .catch(error => {\n consoleLogger.info(`Environment doesn't support IndexedDB: ${error}`);\n });\n } else {\n consoleLogger.info(\n 'Firebase Performance cannot start if the browser does not support ' +\n '\"Fetch\" and \"Promise\", or cookies are disabled.'\n );\n }\n }\n\n set instrumentationEnabled(val: boolean) {\n SettingsService.getInstance().instrumentationEnabled = val;\n }\n get instrumentationEnabled(): boolean {\n return SettingsService.getInstance().instrumentationEnabled;\n }\n\n set dataCollectionEnabled(val: boolean) {\n SettingsService.getInstance().dataCollectionEnabled = val;\n }\n get dataCollectionEnabled(): boolean {\n return SettingsService.getInstance().dataCollectionEnabled;\n }\n}\n","/**\n * The Firebase Performance Monitoring Web SDK.\n * This SDK does not work in a Node.js environment.\n *\n * @packageDocumentation\n */\n\n/**\n * @license\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 * http://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 {\n FirebasePerformance,\n PerformanceSettings,\n PerformanceTrace\n} from './public_types';\nimport { ERROR_FACTORY, ErrorCode } from './utils/errors';\nimport { setupApi } from './services/api_service';\nimport { PerformanceController } from './controllers/perf';\nimport {\n _registerComponent,\n _getProvider,\n registerVersion,\n FirebaseApp,\n getApp\n} from '@firebase/app';\nimport {\n InstanceFactory,\n ComponentContainer,\n Component,\n ComponentType\n} from '@firebase/component';\nimport { name, version } from '../package.json';\nimport { Trace } from './resources/trace';\nimport '@firebase/installations';\nimport { deepEqual, getModularInstance } from '@firebase/util';\n\nconst DEFAULT_ENTRY_NAME = '[DEFAULT]';\n\n/**\n * Returns a {@link FirebasePerformance} instance for the given app.\n * @param app - The {@link @firebase/app#FirebaseApp} to use.\n * @public\n */\nexport function getPerformance(\n app: FirebaseApp = getApp()\n): FirebasePerformance {\n app = getModularInstance(app);\n const provider = _getProvider(app, 'performance');\n const perfInstance = provider.getImmediate() as PerformanceController;\n return perfInstance;\n}\n\n/**\n * Returns a {@link FirebasePerformance} instance for the given app. Can only be called once.\n * @param app - The {@link @firebase/app#FirebaseApp} to use.\n * @param settings - Optional settings for the {@link FirebasePerformance} instance.\n * @public\n */\nexport function initializePerformance(\n app: FirebaseApp,\n settings?: PerformanceSettings\n): FirebasePerformance {\n app = getModularInstance(app);\n const provider = _getProvider(app, 'performance');\n\n // throw if an instance was already created.\n // It could happen if initializePerformance() is called more than once, or getPerformance() is called first.\n if (provider.isInitialized()) {\n const existingInstance = provider.getImmediate();\n const initialSettings = provider.getOptions() as PerformanceSettings;\n if (deepEqual(initialSettings, settings ?? {})) {\n return existingInstance;\n } else {\n throw ERROR_FACTORY.create(ErrorCode.ALREADY_INITIALIZED);\n }\n }\n\n const perfInstance = provider.initialize({\n options: settings\n }) as PerformanceController;\n return perfInstance;\n}\n\n/**\n * Returns a new `PerformanceTrace` instance.\n * @param performance - The {@link FirebasePerformance} instance to use.\n * @param name - The name of the trace.\n * @public\n */\nexport function trace(\n performance: FirebasePerformance,\n name: string\n): PerformanceTrace {\n performance = getModularInstance(performance);\n return new Trace(performance as PerformanceController, name);\n}\n\nconst factory: InstanceFactory<'performance'> = (\n container: ComponentContainer,\n { options: settings }: { options?: PerformanceSettings }\n) => {\n // Dependencies\n const app = container.getProvider('app').getImmediate();\n const installations = container\n .getProvider('installations-internal')\n .getImmediate();\n\n if (app.name !== DEFAULT_ENTRY_NAME) {\n throw ERROR_FACTORY.create(ErrorCode.FB_NOT_DEFAULT);\n }\n if (typeof window === 'undefined') {\n throw ERROR_FACTORY.create(ErrorCode.NO_WINDOW);\n }\n setupApi(window);\n const perfInstance = new PerformanceController(app, installations);\n perfInstance._init(settings);\n\n return perfInstance;\n};\n\nfunction registerPerformance(): void {\n _registerComponent(\n new Component('performance', factory, ComponentType.PUBLIC)\n );\n registerVersion(name, version);\n // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\n}\n\nregisterPerformance();\n\nexport { FirebasePerformance, PerformanceSettings, PerformanceTrace };\n"],"names":["ErrorFactory","Logger","LogLevel","vitalsOnLCP","vitalsOnINP","vitalsOnCLS","areCookiesEnabled","isIndexedDBAvailable","validateIndexedDBOpenable","app","getApp","getModularInstance","_getProvider","deepEqual","_registerComponent","Component","registerVersion"],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAII,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC;AACO,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAC7D;AACO,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D;AACO,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAC5D;AACO,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAE1C,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAEvC,MAAM,mCAAmC,GAAG,MAAM,CAAC;AAEnD,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAE9C,MAAM,oCAAoC,GAAG,MAAM,CAAC;AACpD,MAAM,uCAAuC,GAAG,aAAa,CAAC;AAE9D,MAAM,qCAAqC,GAAG,MAAM,CAAC;AACrD,MAAM,wCAAw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AmC,CAC9C,SAA6B,EAC7B,EAAE,OAAO,EAAE,QAAQ,EAAqC,KACtD;;IAEF,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;IACxD,MAAM,aAAa,GAAG,SAAS;SAC5B,WAAW,CAAC,wBAAwB,CAAC;AACrC,SAAA,YAAY,EAAE,CAAC;AAElB,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB,EAAE;AACnC,QAAA,MAAM,aAAa,CAAC,MAAM,CAAA,gBAAA,gCAA0B,CAAC;KACtD;AACD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,QAAA,MAAM,aAAa,CAAC,MAAM,CAAA,WAAA,2BAAqB,CAAC;KACjD;IACD,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,YAAY,GAAG,IAAI,qBAAqB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;AACnE,IAAA,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAE7B,IAAA,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,SAAS,mBAAmB,GAAA;IAC1BG,sBAAkB,CAChB,IAAIC,mBAAS,CAAC,aAAa,EAAE,OAAO,EAAuB,QAAA,4BAAA,CAC5D,CAAC;AACF,IAAAC,mBAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;;AAE/B,IAAAA,mBAAe,CAAC,IAAI,EAAE,OAAO,EAAE,SAAkB,CAAC,CAAC;AACrD,CAAC;AAED,mBAAmB,EAAE;;;;;;"}
\ No newline at end of file diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/constants.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/constants.d.ts new file mode 100644 index 0000000..dbb2159 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/constants.d.ts @@ -0,0 +1,38 @@ +/** + * @license + * 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 + * + * http://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. + */ +export declare const SDK_VERSION: string; +/** The prefix for start User Timing marks used for creating Traces. */ +export declare const TRACE_START_MARK_PREFIX = "FB-PERF-TRACE-START"; +/** The prefix for stop User Timing marks used for creating Traces. */ +export declare const TRACE_STOP_MARK_PREFIX = "FB-PERF-TRACE-STOP"; +/** The prefix for User Timing measure used for creating Traces. */ +export declare const TRACE_MEASURE_PREFIX = "FB-PERF-TRACE-MEASURE"; +/** The prefix for out of the box page load Trace name. */ +export declare const OOB_TRACE_PAGE_LOAD_PREFIX = "_wt_"; +export declare const FIRST_PAINT_COUNTER_NAME = "_fp"; +export declare const FIRST_CONTENTFUL_PAINT_COUNTER_NAME = "_fcp"; +export declare const FIRST_INPUT_DELAY_COUNTER_NAME = "_fid"; +export declare const LARGEST_CONTENTFUL_PAINT_METRIC_NAME = "_lcp"; +export declare const LARGEST_CONTENTFUL_PAINT_ATTRIBUTE_NAME = "lcp_element"; +export declare const INTERACTION_TO_NEXT_PAINT_METRIC_NAME = "_inp"; +export declare const INTERACTION_TO_NEXT_PAINT_ATTRIBUTE_NAME = "inp_interactionTarget"; +export declare const CUMULATIVE_LAYOUT_SHIFT_METRIC_NAME = "_cls"; +export declare const CUMULATIVE_LAYOUT_SHIFT_ATTRIBUTE_NAME = "cls_largestShiftTarget"; +export declare const CONFIG_LOCAL_STORAGE_KEY = "@firebase/performance/config"; +export declare const CONFIG_EXPIRY_LOCAL_STORAGE_KEY = "@firebase/performance/configexpire"; +export declare const SERVICE = "performance"; +export declare const SERVICE_NAME = "Performance"; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/controllers/perf.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/controllers/perf.d.ts new file mode 100644 index 0000000..bfb45a5 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/controllers/perf.d.ts @@ -0,0 +1,39 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { FirebaseApp } from '@firebase/app'; +import { _FirebaseInstallationsInternal } from '@firebase/installations'; +import { PerformanceSettings, FirebasePerformance } from '../public_types'; +export declare class PerformanceController implements FirebasePerformance { + readonly app: FirebaseApp; + readonly installations: _FirebaseInstallationsInternal; + private initialized; + constructor(app: FirebaseApp, installations: _FirebaseInstallationsInternal); + /** + * This method *must* be called internally as part of creating a + * PerformanceController instance. + * + * Currently it's not possible to pass the settings object through the + * constructor using Components, so this method exists to be called with the + * desired settings, to ensure nothing is collected without the user's + * consent. + */ + _init(settings?: PerformanceSettings): void; + set instrumentationEnabled(val: boolean); + get instrumentationEnabled(): boolean; + set dataCollectionEnabled(val: boolean); + get dataCollectionEnabled(): boolean; +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/index.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/index.d.ts new file mode 100644 index 0000000..eb2968e --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/index.d.ts @@ -0,0 +1,46 @@ +/** + * The Firebase Performance Monitoring Web SDK. + * This SDK does not work in a Node.js environment. + * + * @packageDocumentation + */ +/** + * @license + * 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 + * + * http://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. + */ +import { FirebasePerformance, PerformanceSettings, PerformanceTrace } from './public_types'; +import { FirebaseApp } from '@firebase/app'; +import '@firebase/installations'; +/** + * Returns a {@link FirebasePerformance} instance for the given app. + * @param app - The {@link @firebase/app#FirebaseApp} to use. + * @public + */ +export declare function getPerformance(app?: FirebaseApp): FirebasePerformance; +/** + * Returns a {@link FirebasePerformance} instance for the given app. Can only be called once. + * @param app - The {@link @firebase/app#FirebaseApp} to use. + * @param settings - Optional settings for the {@link FirebasePerformance} instance. + * @public + */ +export declare function initializePerformance(app: FirebaseApp, settings?: PerformanceSettings): FirebasePerformance; +/** + * Returns a new `PerformanceTrace` instance. + * @param performance - The {@link FirebasePerformance} instance to use. + * @param name - The name of the trace. + * @public + */ +export declare function trace(performance: FirebasePerformance, name: string): PerformanceTrace; +export { FirebasePerformance, PerformanceSettings, PerformanceTrace }; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/public_types.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/public_types.d.ts new file mode 100644 index 0000000..5f37697 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/public_types.d.ts @@ -0,0 +1,136 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { FirebaseApp } from '@firebase/app'; +/** + * Defines configuration options for the Performance Monitoring SDK. + * + * @public + */ +export interface PerformanceSettings { + /** Whether to collect custom events. */ + dataCollectionEnabled?: boolean; + /** Whether to collect out of the box events. */ + instrumentationEnabled?: boolean; +} +/** + * The Firebase Performance Monitoring service interface. + * + * @public + */ +export interface FirebasePerformance { + /** + * The {@link @firebase/app#FirebaseApp} this `FirebasePerformance` instance is associated with. + */ + app: FirebaseApp; + /** + * Controls the logging of automatic traces and HTTP/S network monitoring. + */ + instrumentationEnabled: boolean; + /** + * Controls the logging of custom traces. + */ + dataCollectionEnabled: boolean; +} +/** + * The interface representing a `Trace`. + * + * @public + */ +export interface PerformanceTrace { + /** + * Starts the timing for the trace instance. + */ + start(): void; + /** + * Stops the timing of the trace instance and logs the data of the instance. + */ + stop(): void; + /** + * Records a trace from given parameters. This provides a direct way to use trace without a need to + * start/stop. This is useful for use cases in which the trace cannot directly be used + * (e.g. if the duration was captured before the Performance SDK was loaded). + * + * @param startTime - trace start time since epoch in millisec. + * @param duration - The duration of the trace in millisec. + * @param options - An object which can optionally hold maps of custom metrics and + * custom attributes. + */ + record(startTime: number, duration: number, options?: { + metrics?: { + [key: string]: number; + }; + attributes?: { + [key: string]: string; + }; + }): void; + /** + * Adds to the value of a custom metric. If a custom metric with the provided name does not + * exist, it creates one with that name and the value equal to the given number. The value will be floored down to an + * integer. + * + * @param metricName - The name of the custom metric. + * @param num - The number to be added to the value of the custom metric. If not provided, it + * uses a default value of one. + */ + incrementMetric(metricName: string, num?: number): void; + /** + * Sets the value of the specified custom metric to the given number regardless of whether + * a metric with that name already exists on the trace instance or not. The value will be floored down to an + * integer. + * + * @param metricName - Name of the custom metric. + * @param num - Value to of the custom metric. + */ + putMetric(metricName: string, num: number): void; + /** + * Returns the value of the custom metric by that name. If a custom metric with that name does + * not exist will return zero. + * + * @param metricName - Name of the custom metric. + */ + getMetric(metricName: string): number; + /** + * Set a custom attribute of a trace to a certain value. + * + * @param attr - Name of the custom attribute. + * @param value - Value of the custom attribute. + */ + putAttribute(attr: string, value: string): void; + /** + * Retrieves the value which a custom attribute is set to. + * + * @param attr - Name of the custom attribute. + */ + getAttribute(attr: string): string | undefined; + /** + * Removes the specified custom attribute from a trace instance. + * + * @param attr - Name of the custom attribute. + */ + removeAttribute(attr: string): void; + /** + * Returns a map of all custom attributes of a trace instance. + */ + getAttributes(): { + [key: string]: string; + }; +} +declare module '@firebase/component' { + interface NameServiceMapping { + 'performance': FirebasePerformance; + } +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/resources/network_request.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/resources/network_request.d.ts new file mode 100644 index 0000000..cf7f15d --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/resources/network_request.d.ts @@ -0,0 +1,43 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceController } from '../controllers/perf'; +export declare const enum HttpMethod { + HTTP_METHOD_UNKNOWN = 0, + GET = 1, + PUT = 2, + POST = 3, + DELETE = 4, + HEAD = 5, + PATCH = 6, + OPTIONS = 7, + TRACE = 8, + CONNECT = 9 +} +export interface NetworkRequest { + performanceController: PerformanceController; + url: string; + httpMethod?: HttpMethod; + requestPayloadBytes?: number; + responsePayloadBytes?: number; + httpResponseCode?: number; + responseContentType?: string; + startTimeUs?: number; + timeToRequestCompletedUs?: number; + timeToResponseInitiatedUs?: number; + timeToResponseCompletedUs?: number; +} +export declare function createNetworkRequestEntry(performanceController: PerformanceController, entry: PerformanceEntry): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/resources/trace.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/resources/trace.d.ts new file mode 100644 index 0000000..65d9ca4 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/resources/trace.d.ts @@ -0,0 +1,121 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceTrace } from '../public_types'; +import { PerformanceController } from '../controllers/perf'; +import { CoreVitalMetric, WebVitalMetrics } from './web_vitals'; +export declare class Trace implements PerformanceTrace { + readonly performanceController: PerformanceController; + readonly name: string; + readonly isAuto: boolean; + private state; + startTimeUs: number; + durationUs: number; + private customAttributes; + counters: { + [counterName: string]: number; + }; + private api; + private randomId; + private traceStartMark; + private traceStopMark; + private traceMeasure; + /** + * @param performanceController The performance controller running. + * @param name The name of the trace. + * @param isAuto If the trace is auto-instrumented. + * @param traceMeasureName The name of the measure marker in user timing specification. This field + * is only set when the trace is built for logging when the user directly uses the user timing + * api (performance.mark and performance.measure). + */ + constructor(performanceController: PerformanceController, name: string, isAuto?: boolean, traceMeasureName?: string); + /** + * Starts a trace. The measurement of the duration starts at this point. + */ + start(): void; + /** + * Stops the trace. The measurement of the duration of the trace stops at this point and trace + * is logged. + */ + stop(): void; + /** + * Records a trace with predetermined values. If this method is used a trace is created and logged + * directly. No need to use start and stop methods. + * @param startTime Trace start time since epoch in millisec + * @param duration The duration of the trace in millisec + * @param options An object which can optionally hold maps of custom metrics and custom attributes + */ + record(startTime: number, duration: number, options?: { + metrics?: { + [key: string]: number; + }; + attributes?: { + [key: string]: string; + }; + }): void; + /** + * Increments a custom metric by a certain number or 1 if number not specified. Will create a new + * custom metric if one with the given name does not exist. The value will be floored down to an + * integer. + * @param counter Name of the custom metric + * @param numAsInteger Increment by value + */ + incrementMetric(counter: string, numAsInteger?: number): void; + /** + * Sets a custom metric to a specified value. Will create a new custom metric if one with the + * given name does not exist. The value will be floored down to an integer. + * @param counter Name of the custom metric + * @param numAsInteger Set custom metric to this value + */ + putMetric(counter: string, numAsInteger: number): void; + /** + * Returns the value of the custom metric by that name. If a custom metric with that name does + * not exist will return zero. + * @param counter + */ + getMetric(counter: string): number; + /** + * Sets a custom attribute of a trace to a certain value. + * @param attr + * @param value + */ + putAttribute(attr: string, value: string): void; + /** + * Retrieves the value a custom attribute of a trace is set to. + * @param attr + */ + getAttribute(attr: string): string | undefined; + removeAttribute(attr: string): void; + getAttributes(): { + [key: string]: string; + }; + private setStartTime; + private setDuration; + /** + * Calculates and assigns the duration and start time of the trace using the measure performance + * entry. + */ + private calculateTraceMetrics; + /** + * @param navigationTimings A single element array which contains the navigationTIming object of + * the page load + * @param paintTimings A array which contains paintTiming object of the page load + * @param firstInputDelay First input delay in millisec + */ + static createOobTrace(performanceController: PerformanceController, navigationTimings: PerformanceNavigationTiming[], paintTimings: PerformanceEntry[], webVitalMetrics: WebVitalMetrics, firstInputDelay?: number): void; + static addWebVitalMetric(trace: Trace, metricKey: string, attributeKey: string, metric?: CoreVitalMetric): void; + static createUserTimingTrace(performanceController: PerformanceController, measureName: string): void; +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/resources/web_vitals.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/resources/web_vitals.d.ts new file mode 100644 index 0000000..1d9f7a1 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/resources/web_vitals.d.ts @@ -0,0 +1,25 @@ +/** + * @license + * Copyright 2024 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 + * + * http://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. + */ +export interface CoreVitalMetric { + value: number; + elementAttribution?: string; +} +export interface WebVitalMetrics { + cls?: CoreVitalMetric; + inp?: CoreVitalMetric; + lcp?: CoreVitalMetric; +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/services/api_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/services/api_service.d.ts new file mode 100644 index 0000000..e576c29 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/services/api_service.d.ts @@ -0,0 +1,55 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { CLSMetricWithAttribution, INPMetricWithAttribution, LCPMetricWithAttribution } from 'web-vitals/attribution'; +declare global { + interface Window { + PerformanceObserver: typeof PerformanceObserver; + perfMetrics?: { + onFirstInputDelay(fn: (fid: number) => void): void; + }; + } +} +export type EntryType = 'mark' | 'measure' | 'paint' | 'resource' | 'frame' | 'navigation'; +/** + * This class holds a reference to various browser related objects injected by + * set methods. + */ +export declare class Api { + readonly window?: Window | undefined; + private readonly performance; + /** PerformanceObserver constructor function. */ + private readonly PerformanceObserver; + private readonly windowLocation; + readonly onFirstInputDelay?: (fn: (fid: number) => void) => void; + readonly onLCP: (fn: (metric: LCPMetricWithAttribution) => void) => void; + readonly onINP: (fn: (metric: INPMetricWithAttribution) => void) => void; + readonly onCLS: (fn: (metric: CLSMetricWithAttribution) => void) => void; + readonly localStorage?: Storage; + readonly document: Document; + readonly navigator: Navigator; + constructor(window?: Window | undefined); + getUrl(): string; + mark(name: string): void; + measure(measureName: string, mark1: string, mark2: string): void; + getEntriesByType(type: EntryType): PerformanceEntry[]; + getEntriesByName(name: string): PerformanceEntry[]; + getTimeOrigin(): number; + requiredApisAvailable(): boolean; + setupObserver(entryType: EntryType, callback: (entry: PerformanceEntry) => void): void; + static getInstance(): Api; +} +export declare function setupApi(window: Window): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/services/iid_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/services/iid_service.d.ts new file mode 100644 index 0000000..c3387d7 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/services/iid_service.d.ts @@ -0,0 +1,21 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { _FirebaseInstallationsInternal } from '@firebase/installations'; +export declare function getIidPromise(installationsService: _FirebaseInstallationsInternal): Promise<string>; +export declare function getIid(): string | undefined; +export declare function getAuthTokenPromise(installationsService: _FirebaseInstallationsInternal): Promise<string>; +export declare function getAuthenticationToken(): string | undefined; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/services/initialization_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/services/initialization_service.d.ts new file mode 100644 index 0000000..3e16a52 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/services/initialization_service.d.ts @@ -0,0 +1,19 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceController } from '../controllers/perf'; +export declare function getInitializationPromise(performanceController: PerformanceController): Promise<void>; +export declare function isPerfInitialized(): boolean; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/services/oob_resources_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/services/oob_resources_service.d.ts new file mode 100644 index 0000000..2109a59 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/services/oob_resources_service.d.ts @@ -0,0 +1,23 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceController } from '../controllers/perf'; +export declare function setupOobResources(performanceController: PerformanceController): void; +/** + * This service will only export the page load trace once. This function allows + * resetting it for unit tests + */ +export declare function resetForUnitTests(): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/services/perf_logger.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/services/perf_logger.d.ts new file mode 100644 index 0000000..f9dc083 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/services/perf_logger.d.ts @@ -0,0 +1,21 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { NetworkRequest } from '../resources/network_request'; +import { Trace } from '../resources/trace'; +export declare function logTrace(trace: Trace): void; +export declare function flushLogs(): void; +export declare function logNetworkRequest(networkRequest: NetworkRequest): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/services/remote_config_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/services/remote_config_service.d.ts new file mode 100644 index 0000000..22aeb58 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/services/remote_config_service.d.ts @@ -0,0 +1,18 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { PerformanceController } from '../controllers/perf'; +export declare function getConfig(performanceController: PerformanceController, iid: string): Promise<void>; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/services/settings_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/services/settings_service.d.ts new file mode 100644 index 0000000..c343189 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/services/settings_service.d.ts @@ -0,0 +1,33 @@ +/** + * @license + * Copyright 2019 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 + * + * http://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. + */ +export declare class SettingsService { + instrumentationEnabled: boolean; + dataCollectionEnabled: boolean; + loggingEnabled: boolean; + tracesSamplingRate: number; + networkRequestsSamplingRate: number; + logEndPointUrl: string; + flTransportEndpointUrl: string; + transportKey: string; + logSource: number; + logTraceAfterSampling: boolean; + logNetworkAfterSampling: boolean; + configTimeToLive: number; + logMaxFlushSize: number; + getFlTransportFullUrl(): string; + static getInstance(): SettingsService; +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/services/transport_service.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/services/transport_service.d.ts new file mode 100644 index 0000000..d204a91 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/services/transport_service.d.ts @@ -0,0 +1,29 @@ +/** + * @license + * 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 + * + * http://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. + */ +export declare function setupTransportService(): void; +/** + * Utilized by testing to clean up message queue and un-initialize transport service. + */ +export declare function resetTransportService(): void; +/** Log handler for cc service to send the performance logs to the server. */ +export declare function transportHandler(serializer: (...args: any[]) => string): (...args: unknown[]) => void; +/** + * Force flush the queued events. Useful at page unload time to ensure all events are uploaded. + * Flush will attempt to use sendBeacon to send events async and defaults back to fetch as soon as a + * sendBeacon fails. Firefox + */ +export declare function flushQueuedEvents(): void; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/tsdoc-metadata.json b/frontend-old/node_modules/@firebase/performance/dist/src/tsdoc-metadata.json new file mode 100644 index 0000000..6af1f6a --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/tsdoc-metadata.json @@ -0,0 +1,11 @@ +// This file is read by tools that parse documentation comments conforming to the TSDoc standard. +// It should be published with your NPM package. It should not be tracked by Git. +{ + "tsdocVersion": "0.12", + "toolPackages": [ + { + "packageName": "@microsoft/api-extractor", + "packageVersion": "0.1.2" + } + ] +} diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/utils/app_utils.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/utils/app_utils.d.ts new file mode 100644 index 0000000..3c86d5a --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/utils/app_utils.d.ts @@ -0,0 +1,20 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { FirebaseApp } from '@firebase/app'; +export declare function getAppId(firebaseApp: FirebaseApp): string; +export declare function getProjectId(firebaseApp: FirebaseApp): string; +export declare function getApiKey(firebaseApp: FirebaseApp): string; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/utils/attributes_utils.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/utils/attributes_utils.d.ts new file mode 100644 index 0000000..bbdcd52 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/utils/attributes_utils.d.ts @@ -0,0 +1,41 @@ +/** + * @license + * 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 + * + * http://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. + */ +declare const enum ServiceWorkerStatus { + UNKNOWN = 0, + UNSUPPORTED = 1, + CONTROLLED = 2, + UNCONTROLLED = 3 +} +export declare enum VisibilityState { + UNKNOWN = 0, + VISIBLE = 1, + HIDDEN = 2 +} +declare const enum EffectiveConnectionType { + UNKNOWN = 0, + CONNECTION_SLOW_2G = 1, + CONNECTION_2G = 2, + CONNECTION_3G = 3, + CONNECTION_4G = 4 +} +export declare const MAX_ATTRIBUTE_VALUE_LENGTH = 100; +export declare function getServiceWorkerStatus(): ServiceWorkerStatus; +export declare function getVisibilityState(): VisibilityState; +export declare function getEffectiveConnectionType(): EffectiveConnectionType; +export declare function isValidCustomAttributeName(name: string): boolean; +export declare function isValidCustomAttributeValue(value: string): boolean; +export {}; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/utils/console_logger.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/utils/console_logger.d.ts new file mode 100644 index 0000000..3049fb6 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/utils/console_logger.d.ts @@ -0,0 +1,18 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { Logger } from '@firebase/logger'; +export declare const consoleLogger: Logger; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/utils/errors.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/utils/errors.d.ts new file mode 100644 index 0000000..8db0240 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/utils/errors.d.ts @@ -0,0 +1,60 @@ +/** + * @license + * 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 + * + * http://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. + */ +import { ErrorFactory } from '@firebase/util'; +export declare const enum ErrorCode { + TRACE_STARTED_BEFORE = "trace started", + TRACE_STOPPED_BEFORE = "trace stopped", + NONPOSITIVE_TRACE_START_TIME = "nonpositive trace startTime", + NONPOSITIVE_TRACE_DURATION = "nonpositive trace duration", + NO_WINDOW = "no window", + NO_APP_ID = "no app id", + NO_PROJECT_ID = "no project id", + NO_API_KEY = "no api key", + INVALID_CC_LOG = "invalid cc log", + FB_NOT_DEFAULT = "FB not default", + RC_NOT_OK = "RC response not ok", + INVALID_ATTRIBUTE_NAME = "invalid attribute name", + INVALID_ATTRIBUTE_VALUE = "invalid attribute value", + INVALID_CUSTOM_METRIC_NAME = "invalid custom metric name", + INVALID_STRING_MERGER_PARAMETER = "invalid String merger input", + ALREADY_INITIALIZED = "already initialized" +} +interface ErrorParams { + [ErrorCode.TRACE_STARTED_BEFORE]: { + traceName: string; + }; + [ErrorCode.TRACE_STOPPED_BEFORE]: { + traceName: string; + }; + [ErrorCode.NONPOSITIVE_TRACE_START_TIME]: { + traceName: string; + }; + [ErrorCode.NONPOSITIVE_TRACE_DURATION]: { + traceName: string; + }; + [ErrorCode.INVALID_ATTRIBUTE_NAME]: { + attributeName: string; + }; + [ErrorCode.INVALID_ATTRIBUTE_VALUE]: { + attributeValue: string; + }; + [ErrorCode.INVALID_CUSTOM_METRIC_NAME]: { + customMetricName: string; + }; +} +export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>; +export {}; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/utils/metric_utils.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/utils/metric_utils.d.ts new file mode 100644 index 0000000..9639f76 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/utils/metric_utils.d.ts @@ -0,0 +1,28 @@ +/** + * @license + * 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 + * + * http://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 true if the metric is custom and does not start with reserved prefix, or if + * the metric is one of out of the box page load trace metrics. + */ +export declare function isValidMetricName(name: string, traceName?: string): boolean; +/** + * Converts the provided value to an integer value to be used in case of a metric. + * @param providedValue Provided number value of the metric that needs to be converted to an integer. + * + * @returns Converted integer number to be set for the metric. + */ +export declare function convertMetricValueToInteger(providedValue: number): number; diff --git a/frontend-old/node_modules/@firebase/performance/dist/src/utils/string_merger.d.ts b/frontend-old/node_modules/@firebase/performance/dist/src/utils/string_merger.d.ts new file mode 100644 index 0000000..4bdb19e --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/src/utils/string_merger.d.ts @@ -0,0 +1,17 @@ +/** + * @license + * 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 + * + * http://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. + */ +export declare function mergeStrings(part1: string, part2: string): string; diff --git a/frontend-old/node_modules/@firebase/performance/dist/test/setup.d.ts b/frontend-old/node_modules/@firebase/performance/dist/test/setup.d.ts new file mode 100644 index 0000000..731d2d9 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/dist/test/setup.d.ts @@ -0,0 +1,17 @@ +/** + * @license + * 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 + * + * http://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. + */ +export {}; diff --git a/frontend-old/node_modules/@firebase/performance/package.json b/frontend-old/node_modules/@firebase/performance/package.json new file mode 100644 index 0000000..20a1573 --- /dev/null +++ b/frontend-old/node_modules/@firebase/performance/package.json @@ -0,0 +1,71 @@ +{ + "name": "@firebase/performance", + "version": "0.7.9", + "description": "Firebase performance for web", + "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", + "main": "dist/index.cjs.js", + "browser": "dist/esm/index.esm.js", + "module": "dist/esm/index.esm.js", + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist" + ], + "scripts": { + "lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", + "lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", + "build": "rollup -c && yarn api-report", + "build:deps": "lerna run --scope @firebase/performance --include-dependencies build", + "build:release": "yarn build", + "dev": "rollup -c -w", + "test": "run-p --npm-path npm lint test:browser", + "test:ci": "node ../../scripts/run_tests_in_ci.js -s test:browser", + "test:browser": "karma start", + "test:debug": "karma start --browsers=Chrome --auto-watch", + "trusted-type-check": "tsec -p tsconfig.json --noEmit", + "prettier": "prettier --write '{src,test}/**/*.{js,ts}'", + "api-report": "api-extractor run --local --verbose", + "doc": "api-documenter markdown --input temp --output docs", + "build:doc": "yarn build && yarn doc" + }, + "peerDependencies": { + "@firebase/app": "0.x" + }, + "dependencies": { + "@firebase/logger": "0.5.0", + "@firebase/installations": "0.6.19", + "@firebase/util": "1.13.0", + "@firebase/component": "0.7.0", + "tslib": "^2.1.0", + "web-vitals": "^4.2.4" + }, + "license": "Apache-2.0", + "devDependencies": { + "@firebase/app": "0.14.1", + "rollup": "2.79.2", + "@rollup/plugin-json": "6.1.0", + "rollup-plugin-typescript2": "0.36.0", + "typescript": "5.5.4" + }, + "repository": { + "directory": "packages/performance", + "type": "git", + "url": "git+https://github.com/firebase/firebase-js-sdk.git" + }, + "bugs": { + "url": "https://github.com/firebase/firebase-js-sdk/issues" + }, + "typings": "dist/src/index.d.ts", + "nyc": { + "extension": [ + ".ts" + ], + "reportDir": "./coverage/node" + } +} |
