@firebase/analytics 0.8.4 → 0.9.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.
- package/CHANGELOG.md +14 -0
- package/dist/esm/index.esm.js +75 -76
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +50 -51
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/index.cjs.js +75 -76
- package/dist/index.cjs.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @firebase/analytics
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`1625f7a95`](https://github.com/firebase/firebase-js-sdk/commit/1625f7a95cc3ffb666845db0a8044329be74b5be) [#6799](https://github.com/firebase/firebase-js-sdk/pull/6799) - Update TypeScript version to 4.7.4.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`c20633ed3`](https://github.com/firebase/firebase-js-sdk/commit/c20633ed35056cbadc9d65d9ceddf4e28d1ea666), [`1625f7a95`](https://github.com/firebase/firebase-js-sdk/commit/1625f7a95cc3ffb666845db0a8044329be74b5be)]:
|
|
12
|
+
- @firebase/util@1.8.0
|
|
13
|
+
- @firebase/component@0.6.0
|
|
14
|
+
- @firebase/installations@0.6.0
|
|
15
|
+
- @firebase/logger@0.4.0
|
|
16
|
+
|
|
3
17
|
## 0.8.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/esm/index.esm.js
CHANGED
|
@@ -83,7 +83,7 @@ function insertScriptTag(dataLayerName, measurementId) {
|
|
|
83
83
|
var script = document.createElement('script');
|
|
84
84
|
// We are not providing an analyticsId in the URL because it would trigger a `page_view`
|
|
85
85
|
// without fid. We will initialize ga-id using gtag (config) command together with fid.
|
|
86
|
-
script.src = GTAG_URL
|
|
86
|
+
script.src = "".concat(GTAG_URL, "?l=").concat(dataLayerName, "&id=").concat(measurementId);
|
|
87
87
|
script.async = true;
|
|
88
88
|
document.head.appendChild(script);
|
|
89
89
|
}
|
|
@@ -142,7 +142,7 @@ function gtagOnConfig(gtagCore, initializationPromisesMap, dynamicConfigPromises
|
|
|
142
142
|
logger.error(e_1);
|
|
143
143
|
return [3 /*break*/, 8];
|
|
144
144
|
case 8:
|
|
145
|
-
gtagCore("config" /* CONFIG */, measurementId, gtagParams);
|
|
145
|
+
gtagCore("config" /* GtagCommand.CONFIG */, measurementId, gtagParams);
|
|
146
146
|
return [2 /*return*/];
|
|
147
147
|
}
|
|
148
148
|
});
|
|
@@ -211,7 +211,7 @@ function gtagOnEvent(gtagCore, initializationPromisesMap, dynamicConfigPromisesL
|
|
|
211
211
|
// promises have been resolved.
|
|
212
212
|
_a.sent();
|
|
213
213
|
// Workaround for http://b/141370449 - third argument cannot be undefined.
|
|
214
|
-
gtagCore("event" /* EVENT */, measurementId, gtagParams || {});
|
|
214
|
+
gtagCore("event" /* GtagCommand.EVENT */, measurementId, gtagParams || {});
|
|
215
215
|
return [3 /*break*/, 5];
|
|
216
216
|
case 4:
|
|
217
217
|
e_2 = _a.sent();
|
|
@@ -261,7 +261,7 @@ measurementIdToAppId) {
|
|
|
261
261
|
switch (_a.label) {
|
|
262
262
|
case 0:
|
|
263
263
|
_a.trys.push([0, 6, , 7]);
|
|
264
|
-
if (!(command === "event" /* EVENT */)) return [3 /*break*/, 2];
|
|
264
|
+
if (!(command === "event" /* GtagCommand.EVENT */)) return [3 /*break*/, 2];
|
|
265
265
|
// If EVENT, second arg must be measurementId.
|
|
266
266
|
return [4 /*yield*/, gtagOnEvent(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, idOrNameOrParams, gtagParams)];
|
|
267
267
|
case 1:
|
|
@@ -269,7 +269,7 @@ measurementIdToAppId) {
|
|
|
269
269
|
_a.sent();
|
|
270
270
|
return [3 /*break*/, 5];
|
|
271
271
|
case 2:
|
|
272
|
-
if (!(command === "config" /* CONFIG */)) return [3 /*break*/, 4];
|
|
272
|
+
if (!(command === "config" /* GtagCommand.CONFIG */)) return [3 /*break*/, 4];
|
|
273
273
|
// If CONFIG, second arg must be measurementId.
|
|
274
274
|
return [4 /*yield*/, gtagOnConfig(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, measurementIdToAppId, idOrNameOrParams, gtagParams)];
|
|
275
275
|
case 3:
|
|
@@ -277,13 +277,13 @@ measurementIdToAppId) {
|
|
|
277
277
|
_a.sent();
|
|
278
278
|
return [3 /*break*/, 5];
|
|
279
279
|
case 4:
|
|
280
|
-
if (command === "consent" /* CONSENT */) {
|
|
280
|
+
if (command === "consent" /* GtagCommand.CONSENT */) {
|
|
281
281
|
// If CONFIG, second arg must be measurementId.
|
|
282
|
-
gtagCore("consent" /* CONSENT */, 'update', gtagParams);
|
|
282
|
+
gtagCore("consent" /* GtagCommand.CONSENT */, 'update', gtagParams);
|
|
283
283
|
}
|
|
284
284
|
else {
|
|
285
285
|
// If SET, second arg must be params.
|
|
286
|
-
gtagCore("set" /* SET */, idOrNameOrParams);
|
|
286
|
+
gtagCore("set" /* GtagCommand.SET */, idOrNameOrParams);
|
|
287
287
|
}
|
|
288
288
|
_a.label = 5;
|
|
289
289
|
case 5: return [3 /*break*/, 7];
|
|
@@ -362,29 +362,29 @@ function findGtagScriptOnPage(dataLayerName) {
|
|
|
362
362
|
*/
|
|
363
363
|
var _a;
|
|
364
364
|
var ERRORS = (_a = {},
|
|
365
|
-
_a["already-exists" /* ALREADY_EXISTS */] = 'A Firebase Analytics instance with the appId {$id} ' +
|
|
365
|
+
_a["already-exists" /* AnalyticsError.ALREADY_EXISTS */] = 'A Firebase Analytics instance with the appId {$id} ' +
|
|
366
366
|
' already exists. ' +
|
|
367
367
|
'Only one Firebase Analytics instance can be created for each appId.',
|
|
368
|
-
_a["already-initialized" /* ALREADY_INITIALIZED */] = 'initializeAnalytics() cannot be called again with different options than those ' +
|
|
368
|
+
_a["already-initialized" /* AnalyticsError.ALREADY_INITIALIZED */] = 'initializeAnalytics() cannot be called again with different options than those ' +
|
|
369
369
|
'it was initially called with. It can be called again with the same options to ' +
|
|
370
370
|
'return the existing instance, or getAnalytics() can be used ' +
|
|
371
371
|
'to get a reference to the already-intialized instance.',
|
|
372
|
-
_a["already-initialized-settings" /* ALREADY_INITIALIZED_SETTINGS */] = 'Firebase Analytics has already been initialized.' +
|
|
372
|
+
_a["already-initialized-settings" /* AnalyticsError.ALREADY_INITIALIZED_SETTINGS */] = 'Firebase Analytics has already been initialized.' +
|
|
373
373
|
'settings() must be called before initializing any Analytics instance' +
|
|
374
374
|
'or it will have no effect.',
|
|
375
|
-
_a["interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */] = 'Firebase Analytics Interop Component failed to instantiate: {$reason}',
|
|
376
|
-
_a["invalid-analytics-context" /* INVALID_ANALYTICS_CONTEXT */] = 'Firebase Analytics is not supported in this environment. ' +
|
|
375
|
+
_a["interop-component-reg-failed" /* AnalyticsError.INTEROP_COMPONENT_REG_FAILED */] = 'Firebase Analytics Interop Component failed to instantiate: {$reason}',
|
|
376
|
+
_a["invalid-analytics-context" /* AnalyticsError.INVALID_ANALYTICS_CONTEXT */] = 'Firebase Analytics is not supported in this environment. ' +
|
|
377
377
|
'Wrap initialization of analytics in analytics.isSupported() ' +
|
|
378
378
|
'to prevent initialization in unsupported environments. Details: {$errorInfo}',
|
|
379
|
-
_a["indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */] = 'IndexedDB unavailable or restricted in this environment. ' +
|
|
379
|
+
_a["indexeddb-unavailable" /* AnalyticsError.INDEXEDDB_UNAVAILABLE */] = 'IndexedDB unavailable or restricted in this environment. ' +
|
|
380
380
|
'Wrap initialization of analytics in analytics.isSupported() ' +
|
|
381
381
|
'to prevent initialization in unsupported environments. Details: {$errorInfo}',
|
|
382
|
-
_a["fetch-throttle" /* FETCH_THROTTLE */] = 'The config fetch request timed out while in an exponential backoff state.' +
|
|
382
|
+
_a["fetch-throttle" /* AnalyticsError.FETCH_THROTTLE */] = 'The config fetch request timed out while in an exponential backoff state.' +
|
|
383
383
|
' Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',
|
|
384
|
-
_a["config-fetch-failed" /* CONFIG_FETCH_FAILED */] = 'Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}',
|
|
385
|
-
_a["no-api-key" /* NO_API_KEY */] = 'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
384
|
+
_a["config-fetch-failed" /* AnalyticsError.CONFIG_FETCH_FAILED */] = 'Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}',
|
|
385
|
+
_a["no-api-key" /* AnalyticsError.NO_API_KEY */] = 'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
386
386
|
'contain a valid API key.',
|
|
387
|
-
_a["no-app-id" /* NO_APP_ID */] = 'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
387
|
+
_a["no-app-id" /* AnalyticsError.NO_APP_ID */] = 'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
388
388
|
'contain a valid app ID.',
|
|
389
389
|
_a);
|
|
390
390
|
var ERROR_FACTORY = new ErrorFactory('analytics', 'Analytics', ERRORS);
|
|
@@ -483,7 +483,7 @@ function fetchDynamicConfig(appFields) {
|
|
|
483
483
|
case 4:
|
|
484
484
|
_b.sent();
|
|
485
485
|
return [3 /*break*/, 5];
|
|
486
|
-
case 5: throw ERROR_FACTORY.create("config-fetch-failed" /* CONFIG_FETCH_FAILED */, {
|
|
486
|
+
case 5: throw ERROR_FACTORY.create("config-fetch-failed" /* AnalyticsError.CONFIG_FETCH_FAILED */, {
|
|
487
487
|
httpStatus: response.status,
|
|
488
488
|
responseMessage: errorMessage
|
|
489
489
|
});
|
|
@@ -506,7 +506,7 @@ retryData, timeoutMillis) {
|
|
|
506
506
|
return __generator(this, function (_b) {
|
|
507
507
|
_a = app.options, appId = _a.appId, apiKey = _a.apiKey, measurementId = _a.measurementId;
|
|
508
508
|
if (!appId) {
|
|
509
|
-
throw ERROR_FACTORY.create("no-app-id" /* NO_APP_ID */);
|
|
509
|
+
throw ERROR_FACTORY.create("no-app-id" /* AnalyticsError.NO_APP_ID */);
|
|
510
510
|
}
|
|
511
511
|
if (!apiKey) {
|
|
512
512
|
if (measurementId) {
|
|
@@ -515,7 +515,7 @@ retryData, timeoutMillis) {
|
|
|
515
515
|
appId: appId
|
|
516
516
|
}];
|
|
517
517
|
}
|
|
518
|
-
throw ERROR_FACTORY.create("no-api-key" /* NO_API_KEY */);
|
|
518
|
+
throw ERROR_FACTORY.create("no-api-key" /* AnalyticsError.NO_API_KEY */);
|
|
519
519
|
}
|
|
520
520
|
throttleMetadata = retryData.getThrottleMetadata(appId) || {
|
|
521
521
|
backoffCount: 0,
|
|
@@ -541,55 +541,55 @@ retryData, timeoutMillis) {
|
|
|
541
541
|
*/
|
|
542
542
|
function attemptFetchDynamicConfigWithRetry(appFields, _a, signal, retryData // for testing
|
|
543
543
|
) {
|
|
544
|
-
var _b
|
|
544
|
+
var _b;
|
|
545
545
|
var throttleEndTimeMillis = _a.throttleEndTimeMillis, backoffCount = _a.backoffCount;
|
|
546
546
|
if (retryData === void 0) { retryData = defaultRetryData; }
|
|
547
547
|
return __awaiter(this, void 0, void 0, function () {
|
|
548
548
|
var appId, measurementId, e_1, response, e_2, error, backoffMillis, throttleMetadata;
|
|
549
|
-
return __generator(this, function (
|
|
550
|
-
switch (
|
|
549
|
+
return __generator(this, function (_c) {
|
|
550
|
+
switch (_c.label) {
|
|
551
551
|
case 0:
|
|
552
552
|
appId = appFields.appId, measurementId = appFields.measurementId;
|
|
553
|
-
|
|
553
|
+
_c.label = 1;
|
|
554
554
|
case 1:
|
|
555
|
-
|
|
555
|
+
_c.trys.push([1, 3, , 4]);
|
|
556
556
|
return [4 /*yield*/, setAbortableTimeout(signal, throttleEndTimeMillis)];
|
|
557
557
|
case 2:
|
|
558
|
-
|
|
558
|
+
_c.sent();
|
|
559
559
|
return [3 /*break*/, 4];
|
|
560
560
|
case 3:
|
|
561
|
-
e_1 =
|
|
561
|
+
e_1 = _c.sent();
|
|
562
562
|
if (measurementId) {
|
|
563
563
|
logger.warn("Timed out fetching this Firebase app's measurement ID from the server." +
|
|
564
|
-
|
|
565
|
-
|
|
564
|
+
" Falling back to the measurement ID ".concat(measurementId) +
|
|
565
|
+
" provided in the \"measurementId\" field in the local Firebase config. [".concat(e_1 === null || e_1 === void 0 ? void 0 : e_1.message, "]"));
|
|
566
566
|
return [2 /*return*/, { appId: appId, measurementId: measurementId }];
|
|
567
567
|
}
|
|
568
568
|
throw e_1;
|
|
569
569
|
case 4:
|
|
570
|
-
|
|
570
|
+
_c.trys.push([4, 6, , 7]);
|
|
571
571
|
return [4 /*yield*/, fetchDynamicConfig(appFields)];
|
|
572
572
|
case 5:
|
|
573
|
-
response =
|
|
573
|
+
response = _c.sent();
|
|
574
574
|
// Note the SDK only clears throttle state if response is success or non-retriable.
|
|
575
575
|
retryData.deleteThrottleMetadata(appId);
|
|
576
576
|
return [2 /*return*/, response];
|
|
577
577
|
case 6:
|
|
578
|
-
e_2 =
|
|
578
|
+
e_2 = _c.sent();
|
|
579
579
|
error = e_2;
|
|
580
580
|
if (!isRetriableError(error)) {
|
|
581
581
|
retryData.deleteThrottleMetadata(appId);
|
|
582
582
|
if (measurementId) {
|
|
583
583
|
logger.warn("Failed to fetch this Firebase app's measurement ID from the server." +
|
|
584
|
-
|
|
585
|
-
|
|
584
|
+
" Falling back to the measurement ID ".concat(measurementId) +
|
|
585
|
+
" provided in the \"measurementId\" field in the local Firebase config. [".concat(error === null || error === void 0 ? void 0 : error.message, "]"));
|
|
586
586
|
return [2 /*return*/, { appId: appId, measurementId: measurementId }];
|
|
587
587
|
}
|
|
588
588
|
else {
|
|
589
589
|
throw e_2;
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
|
-
backoffMillis = Number((
|
|
592
|
+
backoffMillis = Number((_b = error === null || error === void 0 ? void 0 : error.customData) === null || _b === void 0 ? void 0 : _b.httpStatus) === 503
|
|
593
593
|
? calculateBackoffMillis(backoffCount, retryData.intervalMillis, LONG_RETRY_FACTOR)
|
|
594
594
|
: calculateBackoffMillis(backoffCount, retryData.intervalMillis);
|
|
595
595
|
throttleMetadata = {
|
|
@@ -598,7 +598,7 @@ function attemptFetchDynamicConfigWithRetry(appFields, _a, signal, retryData //
|
|
|
598
598
|
};
|
|
599
599
|
// Persists state.
|
|
600
600
|
retryData.setThrottleMetadata(appId, throttleMetadata);
|
|
601
|
-
logger.debug("Calling attemptFetch again in "
|
|
601
|
+
logger.debug("Calling attemptFetch again in ".concat(backoffMillis, " millis"));
|
|
602
602
|
return [2 /*return*/, attemptFetchDynamicConfigWithRetry(appFields, throttleMetadata, signal, retryData)];
|
|
603
603
|
case 7: return [2 /*return*/];
|
|
604
604
|
}
|
|
@@ -626,7 +626,7 @@ function setAbortableTimeout(signal, throttleEndTimeMillis) {
|
|
|
626
626
|
signal.addEventListener(function () {
|
|
627
627
|
clearTimeout(timeout);
|
|
628
628
|
// If the request completes before this timeout, the rejection has no effect.
|
|
629
|
-
reject(ERROR_FACTORY.create("fetch-throttle" /* FETCH_THROTTLE */, {
|
|
629
|
+
reject(ERROR_FACTORY.create("fetch-throttle" /* AnalyticsError.FETCH_THROTTLE */, {
|
|
630
630
|
throttleEndTimeMillis: throttleEndTimeMillis
|
|
631
631
|
}));
|
|
632
632
|
});
|
|
@@ -701,13 +701,13 @@ function logEvent$1(gtagFunction, initializationPromise, eventName, eventParams,
|
|
|
701
701
|
switch (_a.label) {
|
|
702
702
|
case 0:
|
|
703
703
|
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
704
|
-
gtagFunction("event" /* EVENT */, eventName, eventParams);
|
|
704
|
+
gtagFunction("event" /* GtagCommand.EVENT */, eventName, eventParams);
|
|
705
705
|
return [2 /*return*/];
|
|
706
706
|
case 1: return [4 /*yield*/, initializationPromise];
|
|
707
707
|
case 2:
|
|
708
708
|
measurementId = _a.sent();
|
|
709
709
|
params = __assign(__assign({}, eventParams), { 'send_to': measurementId });
|
|
710
|
-
gtagFunction("event" /* EVENT */, eventName, params);
|
|
710
|
+
gtagFunction("event" /* GtagCommand.EVENT */, eventName, params);
|
|
711
711
|
_a.label = 3;
|
|
712
712
|
case 3: return [2 /*return*/];
|
|
713
713
|
}
|
|
@@ -730,12 +730,12 @@ function setCurrentScreen$1(gtagFunction, initializationPromise, screenName, opt
|
|
|
730
730
|
switch (_a.label) {
|
|
731
731
|
case 0:
|
|
732
732
|
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
733
|
-
gtagFunction("set" /* SET */, { 'screen_name': screenName });
|
|
733
|
+
gtagFunction("set" /* GtagCommand.SET */, { 'screen_name': screenName });
|
|
734
734
|
return [2 /*return*/, Promise.resolve()];
|
|
735
735
|
case 1: return [4 /*yield*/, initializationPromise];
|
|
736
736
|
case 2:
|
|
737
737
|
measurementId = _a.sent();
|
|
738
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
738
|
+
gtagFunction("config" /* GtagCommand.CONFIG */, measurementId, {
|
|
739
739
|
update: true,
|
|
740
740
|
'screen_name': screenName
|
|
741
741
|
});
|
|
@@ -758,12 +758,12 @@ function setUserId$1(gtagFunction, initializationPromise, id, options) {
|
|
|
758
758
|
switch (_a.label) {
|
|
759
759
|
case 0:
|
|
760
760
|
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
761
|
-
gtagFunction("set" /* SET */, { 'user_id': id });
|
|
761
|
+
gtagFunction("set" /* GtagCommand.SET */, { 'user_id': id });
|
|
762
762
|
return [2 /*return*/, Promise.resolve()];
|
|
763
763
|
case 1: return [4 /*yield*/, initializationPromise];
|
|
764
764
|
case 2:
|
|
765
765
|
measurementId = _a.sent();
|
|
766
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
766
|
+
gtagFunction("config" /* GtagCommand.CONFIG */, measurementId, {
|
|
767
767
|
update: true,
|
|
768
768
|
'user_id': id
|
|
769
769
|
});
|
|
@@ -790,14 +790,14 @@ function setUserProperties$1(gtagFunction, initializationPromise, properties, op
|
|
|
790
790
|
for (_i = 0, _a = Object.keys(properties); _i < _a.length; _i++) {
|
|
791
791
|
key = _a[_i];
|
|
792
792
|
// use dot notation for merge behavior in gtag.js
|
|
793
|
-
flatProperties["user_properties."
|
|
793
|
+
flatProperties["user_properties.".concat(key)] = properties[key];
|
|
794
794
|
}
|
|
795
|
-
gtagFunction("set" /* SET */, flatProperties);
|
|
795
|
+
gtagFunction("set" /* GtagCommand.SET */, flatProperties);
|
|
796
796
|
return [2 /*return*/, Promise.resolve()];
|
|
797
797
|
case 1: return [4 /*yield*/, initializationPromise];
|
|
798
798
|
case 2:
|
|
799
799
|
measurementId = _b.sent();
|
|
800
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
800
|
+
gtagFunction("config" /* GtagCommand.CONFIG */, measurementId, {
|
|
801
801
|
update: true,
|
|
802
802
|
'user_properties': properties
|
|
803
803
|
});
|
|
@@ -820,7 +820,7 @@ function setAnalyticsCollectionEnabled$1(initializationPromise, enabled) {
|
|
|
820
820
|
case 0: return [4 /*yield*/, initializationPromise];
|
|
821
821
|
case 1:
|
|
822
822
|
measurementId = _a.sent();
|
|
823
|
-
window["ga-disable-"
|
|
823
|
+
window["ga-disable-".concat(measurementId)] = !enabled;
|
|
824
824
|
return [2 /*return*/];
|
|
825
825
|
}
|
|
826
826
|
});
|
|
@@ -866,27 +866,26 @@ function _setDefaultEventParametersForInit(customParams) {
|
|
|
866
866
|
* limitations under the License.
|
|
867
867
|
*/
|
|
868
868
|
function validateIndexedDB() {
|
|
869
|
-
var _a;
|
|
870
869
|
return __awaiter(this, void 0, void 0, function () {
|
|
871
870
|
var e_1;
|
|
872
|
-
return __generator(this, function (
|
|
873
|
-
switch (
|
|
871
|
+
return __generator(this, function (_a) {
|
|
872
|
+
switch (_a.label) {
|
|
874
873
|
case 0:
|
|
875
874
|
if (!!isIndexedDBAvailable()) return [3 /*break*/, 1];
|
|
876
|
-
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */, {
|
|
875
|
+
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* AnalyticsError.INDEXEDDB_UNAVAILABLE */, {
|
|
877
876
|
errorInfo: 'IndexedDB is not available in this environment.'
|
|
878
877
|
}).message);
|
|
879
878
|
return [2 /*return*/, false];
|
|
880
879
|
case 1:
|
|
881
|
-
|
|
880
|
+
_a.trys.push([1, 3, , 4]);
|
|
882
881
|
return [4 /*yield*/, validateIndexedDBOpenable()];
|
|
883
882
|
case 2:
|
|
884
|
-
|
|
883
|
+
_a.sent();
|
|
885
884
|
return [3 /*break*/, 4];
|
|
886
885
|
case 3:
|
|
887
|
-
e_1 =
|
|
888
|
-
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */, {
|
|
889
|
-
errorInfo:
|
|
886
|
+
e_1 = _a.sent();
|
|
887
|
+
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* AnalyticsError.INDEXEDDB_UNAVAILABLE */, {
|
|
888
|
+
errorInfo: e_1 === null || e_1 === void 0 ? void 0 : e_1.toString()
|
|
890
889
|
}).message);
|
|
891
890
|
return [2 /*return*/, false];
|
|
892
891
|
case 4: return [2 /*return*/, true];
|
|
@@ -921,8 +920,8 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
921
920
|
measurementIdToAppId[config.measurementId] = config.appId;
|
|
922
921
|
if (app.options.measurementId &&
|
|
923
922
|
config.measurementId !== app.options.measurementId) {
|
|
924
|
-
logger.warn("The measurement ID in the local Firebase config ("
|
|
925
|
-
|
|
923
|
+
logger.warn("The measurement ID in the local Firebase config (".concat(app.options.measurementId, ")") +
|
|
924
|
+
" does not match the measurement ID fetched from the server (".concat(config.measurementId, ").") +
|
|
926
925
|
" To ensure analytics events are always sent to the correct Analytics property," +
|
|
927
926
|
" update the" +
|
|
928
927
|
" measurement ID field in the local config or remove it from the local config.");
|
|
@@ -952,7 +951,7 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
952
951
|
}
|
|
953
952
|
// Detects if there are consent settings that need to be configured.
|
|
954
953
|
if (defaultConsentSettingsForInit) {
|
|
955
|
-
gtagCore("consent" /* CONSENT */, 'default', defaultConsentSettingsForInit);
|
|
954
|
+
gtagCore("consent" /* GtagCommand.CONSENT */, 'default', defaultConsentSettingsForInit);
|
|
956
955
|
_setConsentDefaultForInit(undefined);
|
|
957
956
|
}
|
|
958
957
|
// This command initializes gtag.js and only needs to be called once for the entire web app,
|
|
@@ -971,10 +970,10 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
971
970
|
// Initialize this GA-ID and set FID on it using the gtag config API.
|
|
972
971
|
// Note: This will trigger a page_view event unless 'send_page_view' is set to false in
|
|
973
972
|
// `configProperties`.
|
|
974
|
-
gtagCore("config" /* CONFIG */, dynamicConfig.measurementId, configProperties);
|
|
973
|
+
gtagCore("config" /* GtagCommand.CONFIG */, dynamicConfig.measurementId, configProperties);
|
|
975
974
|
// Detects if there is data that will be set on every event logged from the SDK.
|
|
976
975
|
if (defaultEventParametersForInit) {
|
|
977
|
-
gtagCore("set" /* SET */, defaultEventParametersForInit);
|
|
976
|
+
gtagCore("set" /* GtagCommand.SET */, defaultEventParametersForInit);
|
|
978
977
|
_setDefaultEventParametersForInit(undefined);
|
|
979
978
|
}
|
|
980
979
|
return [2 /*return*/, dynamicConfig.measurementId];
|
|
@@ -1068,7 +1067,7 @@ var globalInitDone = false;
|
|
|
1068
1067
|
*/
|
|
1069
1068
|
function settings(options) {
|
|
1070
1069
|
if (globalInitDone) {
|
|
1071
|
-
throw ERROR_FACTORY.create("already-initialized" /* ALREADY_INITIALIZED */);
|
|
1070
|
+
throw ERROR_FACTORY.create("already-initialized" /* AnalyticsError.ALREADY_INITIALIZED */);
|
|
1072
1071
|
}
|
|
1073
1072
|
if (options.dataLayerName) {
|
|
1074
1073
|
dataLayerName = options.dataLayerName;
|
|
@@ -1092,9 +1091,9 @@ function warnOnBrowserContextMismatch() {
|
|
|
1092
1091
|
}
|
|
1093
1092
|
if (mismatchedEnvMessages.length > 0) {
|
|
1094
1093
|
var details = mismatchedEnvMessages
|
|
1095
|
-
.map(function (message, index) { return "("
|
|
1094
|
+
.map(function (message, index) { return "(".concat(index + 1, ") ").concat(message); })
|
|
1096
1095
|
.join(' ');
|
|
1097
|
-
var err = ERROR_FACTORY.create("invalid-analytics-context" /* INVALID_ANALYTICS_CONTEXT */, {
|
|
1096
|
+
var err = ERROR_FACTORY.create("invalid-analytics-context" /* AnalyticsError.INVALID_ANALYTICS_CONTEXT */, {
|
|
1098
1097
|
errorInfo: details
|
|
1099
1098
|
});
|
|
1100
1099
|
logger.warn(err.message);
|
|
@@ -1108,20 +1107,20 @@ function factory(app, installations, options) {
|
|
|
1108
1107
|
warnOnBrowserContextMismatch();
|
|
1109
1108
|
var appId = app.options.appId;
|
|
1110
1109
|
if (!appId) {
|
|
1111
|
-
throw ERROR_FACTORY.create("no-app-id" /* NO_APP_ID */);
|
|
1110
|
+
throw ERROR_FACTORY.create("no-app-id" /* AnalyticsError.NO_APP_ID */);
|
|
1112
1111
|
}
|
|
1113
1112
|
if (!app.options.apiKey) {
|
|
1114
1113
|
if (app.options.measurementId) {
|
|
1115
1114
|
logger.warn("The \"apiKey\" field is empty in the local Firebase config. This is needed to fetch the latest" +
|
|
1116
|
-
|
|
1115
|
+
" measurement ID for this Firebase app. Falling back to the measurement ID ".concat(app.options.measurementId) +
|
|
1117
1116
|
" provided in the \"measurementId\" field in the local Firebase config.");
|
|
1118
1117
|
}
|
|
1119
1118
|
else {
|
|
1120
|
-
throw ERROR_FACTORY.create("no-api-key" /* NO_API_KEY */);
|
|
1119
|
+
throw ERROR_FACTORY.create("no-api-key" /* AnalyticsError.NO_API_KEY */);
|
|
1121
1120
|
}
|
|
1122
1121
|
}
|
|
1123
1122
|
if (initializationPromisesMap[appId] != null) {
|
|
1124
|
-
throw ERROR_FACTORY.create("already-exists" /* ALREADY_EXISTS */, {
|
|
1123
|
+
throw ERROR_FACTORY.create("already-exists" /* AnalyticsError.ALREADY_EXISTS */, {
|
|
1125
1124
|
id: appId
|
|
1126
1125
|
});
|
|
1127
1126
|
}
|
|
@@ -1176,7 +1175,7 @@ function initializeAnalytics(app, options) {
|
|
|
1176
1175
|
return existingInstance;
|
|
1177
1176
|
}
|
|
1178
1177
|
else {
|
|
1179
|
-
throw ERROR_FACTORY.create("already-initialized" /* ALREADY_INITIALIZED */);
|
|
1178
|
+
throw ERROR_FACTORY.create("already-initialized" /* AnalyticsError.ALREADY_INITIALIZED */);
|
|
1180
1179
|
}
|
|
1181
1180
|
}
|
|
1182
1181
|
var analyticsInstance = analyticsProvider.initialize({ options: options });
|
|
@@ -1282,7 +1281,7 @@ function setAnalyticsCollectionEnabled(analyticsInstance, enabled) {
|
|
|
1282
1281
|
function setDefaultEventParameters(customParams) {
|
|
1283
1282
|
// Check if reference to existing gtag function on window object exists
|
|
1284
1283
|
if (wrappedGtagFunction) {
|
|
1285
|
-
wrappedGtagFunction("set" /* SET */, customParams);
|
|
1284
|
+
wrappedGtagFunction("set" /* GtagCommand.SET */, customParams);
|
|
1286
1285
|
}
|
|
1287
1286
|
else {
|
|
1288
1287
|
_setDefaultEventParametersForInit(customParams);
|
|
@@ -1315,7 +1314,7 @@ function logEvent(analyticsInstance, eventName, eventParams, options) {
|
|
|
1315
1314
|
function setConsent(consentSettings) {
|
|
1316
1315
|
// Check if reference to existing gtag function on window object exists
|
|
1317
1316
|
if (wrappedGtagFunction) {
|
|
1318
|
-
wrappedGtagFunction("consent" /* CONSENT */, 'update', consentSettings);
|
|
1317
|
+
wrappedGtagFunction("consent" /* GtagCommand.CONSENT */, 'update', consentSettings);
|
|
1319
1318
|
}
|
|
1320
1319
|
else {
|
|
1321
1320
|
_setConsentDefaultForInit(consentSettings);
|
|
@@ -1323,7 +1322,7 @@ function setConsent(consentSettings) {
|
|
|
1323
1322
|
}
|
|
1324
1323
|
|
|
1325
1324
|
var name = "@firebase/analytics";
|
|
1326
|
-
var version = "0.
|
|
1325
|
+
var version = "0.9.0";
|
|
1327
1326
|
|
|
1328
1327
|
/**
|
|
1329
1328
|
* Firebase Analytics
|
|
@@ -1339,8 +1338,8 @@ function registerAnalytics() {
|
|
|
1339
1338
|
.getProvider('installations-internal')
|
|
1340
1339
|
.getImmediate();
|
|
1341
1340
|
return factory(app, installations, analyticsOptions);
|
|
1342
|
-
}, "PUBLIC" /* PUBLIC */));
|
|
1343
|
-
_registerComponent(new Component('analytics-internal', internalFactory, "PRIVATE" /* PRIVATE */));
|
|
1341
|
+
}, "PUBLIC" /* ComponentType.PUBLIC */));
|
|
1342
|
+
_registerComponent(new Component('analytics-internal', internalFactory, "PRIVATE" /* ComponentType.PRIVATE */));
|
|
1344
1343
|
registerVersion(name, version);
|
|
1345
1344
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
1346
1345
|
registerVersion(name, version, 'esm5');
|
|
@@ -1352,7 +1351,7 @@ function registerAnalytics() {
|
|
|
1352
1351
|
};
|
|
1353
1352
|
}
|
|
1354
1353
|
catch (e) {
|
|
1355
|
-
throw ERROR_FACTORY.create("interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */, {
|
|
1354
|
+
throw ERROR_FACTORY.create("interop-component-reg-failed" /* AnalyticsError.INTEROP_COMPONENT_REG_FAILED */, {
|
|
1356
1355
|
reason: e
|
|
1357
1356
|
});
|
|
1358
1357
|
}
|