@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
|
@@ -456,6 +456,7 @@ retryData = defaultRetryData, timeoutMillis) {
|
|
|
456
456
|
*/
|
|
457
457
|
async function attemptFetchDynamicConfigWithRetry(appFields, { throttleEndTimeMillis, backoffCount }, signal, retryData = defaultRetryData // for testing
|
|
458
458
|
) {
|
|
459
|
+
var _a, _b;
|
|
459
460
|
const { appId, measurementId } = appFields;
|
|
460
461
|
// Starts with a (potentially zero) timeout to support resumption from stored state.
|
|
461
462
|
// Ensures the throttle end time is honored if the last attempt timed out.
|
|
@@ -467,7 +468,7 @@ async function attemptFetchDynamicConfigWithRetry(appFields, { throttleEndTimeMi
|
|
|
467
468
|
if (measurementId) {
|
|
468
469
|
logger.warn(`Timed out fetching this Firebase app's measurement ID from the server.` +
|
|
469
470
|
` Falling back to the measurement ID ${measurementId}` +
|
|
470
|
-
` provided in the "measurementId" field in the local Firebase config. [${e.message}]`);
|
|
471
|
+
` provided in the "measurementId" field in the local Firebase config. [${(_a = e) === null || _a === void 0 ? void 0 : _a.message}]`);
|
|
471
472
|
return { appId, measurementId };
|
|
472
473
|
}
|
|
473
474
|
throw e;
|
|
@@ -479,19 +480,20 @@ async function attemptFetchDynamicConfigWithRetry(appFields, { throttleEndTimeMi
|
|
|
479
480
|
return response;
|
|
480
481
|
}
|
|
481
482
|
catch (e) {
|
|
482
|
-
|
|
483
|
+
const error = e;
|
|
484
|
+
if (!isRetriableError(error)) {
|
|
483
485
|
retryData.deleteThrottleMetadata(appId);
|
|
484
486
|
if (measurementId) {
|
|
485
487
|
logger.warn(`Failed to fetch this Firebase app's measurement ID from the server.` +
|
|
486
488
|
` Falling back to the measurement ID ${measurementId}` +
|
|
487
|
-
` provided in the "measurementId" field in the local Firebase config. [${
|
|
489
|
+
` provided in the "measurementId" field in the local Firebase config. [${error === null || error === void 0 ? void 0 : error.message}]`);
|
|
488
490
|
return { appId, measurementId };
|
|
489
491
|
}
|
|
490
492
|
else {
|
|
491
493
|
throw e;
|
|
492
494
|
}
|
|
493
495
|
}
|
|
494
|
-
const backoffMillis = Number(
|
|
496
|
+
const backoffMillis = Number((_b = error === null || error === void 0 ? void 0 : error.customData) === null || _b === void 0 ? void 0 : _b.httpStatus) === 503
|
|
495
497
|
? calculateBackoffMillis(backoffCount, retryData.intervalMillis, LONG_RETRY_FACTOR)
|
|
496
498
|
: calculateBackoffMillis(backoffCount, retryData.intervalMillis);
|
|
497
499
|
// Increments backoff state.
|
|
@@ -566,6 +568,128 @@ class AnalyticsAbortSignal {
|
|
|
566
568
|
}
|
|
567
569
|
}
|
|
568
570
|
|
|
571
|
+
/**
|
|
572
|
+
* @license
|
|
573
|
+
* Copyright 2019 Google LLC
|
|
574
|
+
*
|
|
575
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
576
|
+
* you may not use this file except in compliance with the License.
|
|
577
|
+
* You may obtain a copy of the License at
|
|
578
|
+
*
|
|
579
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
580
|
+
*
|
|
581
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
582
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
583
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
584
|
+
* See the License for the specific language governing permissions and
|
|
585
|
+
* limitations under the License.
|
|
586
|
+
*/
|
|
587
|
+
/**
|
|
588
|
+
* Event parameters to set on 'gtag' during initialization.
|
|
589
|
+
*/
|
|
590
|
+
let defaultEventParametersForInit;
|
|
591
|
+
/**
|
|
592
|
+
* Logs an analytics event through the Firebase SDK.
|
|
593
|
+
*
|
|
594
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
595
|
+
* @param eventName Google Analytics event name, choose from standard list or use a custom string.
|
|
596
|
+
* @param eventParams Analytics event parameters.
|
|
597
|
+
*/
|
|
598
|
+
async function logEvent$1(gtagFunction, initializationPromise, eventName, eventParams, options) {
|
|
599
|
+
if (options && options.global) {
|
|
600
|
+
gtagFunction("event" /* EVENT */, eventName, eventParams);
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
const measurementId = await initializationPromise;
|
|
605
|
+
const params = Object.assign(Object.assign({}, eventParams), { 'send_to': measurementId });
|
|
606
|
+
gtagFunction("event" /* EVENT */, eventName, params);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Set screen_name parameter for this Google Analytics ID.
|
|
611
|
+
*
|
|
612
|
+
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
|
|
613
|
+
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
|
|
614
|
+
*
|
|
615
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
616
|
+
* @param screenName Screen name string to set.
|
|
617
|
+
*/
|
|
618
|
+
async function setCurrentScreen$1(gtagFunction, initializationPromise, screenName, options) {
|
|
619
|
+
if (options && options.global) {
|
|
620
|
+
gtagFunction("set" /* SET */, { 'screen_name': screenName });
|
|
621
|
+
return Promise.resolve();
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
const measurementId = await initializationPromise;
|
|
625
|
+
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
626
|
+
update: true,
|
|
627
|
+
'screen_name': screenName
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Set user_id parameter for this Google Analytics ID.
|
|
633
|
+
*
|
|
634
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
635
|
+
* @param id User ID string to set
|
|
636
|
+
*/
|
|
637
|
+
async function setUserId$1(gtagFunction, initializationPromise, id, options) {
|
|
638
|
+
if (options && options.global) {
|
|
639
|
+
gtagFunction("set" /* SET */, { 'user_id': id });
|
|
640
|
+
return Promise.resolve();
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
const measurementId = await initializationPromise;
|
|
644
|
+
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
645
|
+
update: true,
|
|
646
|
+
'user_id': id
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Set all other user properties other than user_id and screen_name.
|
|
652
|
+
*
|
|
653
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
654
|
+
* @param properties Map of user properties to set
|
|
655
|
+
*/
|
|
656
|
+
async function setUserProperties$1(gtagFunction, initializationPromise, properties, options) {
|
|
657
|
+
if (options && options.global) {
|
|
658
|
+
const flatProperties = {};
|
|
659
|
+
for (const key of Object.keys(properties)) {
|
|
660
|
+
// use dot notation for merge behavior in gtag.js
|
|
661
|
+
flatProperties[`user_properties.${key}`] = properties[key];
|
|
662
|
+
}
|
|
663
|
+
gtagFunction("set" /* SET */, flatProperties);
|
|
664
|
+
return Promise.resolve();
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
const measurementId = await initializationPromise;
|
|
668
|
+
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
669
|
+
update: true,
|
|
670
|
+
'user_properties': properties
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Set whether collection is enabled for this ID.
|
|
676
|
+
*
|
|
677
|
+
* @param enabled If true, collection is enabled for this ID.
|
|
678
|
+
*/
|
|
679
|
+
async function setAnalyticsCollectionEnabled$1(initializationPromise, enabled) {
|
|
680
|
+
const measurementId = await initializationPromise;
|
|
681
|
+
window[`ga-disable-${measurementId}`] = !enabled;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Sets the variable `defaultEventParametersForInit` for use in the initialization of
|
|
685
|
+
* analytics.
|
|
686
|
+
*
|
|
687
|
+
* @param customParams Any custom params the user may pass to gtag.js.
|
|
688
|
+
*/
|
|
689
|
+
function _setDefaultEventParametersForInit(customParams) {
|
|
690
|
+
defaultEventParametersForInit = customParams;
|
|
691
|
+
}
|
|
692
|
+
|
|
569
693
|
/**
|
|
570
694
|
* @license
|
|
571
695
|
* Copyright 2020 Google LLC
|
|
@@ -670,6 +794,11 @@ async function _initializeAnalytics(app, dynamicConfigPromisesList, measurementI
|
|
|
670
794
|
// Note: This will trigger a page_view event unless 'send_page_view' is set to false in
|
|
671
795
|
// `configProperties`.
|
|
672
796
|
gtagCore("config" /* CONFIG */, dynamicConfig.measurementId, configProperties);
|
|
797
|
+
// Detects if there is data that will be set on every event logged from the SDK.
|
|
798
|
+
if (defaultEventParametersForInit) {
|
|
799
|
+
gtagCore("set" /* SET */, defaultEventParametersForInit);
|
|
800
|
+
_setDefaultEventParametersForInit(undefined);
|
|
801
|
+
}
|
|
673
802
|
return dynamicConfig.measurementId;
|
|
674
803
|
}
|
|
675
804
|
|
|
@@ -830,115 +959,6 @@ function factory(app, installations, options) {
|
|
|
830
959
|
return analyticsInstance;
|
|
831
960
|
}
|
|
832
961
|
|
|
833
|
-
/**
|
|
834
|
-
* @license
|
|
835
|
-
* Copyright 2019 Google LLC
|
|
836
|
-
*
|
|
837
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
838
|
-
* you may not use this file except in compliance with the License.
|
|
839
|
-
* You may obtain a copy of the License at
|
|
840
|
-
*
|
|
841
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
842
|
-
*
|
|
843
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
844
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
845
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
846
|
-
* See the License for the specific language governing permissions and
|
|
847
|
-
* limitations under the License.
|
|
848
|
-
*/
|
|
849
|
-
/**
|
|
850
|
-
* Logs an analytics event through the Firebase SDK.
|
|
851
|
-
*
|
|
852
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
853
|
-
* @param eventName Google Analytics event name, choose from standard list or use a custom string.
|
|
854
|
-
* @param eventParams Analytics event parameters.
|
|
855
|
-
*/
|
|
856
|
-
async function logEvent$1(gtagFunction, initializationPromise, eventName, eventParams, options) {
|
|
857
|
-
if (options && options.global) {
|
|
858
|
-
gtagFunction("event" /* EVENT */, eventName, eventParams);
|
|
859
|
-
return;
|
|
860
|
-
}
|
|
861
|
-
else {
|
|
862
|
-
const measurementId = await initializationPromise;
|
|
863
|
-
const params = Object.assign(Object.assign({}, eventParams), { 'send_to': measurementId });
|
|
864
|
-
gtagFunction("event" /* EVENT */, eventName, params);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
|
-
* Set screen_name parameter for this Google Analytics ID.
|
|
869
|
-
*
|
|
870
|
-
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
|
|
871
|
-
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
|
|
872
|
-
*
|
|
873
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
874
|
-
* @param screenName Screen name string to set.
|
|
875
|
-
*/
|
|
876
|
-
async function setCurrentScreen$1(gtagFunction, initializationPromise, screenName, options) {
|
|
877
|
-
if (options && options.global) {
|
|
878
|
-
gtagFunction("set" /* SET */, { 'screen_name': screenName });
|
|
879
|
-
return Promise.resolve();
|
|
880
|
-
}
|
|
881
|
-
else {
|
|
882
|
-
const measurementId = await initializationPromise;
|
|
883
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
884
|
-
update: true,
|
|
885
|
-
'screen_name': screenName
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
/**
|
|
890
|
-
* Set user_id parameter for this Google Analytics ID.
|
|
891
|
-
*
|
|
892
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
893
|
-
* @param id User ID string to set
|
|
894
|
-
*/
|
|
895
|
-
async function setUserId$1(gtagFunction, initializationPromise, id, options) {
|
|
896
|
-
if (options && options.global) {
|
|
897
|
-
gtagFunction("set" /* SET */, { 'user_id': id });
|
|
898
|
-
return Promise.resolve();
|
|
899
|
-
}
|
|
900
|
-
else {
|
|
901
|
-
const measurementId = await initializationPromise;
|
|
902
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
903
|
-
update: true,
|
|
904
|
-
'user_id': id
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* Set all other user properties other than user_id and screen_name.
|
|
910
|
-
*
|
|
911
|
-
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
912
|
-
* @param properties Map of user properties to set
|
|
913
|
-
*/
|
|
914
|
-
async function setUserProperties$1(gtagFunction, initializationPromise, properties, options) {
|
|
915
|
-
if (options && options.global) {
|
|
916
|
-
const flatProperties = {};
|
|
917
|
-
for (const key of Object.keys(properties)) {
|
|
918
|
-
// use dot notation for merge behavior in gtag.js
|
|
919
|
-
flatProperties[`user_properties.${key}`] = properties[key];
|
|
920
|
-
}
|
|
921
|
-
gtagFunction("set" /* SET */, flatProperties);
|
|
922
|
-
return Promise.resolve();
|
|
923
|
-
}
|
|
924
|
-
else {
|
|
925
|
-
const measurementId = await initializationPromise;
|
|
926
|
-
gtagFunction("config" /* CONFIG */, measurementId, {
|
|
927
|
-
update: true,
|
|
928
|
-
'user_properties': properties
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* Set whether collection is enabled for this ID.
|
|
934
|
-
*
|
|
935
|
-
* @param enabled If true, collection is enabled for this ID.
|
|
936
|
-
*/
|
|
937
|
-
async function setAnalyticsCollectionEnabled$1(initializationPromise, enabled) {
|
|
938
|
-
const measurementId = await initializationPromise;
|
|
939
|
-
window[`ga-disable-${measurementId}`] = !enabled;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
962
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
943
963
|
/**
|
|
944
964
|
* Returns an {@link Analytics} instance for the given app.
|
|
@@ -1056,6 +1076,22 @@ function setAnalyticsCollectionEnabled(analyticsInstance, enabled) {
|
|
|
1056
1076
|
analyticsInstance = getModularInstance(analyticsInstance);
|
|
1057
1077
|
setAnalyticsCollectionEnabled$1(initializationPromisesMap[analyticsInstance.app.options.appId], enabled).catch(e => logger.error(e));
|
|
1058
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Adds data that will be set on every event logged from the SDK, including automatic ones.
|
|
1081
|
+
* With gtag's "set" command, the values passed persist on the current page and are passed with
|
|
1082
|
+
* all subsequent events.
|
|
1083
|
+
* @public
|
|
1084
|
+
* @param customParams Any custom params the user may pass to gtag.js.
|
|
1085
|
+
*/
|
|
1086
|
+
function setDefaultEventParameters(customParams) {
|
|
1087
|
+
// Check if reference to existing gtag function on window object exists
|
|
1088
|
+
if (wrappedGtagFunction) {
|
|
1089
|
+
wrappedGtagFunction("set" /* SET */, customParams);
|
|
1090
|
+
}
|
|
1091
|
+
else {
|
|
1092
|
+
_setDefaultEventParametersForInit(customParams);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1059
1095
|
/**
|
|
1060
1096
|
* Sends a Google Analytics event with given `eventParams`. This method
|
|
1061
1097
|
* automatically associates this logged event with this Firebase web
|
|
@@ -1073,7 +1109,7 @@ function logEvent(analyticsInstance, eventName, eventParams, options) {
|
|
|
1073
1109
|
}
|
|
1074
1110
|
|
|
1075
1111
|
const name = "@firebase/analytics";
|
|
1076
|
-
const version = "0.7.
|
|
1112
|
+
const version = "0.7.11-canary.280c25605";
|
|
1077
1113
|
|
|
1078
1114
|
/**
|
|
1079
1115
|
* Firebase Analytics
|
|
@@ -1109,5 +1145,5 @@ function registerAnalytics() {
|
|
|
1109
1145
|
}
|
|
1110
1146
|
registerAnalytics();
|
|
1111
1147
|
|
|
1112
|
-
export { getAnalytics, initializeAnalytics, isSupported, logEvent, setAnalyticsCollectionEnabled, setCurrentScreen, setUserId, setUserProperties, settings };
|
|
1148
|
+
export { getAnalytics, initializeAnalytics, isSupported, logEvent, setAnalyticsCollectionEnabled, setCurrentScreen, setDefaultEventParameters, setUserId, setUserProperties, settings };
|
|
1113
1149
|
//# sourceMappingURL=index.esm2017.js.map
|