@firebase/analytics 0.9.5 → 0.10.0-canary.9c317277f
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 +6 -0
- package/dist/analytics-public.d.ts +10 -0
- package/dist/analytics.d.ts +10 -0
- package/dist/esm/index.esm.js +67 -10
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +48 -8
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/api.d.ts +9 -0
- package/dist/esm/src/constants.d.ts +2 -1
- package/dist/esm/src/errors.d.ts +1 -0
- package/dist/esm/src/functions.d.ts +7 -0
- package/dist/esm/src/types.d.ts +2 -0
- package/dist/index.cjs.js +66 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/src/api.d.ts +9 -0
- package/dist/src/constants.d.ts +2 -1
- package/dist/src/errors.d.ts +1 -0
- package/dist/src/functions.d.ts +7 -0
- package/dist/src/types.d.ts +2 -0
- package/package.json +7 -7
package/dist/index.cjs.js
CHANGED
|
@@ -96,6 +96,7 @@ var ERRORS = (_a = {},
|
|
|
96
96
|
'contain a valid API key.',
|
|
97
97
|
_a["no-app-id" /* AnalyticsError.NO_APP_ID */] = 'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field to' +
|
|
98
98
|
'contain a valid app ID.',
|
|
99
|
+
_a["no-client-id" /* AnalyticsError.NO_CLIENT_ID */] = 'The "client_id" field is empty.',
|
|
99
100
|
_a["invalid-gtag-resource" /* AnalyticsError.INVALID_GTAG_RESOURCE */] = 'Trusted Types detected an invalid gtag resource: {$gtagURL}.',
|
|
100
101
|
_a);
|
|
101
102
|
var ERROR_FACTORY = new util.ErrorFactory('analytics', 'Analytics', ERRORS);
|
|
@@ -339,36 +340,50 @@ measurementIdToAppId) {
|
|
|
339
340
|
* @param idOrNameOrParams Measurement ID if command is EVENT/CONFIG, params if command is SET.
|
|
340
341
|
* @param gtagParams Params if event is EVENT/CONFIG.
|
|
341
342
|
*/
|
|
342
|
-
function gtagWrapper(command
|
|
343
|
+
function gtagWrapper(command) {
|
|
344
|
+
var args = [];
|
|
345
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
346
|
+
args[_i - 1] = arguments[_i];
|
|
347
|
+
}
|
|
343
348
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
344
|
-
var e_3;
|
|
349
|
+
var measurementId, gtagParams, measurementId, gtagParams, gtagParams, measurementId, fieldName, callback, customParams, e_3;
|
|
345
350
|
return tslib.__generator(this, function (_a) {
|
|
346
351
|
switch (_a.label) {
|
|
347
352
|
case 0:
|
|
348
353
|
_a.trys.push([0, 6, , 7]);
|
|
349
354
|
if (!(command === "event" /* GtagCommand.EVENT */)) return [3 /*break*/, 2];
|
|
355
|
+
measurementId = args[0], gtagParams = args[1];
|
|
350
356
|
// If EVENT, second arg must be measurementId.
|
|
351
|
-
return [4 /*yield*/, gtagOnEvent(gtagCore, initializationPromisesMap, dynamicConfigPromisesList,
|
|
357
|
+
return [4 /*yield*/, gtagOnEvent(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, measurementId, gtagParams)];
|
|
352
358
|
case 1:
|
|
353
359
|
// If EVENT, second arg must be measurementId.
|
|
354
360
|
_a.sent();
|
|
355
361
|
return [3 /*break*/, 5];
|
|
356
362
|
case 2:
|
|
357
363
|
if (!(command === "config" /* GtagCommand.CONFIG */)) return [3 /*break*/, 4];
|
|
364
|
+
measurementId = args[0], gtagParams = args[1];
|
|
358
365
|
// If CONFIG, second arg must be measurementId.
|
|
359
|
-
return [4 /*yield*/, gtagOnConfig(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, measurementIdToAppId,
|
|
366
|
+
return [4 /*yield*/, gtagOnConfig(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, measurementIdToAppId, measurementId, gtagParams)];
|
|
360
367
|
case 3:
|
|
361
368
|
// If CONFIG, second arg must be measurementId.
|
|
362
369
|
_a.sent();
|
|
363
370
|
return [3 /*break*/, 5];
|
|
364
371
|
case 4:
|
|
365
372
|
if (command === "consent" /* GtagCommand.CONSENT */) {
|
|
366
|
-
|
|
373
|
+
gtagParams = args[0];
|
|
367
374
|
gtagCore("consent" /* GtagCommand.CONSENT */, 'update', gtagParams);
|
|
368
375
|
}
|
|
369
|
-
else {
|
|
376
|
+
else if (command === "get" /* GtagCommand.GET */) {
|
|
377
|
+
measurementId = args[0], fieldName = args[1], callback = args[2];
|
|
378
|
+
gtagCore("get" /* GtagCommand.GET */, measurementId, fieldName, callback);
|
|
379
|
+
}
|
|
380
|
+
else if (command === "set" /* GtagCommand.SET */) {
|
|
381
|
+
customParams = args[0];
|
|
370
382
|
// If SET, second arg must be params.
|
|
371
|
-
gtagCore("set" /* GtagCommand.SET */,
|
|
383
|
+
gtagCore("set" /* GtagCommand.SET */, customParams);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
gtagCore.apply(void 0, tslib.__spreadArray([command], args, false));
|
|
372
387
|
}
|
|
373
388
|
_a.label = 5;
|
|
374
389
|
case 5: return [3 /*break*/, 7];
|
|
@@ -847,6 +862,32 @@ function setUserProperties$1(gtagFunction, initializationPromise, properties, op
|
|
|
847
862
|
});
|
|
848
863
|
});
|
|
849
864
|
}
|
|
865
|
+
/**
|
|
866
|
+
* Retrieves a unique Google Analytics identifier for the web client.
|
|
867
|
+
* See {@link https://developers.google.com/analytics/devguides/collection/ga4/reference/config#client_id | client_id}.
|
|
868
|
+
*
|
|
869
|
+
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
|
|
870
|
+
*/
|
|
871
|
+
function internalGetGoogleAnalyticsClientId(gtagFunction, initializationPromise) {
|
|
872
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
873
|
+
var measurementId;
|
|
874
|
+
return tslib.__generator(this, function (_a) {
|
|
875
|
+
switch (_a.label) {
|
|
876
|
+
case 0: return [4 /*yield*/, initializationPromise];
|
|
877
|
+
case 1:
|
|
878
|
+
measurementId = _a.sent();
|
|
879
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
880
|
+
gtagFunction("get" /* GtagCommand.GET */, measurementId, 'client_id', function (clientId) {
|
|
881
|
+
if (!clientId) {
|
|
882
|
+
reject(ERROR_FACTORY.create("no-client-id" /* AnalyticsError.NO_CLIENT_ID */));
|
|
883
|
+
}
|
|
884
|
+
resolve(clientId);
|
|
885
|
+
});
|
|
886
|
+
})];
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
});
|
|
890
|
+
}
|
|
850
891
|
/**
|
|
851
892
|
* Set whether collection is enabled for this ID.
|
|
852
893
|
*
|
|
@@ -1277,6 +1318,22 @@ function setCurrentScreen(analyticsInstance, screenName, options) {
|
|
|
1277
1318
|
analyticsInstance = util.getModularInstance(analyticsInstance);
|
|
1278
1319
|
setCurrentScreen$1(wrappedGtagFunction, initializationPromisesMap[analyticsInstance.app.options.appId], screenName, options).catch(function (e) { return logger.error(e); });
|
|
1279
1320
|
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Retrieves a unique Google Analytics identifier for the web client.
|
|
1323
|
+
* See {@link https://developers.google.com/analytics/devguides/collection/ga4/reference/config#client_id | client_id}.
|
|
1324
|
+
*
|
|
1325
|
+
* @public
|
|
1326
|
+
*
|
|
1327
|
+
* @param app - The {@link @firebase/app#FirebaseApp} to use.
|
|
1328
|
+
*/
|
|
1329
|
+
function getGoogleAnalyticsClientId(analyticsInstance) {
|
|
1330
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1331
|
+
return tslib.__generator(this, function (_a) {
|
|
1332
|
+
analyticsInstance = util.getModularInstance(analyticsInstance);
|
|
1333
|
+
return [2 /*return*/, internalGetGoogleAnalyticsClientId(wrappedGtagFunction, initializationPromisesMap[analyticsInstance.app.options.appId])];
|
|
1334
|
+
});
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1280
1337
|
/**
|
|
1281
1338
|
* Use gtag `config` command to set `user_id`.
|
|
1282
1339
|
*
|
|
@@ -1362,7 +1419,7 @@ function setConsent(consentSettings) {
|
|
|
1362
1419
|
}
|
|
1363
1420
|
|
|
1364
1421
|
var name = "@firebase/analytics";
|
|
1365
|
-
var version = "0.
|
|
1422
|
+
var version = "0.10.0-canary.9c317277f";
|
|
1366
1423
|
|
|
1367
1424
|
/**
|
|
1368
1425
|
* Firebase Analytics
|
|
@@ -1400,6 +1457,7 @@ function registerAnalytics() {
|
|
|
1400
1457
|
registerAnalytics();
|
|
1401
1458
|
|
|
1402
1459
|
exports.getAnalytics = getAnalytics;
|
|
1460
|
+
exports.getGoogleAnalyticsClientId = getGoogleAnalyticsClientId;
|
|
1403
1461
|
exports.initializeAnalytics = initializeAnalytics;
|
|
1404
1462
|
exports.isSupported = isSupported;
|
|
1405
1463
|
exports.logEvent = logEvent;
|