@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/dist/index.cjs.js
CHANGED
|
@@ -87,7 +87,7 @@ function insertScriptTag(dataLayerName, measurementId) {
|
|
|
87
87
|
var script = document.createElement('script');
|
|
88
88
|
// We are not providing an analyticsId in the URL because it would trigger a `page_view`
|
|
89
89
|
// without fid. We will initialize ga-id using gtag (config) command together with fid.
|
|
90
|
-
script.src = GTAG_URL
|
|
90
|
+
script.src = "".concat(GTAG_URL, "?l=").concat(dataLayerName, "&id=").concat(measurementId);
|
|
91
91
|
script.async = true;
|
|
92
92
|
document.head.appendChild(script);
|
|
93
93
|
}
|
|
@@ -146,7 +146,7 @@ function gtagOnConfig(gtagCore, initializationPromisesMap, dynamicConfigPromises
|
|
|
146
146
|
logger.error(e_1);
|
|
147
147
|
return [3 /*break*/, 8];
|
|
148
148
|
case 8:
|
|
149
|
-
gtagCore("config" /* CONFIG */, measurementId, gtagParams);
|
|
149
|
+
gtagCore("config" /* GtagCommand.CONFIG */, measurementId, gtagParams);
|
|
150
150
|
return [2 /*return*/];
|
|
151
151
|
}
|
|
152
152
|
});
|
|
@@ -215,7 +215,7 @@ function gtagOnEvent(gtagCore, initializationPromisesMap, dynamicConfigPromisesL
|
|
|
215
215
|
// promises have been resolved.
|
|
216
216
|
_a.sent();
|
|
217
217
|
// Workaround for http://b/141370449 - third argument cannot be undefined.
|
|
218
|
-
gtagCore("event" /* EVENT */, measurementId, gtagParams || {});
|
|
218
|
+
gtagCore("event" /* GtagCommand.EVENT */, measurementId, gtagParams || {});
|
|
219
219
|
return [3 /*break*/, 5];
|
|
220
220
|
case 4:
|
|
221
221
|
e_2 = _a.sent();
|
|
@@ -265,7 +265,7 @@ measurementIdToAppId) {
|
|
|
265
265
|
switch (_a.label) {
|
|
266
266
|
case 0:
|
|
267
267
|
_a.trys.push([0, 6, , 7]);
|
|
268
|
-
if (!(command === "event" /* EVENT */)) return [3 /*break*/, 2];
|
|
268
|
+
if (!(command === "event" /* GtagCommand.EVENT */)) return [3 /*break*/, 2];
|
|
269
269
|
// If EVENT, second arg must be measurementId.
|
|
270
270
|
return [4 /*yield*/, gtagOnEvent(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, idOrNameOrParams, gtagParams)];
|
|
271
271
|
case 1:
|
|
@@ -273,7 +273,7 @@ measurementIdToAppId) {
|
|
|
273
273
|
_a.sent();
|
|
274
274
|
return [3 /*break*/, 5];
|
|
275
275
|
case 2:
|
|
276
|
-
if (!(command === "config" /* CONFIG */)) return [3 /*break*/, 4];
|
|
276
|
+
if (!(command === "config" /* GtagCommand.CONFIG */)) return [3 /*break*/, 4];
|
|
277
277
|
// If CONFIG, second arg must be measurementId.
|
|
278
278
|
return [4 /*yield*/, gtagOnConfig(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, measurementIdToAppId, idOrNameOrParams, gtagParams)];
|
|
279
279
|
case 3:
|
|
@@ -281,13 +281,13 @@ measurementIdToAppId) {
|
|
|
281
281
|
_a.sent();
|
|
282
282
|
return [3 /*break*/, 5];
|
|
283
283
|
case 4:
|
|
284
|
-
if (command === "consent" /* CONSENT */) {
|
|
284
|
+
if (command === "consent" /* GtagCommand.CONSENT */) {
|
|
285
285
|
// If CONFIG, second arg must be measurementId.
|
|
286
|
-
gtagCore("consent" /* CONSENT */, 'update', gtagParams);
|
|
286
|
+
gtagCore("consent" /* GtagCommand.CONSENT */, 'update', gtagParams);
|
|
287
287
|
}
|
|
288
288
|
else {
|
|
289
289
|
// If SET, second arg must be params.
|
|
290
|
-
gtagCore("set" /* SET */, idOrNameOrParams);
|
|
290
|
+
gtagCore("set" /* GtagCommand.SET */, idOrNameOrParams);
|
|
291
291
|
}
|
|
292
292
|
_a.label = 5;
|
|
293
293
|
case 5: return [3 /*break*/, 7];
|
|
@@ -366,29 +366,29 @@ function findGtagScriptOnPage(dataLayerName) {
|
|
|
366
366
|
*/
|
|
367
367
|
var _a;
|
|
368
368
|
var ERRORS = (_a = {},
|
|
369
|
-
_a["already-exists" /* ALREADY_EXISTS */] = 'A Firebase Analytics instance with the appId {$id} ' +
|
|
369
|
+
_a["already-exists" /* AnalyticsError.ALREADY_EXISTS */] = 'A Firebase Analytics instance with the appId {$id} ' +
|
|
370
370
|
' already exists. ' +
|
|
371
371
|
'Only one Firebase Analytics instance can be created for each appId.',
|
|
372
|
-
_a["already-initialized" /* ALREADY_INITIALIZED */] = 'initializeAnalytics() cannot be called again with different options than those ' +
|
|
372
|
+
_a["already-initialized" /* AnalyticsError.ALREADY_INITIALIZED */] = 'initializeAnalytics() cannot be called again with different options than those ' +
|
|
373
373
|
'it was initially called with. It can be called again with the same options to ' +
|
|
374
374
|
'return the existing instance, or getAnalytics() can be used ' +
|
|
375
375
|
'to get a reference to the already-intialized instance.',
|
|
376
|
-
_a["already-initialized-settings" /* ALREADY_INITIALIZED_SETTINGS */] = 'Firebase Analytics has already been initialized.' +
|
|
376
|
+
_a["already-initialized-settings" /* AnalyticsError.ALREADY_INITIALIZED_SETTINGS */] = 'Firebase Analytics has already been initialized.' +
|
|
377
377
|
'settings() must be called before initializing any Analytics instance' +
|
|
378
378
|
'or it will have no effect.',
|
|
379
|
-
_a["interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */] = 'Firebase Analytics Interop Component failed to instantiate: {$reason}',
|
|
380
|
-
_a["invalid-analytics-context" /* INVALID_ANALYTICS_CONTEXT */] = 'Firebase Analytics is not supported in this environment. ' +
|
|
379
|
+
_a["interop-component-reg-failed" /* AnalyticsError.INTEROP_COMPONENT_REG_FAILED */] = 'Firebase Analytics Interop Component failed to instantiate: {$reason}',
|
|
380
|
+
_a["invalid-analytics-context" /* AnalyticsError.INVALID_ANALYTICS_CONTEXT */] = 'Firebase Analytics is not supported in this environment. ' +
|
|
381
381
|
'Wrap initialization of analytics in analytics.isSupported() ' +
|
|
382
382
|
'to prevent initialization in unsupported environments. Details: {$errorInfo}',
|
|
383
|
-
_a["indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */] = 'IndexedDB unavailable or restricted in this environment. ' +
|
|
383
|
+
_a["indexeddb-unavailable" /* AnalyticsError.INDEXEDDB_UNAVAILABLE */] = 'IndexedDB unavailable or restricted in this environment. ' +
|
|
384
384
|
'Wrap initialization of analytics in analytics.isSupported() ' +
|
|
385
385
|
'to prevent initialization in unsupported environments. Details: {$errorInfo}',
|
|
386
|
-
_a["fetch-throttle" /* FETCH_THROTTLE */] = 'The config fetch request timed out while in an exponential backoff state.' +
|
|
386
|
+
_a["fetch-throttle" /* AnalyticsError.FETCH_THROTTLE */] = 'The config fetch request timed out while in an exponential backoff state.' +
|
|
387
387
|
' Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',
|
|
388
|
-
_a["config-fetch-failed" /* CONFIG_FETCH_FAILED */] = 'Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}',
|
|
389
|
-
_a["no-api-key" /* NO_API_KEY */] = 'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
388
|
+
_a["config-fetch-failed" /* AnalyticsError.CONFIG_FETCH_FAILED */] = 'Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}',
|
|
389
|
+
_a["no-api-key" /* AnalyticsError.NO_API_KEY */] = 'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
390
390
|
'contain a valid API key.',
|
|
391
|
-
_a["no-app-id" /* NO_APP_ID */] = 'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
391
|
+
_a["no-app-id" /* AnalyticsError.NO_APP_ID */] = 'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
392
392
|
'contain a valid app ID.',
|
|
393
393
|
_a);
|
|
394
394
|
var ERROR_FACTORY = new util.ErrorFactory('analytics', 'Analytics', ERRORS);
|
|
@@ -487,7 +487,7 @@ function fetchDynamicConfig(appFields) {
|
|
|
487
487
|
case 4:
|
|
488
488
|
_b.sent();
|
|
489
489
|
return [3 /*break*/, 5];
|
|
490
|
-
case 5: throw ERROR_FACTORY.create("config-fetch-failed" /* CONFIG_FETCH_FAILED */, {
|
|
490
|
+
case 5: throw ERROR_FACTORY.create("config-fetch-failed" /* AnalyticsError.CONFIG_FETCH_FAILED */, {
|
|
491
491
|
httpStatus: response.status,
|
|
492
492
|
responseMessage: errorMessage
|
|
493
493
|
});
|
|
@@ -510,7 +510,7 @@ retryData, timeoutMillis) {
|
|
|
510
510
|
return tslib.__generator(this, function (_b) {
|
|
511
511
|
_a = app.options, appId = _a.appId, apiKey = _a.apiKey, measurementId = _a.measurementId;
|
|
512
512
|
if (!appId) {
|
|
513
|
-
throw ERROR_FACTORY.create("no-app-id" /* NO_APP_ID */);
|
|
513
|
+
throw ERROR_FACTORY.create("no-app-id" /* AnalyticsError.NO_APP_ID */);
|
|
514
514
|
}
|
|
515
515
|
if (!apiKey) {
|
|
516
516
|
if (measurementId) {
|
|
@@ -519,7 +519,7 @@ retryData, timeoutMillis) {
|
|
|
519
519
|
appId: appId
|
|
520
520
|
}];
|
|
521
521
|
}
|
|
522
|
-
throw ERROR_FACTORY.create("no-api-key" /* NO_API_KEY */);
|
|
522
|
+
throw ERROR_FACTORY.create("no-api-key" /* AnalyticsError.NO_API_KEY */);
|
|
523
523
|
}
|
|
524
524
|
throttleMetadata = retryData.getThrottleMetadata(appId) || {
|
|
525
525
|
backoffCount: 0,
|
|
@@ -545,55 +545,55 @@ retryData, timeoutMillis) {
|
|
|
545
545
|
*/
|
|
546
546
|
function attemptFetchDynamicConfigWithRetry(appFields, _a, signal, retryData // for testing
|
|
547
547
|
) {
|
|
548
|
-
var _b
|
|
548
|
+
var _b;
|
|
549
549
|
var throttleEndTimeMillis = _a.throttleEndTimeMillis, backoffCount = _a.backoffCount;
|
|
550
550
|
if (retryData === void 0) { retryData = defaultRetryData; }
|
|
551
551
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
552
552
|
var appId, measurementId, e_1, response, e_2, error, backoffMillis, throttleMetadata;
|
|
553
|
-
return tslib.__generator(this, function (
|
|
554
|
-
switch (
|
|
553
|
+
return tslib.__generator(this, function (_c) {
|
|
554
|
+
switch (_c.label) {
|
|
555
555
|
case 0:
|
|
556
556
|
appId = appFields.appId, measurementId = appFields.measurementId;
|
|
557
|
-
|
|
557
|
+
_c.label = 1;
|
|
558
558
|
case 1:
|
|
559
|
-
|
|
559
|
+
_c.trys.push([1, 3, , 4]);
|
|
560
560
|
return [4 /*yield*/, setAbortableTimeout(signal, throttleEndTimeMillis)];
|
|
561
561
|
case 2:
|
|
562
|
-
|
|
562
|
+
_c.sent();
|
|
563
563
|
return [3 /*break*/, 4];
|
|
564
564
|
case 3:
|
|
565
|
-
e_1 =
|
|
565
|
+
e_1 = _c.sent();
|
|
566
566
|
if (measurementId) {
|
|
567
567
|
logger.warn("Timed out fetching this Firebase app's measurement ID from the server." +
|
|
568
|
-
|
|
569
|
-
|
|
568
|
+
" Falling back to the measurement ID ".concat(measurementId) +
|
|
569
|
+
" provided in the \"measurementId\" field in the local Firebase config. [".concat(e_1 === null || e_1 === void 0 ? void 0 : e_1.message, "]"));
|
|
570
570
|
return [2 /*return*/, { appId: appId, measurementId: measurementId }];
|
|
571
571
|
}
|
|
572
572
|
throw e_1;
|
|
573
573
|
case 4:
|
|
574
|
-
|
|
574
|
+
_c.trys.push([4, 6, , 7]);
|
|
575
575
|
return [4 /*yield*/, fetchDynamicConfig(appFields)];
|
|
576
576
|
case 5:
|
|
577
|
-
response =
|
|
577
|
+
response = _c.sent();
|
|
578
578
|
// Note the SDK only clears throttle state if response is success or non-retriable.
|
|
579
579
|
retryData.deleteThrottleMetadata(appId);
|
|
580
580
|
return [2 /*return*/, response];
|
|
581
581
|
case 6:
|
|
582
|
-
e_2 =
|
|
582
|
+
e_2 = _c.sent();
|
|
583
583
|
error = e_2;
|
|
584
584
|
if (!isRetriableError(error)) {
|
|
585
585
|
retryData.deleteThrottleMetadata(appId);
|
|
586
586
|
if (measurementId) {
|
|
587
587
|
logger.warn("Failed to fetch this Firebase app's measurement ID from the server." +
|
|
588
|
-
|
|
589
|
-
|
|
588
|
+
" Falling back to the measurement ID ".concat(measurementId) +
|
|
589
|
+
" provided in the \"measurementId\" field in the local Firebase config. [".concat(error === null || error === void 0 ? void 0 : error.message, "]"));
|
|
590
590
|
return [2 /*return*/, { appId: appId, measurementId: measurementId }];
|
|
591
591
|
}
|
|
592
592
|
else {
|
|
593
593
|
throw e_2;
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
|
-
backoffMillis = Number((
|
|
596
|
+
backoffMillis = Number((_b = error === null || error === void 0 ? void 0 : error.customData) === null || _b === void 0 ? void 0 : _b.httpStatus) === 503
|
|
597
597
|
? util.calculateBackoffMillis(backoffCount, retryData.intervalMillis, LONG_RETRY_FACTOR)
|
|
598
598
|
: util.calculateBackoffMillis(backoffCount, retryData.intervalMillis);
|
|
599
599
|
throttleMetadata = {
|
|
@@ -602,7 +602,7 @@ function attemptFetchDynamicConfigWithRetry(appFields, _a, signal, retryData //
|
|
|
602
602
|
};
|
|
603
603
|
// Persists state.
|
|
604
604
|
retryData.setThrottleMetadata(appId, throttleMetadata);
|
|
605
|
-
logger.debug("Calling attemptFetch again in "
|
|
605
|
+
logger.debug("Calling attemptFetch again in ".concat(backoffMillis, " millis"));
|
|
606
606
|
return [2 /*return*/, attemptFetchDynamicConfigWithRetry(appFields, throttleMetadata, signal, retryData)];
|
|
607
607
|
case 7: return [2 /*return*/];
|
|
608
608
|
}
|
|
@@ -630,7 +630,7 @@ function setAbortableTimeout(signal, throttleEndTimeMillis) {
|
|
|
630
630
|
signal.addEventListener(function () {
|
|
631
631
|
clearTimeout(timeout);
|
|
632
632
|
// If the request completes before this timeout, the rejection has no effect.
|
|
633
|
-
reject(ERROR_FACTORY.create("fetch-throttle" /* FETCH_THROTTLE */, {
|
|
633
|
+
reject(ERROR_FACTORY.create("fetch-throttle" /* AnalyticsError.FETCH_THROTTLE */, {
|
|
634
634
|
throttleEndTimeMillis: throttleEndTimeMillis
|
|
635
635
|
}));
|
|
636
636
|
});
|
|
@@ -705,13 +705,13 @@ function logEvent$1(gtagFunction, initializationPromise, eventName, eventParams,
|
|
|
705
705
|
switch (_a.label) {
|
|
706
706
|
case 0:
|
|
707
707
|
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
708
|
-
gtagFunction("event" /* EVENT */, eventName, eventParams);
|
|
708
|
+
gtagFunction("event" /* GtagCommand.EVENT */, eventName, eventParams);
|
|
709
709
|
return [2 /*return*/];
|
|
710
710
|
case 1: return [4 /*yield*/, initializationPromise];
|
|
711
711
|
case 2:
|
|
712
712
|
measurementId = _a.sent();
|
|
713
713
|
params = tslib.__assign(tslib.__assign({}, eventParams), { 'send_to': measurementId });
|
|
714
|
-
gtagFunction("event" /* EVENT */, eventName, params);
|
|
714
|
+
gtagFunction("event" /* GtagCommand.EVENT */, eventName, params);
|
|
715
715
|
_a.label = 3;
|
|
716
716
|
case 3: return [2 /*return*/];
|
|
717
717
|
}
|
|
@@ -734,12 +734,12 @@ function setCurrentScreen$1(gtagFunction, initializationPromise, screenName, opt
|
|
|
734
734
|
switch (_a.label) {
|
|
735
735
|
case 0:
|
|
736
736
|
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
737
|
-
gtagFunction("set" /* SET */, { 'screen_name': screenName });
|
|
737
|
+
gtagFunction("set" /* GtagCommand.SET */, { 'screen_name': screenName });
|
|
738
738
|
return [2 /*return*/, Promise.resolve()];
|
|
739
739
|
case 1: return [4 /*yield*/, initializationPromise];
|
|
740
740
|
case 2:
|
|
741
741
|
measurementId = _a.sent();
|
|
742
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
742
|
+
gtagFunction("config" /* GtagCommand.CONFIG */, measurementId, {
|
|
743
743
|
update: true,
|
|
744
744
|
'screen_name': screenName
|
|
745
745
|
});
|
|
@@ -762,12 +762,12 @@ function setUserId$1(gtagFunction, initializationPromise, id, options) {
|
|
|
762
762
|
switch (_a.label) {
|
|
763
763
|
case 0:
|
|
764
764
|
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
765
|
-
gtagFunction("set" /* SET */, { 'user_id': id });
|
|
765
|
+
gtagFunction("set" /* GtagCommand.SET */, { 'user_id': id });
|
|
766
766
|
return [2 /*return*/, Promise.resolve()];
|
|
767
767
|
case 1: return [4 /*yield*/, initializationPromise];
|
|
768
768
|
case 2:
|
|
769
769
|
measurementId = _a.sent();
|
|
770
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
770
|
+
gtagFunction("config" /* GtagCommand.CONFIG */, measurementId, {
|
|
771
771
|
update: true,
|
|
772
772
|
'user_id': id
|
|
773
773
|
});
|
|
@@ -794,14 +794,14 @@ function setUserProperties$1(gtagFunction, initializationPromise, properties, op
|
|
|
794
794
|
for (_i = 0, _a = Object.keys(properties); _i < _a.length; _i++) {
|
|
795
795
|
key = _a[_i];
|
|
796
796
|
// use dot notation for merge behavior in gtag.js
|
|
797
|
-
flatProperties["user_properties."
|
|
797
|
+
flatProperties["user_properties.".concat(key)] = properties[key];
|
|
798
798
|
}
|
|
799
|
-
gtagFunction("set" /* SET */, flatProperties);
|
|
799
|
+
gtagFunction("set" /* GtagCommand.SET */, flatProperties);
|
|
800
800
|
return [2 /*return*/, Promise.resolve()];
|
|
801
801
|
case 1: return [4 /*yield*/, initializationPromise];
|
|
802
802
|
case 2:
|
|
803
803
|
measurementId = _b.sent();
|
|
804
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
804
|
+
gtagFunction("config" /* GtagCommand.CONFIG */, measurementId, {
|
|
805
805
|
update: true,
|
|
806
806
|
'user_properties': properties
|
|
807
807
|
});
|
|
@@ -824,7 +824,7 @@ function setAnalyticsCollectionEnabled$1(initializationPromise, enabled) {
|
|
|
824
824
|
case 0: return [4 /*yield*/, initializationPromise];
|
|
825
825
|
case 1:
|
|
826
826
|
measurementId = _a.sent();
|
|
827
|
-
window["ga-disable-"
|
|
827
|
+
window["ga-disable-".concat(measurementId)] = !enabled;
|
|
828
828
|
return [2 /*return*/];
|
|
829
829
|
}
|
|
830
830
|
});
|
|
@@ -870,27 +870,26 @@ function _setDefaultEventParametersForInit(customParams) {
|
|
|
870
870
|
* limitations under the License.
|
|
871
871
|
*/
|
|
872
872
|
function validateIndexedDB() {
|
|
873
|
-
var _a;
|
|
874
873
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
875
874
|
var e_1;
|
|
876
|
-
return tslib.__generator(this, function (
|
|
877
|
-
switch (
|
|
875
|
+
return tslib.__generator(this, function (_a) {
|
|
876
|
+
switch (_a.label) {
|
|
878
877
|
case 0:
|
|
879
878
|
if (!!util.isIndexedDBAvailable()) return [3 /*break*/, 1];
|
|
880
|
-
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */, {
|
|
879
|
+
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* AnalyticsError.INDEXEDDB_UNAVAILABLE */, {
|
|
881
880
|
errorInfo: 'IndexedDB is not available in this environment.'
|
|
882
881
|
}).message);
|
|
883
882
|
return [2 /*return*/, false];
|
|
884
883
|
case 1:
|
|
885
|
-
|
|
884
|
+
_a.trys.push([1, 3, , 4]);
|
|
886
885
|
return [4 /*yield*/, util.validateIndexedDBOpenable()];
|
|
887
886
|
case 2:
|
|
888
|
-
|
|
887
|
+
_a.sent();
|
|
889
888
|
return [3 /*break*/, 4];
|
|
890
889
|
case 3:
|
|
891
|
-
e_1 =
|
|
892
|
-
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */, {
|
|
893
|
-
errorInfo:
|
|
890
|
+
e_1 = _a.sent();
|
|
891
|
+
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* AnalyticsError.INDEXEDDB_UNAVAILABLE */, {
|
|
892
|
+
errorInfo: e_1 === null || e_1 === void 0 ? void 0 : e_1.toString()
|
|
894
893
|
}).message);
|
|
895
894
|
return [2 /*return*/, false];
|
|
896
895
|
case 4: return [2 /*return*/, true];
|
|
@@ -925,8 +924,8 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
925
924
|
measurementIdToAppId[config.measurementId] = config.appId;
|
|
926
925
|
if (app.options.measurementId &&
|
|
927
926
|
config.measurementId !== app.options.measurementId) {
|
|
928
|
-
logger.warn("The measurement ID in the local Firebase config ("
|
|
929
|
-
|
|
927
|
+
logger.warn("The measurement ID in the local Firebase config (".concat(app.options.measurementId, ")") +
|
|
928
|
+
" does not match the measurement ID fetched from the server (".concat(config.measurementId, ").") +
|
|
930
929
|
" To ensure analytics events are always sent to the correct Analytics property," +
|
|
931
930
|
" update the" +
|
|
932
931
|
" measurement ID field in the local config or remove it from the local config.");
|
|
@@ -956,7 +955,7 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
956
955
|
}
|
|
957
956
|
// Detects if there are consent settings that need to be configured.
|
|
958
957
|
if (defaultConsentSettingsForInit) {
|
|
959
|
-
gtagCore("consent" /* CONSENT */, 'default', defaultConsentSettingsForInit);
|
|
958
|
+
gtagCore("consent" /* GtagCommand.CONSENT */, 'default', defaultConsentSettingsForInit);
|
|
960
959
|
_setConsentDefaultForInit(undefined);
|
|
961
960
|
}
|
|
962
961
|
// This command initializes gtag.js and only needs to be called once for the entire web app,
|
|
@@ -975,10 +974,10 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
975
974
|
// Initialize this GA-ID and set FID on it using the gtag config API.
|
|
976
975
|
// Note: This will trigger a page_view event unless 'send_page_view' is set to false in
|
|
977
976
|
// `configProperties`.
|
|
978
|
-
gtagCore("config" /* CONFIG */, dynamicConfig.measurementId, configProperties);
|
|
977
|
+
gtagCore("config" /* GtagCommand.CONFIG */, dynamicConfig.measurementId, configProperties);
|
|
979
978
|
// Detects if there is data that will be set on every event logged from the SDK.
|
|
980
979
|
if (defaultEventParametersForInit) {
|
|
981
|
-
gtagCore("set" /* SET */, defaultEventParametersForInit);
|
|
980
|
+
gtagCore("set" /* GtagCommand.SET */, defaultEventParametersForInit);
|
|
982
981
|
_setDefaultEventParametersForInit(undefined);
|
|
983
982
|
}
|
|
984
983
|
return [2 /*return*/, dynamicConfig.measurementId];
|
|
@@ -1072,7 +1071,7 @@ var globalInitDone = false;
|
|
|
1072
1071
|
*/
|
|
1073
1072
|
function settings(options) {
|
|
1074
1073
|
if (globalInitDone) {
|
|
1075
|
-
throw ERROR_FACTORY.create("already-initialized" /* ALREADY_INITIALIZED */);
|
|
1074
|
+
throw ERROR_FACTORY.create("already-initialized" /* AnalyticsError.ALREADY_INITIALIZED */);
|
|
1076
1075
|
}
|
|
1077
1076
|
if (options.dataLayerName) {
|
|
1078
1077
|
dataLayerName = options.dataLayerName;
|
|
@@ -1096,9 +1095,9 @@ function warnOnBrowserContextMismatch() {
|
|
|
1096
1095
|
}
|
|
1097
1096
|
if (mismatchedEnvMessages.length > 0) {
|
|
1098
1097
|
var details = mismatchedEnvMessages
|
|
1099
|
-
.map(function (message, index) { return "("
|
|
1098
|
+
.map(function (message, index) { return "(".concat(index + 1, ") ").concat(message); })
|
|
1100
1099
|
.join(' ');
|
|
1101
|
-
var err = ERROR_FACTORY.create("invalid-analytics-context" /* INVALID_ANALYTICS_CONTEXT */, {
|
|
1100
|
+
var err = ERROR_FACTORY.create("invalid-analytics-context" /* AnalyticsError.INVALID_ANALYTICS_CONTEXT */, {
|
|
1102
1101
|
errorInfo: details
|
|
1103
1102
|
});
|
|
1104
1103
|
logger.warn(err.message);
|
|
@@ -1112,20 +1111,20 @@ function factory(app, installations, options) {
|
|
|
1112
1111
|
warnOnBrowserContextMismatch();
|
|
1113
1112
|
var appId = app.options.appId;
|
|
1114
1113
|
if (!appId) {
|
|
1115
|
-
throw ERROR_FACTORY.create("no-app-id" /* NO_APP_ID */);
|
|
1114
|
+
throw ERROR_FACTORY.create("no-app-id" /* AnalyticsError.NO_APP_ID */);
|
|
1116
1115
|
}
|
|
1117
1116
|
if (!app.options.apiKey) {
|
|
1118
1117
|
if (app.options.measurementId) {
|
|
1119
1118
|
logger.warn("The \"apiKey\" field is empty in the local Firebase config. This is needed to fetch the latest" +
|
|
1120
|
-
|
|
1119
|
+
" measurement ID for this Firebase app. Falling back to the measurement ID ".concat(app.options.measurementId) +
|
|
1121
1120
|
" provided in the \"measurementId\" field in the local Firebase config.");
|
|
1122
1121
|
}
|
|
1123
1122
|
else {
|
|
1124
|
-
throw ERROR_FACTORY.create("no-api-key" /* NO_API_KEY */);
|
|
1123
|
+
throw ERROR_FACTORY.create("no-api-key" /* AnalyticsError.NO_API_KEY */);
|
|
1125
1124
|
}
|
|
1126
1125
|
}
|
|
1127
1126
|
if (initializationPromisesMap[appId] != null) {
|
|
1128
|
-
throw ERROR_FACTORY.create("already-exists" /* ALREADY_EXISTS */, {
|
|
1127
|
+
throw ERROR_FACTORY.create("already-exists" /* AnalyticsError.ALREADY_EXISTS */, {
|
|
1129
1128
|
id: appId
|
|
1130
1129
|
});
|
|
1131
1130
|
}
|
|
@@ -1180,7 +1179,7 @@ function initializeAnalytics(app$1, options) {
|
|
|
1180
1179
|
return existingInstance;
|
|
1181
1180
|
}
|
|
1182
1181
|
else {
|
|
1183
|
-
throw ERROR_FACTORY.create("already-initialized" /* ALREADY_INITIALIZED */);
|
|
1182
|
+
throw ERROR_FACTORY.create("already-initialized" /* AnalyticsError.ALREADY_INITIALIZED */);
|
|
1184
1183
|
}
|
|
1185
1184
|
}
|
|
1186
1185
|
var analyticsInstance = analyticsProvider.initialize({ options: options });
|
|
@@ -1286,7 +1285,7 @@ function setAnalyticsCollectionEnabled(analyticsInstance, enabled) {
|
|
|
1286
1285
|
function setDefaultEventParameters(customParams) {
|
|
1287
1286
|
// Check if reference to existing gtag function on window object exists
|
|
1288
1287
|
if (wrappedGtagFunction) {
|
|
1289
|
-
wrappedGtagFunction("set" /* SET */, customParams);
|
|
1288
|
+
wrappedGtagFunction("set" /* GtagCommand.SET */, customParams);
|
|
1290
1289
|
}
|
|
1291
1290
|
else {
|
|
1292
1291
|
_setDefaultEventParametersForInit(customParams);
|
|
@@ -1319,7 +1318,7 @@ function logEvent(analyticsInstance, eventName, eventParams, options) {
|
|
|
1319
1318
|
function setConsent(consentSettings) {
|
|
1320
1319
|
// Check if reference to existing gtag function on window object exists
|
|
1321
1320
|
if (wrappedGtagFunction) {
|
|
1322
|
-
wrappedGtagFunction("consent" /* CONSENT */, 'update', consentSettings);
|
|
1321
|
+
wrappedGtagFunction("consent" /* GtagCommand.CONSENT */, 'update', consentSettings);
|
|
1323
1322
|
}
|
|
1324
1323
|
else {
|
|
1325
1324
|
_setConsentDefaultForInit(consentSettings);
|
|
@@ -1327,7 +1326,7 @@ function setConsent(consentSettings) {
|
|
|
1327
1326
|
}
|
|
1328
1327
|
|
|
1329
1328
|
var name = "@firebase/analytics";
|
|
1330
|
-
var version = "0.
|
|
1329
|
+
var version = "0.9.0";
|
|
1331
1330
|
|
|
1332
1331
|
/**
|
|
1333
1332
|
* Firebase Analytics
|
|
@@ -1343,8 +1342,8 @@ function registerAnalytics() {
|
|
|
1343
1342
|
.getProvider('installations-internal')
|
|
1344
1343
|
.getImmediate();
|
|
1345
1344
|
return factory(app, installations, analyticsOptions);
|
|
1346
|
-
}, "PUBLIC" /* PUBLIC */));
|
|
1347
|
-
app._registerComponent(new component.Component('analytics-internal', internalFactory, "PRIVATE" /* PRIVATE */));
|
|
1345
|
+
}, "PUBLIC" /* ComponentType.PUBLIC */));
|
|
1346
|
+
app._registerComponent(new component.Component('analytics-internal', internalFactory, "PRIVATE" /* ComponentType.PRIVATE */));
|
|
1348
1347
|
app.registerVersion(name, version);
|
|
1349
1348
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
1350
1349
|
app.registerVersion(name, version, 'cjs5');
|
|
@@ -1356,7 +1355,7 @@ function registerAnalytics() {
|
|
|
1356
1355
|
};
|
|
1357
1356
|
}
|
|
1358
1357
|
catch (e) {
|
|
1359
|
-
throw ERROR_FACTORY.create("interop-component-reg-failed" /* INTEROP_COMPONENT_REG_FAILED */, {
|
|
1358
|
+
throw ERROR_FACTORY.create("interop-component-reg-failed" /* AnalyticsError.INTEROP_COMPONENT_REG_FAILED */, {
|
|
1360
1359
|
reason: e
|
|
1361
1360
|
});
|
|
1362
1361
|
}
|