-
Notifications
You must be signed in to change notification settings - Fork 895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement heartbeat controller #5723
Conversation
🦋 Changeset detectedLatest commit: 3125e64 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1This report is too large (193,683 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.Test Logs |
packages/util/src/indexeddb.ts
Outdated
reject((event.target as IDBRequest).error?.message); | ||
}; | ||
|
||
request.onupgradeneeded = event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd want this callback to be provided by the users of this utility class because the upgrade logic varies from use case to use case, and thus can't be generalized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in favor of using idb
.
packages/util/src/indexeddb.ts
Outdated
* limitations under the License. | ||
*/ | ||
|
||
export class IndexedDbDatabaseService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth considering using the idb library which is tiny and provides the convenient APIs instead of rolling our own solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
packages/app/src/types.ts
Outdated
*/ | ||
heartbeatsCachePromise: Promise<HeartbeatsByUserAgent[]>; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments are still useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put the comments on the class itself, do they need to be in both places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. The consumer of the component will only look at the interface definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored.
await heartbeatService.triggerHeartbeat(); | ||
expect(heartbeatService._heartbeatsCache?.length).to.equal(1); | ||
const heartbeat1 = heartbeatService._heartbeatsCache?.[0]; | ||
expect(heartbeat1?.userAgent).to.equal('vs1/1.2.3 vs2/2.3.4'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For hardcoded strings we expect to match do we typically enter than as raw compares rather than define them as constants at the top of the file?
This isn't a neccesary change, the ROI might be low but it would reduce typo mistakes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, changed.
packages/app/src/heartbeatService.ts
Outdated
const monthString = month < 10 ? '0' + month : month.toString(); | ||
const date = today.getUTCDate(); | ||
const dayString = date < 10 ? '0' + date : date.toString(); | ||
return `${yearString}-${monthString}-${dayString}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to get rid of the custom logic here you could just do:
today.toISOString().substring(0,10)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Changed.
Implement heartbeat controller.
Design doc (internal): go/firebasejssdk-heartbeat