@firebase/analytics 0.7.10 → 0.7.11-canary.13550089f
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 +11 -0
- package/dist/analytics-public.d.ts +53 -1
- package/dist/analytics.d.ts +53 -1
- package/dist/esm/index.esm.js +259 -180
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +193 -116
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/api.d.ts +19 -1
- package/dist/esm/src/constants.d.ts +2 -1
- package/dist/esm/src/functions.d.ts +23 -1
- package/dist/esm/src/public-types.d.ts +31 -1
- package/dist/esm/src/types.d.ts +2 -1
- package/dist/index.cjs.js +260 -179
- package/dist/index.cjs.js.map +1 -1
- package/dist/src/api.d.ts +19 -1
- package/dist/src/constants.d.ts +2 -1
- package/dist/src/functions.d.ts +23 -1
- package/dist/src/public-types.d.ts +31 -1
- package/dist/src/types.d.ts +2 -1
- package/package.json +7 -7
package/dist/esm/index.esm.js
CHANGED
|
@@ -277,8 +277,14 @@ measurementIdToAppId) {
|
|
|
277
277
|
_a.sent();
|
|
278
278
|
return [3 /*break*/, 5];
|
|
279
279
|
case 4:
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
if (command === "consent" /* CONSENT */) {
|
|
281
|
+
// If CONFIG, second arg must be measurementId.
|
|
282
|
+
gtagCore("consent" /* CONSENT */, 'update', gtagParams);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
// If SET, second arg must be params.
|
|
286
|
+
gtagCore("set" /* SET */, idOrNameOrParams);
|
|
287
|
+
}
|
|
282
288
|
_a.label = 5;
|
|
283
289
|
case 5: return [3 /*break*/, 7];
|
|
284
290
|
case 6:
|
|
@@ -536,53 +542,55 @@ retryData, timeoutMillis) {
|
|
|
536
542
|
*/
|
|
537
543
|
function attemptFetchDynamicConfigWithRetry(appFields, _a, signal, retryData // for testing
|
|
538
544
|
) {
|
|
545
|
+
var _b, _c;
|
|
539
546
|
var throttleEndTimeMillis = _a.throttleEndTimeMillis, backoffCount = _a.backoffCount;
|
|
540
547
|
if (retryData === void 0) { retryData = defaultRetryData; }
|
|
541
548
|
return __awaiter(this, void 0, void 0, function () {
|
|
542
|
-
var appId, measurementId, e_1, response, e_2, backoffMillis, throttleMetadata;
|
|
543
|
-
return __generator(this, function (
|
|
544
|
-
switch (
|
|
549
|
+
var appId, measurementId, e_1, response, e_2, error, backoffMillis, throttleMetadata;
|
|
550
|
+
return __generator(this, function (_d) {
|
|
551
|
+
switch (_d.label) {
|
|
545
552
|
case 0:
|
|
546
553
|
appId = appFields.appId, measurementId = appFields.measurementId;
|
|
547
|
-
|
|
554
|
+
_d.label = 1;
|
|
548
555
|
case 1:
|
|
549
|
-
|
|
556
|
+
_d.trys.push([1, 3, , 4]);
|
|
550
557
|
return [4 /*yield*/, setAbortableTimeout(signal, throttleEndTimeMillis)];
|
|
551
558
|
case 2:
|
|
552
|
-
|
|
559
|
+
_d.sent();
|
|
553
560
|
return [3 /*break*/, 4];
|
|
554
561
|
case 3:
|
|
555
|
-
e_1 =
|
|
562
|
+
e_1 = _d.sent();
|
|
556
563
|
if (measurementId) {
|
|
557
564
|
logger.warn("Timed out fetching this Firebase app's measurement ID from the server." +
|
|
558
565
|
(" Falling back to the measurement ID " + measurementId) +
|
|
559
|
-
(" provided in the \"measurementId\" field in the local Firebase config. [" + e_1.message + "]"));
|
|
566
|
+
(" provided in the \"measurementId\" field in the local Firebase config. [" + ((_b = e_1) === null || _b === void 0 ? void 0 : _b.message) + "]"));
|
|
560
567
|
return [2 /*return*/, { appId: appId, measurementId: measurementId }];
|
|
561
568
|
}
|
|
562
569
|
throw e_1;
|
|
563
570
|
case 4:
|
|
564
|
-
|
|
571
|
+
_d.trys.push([4, 6, , 7]);
|
|
565
572
|
return [4 /*yield*/, fetchDynamicConfig(appFields)];
|
|
566
573
|
case 5:
|
|
567
|
-
response =
|
|
574
|
+
response = _d.sent();
|
|
568
575
|
// Note the SDK only clears throttle state if response is success or non-retriable.
|
|
569
576
|
retryData.deleteThrottleMetadata(appId);
|
|
570
577
|
return [2 /*return*/, response];
|
|
571
578
|
case 6:
|
|
572
|
-
e_2 =
|
|
573
|
-
|
|
579
|
+
e_2 = _d.sent();
|
|
580
|
+
error = e_2;
|
|
581
|
+
if (!isRetriableError(error)) {
|
|
574
582
|
retryData.deleteThrottleMetadata(appId);
|
|
575
583
|
if (measurementId) {
|
|
576
584
|
logger.warn("Failed to fetch this Firebase app's measurement ID from the server." +
|
|
577
585
|
(" Falling back to the measurement ID " + measurementId) +
|
|
578
|
-
(" provided in the \"measurementId\" field in the local Firebase config. [" +
|
|
586
|
+
(" provided in the \"measurementId\" field in the local Firebase config. [" + (error === null || error === void 0 ? void 0 : error.message) + "]"));
|
|
579
587
|
return [2 /*return*/, { appId: appId, measurementId: measurementId }];
|
|
580
588
|
}
|
|
581
589
|
else {
|
|
582
590
|
throw e_2;
|
|
583
591
|
}
|
|
584
592
|
}
|
|
585
|
-
backoffMillis = Number(
|
|
593
|
+
backoffMillis = Number((_c = error === null || error === void 0 ? void 0 : error.customData) === null || _c === void 0 ? void 0 : _c.httpStatus) === 503
|
|
586
594
|
? calculateBackoffMillis(backoffCount, retryData.intervalMillis, LONG_RETRY_FACTOR)
|
|
587
595
|
: calculateBackoffMillis(backoffCount, retryData.intervalMillis);
|
|
588
596
|
throttleMetadata = {
|
|
@@ -660,6 +668,188 @@ var AnalyticsAbortSignal = /** @class */ (function () {
|
|
|
660
668
|
return AnalyticsAbortSignal;
|
|
661
669
|
}());
|
|
662
670
|
|
|
671
|
+
/**
|
|
672
|
+
* @license
|
|
673
|
+
* Copyright 2019 Google LLC
|
|
674
|
+
*
|
|
675
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
676
|
+
* you may not use this file except in compliance with the License.
|
|
677
|
+
* You may obtain a copy of the License at
|
|
678
|
+
*
|
|
679
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
680
|
+
*
|
|
681
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
682
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
683
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
684
|
+
* See the License for the specific language governing permissions and
|
|
685
|
+
* limitations under the License.
|
|
686
|
+
*/
|
|
687
|
+
/**
|
|
688
|
+
* Event parameters to set on 'gtag' during initialization.
|
|
689
|
+
*/
|
|
690
|
+
var defaultEventParametersForInit;
|
|
691
|
+
/**
|
|
692
|
+
* Logs an analytics event through the Firebase SDK.
|
|
693
|
+
*
|
|
694
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
695
|
+
* @param eventName Google Analytics event name, choose from standard list or use a custom string.
|
|
696
|
+
* @param eventParams Analytics event parameters.
|
|
697
|
+
*/
|
|
698
|
+
function logEvent$1(gtagFunction, initializationPromise, eventName, eventParams, options) {
|
|
699
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
700
|
+
var measurementId, params;
|
|
701
|
+
return __generator(this, function (_a) {
|
|
702
|
+
switch (_a.label) {
|
|
703
|
+
case 0:
|
|
704
|
+
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
705
|
+
gtagFunction("event" /* EVENT */, eventName, eventParams);
|
|
706
|
+
return [2 /*return*/];
|
|
707
|
+
case 1: return [4 /*yield*/, initializationPromise];
|
|
708
|
+
case 2:
|
|
709
|
+
measurementId = _a.sent();
|
|
710
|
+
params = __assign(__assign({}, eventParams), { 'send_to': measurementId });
|
|
711
|
+
gtagFunction("event" /* EVENT */, eventName, params);
|
|
712
|
+
_a.label = 3;
|
|
713
|
+
case 3: return [2 /*return*/];
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Set screen_name parameter for this Google Analytics ID.
|
|
720
|
+
*
|
|
721
|
+
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
|
|
722
|
+
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
|
|
723
|
+
*
|
|
724
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
725
|
+
* @param screenName Screen name string to set.
|
|
726
|
+
*/
|
|
727
|
+
function setCurrentScreen$1(gtagFunction, initializationPromise, screenName, options) {
|
|
728
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
729
|
+
var measurementId;
|
|
730
|
+
return __generator(this, function (_a) {
|
|
731
|
+
switch (_a.label) {
|
|
732
|
+
case 0:
|
|
733
|
+
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
734
|
+
gtagFunction("set" /* SET */, { 'screen_name': screenName });
|
|
735
|
+
return [2 /*return*/, Promise.resolve()];
|
|
736
|
+
case 1: return [4 /*yield*/, initializationPromise];
|
|
737
|
+
case 2:
|
|
738
|
+
measurementId = _a.sent();
|
|
739
|
+
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
740
|
+
update: true,
|
|
741
|
+
'screen_name': screenName
|
|
742
|
+
});
|
|
743
|
+
_a.label = 3;
|
|
744
|
+
case 3: return [2 /*return*/];
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Set user_id parameter for this Google Analytics ID.
|
|
751
|
+
*
|
|
752
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
753
|
+
* @param id User ID string to set
|
|
754
|
+
*/
|
|
755
|
+
function setUserId$1(gtagFunction, initializationPromise, id, options) {
|
|
756
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
757
|
+
var measurementId;
|
|
758
|
+
return __generator(this, function (_a) {
|
|
759
|
+
switch (_a.label) {
|
|
760
|
+
case 0:
|
|
761
|
+
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
762
|
+
gtagFunction("set" /* SET */, { 'user_id': id });
|
|
763
|
+
return [2 /*return*/, Promise.resolve()];
|
|
764
|
+
case 1: return [4 /*yield*/, initializationPromise];
|
|
765
|
+
case 2:
|
|
766
|
+
measurementId = _a.sent();
|
|
767
|
+
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
768
|
+
update: true,
|
|
769
|
+
'user_id': id
|
|
770
|
+
});
|
|
771
|
+
_a.label = 3;
|
|
772
|
+
case 3: return [2 /*return*/];
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Set all other user properties other than user_id and screen_name.
|
|
779
|
+
*
|
|
780
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
781
|
+
* @param properties Map of user properties to set
|
|
782
|
+
*/
|
|
783
|
+
function setUserProperties$1(gtagFunction, initializationPromise, properties, options) {
|
|
784
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
785
|
+
var flatProperties, _i, _a, key, measurementId;
|
|
786
|
+
return __generator(this, function (_b) {
|
|
787
|
+
switch (_b.label) {
|
|
788
|
+
case 0:
|
|
789
|
+
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
790
|
+
flatProperties = {};
|
|
791
|
+
for (_i = 0, _a = Object.keys(properties); _i < _a.length; _i++) {
|
|
792
|
+
key = _a[_i];
|
|
793
|
+
// use dot notation for merge behavior in gtag.js
|
|
794
|
+
flatProperties["user_properties." + key] = properties[key];
|
|
795
|
+
}
|
|
796
|
+
gtagFunction("set" /* SET */, flatProperties);
|
|
797
|
+
return [2 /*return*/, Promise.resolve()];
|
|
798
|
+
case 1: return [4 /*yield*/, initializationPromise];
|
|
799
|
+
case 2:
|
|
800
|
+
measurementId = _b.sent();
|
|
801
|
+
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
802
|
+
update: true,
|
|
803
|
+
'user_properties': properties
|
|
804
|
+
});
|
|
805
|
+
_b.label = 3;
|
|
806
|
+
case 3: return [2 /*return*/];
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Set whether collection is enabled for this ID.
|
|
813
|
+
*
|
|
814
|
+
* @param enabled If true, collection is enabled for this ID.
|
|
815
|
+
*/
|
|
816
|
+
function setAnalyticsCollectionEnabled$1(initializationPromise, enabled) {
|
|
817
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
818
|
+
var measurementId;
|
|
819
|
+
return __generator(this, function (_a) {
|
|
820
|
+
switch (_a.label) {
|
|
821
|
+
case 0: return [4 /*yield*/, initializationPromise];
|
|
822
|
+
case 1:
|
|
823
|
+
measurementId = _a.sent();
|
|
824
|
+
window["ga-disable-" + measurementId] = !enabled;
|
|
825
|
+
return [2 /*return*/];
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Consent parameters to default to during 'gtag' initialization.
|
|
832
|
+
*/
|
|
833
|
+
var defaultConsentSettingsForInit;
|
|
834
|
+
/**
|
|
835
|
+
* Sets the variable {@link defaultConsentSettingsForInit} for use in the initialization of
|
|
836
|
+
* analytics.
|
|
837
|
+
*
|
|
838
|
+
* @param consentSettings Maps the applicable end user consent state for gtag.js.
|
|
839
|
+
*/
|
|
840
|
+
function _setConsentDefaultForInit(consentSettings) {
|
|
841
|
+
defaultConsentSettingsForInit = consentSettings;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Sets the variable `defaultEventParametersForInit` for use in the initialization of
|
|
845
|
+
* analytics.
|
|
846
|
+
*
|
|
847
|
+
* @param customParams Any custom params the user may pass to gtag.js.
|
|
848
|
+
*/
|
|
849
|
+
function _setDefaultEventParametersForInit(customParams) {
|
|
850
|
+
defaultEventParametersForInit = customParams;
|
|
851
|
+
}
|
|
852
|
+
|
|
663
853
|
/**
|
|
664
854
|
* @license
|
|
665
855
|
* Copyright 2020 Google LLC
|
|
@@ -677,10 +867,11 @@ var AnalyticsAbortSignal = /** @class */ (function () {
|
|
|
677
867
|
* limitations under the License.
|
|
678
868
|
*/
|
|
679
869
|
function validateIndexedDB() {
|
|
870
|
+
var _a;
|
|
680
871
|
return __awaiter(this, void 0, void 0, function () {
|
|
681
872
|
var e_1;
|
|
682
|
-
return __generator(this, function (
|
|
683
|
-
switch (
|
|
873
|
+
return __generator(this, function (_b) {
|
|
874
|
+
switch (_b.label) {
|
|
684
875
|
case 0:
|
|
685
876
|
if (!!isIndexedDBAvailable()) return [3 /*break*/, 1];
|
|
686
877
|
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */, {
|
|
@@ -688,15 +879,15 @@ function validateIndexedDB() {
|
|
|
688
879
|
}).message);
|
|
689
880
|
return [2 /*return*/, false];
|
|
690
881
|
case 1:
|
|
691
|
-
|
|
882
|
+
_b.trys.push([1, 3, , 4]);
|
|
692
883
|
return [4 /*yield*/, validateIndexedDBOpenable()];
|
|
693
884
|
case 2:
|
|
694
|
-
|
|
885
|
+
_b.sent();
|
|
695
886
|
return [3 /*break*/, 4];
|
|
696
887
|
case 3:
|
|
697
|
-
e_1 =
|
|
888
|
+
e_1 = _b.sent();
|
|
698
889
|
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */, {
|
|
699
|
-
errorInfo: e_1
|
|
890
|
+
errorInfo: (_a = e_1) === null || _a === void 0 ? void 0 : _a.toString()
|
|
700
891
|
}).message);
|
|
701
892
|
return [2 /*return*/, false];
|
|
702
893
|
case 4: return [2 /*return*/, true];
|
|
@@ -759,6 +950,11 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
759
950
|
if (!findGtagScriptOnPage()) {
|
|
760
951
|
insertScriptTag(dataLayerName, dynamicConfig.measurementId);
|
|
761
952
|
}
|
|
953
|
+
// Detects if there are consent settings that need to be configured.
|
|
954
|
+
if (defaultConsentSettingsForInit) {
|
|
955
|
+
gtagCore("consent" /* CONSENT */, 'default', defaultConsentSettingsForInit);
|
|
956
|
+
_setConsentDefaultForInit(undefined);
|
|
957
|
+
}
|
|
762
958
|
// This command initializes gtag.js and only needs to be called once for the entire web app,
|
|
763
959
|
// but since it is idempotent, we can call it multiple times.
|
|
764
960
|
// We keep it together with other initialization logic for better code structure.
|
|
@@ -776,6 +972,11 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
776
972
|
// Note: This will trigger a page_view event unless 'send_page_view' is set to false in
|
|
777
973
|
// `configProperties`.
|
|
778
974
|
gtagCore("config" /* CONFIG */, dynamicConfig.measurementId, configProperties);
|
|
975
|
+
// Detects if there is data that will be set on every event logged from the SDK.
|
|
976
|
+
if (defaultEventParametersForInit) {
|
|
977
|
+
gtagCore("set" /* SET */, defaultEventParametersForInit);
|
|
978
|
+
_setDefaultEventParametersForInit(undefined);
|
|
979
|
+
}
|
|
779
980
|
return [2 /*return*/, dynamicConfig.measurementId];
|
|
780
981
|
}
|
|
781
982
|
});
|
|
@@ -940,162 +1141,6 @@ function factory(app, installations, options) {
|
|
|
940
1141
|
return analyticsInstance;
|
|
941
1142
|
}
|
|
942
1143
|
|
|
943
|
-
/**
|
|
944
|
-
* @license
|
|
945
|
-
* Copyright 2019 Google LLC
|
|
946
|
-
*
|
|
947
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
948
|
-
* you may not use this file except in compliance with the License.
|
|
949
|
-
* You may obtain a copy of the License at
|
|
950
|
-
*
|
|
951
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
952
|
-
*
|
|
953
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
954
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
955
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
956
|
-
* See the License for the specific language governing permissions and
|
|
957
|
-
* limitations under the License.
|
|
958
|
-
*/
|
|
959
|
-
/**
|
|
960
|
-
* Logs an analytics event through the Firebase SDK.
|
|
961
|
-
*
|
|
962
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
963
|
-
* @param eventName Google Analytics event name, choose from standard list or use a custom string.
|
|
964
|
-
* @param eventParams Analytics event parameters.
|
|
965
|
-
*/
|
|
966
|
-
function logEvent$1(gtagFunction, initializationPromise, eventName, eventParams, options) {
|
|
967
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
968
|
-
var measurementId, params;
|
|
969
|
-
return __generator(this, function (_a) {
|
|
970
|
-
switch (_a.label) {
|
|
971
|
-
case 0:
|
|
972
|
-
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
973
|
-
gtagFunction("event" /* EVENT */, eventName, eventParams);
|
|
974
|
-
return [2 /*return*/];
|
|
975
|
-
case 1: return [4 /*yield*/, initializationPromise];
|
|
976
|
-
case 2:
|
|
977
|
-
measurementId = _a.sent();
|
|
978
|
-
params = __assign(__assign({}, eventParams), { 'send_to': measurementId });
|
|
979
|
-
gtagFunction("event" /* EVENT */, eventName, params);
|
|
980
|
-
_a.label = 3;
|
|
981
|
-
case 3: return [2 /*return*/];
|
|
982
|
-
}
|
|
983
|
-
});
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* Set screen_name parameter for this Google Analytics ID.
|
|
988
|
-
*
|
|
989
|
-
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
|
|
990
|
-
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
|
|
991
|
-
*
|
|
992
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
993
|
-
* @param screenName Screen name string to set.
|
|
994
|
-
*/
|
|
995
|
-
function setCurrentScreen$1(gtagFunction, initializationPromise, screenName, options) {
|
|
996
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
997
|
-
var measurementId;
|
|
998
|
-
return __generator(this, function (_a) {
|
|
999
|
-
switch (_a.label) {
|
|
1000
|
-
case 0:
|
|
1001
|
-
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
1002
|
-
gtagFunction("set" /* SET */, { 'screen_name': screenName });
|
|
1003
|
-
return [2 /*return*/, Promise.resolve()];
|
|
1004
|
-
case 1: return [4 /*yield*/, initializationPromise];
|
|
1005
|
-
case 2:
|
|
1006
|
-
measurementId = _a.sent();
|
|
1007
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
1008
|
-
update: true,
|
|
1009
|
-
'screen_name': screenName
|
|
1010
|
-
});
|
|
1011
|
-
_a.label = 3;
|
|
1012
|
-
case 3: return [2 /*return*/];
|
|
1013
|
-
}
|
|
1014
|
-
});
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
/**
|
|
1018
|
-
* Set user_id parameter for this Google Analytics ID.
|
|
1019
|
-
*
|
|
1020
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
1021
|
-
* @param id User ID string to set
|
|
1022
|
-
*/
|
|
1023
|
-
function setUserId$1(gtagFunction, initializationPromise, id, options) {
|
|
1024
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1025
|
-
var measurementId;
|
|
1026
|
-
return __generator(this, function (_a) {
|
|
1027
|
-
switch (_a.label) {
|
|
1028
|
-
case 0:
|
|
1029
|
-
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
1030
|
-
gtagFunction("set" /* SET */, { 'user_id': id });
|
|
1031
|
-
return [2 /*return*/, Promise.resolve()];
|
|
1032
|
-
case 1: return [4 /*yield*/, initializationPromise];
|
|
1033
|
-
case 2:
|
|
1034
|
-
measurementId = _a.sent();
|
|
1035
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
1036
|
-
update: true,
|
|
1037
|
-
'user_id': id
|
|
1038
|
-
});
|
|
1039
|
-
_a.label = 3;
|
|
1040
|
-
case 3: return [2 /*return*/];
|
|
1041
|
-
}
|
|
1042
|
-
});
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Set all other user properties other than user_id and screen_name.
|
|
1047
|
-
*
|
|
1048
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
1049
|
-
* @param properties Map of user properties to set
|
|
1050
|
-
*/
|
|
1051
|
-
function setUserProperties$1(gtagFunction, initializationPromise, properties, options) {
|
|
1052
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1053
|
-
var flatProperties, _i, _a, key, measurementId;
|
|
1054
|
-
return __generator(this, function (_b) {
|
|
1055
|
-
switch (_b.label) {
|
|
1056
|
-
case 0:
|
|
1057
|
-
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
1058
|
-
flatProperties = {};
|
|
1059
|
-
for (_i = 0, _a = Object.keys(properties); _i < _a.length; _i++) {
|
|
1060
|
-
key = _a[_i];
|
|
1061
|
-
// use dot notation for merge behavior in gtag.js
|
|
1062
|
-
flatProperties["user_properties." + key] = properties[key];
|
|
1063
|
-
}
|
|
1064
|
-
gtagFunction("set" /* SET */, flatProperties);
|
|
1065
|
-
return [2 /*return*/, Promise.resolve()];
|
|
1066
|
-
case 1: return [4 /*yield*/, initializationPromise];
|
|
1067
|
-
case 2:
|
|
1068
|
-
measurementId = _b.sent();
|
|
1069
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
1070
|
-
update: true,
|
|
1071
|
-
'user_properties': properties
|
|
1072
|
-
});
|
|
1073
|
-
_b.label = 3;
|
|
1074
|
-
case 3: return [2 /*return*/];
|
|
1075
|
-
}
|
|
1076
|
-
});
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
|
-
/**
|
|
1080
|
-
* Set whether collection is enabled for this ID.
|
|
1081
|
-
*
|
|
1082
|
-
* @param enabled If true, collection is enabled for this ID.
|
|
1083
|
-
*/
|
|
1084
|
-
function setAnalyticsCollectionEnabled$1(initializationPromise, enabled) {
|
|
1085
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1086
|
-
var measurementId;
|
|
1087
|
-
return __generator(this, function (_a) {
|
|
1088
|
-
switch (_a.label) {
|
|
1089
|
-
case 0: return [4 /*yield*/, initializationPromise];
|
|
1090
|
-
case 1:
|
|
1091
|
-
measurementId = _a.sent();
|
|
1092
|
-
window["ga-disable-" + measurementId] = !enabled;
|
|
1093
|
-
return [2 /*return*/];
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
1144
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1100
1145
|
/**
|
|
1101
1146
|
* Returns an {@link Analytics} instance for the given app.
|
|
@@ -1227,6 +1272,22 @@ function setAnalyticsCollectionEnabled(analyticsInstance, enabled) {
|
|
|
1227
1272
|
analyticsInstance = getModularInstance(analyticsInstance);
|
|
1228
1273
|
setAnalyticsCollectionEnabled$1(initializationPromisesMap[analyticsInstance.app.options.appId], enabled).catch(function (e) { return logger.error(e); });
|
|
1229
1274
|
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Adds data that will be set on every event logged from the SDK, including automatic ones.
|
|
1277
|
+
* With gtag's "set" command, the values passed persist on the current page and are passed with
|
|
1278
|
+
* all subsequent events.
|
|
1279
|
+
* @public
|
|
1280
|
+
* @param customParams - Any custom params the user may pass to gtag.js.
|
|
1281
|
+
*/
|
|
1282
|
+
function setDefaultEventParameters(customParams) {
|
|
1283
|
+
// Check if reference to existing gtag function on window object exists
|
|
1284
|
+
if (wrappedGtagFunction) {
|
|
1285
|
+
wrappedGtagFunction("set" /* SET */, customParams);
|
|
1286
|
+
}
|
|
1287
|
+
else {
|
|
1288
|
+
_setDefaultEventParametersForInit(customParams);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1230
1291
|
/**
|
|
1231
1292
|
* Sends a Google Analytics event with given `eventParams`. This method
|
|
1232
1293
|
* automatically associates this logged event with this Firebase web
|
|
@@ -1241,10 +1302,28 @@ function setAnalyticsCollectionEnabled(analyticsInstance, enabled) {
|
|
|
1241
1302
|
function logEvent(analyticsInstance, eventName, eventParams, options) {
|
|
1242
1303
|
analyticsInstance = getModularInstance(analyticsInstance);
|
|
1243
1304
|
logEvent$1(wrappedGtagFunction, initializationPromisesMap[analyticsInstance.app.options.appId], eventName, eventParams, options).catch(function (e) { return logger.error(e); });
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Sets the applicable end user consent state for this web app across all gtag references once
|
|
1308
|
+
* Firebase Analytics is initialized.
|
|
1309
|
+
*
|
|
1310
|
+
* Use the {@link ConsentSettings} to specify individual consent type values. By default consent
|
|
1311
|
+
* types are set to "granted".
|
|
1312
|
+
* @public
|
|
1313
|
+
* @param consentSettings - Maps the applicable end user consent state for gtag.js.
|
|
1314
|
+
*/
|
|
1315
|
+
function setConsent(consentSettings) {
|
|
1316
|
+
// Check if reference to existing gtag function on window object exists
|
|
1317
|
+
if (wrappedGtagFunction) {
|
|
1318
|
+
wrappedGtagFunction("consent" /* CONSENT */, 'update', consentSettings);
|
|
1319
|
+
}
|
|
1320
|
+
else {
|
|
1321
|
+
_setConsentDefaultForInit(consentSettings);
|
|
1322
|
+
}
|
|
1244
1323
|
}
|
|
1245
1324
|
|
|
1246
1325
|
var name = "@firebase/analytics";
|
|
1247
|
-
var version = "0.7.
|
|
1326
|
+
var version = "0.7.11-canary.13550089f";
|
|
1248
1327
|
|
|
1249
1328
|
/**
|
|
1250
1329
|
* Firebase Analytics
|
|
@@ -1281,5 +1360,5 @@ function registerAnalytics() {
|
|
|
1281
1360
|
}
|
|
1282
1361
|
registerAnalytics();
|
|
1283
1362
|
|
|
1284
|
-
export { getAnalytics, initializeAnalytics, isSupported, logEvent, setAnalyticsCollectionEnabled, setCurrentScreen, setUserId, setUserProperties, settings };
|
|
1363
|
+
export { getAnalytics, initializeAnalytics, isSupported, logEvent, setAnalyticsCollectionEnabled, setConsent, setCurrentScreen, setDefaultEventParameters, setUserId, setUserProperties, settings };
|
|
1285
1364
|
//# sourceMappingURL=index.esm.js.map
|