@firebase/analytics 0.7.10-canary.efe2000fc → 0.7.11-canary.280c25605
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 +9 -0
- package/dist/analytics.d.ts +9 -0
- package/dist/esm/index.esm.js +208 -172
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +151 -115
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/api.d.ts +8 -0
- package/dist/esm/src/functions.d.ts +11 -0
- package/dist/index.cjs.js +208 -171
- package/dist/index.cjs.js.map +1 -1
- package/dist/src/api.d.ts +8 -0
- package/dist/src/functions.d.ts +11 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @firebase/analytics
|
|
2
2
|
|
|
3
|
+
## 0.7.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`835f1d46a`](https://github.com/firebase/firebase-js-sdk/commit/835f1d46a6780535bc660ef7dc23293350d5fe43) [#6357](https://github.com/firebase/firebase-js-sdk/pull/6357) - Fix typo in GtagConfigParams
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`efe2000fc`](https://github.com/firebase/firebase-js-sdk/commit/efe2000fc499e2c85c4e5e0fef6741ff3bad2eb0)]:
|
|
10
|
+
- @firebase/util@1.6.2
|
|
11
|
+
- @firebase/component@0.5.16
|
|
12
|
+
- @firebase/installations@0.5.11
|
|
13
|
+
|
|
3
14
|
## 0.7.10
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -650,6 +650,15 @@ export declare function setAnalyticsCollectionEnabled(analyticsInstance: Analyti
|
|
|
650
650
|
*/
|
|
651
651
|
export declare function setCurrentScreen(analyticsInstance: Analytics, screenName: string, options?: AnalyticsCallOptions): void;
|
|
652
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Adds data that will be set on every event logged from the SDK, including automatic ones.
|
|
655
|
+
* With gtag's "set" command, the values passed persist on the current page and are passed with
|
|
656
|
+
* all subsequent events.
|
|
657
|
+
* @public
|
|
658
|
+
* @param customParams Any custom params the user may pass to gtag.js.
|
|
659
|
+
*/
|
|
660
|
+
export declare function setDefaultEventParameters(customParams: CustomParams): void;
|
|
661
|
+
|
|
653
662
|
/**
|
|
654
663
|
* Configures Firebase Analytics to use custom `gtag` or `dataLayer` names.
|
|
655
664
|
* Intended to be used if `gtag.js` script has been installed on
|
package/dist/analytics.d.ts
CHANGED
|
@@ -650,6 +650,15 @@ export declare function setAnalyticsCollectionEnabled(analyticsInstance: Analyti
|
|
|
650
650
|
*/
|
|
651
651
|
export declare function setCurrentScreen(analyticsInstance: Analytics, screenName: string, options?: AnalyticsCallOptions): void;
|
|
652
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Adds data that will be set on every event logged from the SDK, including automatic ones.
|
|
655
|
+
* With gtag's "set" command, the values passed persist on the current page and are passed with
|
|
656
|
+
* all subsequent events.
|
|
657
|
+
* @public
|
|
658
|
+
* @param customParams Any custom params the user may pass to gtag.js.
|
|
659
|
+
*/
|
|
660
|
+
export declare function setDefaultEventParameters(customParams: CustomParams): void;
|
|
661
|
+
|
|
653
662
|
/**
|
|
654
663
|
* Configures Firebase Analytics to use custom `gtag` or `dataLayer` names.
|
|
655
664
|
* Intended to be used if `gtag.js` script has been installed on
|
package/dist/esm/index.esm.js
CHANGED
|
@@ -536,53 +536,55 @@ retryData, timeoutMillis) {
|
|
|
536
536
|
*/
|
|
537
537
|
function attemptFetchDynamicConfigWithRetry(appFields, _a, signal, retryData // for testing
|
|
538
538
|
) {
|
|
539
|
+
var _b, _c;
|
|
539
540
|
var throttleEndTimeMillis = _a.throttleEndTimeMillis, backoffCount = _a.backoffCount;
|
|
540
541
|
if (retryData === void 0) { retryData = defaultRetryData; }
|
|
541
542
|
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 (
|
|
543
|
+
var appId, measurementId, e_1, response, e_2, error, backoffMillis, throttleMetadata;
|
|
544
|
+
return __generator(this, function (_d) {
|
|
545
|
+
switch (_d.label) {
|
|
545
546
|
case 0:
|
|
546
547
|
appId = appFields.appId, measurementId = appFields.measurementId;
|
|
547
|
-
|
|
548
|
+
_d.label = 1;
|
|
548
549
|
case 1:
|
|
549
|
-
|
|
550
|
+
_d.trys.push([1, 3, , 4]);
|
|
550
551
|
return [4 /*yield*/, setAbortableTimeout(signal, throttleEndTimeMillis)];
|
|
551
552
|
case 2:
|
|
552
|
-
|
|
553
|
+
_d.sent();
|
|
553
554
|
return [3 /*break*/, 4];
|
|
554
555
|
case 3:
|
|
555
|
-
e_1 =
|
|
556
|
+
e_1 = _d.sent();
|
|
556
557
|
if (measurementId) {
|
|
557
558
|
logger.warn("Timed out fetching this Firebase app's measurement ID from the server." +
|
|
558
559
|
(" Falling back to the measurement ID " + measurementId) +
|
|
559
|
-
(" provided in the \"measurementId\" field in the local Firebase config. [" + e_1.message + "]"));
|
|
560
|
+
(" provided in the \"measurementId\" field in the local Firebase config. [" + ((_b = e_1) === null || _b === void 0 ? void 0 : _b.message) + "]"));
|
|
560
561
|
return [2 /*return*/, { appId: appId, measurementId: measurementId }];
|
|
561
562
|
}
|
|
562
563
|
throw e_1;
|
|
563
564
|
case 4:
|
|
564
|
-
|
|
565
|
+
_d.trys.push([4, 6, , 7]);
|
|
565
566
|
return [4 /*yield*/, fetchDynamicConfig(appFields)];
|
|
566
567
|
case 5:
|
|
567
|
-
response =
|
|
568
|
+
response = _d.sent();
|
|
568
569
|
// Note the SDK only clears throttle state if response is success or non-retriable.
|
|
569
570
|
retryData.deleteThrottleMetadata(appId);
|
|
570
571
|
return [2 /*return*/, response];
|
|
571
572
|
case 6:
|
|
572
|
-
e_2 =
|
|
573
|
-
|
|
573
|
+
e_2 = _d.sent();
|
|
574
|
+
error = e_2;
|
|
575
|
+
if (!isRetriableError(error)) {
|
|
574
576
|
retryData.deleteThrottleMetadata(appId);
|
|
575
577
|
if (measurementId) {
|
|
576
578
|
logger.warn("Failed to fetch this Firebase app's measurement ID from the server." +
|
|
577
579
|
(" Falling back to the measurement ID " + measurementId) +
|
|
578
|
-
(" provided in the \"measurementId\" field in the local Firebase config. [" +
|
|
580
|
+
(" provided in the \"measurementId\" field in the local Firebase config. [" + (error === null || error === void 0 ? void 0 : error.message) + "]"));
|
|
579
581
|
return [2 /*return*/, { appId: appId, measurementId: measurementId }];
|
|
580
582
|
}
|
|
581
583
|
else {
|
|
582
584
|
throw e_2;
|
|
583
585
|
}
|
|
584
586
|
}
|
|
585
|
-
backoffMillis = Number(
|
|
587
|
+
backoffMillis = Number((_c = error === null || error === void 0 ? void 0 : error.customData) === null || _c === void 0 ? void 0 : _c.httpStatus) === 503
|
|
586
588
|
? calculateBackoffMillis(backoffCount, retryData.intervalMillis, LONG_RETRY_FACTOR)
|
|
587
589
|
: calculateBackoffMillis(backoffCount, retryData.intervalMillis);
|
|
588
590
|
throttleMetadata = {
|
|
@@ -660,6 +662,175 @@ var AnalyticsAbortSignal = /** @class */ (function () {
|
|
|
660
662
|
return AnalyticsAbortSignal;
|
|
661
663
|
}());
|
|
662
664
|
|
|
665
|
+
/**
|
|
666
|
+
* @license
|
|
667
|
+
* Copyright 2019 Google LLC
|
|
668
|
+
*
|
|
669
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
670
|
+
* you may not use this file except in compliance with the License.
|
|
671
|
+
* You may obtain a copy of the License at
|
|
672
|
+
*
|
|
673
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
674
|
+
*
|
|
675
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
676
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
677
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
678
|
+
* See the License for the specific language governing permissions and
|
|
679
|
+
* limitations under the License.
|
|
680
|
+
*/
|
|
681
|
+
/**
|
|
682
|
+
* Event parameters to set on 'gtag' during initialization.
|
|
683
|
+
*/
|
|
684
|
+
var defaultEventParametersForInit;
|
|
685
|
+
/**
|
|
686
|
+
* Logs an analytics event through the Firebase SDK.
|
|
687
|
+
*
|
|
688
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
689
|
+
* @param eventName Google Analytics event name, choose from standard list or use a custom string.
|
|
690
|
+
* @param eventParams Analytics event parameters.
|
|
691
|
+
*/
|
|
692
|
+
function logEvent$1(gtagFunction, initializationPromise, eventName, eventParams, options) {
|
|
693
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
694
|
+
var measurementId, params;
|
|
695
|
+
return __generator(this, function (_a) {
|
|
696
|
+
switch (_a.label) {
|
|
697
|
+
case 0:
|
|
698
|
+
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
699
|
+
gtagFunction("event" /* EVENT */, eventName, eventParams);
|
|
700
|
+
return [2 /*return*/];
|
|
701
|
+
case 1: return [4 /*yield*/, initializationPromise];
|
|
702
|
+
case 2:
|
|
703
|
+
measurementId = _a.sent();
|
|
704
|
+
params = __assign(__assign({}, eventParams), { 'send_to': measurementId });
|
|
705
|
+
gtagFunction("event" /* EVENT */, eventName, params);
|
|
706
|
+
_a.label = 3;
|
|
707
|
+
case 3: return [2 /*return*/];
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Set screen_name parameter for this Google Analytics ID.
|
|
714
|
+
*
|
|
715
|
+
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
|
|
716
|
+
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
|
|
717
|
+
*
|
|
718
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
719
|
+
* @param screenName Screen name string to set.
|
|
720
|
+
*/
|
|
721
|
+
function setCurrentScreen$1(gtagFunction, initializationPromise, screenName, options) {
|
|
722
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
723
|
+
var measurementId;
|
|
724
|
+
return __generator(this, function (_a) {
|
|
725
|
+
switch (_a.label) {
|
|
726
|
+
case 0:
|
|
727
|
+
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
728
|
+
gtagFunction("set" /* SET */, { 'screen_name': screenName });
|
|
729
|
+
return [2 /*return*/, Promise.resolve()];
|
|
730
|
+
case 1: return [4 /*yield*/, initializationPromise];
|
|
731
|
+
case 2:
|
|
732
|
+
measurementId = _a.sent();
|
|
733
|
+
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
734
|
+
update: true,
|
|
735
|
+
'screen_name': screenName
|
|
736
|
+
});
|
|
737
|
+
_a.label = 3;
|
|
738
|
+
case 3: return [2 /*return*/];
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Set user_id parameter for this Google Analytics ID.
|
|
745
|
+
*
|
|
746
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
747
|
+
* @param id User ID string to set
|
|
748
|
+
*/
|
|
749
|
+
function setUserId$1(gtagFunction, initializationPromise, id, options) {
|
|
750
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
751
|
+
var measurementId;
|
|
752
|
+
return __generator(this, function (_a) {
|
|
753
|
+
switch (_a.label) {
|
|
754
|
+
case 0:
|
|
755
|
+
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
756
|
+
gtagFunction("set" /* SET */, { 'user_id': id });
|
|
757
|
+
return [2 /*return*/, Promise.resolve()];
|
|
758
|
+
case 1: return [4 /*yield*/, initializationPromise];
|
|
759
|
+
case 2:
|
|
760
|
+
measurementId = _a.sent();
|
|
761
|
+
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
762
|
+
update: true,
|
|
763
|
+
'user_id': id
|
|
764
|
+
});
|
|
765
|
+
_a.label = 3;
|
|
766
|
+
case 3: return [2 /*return*/];
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Set all other user properties other than user_id and screen_name.
|
|
773
|
+
*
|
|
774
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
775
|
+
* @param properties Map of user properties to set
|
|
776
|
+
*/
|
|
777
|
+
function setUserProperties$1(gtagFunction, initializationPromise, properties, options) {
|
|
778
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
779
|
+
var flatProperties, _i, _a, key, measurementId;
|
|
780
|
+
return __generator(this, function (_b) {
|
|
781
|
+
switch (_b.label) {
|
|
782
|
+
case 0:
|
|
783
|
+
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
784
|
+
flatProperties = {};
|
|
785
|
+
for (_i = 0, _a = Object.keys(properties); _i < _a.length; _i++) {
|
|
786
|
+
key = _a[_i];
|
|
787
|
+
// use dot notation for merge behavior in gtag.js
|
|
788
|
+
flatProperties["user_properties." + key] = properties[key];
|
|
789
|
+
}
|
|
790
|
+
gtagFunction("set" /* SET */, flatProperties);
|
|
791
|
+
return [2 /*return*/, Promise.resolve()];
|
|
792
|
+
case 1: return [4 /*yield*/, initializationPromise];
|
|
793
|
+
case 2:
|
|
794
|
+
measurementId = _b.sent();
|
|
795
|
+
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
796
|
+
update: true,
|
|
797
|
+
'user_properties': properties
|
|
798
|
+
});
|
|
799
|
+
_b.label = 3;
|
|
800
|
+
case 3: return [2 /*return*/];
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Set whether collection is enabled for this ID.
|
|
807
|
+
*
|
|
808
|
+
* @param enabled If true, collection is enabled for this ID.
|
|
809
|
+
*/
|
|
810
|
+
function setAnalyticsCollectionEnabled$1(initializationPromise, enabled) {
|
|
811
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
812
|
+
var measurementId;
|
|
813
|
+
return __generator(this, function (_a) {
|
|
814
|
+
switch (_a.label) {
|
|
815
|
+
case 0: return [4 /*yield*/, initializationPromise];
|
|
816
|
+
case 1:
|
|
817
|
+
measurementId = _a.sent();
|
|
818
|
+
window["ga-disable-" + measurementId] = !enabled;
|
|
819
|
+
return [2 /*return*/];
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Sets the variable `defaultEventParametersForInit` for use in the initialization of
|
|
826
|
+
* analytics.
|
|
827
|
+
*
|
|
828
|
+
* @param customParams Any custom params the user may pass to gtag.js.
|
|
829
|
+
*/
|
|
830
|
+
function _setDefaultEventParametersForInit(customParams) {
|
|
831
|
+
defaultEventParametersForInit = customParams;
|
|
832
|
+
}
|
|
833
|
+
|
|
663
834
|
/**
|
|
664
835
|
* @license
|
|
665
836
|
* Copyright 2020 Google LLC
|
|
@@ -777,6 +948,11 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
777
948
|
// Note: This will trigger a page_view event unless 'send_page_view' is set to false in
|
|
778
949
|
// `configProperties`.
|
|
779
950
|
gtagCore("config" /* CONFIG */, dynamicConfig.measurementId, configProperties);
|
|
951
|
+
// Detects if there is data that will be set on every event logged from the SDK.
|
|
952
|
+
if (defaultEventParametersForInit) {
|
|
953
|
+
gtagCore("set" /* SET */, defaultEventParametersForInit);
|
|
954
|
+
_setDefaultEventParametersForInit(undefined);
|
|
955
|
+
}
|
|
780
956
|
return [2 /*return*/, dynamicConfig.measurementId];
|
|
781
957
|
}
|
|
782
958
|
});
|
|
@@ -941,162 +1117,6 @@ function factory(app, installations, options) {
|
|
|
941
1117
|
return analyticsInstance;
|
|
942
1118
|
}
|
|
943
1119
|
|
|
944
|
-
/**
|
|
945
|
-
* @license
|
|
946
|
-
* Copyright 2019 Google LLC
|
|
947
|
-
*
|
|
948
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
949
|
-
* you may not use this file except in compliance with the License.
|
|
950
|
-
* You may obtain a copy of the License at
|
|
951
|
-
*
|
|
952
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
953
|
-
*
|
|
954
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
955
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
956
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
957
|
-
* See the License for the specific language governing permissions and
|
|
958
|
-
* limitations under the License.
|
|
959
|
-
*/
|
|
960
|
-
/**
|
|
961
|
-
* Logs an analytics event through the Firebase SDK.
|
|
962
|
-
*
|
|
963
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
964
|
-
* @param eventName Google Analytics event name, choose from standard list or use a custom string.
|
|
965
|
-
* @param eventParams Analytics event parameters.
|
|
966
|
-
*/
|
|
967
|
-
function logEvent$1(gtagFunction, initializationPromise, eventName, eventParams, options) {
|
|
968
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
969
|
-
var measurementId, params;
|
|
970
|
-
return __generator(this, function (_a) {
|
|
971
|
-
switch (_a.label) {
|
|
972
|
-
case 0:
|
|
973
|
-
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
974
|
-
gtagFunction("event" /* EVENT */, eventName, eventParams);
|
|
975
|
-
return [2 /*return*/];
|
|
976
|
-
case 1: return [4 /*yield*/, initializationPromise];
|
|
977
|
-
case 2:
|
|
978
|
-
measurementId = _a.sent();
|
|
979
|
-
params = __assign(__assign({}, eventParams), { 'send_to': measurementId });
|
|
980
|
-
gtagFunction("event" /* EVENT */, eventName, params);
|
|
981
|
-
_a.label = 3;
|
|
982
|
-
case 3: return [2 /*return*/];
|
|
983
|
-
}
|
|
984
|
-
});
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
/**
|
|
988
|
-
* Set screen_name parameter for this Google Analytics ID.
|
|
989
|
-
*
|
|
990
|
-
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
|
|
991
|
-
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
|
|
992
|
-
*
|
|
993
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
994
|
-
* @param screenName Screen name string to set.
|
|
995
|
-
*/
|
|
996
|
-
function setCurrentScreen$1(gtagFunction, initializationPromise, screenName, options) {
|
|
997
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
998
|
-
var measurementId;
|
|
999
|
-
return __generator(this, function (_a) {
|
|
1000
|
-
switch (_a.label) {
|
|
1001
|
-
case 0:
|
|
1002
|
-
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
1003
|
-
gtagFunction("set" /* SET */, { 'screen_name': screenName });
|
|
1004
|
-
return [2 /*return*/, Promise.resolve()];
|
|
1005
|
-
case 1: return [4 /*yield*/, initializationPromise];
|
|
1006
|
-
case 2:
|
|
1007
|
-
measurementId = _a.sent();
|
|
1008
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
1009
|
-
update: true,
|
|
1010
|
-
'screen_name': screenName
|
|
1011
|
-
});
|
|
1012
|
-
_a.label = 3;
|
|
1013
|
-
case 3: return [2 /*return*/];
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Set user_id parameter for this Google Analytics ID.
|
|
1020
|
-
*
|
|
1021
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
1022
|
-
* @param id User ID string to set
|
|
1023
|
-
*/
|
|
1024
|
-
function setUserId$1(gtagFunction, initializationPromise, id, options) {
|
|
1025
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1026
|
-
var measurementId;
|
|
1027
|
-
return __generator(this, function (_a) {
|
|
1028
|
-
switch (_a.label) {
|
|
1029
|
-
case 0:
|
|
1030
|
-
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
1031
|
-
gtagFunction("set" /* SET */, { 'user_id': id });
|
|
1032
|
-
return [2 /*return*/, Promise.resolve()];
|
|
1033
|
-
case 1: return [4 /*yield*/, initializationPromise];
|
|
1034
|
-
case 2:
|
|
1035
|
-
measurementId = _a.sent();
|
|
1036
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
1037
|
-
update: true,
|
|
1038
|
-
'user_id': id
|
|
1039
|
-
});
|
|
1040
|
-
_a.label = 3;
|
|
1041
|
-
case 3: return [2 /*return*/];
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
/**
|
|
1047
|
-
* Set all other user properties other than user_id and screen_name.
|
|
1048
|
-
*
|
|
1049
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
1050
|
-
* @param properties Map of user properties to set
|
|
1051
|
-
*/
|
|
1052
|
-
function setUserProperties$1(gtagFunction, initializationPromise, properties, options) {
|
|
1053
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1054
|
-
var flatProperties, _i, _a, key, measurementId;
|
|
1055
|
-
return __generator(this, function (_b) {
|
|
1056
|
-
switch (_b.label) {
|
|
1057
|
-
case 0:
|
|
1058
|
-
if (!(options && options.global)) return [3 /*break*/, 1];
|
|
1059
|
-
flatProperties = {};
|
|
1060
|
-
for (_i = 0, _a = Object.keys(properties); _i < _a.length; _i++) {
|
|
1061
|
-
key = _a[_i];
|
|
1062
|
-
// use dot notation for merge behavior in gtag.js
|
|
1063
|
-
flatProperties["user_properties." + key] = properties[key];
|
|
1064
|
-
}
|
|
1065
|
-
gtagFunction("set" /* SET */, flatProperties);
|
|
1066
|
-
return [2 /*return*/, Promise.resolve()];
|
|
1067
|
-
case 1: return [4 /*yield*/, initializationPromise];
|
|
1068
|
-
case 2:
|
|
1069
|
-
measurementId = _b.sent();
|
|
1070
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
1071
|
-
update: true,
|
|
1072
|
-
'user_properties': properties
|
|
1073
|
-
});
|
|
1074
|
-
_b.label = 3;
|
|
1075
|
-
case 3: return [2 /*return*/];
|
|
1076
|
-
}
|
|
1077
|
-
});
|
|
1078
|
-
});
|
|
1079
|
-
}
|
|
1080
|
-
/**
|
|
1081
|
-
* Set whether collection is enabled for this ID.
|
|
1082
|
-
*
|
|
1083
|
-
* @param enabled If true, collection is enabled for this ID.
|
|
1084
|
-
*/
|
|
1085
|
-
function setAnalyticsCollectionEnabled$1(initializationPromise, enabled) {
|
|
1086
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1087
|
-
var measurementId;
|
|
1088
|
-
return __generator(this, function (_a) {
|
|
1089
|
-
switch (_a.label) {
|
|
1090
|
-
case 0: return [4 /*yield*/, initializationPromise];
|
|
1091
|
-
case 1:
|
|
1092
|
-
measurementId = _a.sent();
|
|
1093
|
-
window["ga-disable-" + measurementId] = !enabled;
|
|
1094
|
-
return [2 /*return*/];
|
|
1095
|
-
}
|
|
1096
|
-
});
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
1120
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1101
1121
|
/**
|
|
1102
1122
|
* Returns an {@link Analytics} instance for the given app.
|
|
@@ -1228,6 +1248,22 @@ function setAnalyticsCollectionEnabled(analyticsInstance, enabled) {
|
|
|
1228
1248
|
analyticsInstance = getModularInstance(analyticsInstance);
|
|
1229
1249
|
setAnalyticsCollectionEnabled$1(initializationPromisesMap[analyticsInstance.app.options.appId], enabled).catch(function (e) { return logger.error(e); });
|
|
1230
1250
|
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Adds data that will be set on every event logged from the SDK, including automatic ones.
|
|
1253
|
+
* With gtag's "set" command, the values passed persist on the current page and are passed with
|
|
1254
|
+
* all subsequent events.
|
|
1255
|
+
* @public
|
|
1256
|
+
* @param customParams Any custom params the user may pass to gtag.js.
|
|
1257
|
+
*/
|
|
1258
|
+
function setDefaultEventParameters(customParams) {
|
|
1259
|
+
// Check if reference to existing gtag function on window object exists
|
|
1260
|
+
if (wrappedGtagFunction) {
|
|
1261
|
+
wrappedGtagFunction("set" /* SET */, customParams);
|
|
1262
|
+
}
|
|
1263
|
+
else {
|
|
1264
|
+
_setDefaultEventParametersForInit(customParams);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1231
1267
|
/**
|
|
1232
1268
|
* Sends a Google Analytics event with given `eventParams`. This method
|
|
1233
1269
|
* automatically associates this logged event with this Firebase web
|
|
@@ -1245,7 +1281,7 @@ function logEvent(analyticsInstance, eventName, eventParams, options) {
|
|
|
1245
1281
|
}
|
|
1246
1282
|
|
|
1247
1283
|
var name = "@firebase/analytics";
|
|
1248
|
-
var version = "0.7.
|
|
1284
|
+
var version = "0.7.11-canary.280c25605";
|
|
1249
1285
|
|
|
1250
1286
|
/**
|
|
1251
1287
|
* Firebase Analytics
|
|
@@ -1282,5 +1318,5 @@ function registerAnalytics() {
|
|
|
1282
1318
|
}
|
|
1283
1319
|
registerAnalytics();
|
|
1284
1320
|
|
|
1285
|
-
export { getAnalytics, initializeAnalytics, isSupported, logEvent, setAnalyticsCollectionEnabled, setCurrentScreen, setUserId, setUserProperties, settings };
|
|
1321
|
+
export { getAnalytics, initializeAnalytics, isSupported, logEvent, setAnalyticsCollectionEnabled, setCurrentScreen, setDefaultEventParameters, setUserId, setUserProperties, settings };
|
|
1286
1322
|
//# sourceMappingURL=index.esm.js.map
|