@firebase/app
Advanced tools
Comparing version 0.10.8-canary.6b0ca77b2 to 0.10.8-canary.6d6ce8100
@@ -61,3 +61,3 @@ import { Component, ComponentContainer } from '@firebase/component'; | ||
const name$p = "@firebase/app"; | ||
const version$1 = "0.10.8-canary.6b0ca77b2"; | ||
const version$1 = "0.10.8-canary.6d6ce8100"; | ||
@@ -131,3 +131,3 @@ /** | ||
const name = "firebase"; | ||
const version = "10.12.5-canary.6b0ca77b2"; | ||
const version = "10.12.5-canary.6d6ce8100"; | ||
@@ -910,34 +910,41 @@ /** | ||
async triggerHeartbeat() { | ||
var _a, _b; | ||
const platformLogger = this.container | ||
.getProvider('platform-logger') | ||
.getImmediate(); | ||
// This is the "Firebase user agent" string from the platform logger | ||
// service, not the browser user agent. | ||
const agent = platformLogger.getPlatformInfoString(); | ||
const date = getUTCDateString(); | ||
if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null) { | ||
this._heartbeatsCache = await this._heartbeatsCachePromise; | ||
// If we failed to construct a heartbeats cache, then return immediately. | ||
var _a, _b, _c; | ||
try { | ||
const platformLogger = this.container | ||
.getProvider('platform-logger') | ||
.getImmediate(); | ||
// This is the "Firebase user agent" string from the platform logger | ||
// service, not the browser user agent. | ||
const agent = platformLogger.getPlatformInfoString(); | ||
const date = getUTCDateString(); | ||
console.log('heartbeats', (_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats); | ||
if (((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null) { | ||
this._heartbeatsCache = await this._heartbeatsCachePromise; | ||
// If we failed to construct a heartbeats cache, then return immediately. | ||
if (((_c = this._heartbeatsCache) === null || _c === void 0 ? void 0 : _c.heartbeats) == null) { | ||
return; | ||
} | ||
} | ||
// Do not store a heartbeat if one is already stored for this day | ||
// or if a header has already been sent today. | ||
if (this._heartbeatsCache.lastSentHeartbeatDate === date || | ||
this._heartbeatsCache.heartbeats.some(singleDateHeartbeat => singleDateHeartbeat.date === date)) { | ||
return; | ||
} | ||
else { | ||
// There is no entry for this date. Create one. | ||
this._heartbeatsCache.heartbeats.push({ date, agent }); | ||
} | ||
// Remove entries older than 30 days. | ||
this._heartbeatsCache.heartbeats = | ||
this._heartbeatsCache.heartbeats.filter(singleDateHeartbeat => { | ||
const hbTimestamp = new Date(singleDateHeartbeat.date).valueOf(); | ||
const now = Date.now(); | ||
return now - hbTimestamp <= STORED_HEARTBEAT_RETENTION_MAX_MILLIS; | ||
}); | ||
return this._storage.overwrite(this._heartbeatsCache); | ||
} | ||
// Do not store a heartbeat if one is already stored for this day | ||
// or if a header has already been sent today. | ||
if (this._heartbeatsCache.lastSentHeartbeatDate === date || | ||
this._heartbeatsCache.heartbeats.some(singleDateHeartbeat => singleDateHeartbeat.date === date)) { | ||
return; | ||
catch (e) { | ||
logger.warn(e); | ||
} | ||
else { | ||
// There is no entry for this date. Create one. | ||
this._heartbeatsCache.heartbeats.push({ date, agent }); | ||
} | ||
// Remove entries older than 30 days. | ||
this._heartbeatsCache.heartbeats = this._heartbeatsCache.heartbeats.filter(singleDateHeartbeat => { | ||
const hbTimestamp = new Date(singleDateHeartbeat.date).valueOf(); | ||
const now = Date.now(); | ||
return now - hbTimestamp <= STORED_HEARTBEAT_RETENTION_MAX_MILLIS; | ||
}); | ||
return this._storage.overwrite(this._heartbeatsCache); | ||
} | ||
@@ -953,30 +960,36 @@ /** | ||
var _a; | ||
if (this._heartbeatsCache === null) { | ||
await this._heartbeatsCachePromise; | ||
try { | ||
if (this._heartbeatsCache === null) { | ||
await this._heartbeatsCachePromise; | ||
} | ||
// If it's still null or the array is empty, there is no data to send. | ||
if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null || | ||
this._heartbeatsCache.heartbeats.length === 0) { | ||
return ''; | ||
} | ||
const date = getUTCDateString(); | ||
// Extract as many heartbeats from the cache as will fit under the size limit. | ||
const { heartbeatsToSend, unsentEntries } = extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats); | ||
const headerString = base64urlEncodeWithoutPadding(JSON.stringify({ version: 2, heartbeats: heartbeatsToSend })); | ||
// Store last sent date to prevent another being logged/sent for the same day. | ||
this._heartbeatsCache.lastSentHeartbeatDate = date; | ||
if (unsentEntries.length > 0) { | ||
// Store any unsent entries if they exist. | ||
this._heartbeatsCache.heartbeats = unsentEntries; | ||
// This seems more likely than emptying the array (below) to lead to some odd state | ||
// since the cache isn't empty and this will be called again on the next request, | ||
// and is probably safest if we await it. | ||
await this._storage.overwrite(this._heartbeatsCache); | ||
} | ||
else { | ||
this._heartbeatsCache.heartbeats = []; | ||
// Do not wait for this, to reduce latency. | ||
void this._storage.overwrite(this._heartbeatsCache); | ||
} | ||
return headerString; | ||
} | ||
// If it's still null or the array is empty, there is no data to send. | ||
if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null || | ||
this._heartbeatsCache.heartbeats.length === 0) { | ||
catch (e) { | ||
logger.warn(e); | ||
return ''; | ||
} | ||
const date = getUTCDateString(); | ||
// Extract as many heartbeats from the cache as will fit under the size limit. | ||
const { heartbeatsToSend, unsentEntries } = extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats); | ||
const headerString = base64urlEncodeWithoutPadding(JSON.stringify({ version: 2, heartbeats: heartbeatsToSend })); | ||
// Store last sent date to prevent another being logged/sent for the same day. | ||
this._heartbeatsCache.lastSentHeartbeatDate = date; | ||
if (unsentEntries.length > 0) { | ||
// Store any unsent entries if they exist. | ||
this._heartbeatsCache.heartbeats = unsentEntries; | ||
// This seems more likely than emptying the array (below) to lead to some odd state | ||
// since the cache isn't empty and this will be called again on the next request, | ||
// and is probably safest if we await it. | ||
await this._storage.overwrite(this._heartbeatsCache); | ||
} | ||
else { | ||
this._heartbeatsCache.heartbeats = []; | ||
// Do not wait for this, to reduce latency. | ||
void this._storage.overwrite(this._heartbeatsCache); | ||
} | ||
return headerString; | ||
} | ||
@@ -983,0 +996,0 @@ } |
@@ -63,3 +63,3 @@ import { Component, ComponentContainer } from '@firebase/component'; | ||
var name$p = "@firebase/app"; | ||
var version$1 = "0.10.8-canary.6b0ca77b2"; | ||
var version$1 = "0.10.8-canary.6d6ce8100"; | ||
@@ -133,3 +133,3 @@ /** | ||
var name = "firebase"; | ||
var version = "10.12.5-canary.6b0ca77b2"; | ||
var version = "10.12.5-canary.6d6ce8100"; | ||
@@ -1043,8 +1043,9 @@ /** | ||
HeartbeatServiceImpl.prototype.triggerHeartbeat = function () { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var platformLogger, agent, date, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
var platformLogger, agent, date_1, _d, e_1; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
_e.trys.push([0, 3, , 4]); | ||
platformLogger = this.container | ||
@@ -1054,18 +1055,19 @@ .getProvider('platform-logger') | ||
agent = platformLogger.getPlatformInfoString(); | ||
date = getUTCDateString(); | ||
if (!(((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null)) return [3 /*break*/, 2]; | ||
_c = this; | ||
date_1 = getUTCDateString(); | ||
console.log('heartbeats', (_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats); | ||
if (!(((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null)) return [3 /*break*/, 2]; | ||
_d = this; | ||
return [4 /*yield*/, this._heartbeatsCachePromise]; | ||
case 1: | ||
_c._heartbeatsCache = _d.sent(); | ||
_d._heartbeatsCache = _e.sent(); | ||
// If we failed to construct a heartbeats cache, then return immediately. | ||
if (((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null) { | ||
if (((_c = this._heartbeatsCache) === null || _c === void 0 ? void 0 : _c.heartbeats) == null) { | ||
return [2 /*return*/]; | ||
} | ||
_d.label = 2; | ||
_e.label = 2; | ||
case 2: | ||
// Do not store a heartbeat if one is already stored for this day | ||
// or if a header has already been sent today. | ||
if (this._heartbeatsCache.lastSentHeartbeatDate === date || | ||
this._heartbeatsCache.heartbeats.some(function (singleDateHeartbeat) { return singleDateHeartbeat.date === date; })) { | ||
if (this._heartbeatsCache.lastSentHeartbeatDate === date_1 || | ||
this._heartbeatsCache.heartbeats.some(function (singleDateHeartbeat) { return singleDateHeartbeat.date === date_1; })) { | ||
return [2 /*return*/]; | ||
@@ -1075,11 +1077,17 @@ } | ||
// There is no entry for this date. Create one. | ||
this._heartbeatsCache.heartbeats.push({ date: date, agent: agent }); | ||
this._heartbeatsCache.heartbeats.push({ date: date_1, agent: agent }); | ||
} | ||
// Remove entries older than 30 days. | ||
this._heartbeatsCache.heartbeats = this._heartbeatsCache.heartbeats.filter(function (singleDateHeartbeat) { | ||
var hbTimestamp = new Date(singleDateHeartbeat.date).valueOf(); | ||
var now = Date.now(); | ||
return now - hbTimestamp <= STORED_HEARTBEAT_RETENTION_MAX_MILLIS; | ||
}); | ||
this._heartbeatsCache.heartbeats = | ||
this._heartbeatsCache.heartbeats.filter(function (singleDateHeartbeat) { | ||
var hbTimestamp = new Date(singleDateHeartbeat.date).valueOf(); | ||
var now = Date.now(); | ||
return now - hbTimestamp <= STORED_HEARTBEAT_RETENTION_MAX_MILLIS; | ||
}); | ||
return [2 /*return*/, this._storage.overwrite(this._heartbeatsCache)]; | ||
case 3: | ||
e_1 = _e.sent(); | ||
logger.warn(e_1); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -1099,6 +1107,7 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var date, _b, heartbeatsToSend, unsentEntries, headerString; | ||
var date, _b, heartbeatsToSend, unsentEntries, headerString, e_2; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_c.trys.push([0, 6, , 7]); | ||
if (!(this._heartbeatsCache === null)) return [3 /*break*/, 2]; | ||
@@ -1139,2 +1148,7 @@ return [4 /*yield*/, this._heartbeatsCachePromise]; | ||
case 5: return [2 /*return*/, headerString]; | ||
case 6: | ||
e_2 = _c.sent(); | ||
logger.warn(e_2); | ||
return [2 /*return*/, '']; | ||
case 7: return [2 /*return*/]; | ||
} | ||
@@ -1152,3 +1166,3 @@ }); | ||
function extractHeartbeatsForHeader(heartbeatsCache, maxSize) { | ||
var e_1, _a; | ||
var e_3, _a; | ||
if (maxSize === void 0) { maxSize = MAX_HEADER_BYTES; } | ||
@@ -1197,3 +1211,3 @@ // Heartbeats grouped by user agent in the standard format to be sent in | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
@@ -1203,3 +1217,3 @@ try { | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
@@ -1206,0 +1220,0 @@ return { |
@@ -66,3 +66,3 @@ 'use strict'; | ||
var name$p = "@firebase/app"; | ||
var version$1 = "0.10.8-canary.6b0ca77b2"; | ||
var version$1 = "0.10.8-canary.6d6ce8100"; | ||
@@ -136,3 +136,3 @@ /** | ||
var name = "firebase"; | ||
var version = "10.12.5-canary.6b0ca77b2"; | ||
var version = "10.12.5-canary.6d6ce8100"; | ||
@@ -1046,8 +1046,9 @@ /** | ||
HeartbeatServiceImpl.prototype.triggerHeartbeat = function () { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
var platformLogger, agent, date, _c; | ||
return tslib.__generator(this, function (_d) { | ||
switch (_d.label) { | ||
var platformLogger, agent, date_1, _d, e_1; | ||
return tslib.__generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
_e.trys.push([0, 3, , 4]); | ||
platformLogger = this.container | ||
@@ -1057,18 +1058,19 @@ .getProvider('platform-logger') | ||
agent = platformLogger.getPlatformInfoString(); | ||
date = getUTCDateString(); | ||
if (!(((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null)) return [3 /*break*/, 2]; | ||
_c = this; | ||
date_1 = getUTCDateString(); | ||
console.log('heartbeats', (_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats); | ||
if (!(((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null)) return [3 /*break*/, 2]; | ||
_d = this; | ||
return [4 /*yield*/, this._heartbeatsCachePromise]; | ||
case 1: | ||
_c._heartbeatsCache = _d.sent(); | ||
_d._heartbeatsCache = _e.sent(); | ||
// If we failed to construct a heartbeats cache, then return immediately. | ||
if (((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null) { | ||
if (((_c = this._heartbeatsCache) === null || _c === void 0 ? void 0 : _c.heartbeats) == null) { | ||
return [2 /*return*/]; | ||
} | ||
_d.label = 2; | ||
_e.label = 2; | ||
case 2: | ||
// Do not store a heartbeat if one is already stored for this day | ||
// or if a header has already been sent today. | ||
if (this._heartbeatsCache.lastSentHeartbeatDate === date || | ||
this._heartbeatsCache.heartbeats.some(function (singleDateHeartbeat) { return singleDateHeartbeat.date === date; })) { | ||
if (this._heartbeatsCache.lastSentHeartbeatDate === date_1 || | ||
this._heartbeatsCache.heartbeats.some(function (singleDateHeartbeat) { return singleDateHeartbeat.date === date_1; })) { | ||
return [2 /*return*/]; | ||
@@ -1078,11 +1080,17 @@ } | ||
// There is no entry for this date. Create one. | ||
this._heartbeatsCache.heartbeats.push({ date: date, agent: agent }); | ||
this._heartbeatsCache.heartbeats.push({ date: date_1, agent: agent }); | ||
} | ||
// Remove entries older than 30 days. | ||
this._heartbeatsCache.heartbeats = this._heartbeatsCache.heartbeats.filter(function (singleDateHeartbeat) { | ||
var hbTimestamp = new Date(singleDateHeartbeat.date).valueOf(); | ||
var now = Date.now(); | ||
return now - hbTimestamp <= STORED_HEARTBEAT_RETENTION_MAX_MILLIS; | ||
}); | ||
this._heartbeatsCache.heartbeats = | ||
this._heartbeatsCache.heartbeats.filter(function (singleDateHeartbeat) { | ||
var hbTimestamp = new Date(singleDateHeartbeat.date).valueOf(); | ||
var now = Date.now(); | ||
return now - hbTimestamp <= STORED_HEARTBEAT_RETENTION_MAX_MILLIS; | ||
}); | ||
return [2 /*return*/, this._storage.overwrite(this._heartbeatsCache)]; | ||
case 3: | ||
e_1 = _e.sent(); | ||
logger.warn(e_1); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -1102,6 +1110,7 @@ }); | ||
return tslib.__awaiter(this, void 0, void 0, function () { | ||
var date, _b, heartbeatsToSend, unsentEntries, headerString; | ||
var date, _b, heartbeatsToSend, unsentEntries, headerString, e_2; | ||
return tslib.__generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_c.trys.push([0, 6, , 7]); | ||
if (!(this._heartbeatsCache === null)) return [3 /*break*/, 2]; | ||
@@ -1142,2 +1151,7 @@ return [4 /*yield*/, this._heartbeatsCachePromise]; | ||
case 5: return [2 /*return*/, headerString]; | ||
case 6: | ||
e_2 = _c.sent(); | ||
logger.warn(e_2); | ||
return [2 /*return*/, '']; | ||
case 7: return [2 /*return*/]; | ||
} | ||
@@ -1155,3 +1169,3 @@ }); | ||
function extractHeartbeatsForHeader(heartbeatsCache, maxSize) { | ||
var e_1, _a; | ||
var e_3, _a; | ||
if (maxSize === void 0) { maxSize = MAX_HEADER_BYTES; } | ||
@@ -1200,3 +1214,3 @@ // Heartbeats grouped by user agent in the standard format to be sent in | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
@@ -1206,3 +1220,3 @@ try { | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
@@ -1209,0 +1223,0 @@ return { |
{ | ||
"name": "@firebase/app", | ||
"version": "0.10.8-canary.6b0ca77b2", | ||
"version": "0.10.8-canary.6d6ce8100", | ||
"description": "The primary entrypoint to the Firebase JS SDK", | ||
@@ -42,5 +42,5 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", | ||
"dependencies": { | ||
"@firebase/util": "1.9.7-canary.6b0ca77b2", | ||
"@firebase/logger": "0.4.2-canary.6b0ca77b2", | ||
"@firebase/component": "0.6.8-canary.6b0ca77b2", | ||
"@firebase/util": "1.9.7-canary.6d6ce8100", | ||
"@firebase/logger": "0.4.2-canary.6d6ce8100", | ||
"@firebase/component": "0.6.8-canary.6d6ce8100", | ||
"idb": "7.1.1", | ||
@@ -47,0 +47,0 @@ "tslib": "^2.1.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
542650
7805
+ Added@firebase/component@0.6.8-canary.6d6ce8100(transitive)
+ Added@firebase/logger@0.4.2-canary.6d6ce8100(transitive)
+ Added@firebase/util@1.9.7-canary.6d6ce8100(transitive)
- Removed@firebase/component@0.6.8-canary.6b0ca77b2(transitive)
- Removed@firebase/logger@0.4.2-canary.6b0ca77b2(transitive)
- Removed@firebase/util@1.9.7-canary.6b0ca77b2(transitive)