@depup/firebase__performance 0.7.10-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +32 -0
  2. package/changes.json +14 -0
  3. package/dist/esm/index.esm.js +1614 -0
  4. package/dist/esm/index.esm.js.map +1 -0
  5. package/dist/esm/package.json +1 -0
  6. package/dist/esm/src/constants.d.ts +38 -0
  7. package/dist/esm/src/controllers/perf.d.ts +39 -0
  8. package/dist/esm/src/index.d.ts +46 -0
  9. package/dist/esm/src/public_types.d.ts +136 -0
  10. package/dist/esm/src/resources/network_request.d.ts +43 -0
  11. package/dist/esm/src/resources/trace.d.ts +121 -0
  12. package/dist/esm/src/resources/web_vitals.d.ts +25 -0
  13. package/dist/esm/src/services/api_service.d.ts +55 -0
  14. package/dist/esm/src/services/iid_service.d.ts +21 -0
  15. package/dist/esm/src/services/initialization_service.d.ts +19 -0
  16. package/dist/esm/src/services/oob_resources_service.d.ts +23 -0
  17. package/dist/esm/src/services/perf_logger.d.ts +21 -0
  18. package/dist/esm/src/services/remote_config_service.d.ts +18 -0
  19. package/dist/esm/src/services/settings_service.d.ts +33 -0
  20. package/dist/esm/src/services/transport_service.d.ts +29 -0
  21. package/dist/esm/src/utils/app_utils.d.ts +20 -0
  22. package/dist/esm/src/utils/attributes_utils.d.ts +41 -0
  23. package/dist/esm/src/utils/console_logger.d.ts +18 -0
  24. package/dist/esm/src/utils/errors.d.ts +60 -0
  25. package/dist/esm/src/utils/metric_utils.d.ts +28 -0
  26. package/dist/esm/src/utils/string_merger.d.ts +17 -0
  27. package/dist/esm/test/setup.d.ts +17 -0
  28. package/dist/index.cjs.js +1620 -0
  29. package/dist/index.cjs.js.map +1 -0
  30. package/dist/src/constants.d.ts +38 -0
  31. package/dist/src/controllers/perf.d.ts +39 -0
  32. package/dist/src/index.d.ts +46 -0
  33. package/dist/src/public_types.d.ts +136 -0
  34. package/dist/src/resources/network_request.d.ts +43 -0
  35. package/dist/src/resources/trace.d.ts +121 -0
  36. package/dist/src/resources/web_vitals.d.ts +25 -0
  37. package/dist/src/services/api_service.d.ts +55 -0
  38. package/dist/src/services/iid_service.d.ts +21 -0
  39. package/dist/src/services/initialization_service.d.ts +19 -0
  40. package/dist/src/services/oob_resources_service.d.ts +23 -0
  41. package/dist/src/services/perf_logger.d.ts +21 -0
  42. package/dist/src/services/remote_config_service.d.ts +18 -0
  43. package/dist/src/services/settings_service.d.ts +33 -0
  44. package/dist/src/services/transport_service.d.ts +29 -0
  45. package/dist/src/tsdoc-metadata.json +11 -0
  46. package/dist/src/utils/app_utils.d.ts +20 -0
  47. package/dist/src/utils/attributes_utils.d.ts +41 -0
  48. package/dist/src/utils/console_logger.d.ts +18 -0
  49. package/dist/src/utils/errors.d.ts +60 -0
  50. package/dist/src/utils/metric_utils.d.ts +28 -0
  51. package/dist/src/utils/string_merger.d.ts +17 -0
  52. package/dist/test/setup.d.ts +17 -0
  53. package/package.json +96 -0
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { PerformanceTrace } from '../public_types';
18
+ import { PerformanceController } from '../controllers/perf';
19
+ import { CoreVitalMetric, WebVitalMetrics } from './web_vitals';
20
+ export declare class Trace implements PerformanceTrace {
21
+ readonly performanceController: PerformanceController;
22
+ readonly name: string;
23
+ readonly isAuto: boolean;
24
+ private state;
25
+ startTimeUs: number;
26
+ durationUs: number;
27
+ private customAttributes;
28
+ counters: {
29
+ [counterName: string]: number;
30
+ };
31
+ private api;
32
+ private randomId;
33
+ private traceStartMark;
34
+ private traceStopMark;
35
+ private traceMeasure;
36
+ /**
37
+ * @param performanceController The performance controller running.
38
+ * @param name The name of the trace.
39
+ * @param isAuto If the trace is auto-instrumented.
40
+ * @param traceMeasureName The name of the measure marker in user timing specification. This field
41
+ * is only set when the trace is built for logging when the user directly uses the user timing
42
+ * api (performance.mark and performance.measure).
43
+ */
44
+ constructor(performanceController: PerformanceController, name: string, isAuto?: boolean, traceMeasureName?: string);
45
+ /**
46
+ * Starts a trace. The measurement of the duration starts at this point.
47
+ */
48
+ start(): void;
49
+ /**
50
+ * Stops the trace. The measurement of the duration of the trace stops at this point and trace
51
+ * is logged.
52
+ */
53
+ stop(): void;
54
+ /**
55
+ * Records a trace with predetermined values. If this method is used a trace is created and logged
56
+ * directly. No need to use start and stop methods.
57
+ * @param startTime Trace start time since epoch in millisec
58
+ * @param duration The duration of the trace in millisec
59
+ * @param options An object which can optionally hold maps of custom metrics and custom attributes
60
+ */
61
+ record(startTime: number, duration: number, options?: {
62
+ metrics?: {
63
+ [key: string]: number;
64
+ };
65
+ attributes?: {
66
+ [key: string]: string;
67
+ };
68
+ }): void;
69
+ /**
70
+ * Increments a custom metric by a certain number or 1 if number not specified. Will create a new
71
+ * custom metric if one with the given name does not exist. The value will be floored down to an
72
+ * integer.
73
+ * @param counter Name of the custom metric
74
+ * @param numAsInteger Increment by value
75
+ */
76
+ incrementMetric(counter: string, numAsInteger?: number): void;
77
+ /**
78
+ * Sets a custom metric to a specified value. Will create a new custom metric if one with the
79
+ * given name does not exist. The value will be floored down to an integer.
80
+ * @param counter Name of the custom metric
81
+ * @param numAsInteger Set custom metric to this value
82
+ */
83
+ putMetric(counter: string, numAsInteger: number): void;
84
+ /**
85
+ * Returns the value of the custom metric by that name. If a custom metric with that name does
86
+ * not exist will return zero.
87
+ * @param counter
88
+ */
89
+ getMetric(counter: string): number;
90
+ /**
91
+ * Sets a custom attribute of a trace to a certain value.
92
+ * @param attr
93
+ * @param value
94
+ */
95
+ putAttribute(attr: string, value: string): void;
96
+ /**
97
+ * Retrieves the value a custom attribute of a trace is set to.
98
+ * @param attr
99
+ */
100
+ getAttribute(attr: string): string | undefined;
101
+ removeAttribute(attr: string): void;
102
+ getAttributes(): {
103
+ [key: string]: string;
104
+ };
105
+ private setStartTime;
106
+ private setDuration;
107
+ /**
108
+ * Calculates and assigns the duration and start time of the trace using the measure performance
109
+ * entry.
110
+ */
111
+ private calculateTraceMetrics;
112
+ /**
113
+ * @param navigationTimings A single element array which contains the navigationTIming object of
114
+ * the page load
115
+ * @param paintTimings A array which contains paintTiming object of the page load
116
+ * @param firstInputDelay First input delay in millisec
117
+ */
118
+ static createOobTrace(performanceController: PerformanceController, navigationTimings: PerformanceNavigationTiming[], paintTimings: PerformanceEntry[], webVitalMetrics: WebVitalMetrics, firstInputDelay?: number): void;
119
+ static addWebVitalMetric(trace: Trace, metricKey: string, attributeKey: string, metric?: CoreVitalMetric): void;
120
+ static createUserTimingTrace(performanceController: PerformanceController, measureName: string): void;
121
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export interface CoreVitalMetric {
18
+ value: number;
19
+ elementAttribution?: string;
20
+ }
21
+ export interface WebVitalMetrics {
22
+ cls?: CoreVitalMetric;
23
+ inp?: CoreVitalMetric;
24
+ lcp?: CoreVitalMetric;
25
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { CLSMetricWithAttribution, INPMetricWithAttribution, LCPMetricWithAttribution } from 'web-vitals/attribution';
18
+ declare global {
19
+ interface Window {
20
+ PerformanceObserver: typeof PerformanceObserver;
21
+ perfMetrics?: {
22
+ onFirstInputDelay(fn: (fid: number) => void): void;
23
+ };
24
+ }
25
+ }
26
+ export type EntryType = 'mark' | 'measure' | 'paint' | 'resource' | 'frame' | 'navigation';
27
+ /**
28
+ * This class holds a reference to various browser related objects injected by
29
+ * set methods.
30
+ */
31
+ export declare class Api {
32
+ readonly window?: Window | undefined;
33
+ private readonly performance;
34
+ /** PerformanceObserver constructor function. */
35
+ private readonly PerformanceObserver;
36
+ private readonly windowLocation;
37
+ readonly onFirstInputDelay?: (fn: (fid: number) => void) => void;
38
+ readonly onLCP: (fn: (metric: LCPMetricWithAttribution) => void) => void;
39
+ readonly onINP: (fn: (metric: INPMetricWithAttribution) => void) => void;
40
+ readonly onCLS: (fn: (metric: CLSMetricWithAttribution) => void) => void;
41
+ readonly localStorage?: Storage;
42
+ readonly document: Document;
43
+ readonly navigator: Navigator;
44
+ constructor(window?: Window | undefined);
45
+ getUrl(): string;
46
+ mark(name: string): void;
47
+ measure(measureName: string, mark1: string, mark2: string): void;
48
+ getEntriesByType(type: EntryType): PerformanceEntry[];
49
+ getEntriesByName(name: string): PerformanceEntry[];
50
+ getTimeOrigin(): number;
51
+ requiredApisAvailable(): boolean;
52
+ setupObserver(entryType: EntryType, callback: (entry: PerformanceEntry) => void): void;
53
+ static getInstance(): Api;
54
+ }
55
+ export declare function setupApi(window: Window): void;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { _FirebaseInstallationsInternal } from '@firebase/installations';
18
+ export declare function getIidPromise(installationsService: _FirebaseInstallationsInternal): Promise<string>;
19
+ export declare function getIid(): string | undefined;
20
+ export declare function getAuthTokenPromise(installationsService: _FirebaseInstallationsInternal): Promise<string>;
21
+ export declare function getAuthenticationToken(): string | undefined;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { PerformanceController } from '../controllers/perf';
18
+ export declare function getInitializationPromise(performanceController: PerformanceController): Promise<void>;
19
+ export declare function isPerfInitialized(): boolean;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { PerformanceController } from '../controllers/perf';
18
+ export declare function setupOobResources(performanceController: PerformanceController): void;
19
+ /**
20
+ * This service will only export the page load trace once. This function allows
21
+ * resetting it for unit tests
22
+ */
23
+ export declare function resetForUnitTests(): void;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { NetworkRequest } from '../resources/network_request';
18
+ import { Trace } from '../resources/trace';
19
+ export declare function logTrace(trace: Trace): void;
20
+ export declare function flushLogs(): void;
21
+ export declare function logNetworkRequest(networkRequest: NetworkRequest): void;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { PerformanceController } from '../controllers/perf';
18
+ export declare function getConfig(performanceController: PerformanceController, iid: string): Promise<void>;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare class SettingsService {
18
+ instrumentationEnabled: boolean;
19
+ dataCollectionEnabled: boolean;
20
+ loggingEnabled: boolean;
21
+ tracesSamplingRate: number;
22
+ networkRequestsSamplingRate: number;
23
+ logEndPointUrl: string;
24
+ flTransportEndpointUrl: string;
25
+ transportKey: string;
26
+ logSource: number;
27
+ logTraceAfterSampling: boolean;
28
+ logNetworkAfterSampling: boolean;
29
+ configTimeToLive: number;
30
+ logMaxFlushSize: number;
31
+ getFlTransportFullUrl(): string;
32
+ static getInstance(): SettingsService;
33
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare function setupTransportService(): void;
18
+ /**
19
+ * Utilized by testing to clean up message queue and un-initialize transport service.
20
+ */
21
+ export declare function resetTransportService(): void;
22
+ /** Log handler for cc service to send the performance logs to the server. */
23
+ export declare function transportHandler(serializer: (...args: any[]) => string): (...args: unknown[]) => void;
24
+ /**
25
+ * Force flush the queued events. Useful at page unload time to ensure all events are uploaded.
26
+ * Flush will attempt to use sendBeacon to send events async and defaults back to fetch as soon as a
27
+ * sendBeacon fails. Firefox
28
+ */
29
+ export declare function flushQueuedEvents(): void;
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "0.1.2"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FirebaseApp } from '@firebase/app';
18
+ export declare function getAppId(firebaseApp: FirebaseApp): string;
19
+ export declare function getProjectId(firebaseApp: FirebaseApp): string;
20
+ export declare function getApiKey(firebaseApp: FirebaseApp): string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ declare const enum ServiceWorkerStatus {
18
+ UNKNOWN = 0,
19
+ UNSUPPORTED = 1,
20
+ CONTROLLED = 2,
21
+ UNCONTROLLED = 3
22
+ }
23
+ export declare enum VisibilityState {
24
+ UNKNOWN = 0,
25
+ VISIBLE = 1,
26
+ HIDDEN = 2
27
+ }
28
+ declare const enum EffectiveConnectionType {
29
+ UNKNOWN = 0,
30
+ CONNECTION_SLOW_2G = 1,
31
+ CONNECTION_2G = 2,
32
+ CONNECTION_3G = 3,
33
+ CONNECTION_4G = 4
34
+ }
35
+ export declare const MAX_ATTRIBUTE_VALUE_LENGTH = 100;
36
+ export declare function getServiceWorkerStatus(): ServiceWorkerStatus;
37
+ export declare function getVisibilityState(): VisibilityState;
38
+ export declare function getEffectiveConnectionType(): EffectiveConnectionType;
39
+ export declare function isValidCustomAttributeName(name: string): boolean;
40
+ export declare function isValidCustomAttributeValue(value: string): boolean;
41
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Logger } from '@firebase/logger';
18
+ export declare const consoleLogger: Logger;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ErrorFactory } from '@firebase/util';
18
+ export declare const enum ErrorCode {
19
+ TRACE_STARTED_BEFORE = "trace started",
20
+ TRACE_STOPPED_BEFORE = "trace stopped",
21
+ NONPOSITIVE_TRACE_START_TIME = "nonpositive trace startTime",
22
+ NONPOSITIVE_TRACE_DURATION = "nonpositive trace duration",
23
+ NO_WINDOW = "no window",
24
+ NO_APP_ID = "no app id",
25
+ NO_PROJECT_ID = "no project id",
26
+ NO_API_KEY = "no api key",
27
+ INVALID_CC_LOG = "invalid cc log",
28
+ FB_NOT_DEFAULT = "FB not default",
29
+ RC_NOT_OK = "RC response not ok",
30
+ INVALID_ATTRIBUTE_NAME = "invalid attribute name",
31
+ INVALID_ATTRIBUTE_VALUE = "invalid attribute value",
32
+ INVALID_CUSTOM_METRIC_NAME = "invalid custom metric name",
33
+ INVALID_STRING_MERGER_PARAMETER = "invalid String merger input",
34
+ ALREADY_INITIALIZED = "already initialized"
35
+ }
36
+ interface ErrorParams {
37
+ [ErrorCode.TRACE_STARTED_BEFORE]: {
38
+ traceName: string;
39
+ };
40
+ [ErrorCode.TRACE_STOPPED_BEFORE]: {
41
+ traceName: string;
42
+ };
43
+ [ErrorCode.NONPOSITIVE_TRACE_START_TIME]: {
44
+ traceName: string;
45
+ };
46
+ [ErrorCode.NONPOSITIVE_TRACE_DURATION]: {
47
+ traceName: string;
48
+ };
49
+ [ErrorCode.INVALID_ATTRIBUTE_NAME]: {
50
+ attributeName: string;
51
+ };
52
+ [ErrorCode.INVALID_ATTRIBUTE_VALUE]: {
53
+ attributeValue: string;
54
+ };
55
+ [ErrorCode.INVALID_CUSTOM_METRIC_NAME]: {
56
+ customMetricName: string;
57
+ };
58
+ }
59
+ export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
60
+ export {};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Returns true if the metric is custom and does not start with reserved prefix, or if
19
+ * the metric is one of out of the box page load trace metrics.
20
+ */
21
+ export declare function isValidMetricName(name: string, traceName?: string): boolean;
22
+ /**
23
+ * Converts the provided value to an integer value to be used in case of a metric.
24
+ * @param providedValue Provided number value of the metric that needs to be converted to an integer.
25
+ *
26
+ * @returns Converted integer number to be set for the metric.
27
+ */
28
+ export declare function convertMetricValueToInteger(providedValue: number): number;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare function mergeStrings(part1: string, part2: string): string;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export {};