@firebase/analytics 0.7.10 → 0.7.11-canary.69e2ee064
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 +10 -1
- package/dist/analytics.d.ts +10 -1
- package/dist/esm/index.esm.js +215 -178
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +153 -116
- 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/esm/src/public-types.d.ts +1 -1
- package/dist/index.cjs.js +215 -177
- 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/dist/src/public-types.d.ts +1 -1
- 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
|
|
@@ -195,7 +195,7 @@ export declare interface GtagConfigParams {
|
|
|
195
195
|
* If set to false, disables all advertising features with `gtag.js`.
|
|
196
196
|
* See {@link https://developers.google.com/analytics/devguides/collection/ga4/display-features | Disable advertising features }
|
|
197
197
|
*/
|
|
198
|
-
'allow_google_signals
|
|
198
|
+
'allow_google_signals'?: boolean;
|
|
199
199
|
/**
|
|
200
200
|
* If set to false, disables all advertising personalization with `gtag.js`.
|
|
201
201
|
* See {@link https://developers.google.com/analytics/devguides/collection/ga4/display-features | Disable advertising features }
|
|
@@ -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
|
@@ -195,7 +195,7 @@ export declare interface GtagConfigParams {
|
|
|
195
195
|
* If set to false, disables all advertising features with `gtag.js`.
|
|
196
196
|
* See {@link https://developers.google.com/analytics/devguides/collection/ga4/display-features | Disable advertising features }
|
|
197
197
|
*/
|
|
198
|
-
'allow_google_signals
|
|
198
|
+
'allow_google_signals'?: boolean;
|
|
199
199
|
/**
|
|
200
200
|
* If set to false, disables all advertising personalization with `gtag.js`.
|
|
201
201
|
* See {@link https://developers.google.com/analytics/devguides/collection/ga4/display-features | Disable advertising features }
|
|
@@ -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
|
|
@@ -677,10 +848,11 @@ var AnalyticsAbortSignal = /** @class */ (function () {
|
|
|
677
848
|
* limitations under the License.
|
|
678
849
|
*/
|
|
679
850
|
function validateIndexedDB() {
|
|
851
|
+
var _a;
|
|
680
852
|
return __awaiter(this, void 0, void 0, function () {
|
|
681
853
|
var e_1;
|
|
682
|
-
return __generator(this, function (
|
|
683
|
-
switch (
|
|
854
|
+
return __generator(this, function (_b) {
|
|
855
|
+
switch (_b.label) {
|
|
684
856
|
case 0:
|
|
685
857
|
if (!!isIndexedDBAvailable()) return [3 /*break*/, 1];
|
|
686
858
|
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */, {
|
|
@@ -688,15 +860,15 @@ function validateIndexedDB() {
|
|
|
688
860
|
}).message);
|
|
689
861
|
return [2 /*return*/, false];
|
|
690
862
|
case 1:
|
|
691
|
-
|
|
863
|
+
_b.trys.push([1, 3, , 4]);
|
|
692
864
|
return [4 /*yield*/, validateIndexedDBOpenable()];
|
|
693
865
|
case 2:
|
|
694
|
-
|
|
866
|
+
_b.sent();
|
|
695
867
|
return [3 /*break*/, 4];
|
|
696
868
|
case 3:
|
|
697
|
-
e_1 =
|
|
869
|
+
e_1 = _b.sent();
|
|
698
870
|
logger.warn(ERROR_FACTORY.create("indexeddb-unavailable" /* INDEXEDDB_UNAVAILABLE */, {
|
|
699
|
-
errorInfo: e_1
|
|
871
|
+
errorInfo: (_a = e_1) === null || _a === void 0 ? void 0 : _a.toString()
|
|
700
872
|
}).message);
|
|
701
873
|
return [2 /*return*/, false];
|
|
702
874
|
case 4: return [2 /*return*/, true];
|
|
@@ -776,6 +948,11 @@ function _initializeAnalytics(app, dynamicConfigPromisesList, measurementIdToApp
|
|
|
776
948
|
// Note: This will trigger a page_view event unless 'send_page_view' is set to false in
|
|
777
949
|
// `configProperties`.
|
|
778
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
|
+
}
|
|
779
956
|
return [2 /*return*/, dynamicConfig.measurementId];
|
|
780
957
|
}
|
|
781
958
|
});
|
|
@@ -940,162 +1117,6 @@ function factory(app, installations, options) {
|
|
|
940
1117
|
return analyticsInstance;
|
|
941
1118
|
}
|
|
942
1119
|
|
|
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
1120
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1100
1121
|
/**
|
|
1101
1122
|
* Returns an {@link Analytics} instance for the given app.
|
|
@@ -1227,6 +1248,22 @@ function setAnalyticsCollectionEnabled(analyticsInstance, enabled) {
|
|
|
1227
1248
|
analyticsInstance = getModularInstance(analyticsInstance);
|
|
1228
1249
|
setAnalyticsCollectionEnabled$1(initializationPromisesMap[analyticsInstance.app.options.appId], enabled).catch(function (e) { return logger.error(e); });
|
|
1229
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
|
+
}
|
|
1230
1267
|
/**
|
|
1231
1268
|
* Sends a Google Analytics event with given `eventParams`. This method
|
|
1232
1269
|
* automatically associates this logged event with this Firebase web
|
|
@@ -1244,7 +1281,7 @@ function logEvent(analyticsInstance, eventName, eventParams, options) {
|
|
|
1244
1281
|
}
|
|
1245
1282
|
|
|
1246
1283
|
var name = "@firebase/analytics";
|
|
1247
|
-
var version = "0.7.
|
|
1284
|
+
var version = "0.7.11-canary.69e2ee064";
|
|
1248
1285
|
|
|
1249
1286
|
/**
|
|
1250
1287
|
* Firebase Analytics
|
|
@@ -1281,5 +1318,5 @@ function registerAnalytics() {
|
|
|
1281
1318
|
}
|
|
1282
1319
|
registerAnalytics();
|
|
1283
1320
|
|
|
1284
|
-
export { getAnalytics, initializeAnalytics, isSupported, logEvent, setAnalyticsCollectionEnabled, setCurrentScreen, setUserId, setUserProperties, settings };
|
|
1321
|
+
export { getAnalytics, initializeAnalytics, isSupported, logEvent, setAnalyticsCollectionEnabled, setCurrentScreen, setDefaultEventParameters, setUserId, setUserProperties, settings };
|
|
1285
1322
|
//# sourceMappingURL=index.esm.js.map
|