Skip to content
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

Fireperf web vitals #8644

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Fireperf web vitals #8644

wants to merge 12 commits into from

Conversation

bryanatkinson
Copy link

  • Add support for capturing web vitals metrics in Firebase performance for Web (Largest Contentful Paint, Interaction to Next Paint, Cumulative Layout Shift)
  • Modifies export to use sendBeacon instead of fetch API, and shifts the upload time to the first time the page is hidden or unloaded.

@bryanatkinson bryanatkinson requested review from jposuna and a team as code owners November 18, 2024 22:18
Copy link

changeset-bot bot commented Nov 18, 2024

⚠️ No Changeset found

Latest commit: 8ca7c35

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 18, 2024

Size Report 1

Affected Products

  • @firebase/data-connect

    TypeBase (ffbf5a6)Merge (7685f5f)Diff
    browser19.9 kB20.2 kB+329 B (+1.7%)
    main21.7 kB22.1 kB+455 B (+2.1%)
    module19.9 kB20.2 kB+329 B (+1.7%)
  • @firebase/firestore

    TypeBase (ffbf5a6)Merge (7685f5f)Diff
    browser381 kB382 kB+367 B (+0.1%)
    main588 kB589 kB+614 B (+0.1%)
    module381 kB382 kB+367 B (+0.1%)
    react-native382 kB382 kB+367 B (+0.1%)
  • @firebase/firestore-lite

    TypeBase (ffbf5a6)Merge (7685f5f)Diff
    browser111 kB111 kB+402 B (+0.4%)
    main153 kB154 kB+635 B (+0.4%)
    module111 kB111 kB+402 B (+0.4%)
    react-native111 kB112 kB+402 B (+0.4%)
  • @firebase/functions

    TypeBase (ffbf5a6)Merge (7685f5f)Diff
    browser9.72 kB13.7 kB+3.95 kB (+40.6%)
    main10.3 kB14.2 kB+3.95 kB (+38.3%)
    module9.72 kB13.7 kB+3.95 kB (+40.6%)
  • @firebase/messaging

    TypeBase (ffbf5a6)Merge (7685f5f)Diff
    browser21.3 kB22.0 kB+765 B (+3.6%)
    main21.7 kB22.4 kB+765 B (+3.5%)
    module21.3 kB22.0 kB+765 B (+3.6%)
  • @firebase/performance

    TypeBase (ffbf5a6)Merge (7685f5f)Diff
    browser29.1 kB30.6 kB+1.51 kB (+5.2%)
    main29.5 kB31.1 kB+1.56 kB (+5.3%)
    module29.1 kB30.6 kB+1.51 kB (+5.2%)
  • @firebase/vertexai

    TypeBase (ffbf5a6)Merge (7685f5f)Diff
    browser28.9 kB28.8 kB-83 B (-0.3%)
    main29.7 kB29.6 kB-83 B (-0.3%)
    module28.9 kB28.8 kB-83 B (-0.3%)
  • bundle

    18 size changes

    TypeBase (ffbf5a6)Merge (7685f5f)Diff
    firestore (CSI Auto Indexing Disable and Delete)272 kB272 kB+332 B (+0.1%)
    firestore (CSI Auto Indexing Enable)272 kB272 kB+332 B (+0.1%)
    firestore (Persistence)303 kB304 kB+332 B (+0.1%)
    firestore (Query Cursors)249 kB249 kB+332 B (+0.1%)
    firestore (Query)247 kB247 kB+332 B (+0.1%)
    firestore (Read data once)234 kB235 kB+332 B (+0.1%)
    firestore (Read Write w Persistence)328 kB328 kB+332 B (+0.1%)
    firestore (Realtime updates)237 kB237 kB+332 B (+0.1%)
    firestore (Transaction)214 kB214 kB+332 B (+0.2%)
    firestore (Write data)213 kB213 kB+332 B (+0.2%)
    firestore-lite (Query Cursors)91.4 kB103 kB+11.3 kB (+12.3%)
    firestore-lite (Query)87.6 kB98.8 kB+11.3 kB (+12.9%)
    firestore-lite (Read data once)63.0 kB74.3 kB+11.3 kB (+17.9%)
    firestore-lite (Transaction)88.3 kB99.5 kB+11.3 kB (+12.8%)
    firestore-lite (Write data)72.6 kB83.9 kB+11.3 kB (+15.5%)
    functions (call)32.0 kB34.4 kB+2.36 kB (+7.4%)
    messaging (send + receive)46.9 kB47.4 kB+466 B (+1.0%)
    performance (trace)51.8 kB62.3 kB+10.5 kB (+20.2%)

  • firebase

    13 size changes

    TypeBase (ffbf5a6)Merge (7685f5f)Diff
    firebase-compat.js794 kB808 kB+13.1 kB (+1.6%)
    firebase-data-connect.js16.6 kB16.7 kB+186 B (+1.1%)
    firebase-firestore-compat.js346 kB347 kB+329 B (+0.1%)
    firebase-firestore-lite.js119 kB130 kB+11.3 kB (+9.5%)
    firebase-firestore.js440 kB441 kB+361 B (+0.1%)
    firebase-functions-compat.js8.21 kB10.4 kB+2.20 kB (+26.8%)
    firebase-functions.js12.0 kB14.6 kB+2.57 kB (+21.5%)
    firebase-messaging-compat.js38.3 kB38.7 kB+408 B (+1.1%)
    firebase-messaging.js28.7 kB29.1 kB+452 B (+1.6%)
    firebase-performance-compat.js30.8 kB40.9 kB+10.1 kB (+32.7%)
    firebase-performance-standalone-compat.js93.7 kB104 kB+10.3 kB (+11.0%)
    firebase-performance.js35.1 kB45.5 kB+10.4 kB (+29.7%)
    firebase-vertexai.js23.9 kB23.8 kB-90 B (-0.4%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/BN9VGyn6b2.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Nov 18, 2024

Size Analysis Report 1

This report is too large (123,441 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

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/66FfBhXUIA.html

… often updates the values at unload time, and os queuing this until the end means those latest values get captured.
let getEntriesByTypeStub: SinonStub<[EntryType], PerformanceEntry[]>;
let setupObserverStub: SinonStub<
[EntryType, (entry: PerformanceEntry) => void],
void
>;
let createOobTraceStub: SinonStub<
let createOobTraceStub: SinonSpy<
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: createOobTraceStub -> createOobTraceSpy

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

method: 'POST',
body: JSON.stringify(data)
});
return navigator.sendBeacon(flTransportFullUrl, JSON.stringify(data));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a fall back to fetch if sendBeacon fails (eg. payload is > then the ~64KB limit)

(navigator.sendBeacon && navigator.sendBeacon(flTransportFullUrl, JSON.stringify(data))) ||
    fetch(flTransportFullUrl, {
        method: 'POST',
        body: JSON.stringify(data),
        keepalive: true
     }
     );

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants