@firebase/analytics 0.10.6-canary.e542f1dbd → 0.10.7-20240730204232
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.
- package/dist/esm/index.esm.js +86 -60
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +83 -56
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/helpers.d.ts +13 -0
- package/dist/index.cjs.js +85 -59
- package/dist/index.cjs.js.map +1 -1
- package/dist/src/helpers.d.ts +13 -0
- package/package.json +9 -10
package/dist/esm/index.esm.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { getApp, _getProvider, _registerComponent, registerVersion } from '@firebase/app';
|
|
2
|
-
import {
|
|
2
|
+
import { __awaiter, __generator, __spreadArray, __assign } from 'tslib';
|
|
3
3
|
import { Logger } from '@firebase/logger';
|
|
4
|
-
import { trustedResourceUrl } from 'safevalues';
|
|
5
|
-
import { safeScriptEl } from 'safevalues/dom';
|
|
6
4
|
import { ErrorFactory, calculateBackoffMillis, FirebaseError, validateIndexedDBOpenable, isIndexedDBAvailable, isBrowserExtension, areCookiesEnabled, getModularInstance, deepEqual } from '@firebase/util';
|
|
7
5
|
import { Component } from '@firebase/component';
|
|
8
6
|
import '@firebase/installations';
|
|
@@ -68,6 +66,66 @@ var logger = new Logger('@firebase/analytics');
|
|
|
68
66
|
* See the License for the specific language governing permissions and
|
|
69
67
|
* limitations under the License.
|
|
70
68
|
*/
|
|
69
|
+
var _a;
|
|
70
|
+
var ERRORS = (_a = {},
|
|
71
|
+
_a["already-exists" /* AnalyticsError.ALREADY_EXISTS */] = 'A Firebase Analytics instance with the appId {$id} ' +
|
|
72
|
+
' already exists. ' +
|
|
73
|
+
'Only one Firebase Analytics instance can be created for each appId.',
|
|
74
|
+
_a["already-initialized" /* AnalyticsError.ALREADY_INITIALIZED */] = 'initializeAnalytics() cannot be called again with different options than those ' +
|
|
75
|
+
'it was initially called with. It can be called again with the same options to ' +
|
|
76
|
+
'return the existing instance, or getAnalytics() can be used ' +
|
|
77
|
+
'to get a reference to the already-initialized instance.',
|
|
78
|
+
_a["already-initialized-settings" /* AnalyticsError.ALREADY_INITIALIZED_SETTINGS */] = 'Firebase Analytics has already been initialized.' +
|
|
79
|
+
'settings() must be called before initializing any Analytics instance' +
|
|
80
|
+
'or it will have no effect.',
|
|
81
|
+
_a["interop-component-reg-failed" /* AnalyticsError.INTEROP_COMPONENT_REG_FAILED */] = 'Firebase Analytics Interop Component failed to instantiate: {$reason}',
|
|
82
|
+
_a["invalid-analytics-context" /* AnalyticsError.INVALID_ANALYTICS_CONTEXT */] = 'Firebase Analytics is not supported in this environment. ' +
|
|
83
|
+
'Wrap initialization of analytics in analytics.isSupported() ' +
|
|
84
|
+
'to prevent initialization in unsupported environments. Details: {$errorInfo}',
|
|
85
|
+
_a["indexeddb-unavailable" /* AnalyticsError.INDEXEDDB_UNAVAILABLE */] = 'IndexedDB unavailable or restricted in this environment. ' +
|
|
86
|
+
'Wrap initialization of analytics in analytics.isSupported() ' +
|
|
87
|
+
'to prevent initialization in unsupported environments. Details: {$errorInfo}',
|
|
88
|
+
_a["fetch-throttle" /* AnalyticsError.FETCH_THROTTLE */] = 'The config fetch request timed out while in an exponential backoff state.' +
|
|
89
|
+
' Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',
|
|
90
|
+
_a["config-fetch-failed" /* AnalyticsError.CONFIG_FETCH_FAILED */] = 'Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}',
|
|
91
|
+
_a["no-api-key" /* AnalyticsError.NO_API_KEY */] = 'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
92
|
+
'contain a valid API key.',
|
|
93
|
+
_a["no-app-id" /* AnalyticsError.NO_APP_ID */] = 'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
94
|
+
'contain a valid app ID.',
|
|
95
|
+
_a["no-client-id" /* AnalyticsError.NO_CLIENT_ID */] = 'The "client_id" field is empty.',
|
|
96
|
+
_a["invalid-gtag-resource" /* AnalyticsError.INVALID_GTAG_RESOURCE */] = 'Trusted Types detected an invalid gtag resource: {$gtagURL}.',
|
|
97
|
+
_a);
|
|
98
|
+
var ERROR_FACTORY = new ErrorFactory('analytics', 'Analytics', ERRORS);
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @license
|
|
102
|
+
* Copyright 2019 Google LLC
|
|
103
|
+
*
|
|
104
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
105
|
+
* you may not use this file except in compliance with the License.
|
|
106
|
+
* You may obtain a copy of the License at
|
|
107
|
+
*
|
|
108
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
109
|
+
*
|
|
110
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
111
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
112
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
113
|
+
* See the License for the specific language governing permissions and
|
|
114
|
+
* limitations under the License.
|
|
115
|
+
*/
|
|
116
|
+
/**
|
|
117
|
+
* Verifies and creates a TrustedScriptURL.
|
|
118
|
+
*/
|
|
119
|
+
function createGtagTrustedTypesScriptURL(url) {
|
|
120
|
+
if (!url.startsWith(GTAG_URL)) {
|
|
121
|
+
var err = ERROR_FACTORY.create("invalid-gtag-resource" /* AnalyticsError.INVALID_GTAG_RESOURCE */, {
|
|
122
|
+
gtagURL: url
|
|
123
|
+
});
|
|
124
|
+
logger.warn(err.message);
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
return url;
|
|
128
|
+
}
|
|
71
129
|
/**
|
|
72
130
|
* Makeshift polyfill for Promise.allSettled(). Resolves when all promises
|
|
73
131
|
* have either resolved or rejected.
|
|
@@ -77,21 +135,37 @@ var logger = new Logger('@firebase/analytics');
|
|
|
77
135
|
function promiseAllSettled(promises) {
|
|
78
136
|
return Promise.all(promises.map(function (promise) { return promise.catch(function (e) { return e; }); }));
|
|
79
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Creates a TrustedTypePolicy object that implements the rules passed as policyOptions.
|
|
140
|
+
*
|
|
141
|
+
* @param policyName A string containing the name of the policy
|
|
142
|
+
* @param policyOptions Object containing implementations of instance methods for TrustedTypesPolicy, see {@link https://developer.mozilla.org/en-US/docs/Web/API/TrustedTypePolicy#instance_methods
|
|
143
|
+
* | the TrustedTypePolicy reference documentation}.
|
|
144
|
+
*/
|
|
145
|
+
function createTrustedTypesPolicy(policyName, policyOptions) {
|
|
146
|
+
// Create a TrustedTypes policy that we can use for updating src
|
|
147
|
+
// properties
|
|
148
|
+
var trustedTypesPolicy;
|
|
149
|
+
if (window.trustedTypes) {
|
|
150
|
+
trustedTypesPolicy = window.trustedTypes.createPolicy(policyName, policyOptions);
|
|
151
|
+
}
|
|
152
|
+
return trustedTypesPolicy;
|
|
153
|
+
}
|
|
80
154
|
/**
|
|
81
155
|
* Inserts gtag script tag into the page to asynchronously download gtag.
|
|
82
156
|
* @param dataLayerName Name of datalayer (most often the default, "_dataLayer").
|
|
83
157
|
*/
|
|
84
158
|
function insertScriptTag(dataLayerName, measurementId) {
|
|
159
|
+
var trustedTypesPolicy = createTrustedTypesPolicy('firebase-js-sdk-policy', {
|
|
160
|
+
createScriptURL: createGtagTrustedTypesScriptURL
|
|
161
|
+
});
|
|
85
162
|
var script = document.createElement('script');
|
|
86
163
|
// We are not providing an analyticsId in the URL because it would trigger a `page_view`
|
|
87
164
|
// without fid. We will initialize ga-id using gtag (config) command together with fid.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// empty initial string.
|
|
93
|
-
var url = trustedResourceUrl(templateObject_1 || (templateObject_1 = __makeTemplateObject(["https://www.googletagmanager.com/gtag/js?l=", "&id=", ""], ["https://www.googletagmanager.com/gtag/js?l=", "&id=", ""])), dataLayerName, measurementId);
|
|
94
|
-
safeScriptEl.setSrc(script, url);
|
|
165
|
+
var gtagScriptURL = "".concat(GTAG_URL, "?l=").concat(dataLayerName, "&id=").concat(measurementId);
|
|
166
|
+
script.src = trustedTypesPolicy
|
|
167
|
+
? trustedTypesPolicy === null || trustedTypesPolicy === void 0 ? void 0 : trustedTypesPolicy.createScriptURL(gtagScriptURL)
|
|
168
|
+
: gtagScriptURL;
|
|
95
169
|
script.async = true;
|
|
96
170
|
document.head.appendChild(script);
|
|
97
171
|
}
|
|
@@ -366,55 +440,7 @@ function findGtagScriptOnPage(dataLayerName) {
|
|
|
366
440
|
}
|
|
367
441
|
}
|
|
368
442
|
return null;
|
|
369
|
-
}
|
|
370
|
-
var templateObject_1;
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* @license
|
|
374
|
-
* Copyright 2019 Google LLC
|
|
375
|
-
*
|
|
376
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
377
|
-
* you may not use this file except in compliance with the License.
|
|
378
|
-
* You may obtain a copy of the License at
|
|
379
|
-
*
|
|
380
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
381
|
-
*
|
|
382
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
383
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
384
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
385
|
-
* See the License for the specific language governing permissions and
|
|
386
|
-
* limitations under the License.
|
|
387
|
-
*/
|
|
388
|
-
var _a;
|
|
389
|
-
var ERRORS = (_a = {},
|
|
390
|
-
_a["already-exists" /* AnalyticsError.ALREADY_EXISTS */] = 'A Firebase Analytics instance with the appId {$id} ' +
|
|
391
|
-
' already exists. ' +
|
|
392
|
-
'Only one Firebase Analytics instance can be created for each appId.',
|
|
393
|
-
_a["already-initialized" /* AnalyticsError.ALREADY_INITIALIZED */] = 'initializeAnalytics() cannot be called again with different options than those ' +
|
|
394
|
-
'it was initially called with. It can be called again with the same options to ' +
|
|
395
|
-
'return the existing instance, or getAnalytics() can be used ' +
|
|
396
|
-
'to get a reference to the already-initialized instance.',
|
|
397
|
-
_a["already-initialized-settings" /* AnalyticsError.ALREADY_INITIALIZED_SETTINGS */] = 'Firebase Analytics has already been initialized.' +
|
|
398
|
-
'settings() must be called before initializing any Analytics instance' +
|
|
399
|
-
'or it will have no effect.',
|
|
400
|
-
_a["interop-component-reg-failed" /* AnalyticsError.INTEROP_COMPONENT_REG_FAILED */] = 'Firebase Analytics Interop Component failed to instantiate: {$reason}',
|
|
401
|
-
_a["invalid-analytics-context" /* AnalyticsError.INVALID_ANALYTICS_CONTEXT */] = 'Firebase Analytics is not supported in this environment. ' +
|
|
402
|
-
'Wrap initialization of analytics in analytics.isSupported() ' +
|
|
403
|
-
'to prevent initialization in unsupported environments. Details: {$errorInfo}',
|
|
404
|
-
_a["indexeddb-unavailable" /* AnalyticsError.INDEXEDDB_UNAVAILABLE */] = 'IndexedDB unavailable or restricted in this environment. ' +
|
|
405
|
-
'Wrap initialization of analytics in analytics.isSupported() ' +
|
|
406
|
-
'to prevent initialization in unsupported environments. Details: {$errorInfo}',
|
|
407
|
-
_a["fetch-throttle" /* AnalyticsError.FETCH_THROTTLE */] = 'The config fetch request timed out while in an exponential backoff state.' +
|
|
408
|
-
' Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',
|
|
409
|
-
_a["config-fetch-failed" /* AnalyticsError.CONFIG_FETCH_FAILED */] = 'Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}',
|
|
410
|
-
_a["no-api-key" /* AnalyticsError.NO_API_KEY */] = 'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
411
|
-
'contain a valid API key.',
|
|
412
|
-
_a["no-app-id" /* AnalyticsError.NO_APP_ID */] = 'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
413
|
-
'contain a valid app ID.',
|
|
414
|
-
_a["no-client-id" /* AnalyticsError.NO_CLIENT_ID */] = 'The "client_id" field is empty.',
|
|
415
|
-
_a["invalid-gtag-resource" /* AnalyticsError.INVALID_GTAG_RESOURCE */] = 'Trusted Types detected an invalid gtag resource: {$gtagURL}.',
|
|
416
|
-
_a);
|
|
417
|
-
var ERROR_FACTORY = new ErrorFactory('analytics', 'Analytics', ERRORS);
|
|
443
|
+
}
|
|
418
444
|
|
|
419
445
|
/**
|
|
420
446
|
* @license
|
|
@@ -1391,7 +1417,7 @@ function setConsent(consentSettings) {
|
|
|
1391
1417
|
}
|
|
1392
1418
|
|
|
1393
1419
|
var name = "@firebase/analytics";
|
|
1394
|
-
var version = "0.10.
|
|
1420
|
+
var version = "0.10.7-20240730204232";
|
|
1395
1421
|
|
|
1396
1422
|
/**
|
|
1397
1423
|
* The Firebase Analytics Web SDK.
|