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