Skip to content

EDSC-4613: Build metrics for how long it takes for the map to load - #2083

Open
eudoroolivares2016 wants to merge 12 commits into
mainfrom
EDSC-4613
Open

EDSC-4613: Build metrics for how long it takes for the map to load#2083
eudoroolivares2016 wants to merge 12 commits into
mainfrom
EDSC-4613

Conversation

@eudoroolivares2016

@eudoroolivares2016 eudoroolivares2016 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Overview

What is the feature?

Creates three events for the map to track
Performance of the granule outlines, background, and a performance indicator for the sluggishness of the map.

This also fixes the main issue by cleaning up accumulating listener objects from the interface and some minor improvements by just bailing out before extra processing is done

What is the Solution?

  1. For the granule performance metrics we can just listen for the postrender events that openlayers producers collect them and then send that to the dataLayer GTM event middleware. Within these events we are also bucketing users based on granule count. This is so that we can get an idea of how many granules users are observing at a time as we may decide to cap that amount.

  2. For the "FPS" timing: we create a timer for a configurable length proposing 3 minutes and use that in conjunction to a listener on MoveEnd events. This is so that we don't collect stats for when people aren't moving the map. The idea is to understand how fast/slow the map moves for users. When a move-end occurs and the time has passed we divide up that metric into percentiles so its easier for us to use this metrics on the analytics side.

  3. The main performance improvement in this PR is the useEffect at the end this is just cleaning up the granule outline listeners which were accumulating and causing the slowdown. There are a few other improvements based on console.counts appearing e.g. calls that don't need to happen

What areas of the application does this impact?

Map.jsx and data layer metrics

Testing

Reproduction steps

  • **Environment for testing:Prod
  • Collection to test with:
    C1701805625-GES_DISC - granule with many data layers

    C2259345545-GES_DISC - main issue one; complex granule vertices
    C3104974973-SEDAC - simple use-case; control
  1. Navigate to the granules menu
  2. Use https://tagmanager.google.com/#/home preview mode or add console logs to see the data layer events firing
  3. The two should fire when granule drawing events render. The latter requires moving around/zooming the map for a few minutes to see the event then fire

Attachments

C2259345545-GES_DISC - without the use-effect cleanup
image

C2259345545-GES_DISC - after the use-effect cleanup
image

Checklist

  • I have added automated tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have run npm audit fix and made note of any changes in this PR
  • My changes generate no new warnings

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

Bundle Size Comparison

Full build details

> earthdata-search@1.0.0 build
> vite build

vite v6.4.3 building for production...
transforming...
✓ 4031 modules transformed.
rendering chunks...
computing gzip size...
static/dist/assets/logo-Bl7CmmEi.webp                                                      0.98 kB
static/dist/assets/logo-CZz0VEVL.webp                                                      1.14 kB
static/dist/assets/logo-Cycj4Zl7.webp                                                      1.33 kB
static/dist/assets/logo-U_2b2F1P.webp                                                      1.37 kB
static/dist/assets/logo-DrQyzv8O.webp                                                      1.54 kB
static/dist/assets/logo-BtXPiD8D.webp                                                      1.81 kB
static/dist/assets/logo-CBoC93bb.webp                                                      2.16 kB
static/dist/assets/logo-DjzD1LMz.webp                                                      2.39 kB
static/dist/assets/orange-bars-circle-D7AglAGM.webp                                        2.77 kB
static/dist/assets/logo-mTUaHBfB.webp                                                      3.11 kB
static/dist/assets/blue-bars-circle-BoIdEwIS.webp                                          3.67 kB
static/dist/assets/logo-BRHnty9h.webp                                                      4.09 kB
static/dist/assets/cryosphere-icon-DSWEvPIt.svg                                            4.11 kB │ gzip:   1.64 kB
static/dist/assets/logo-DPcWY5XI.webp                                                      4.25 kB
static/dist/assets/logo-BI7QOwpp.webp                                                      4.72 kB
static/dist/assets/logo-CjKnSDvE.webp                                                      7.06 kB
static/dist/index.html                                                                    13.24 kB │ gzip:   3.10 kB
static/dist/assets/plate_carree_earth_scaled-RfqGhO39.png                                 18.14 kB
static/dist/assets/tour-video-thumbnail-BxsZeqvq.webp                                     18.84 kB
static/dist/assets/plate_carree_earth_scaled@2x-BIj0Wstc.png                              45.03 kB
static/dist/assets/image-unavailable-CcXgOtQr.svg                                         52.20 kB │ gzip:  20.77 kB
static/dist/assets/earthdata-search-og-image-Cs5RILJ1.webp                                92.82 kB
static/dist/assets/MODIS-Terra-Swirling-Clouds-In-Atlantic-800x600@2x-DdSR_KXb.webp      132.70 kB
static/dist/assets/MODIS-Terra-Swirling-Clouds-In-Atlantic-2560x1440@2x-CZbMhKXi.webp    224.17 kB
static/dist/assets/MODIS-Terra-Swirling-Clouds-In-Atlantic-800x600@2x-DFWWupvf.webp      381.18 kB
static/dist/assets/MODIS-Terra-Swirling-Clouds-In-Atlantic-2560x1440@2x-BwDp59vN.webp    464.37 kB
static/dist/assets/MODIS-Terra-Swirling-Clouds-In-Atlantic-2560x1440@2x-CeYlmMCD.webp    737.44 kB
static/dist/assets/MODIS-Terra-Swirling-Clouds-In-Atlantic-2560x1440@2x-tQ4uTIyn.webp  1,255.87 kB
static/dist/assets/MODIS-Terra-Swirling-Clouds-In-Atlantic-2560x1440@2x-BqbXRJmQ.webp  1,516.81 kB
static/dist/assets/AdminRetrieval-nNSujMnn.css                                             0.06 kB │ gzip:   0.08 kB
static/dist/assets/AdminPreferencesMetrics-GkGryAtC.css                                    0.10 kB │ gzip:   0.11 kB
static/dist/assets/ChunkedOrderModal-DIli9vpQ.css                                          0.11 kB │ gzip:   0.10 kB
static/dist/assets/TooManyPointsModal-D8ufPyjz.css                                         0.14 kB │ gzip:   0.12 kB
static/dist/assets/AdminRetrievalsMetrics-CT7bgXZt.css                                     0.22 kB │ gzip:   0.13 kB
static/dist/assets/AdminPage-D19229XC.css                                                  0.23 kB │ gzip:   0.16 kB
static/dist/assets/ContactInfo-C7Pr11wu.css                                                0.28 kB │ gzip:   0.18 kB
static/dist/assets/useDeleteSubscription-YPccXDF3.css                                      0.46 kB │ gzip:   0.23 kB
static/dist/assets/ShapefileDropzoneContainer-BG7JE7Dj.css                                 0.53 kB │ gzip:   0.26 kB
static/dist/assets/GranuleFiltersContainer-CfwvM6Mp.css                                    0.59 kB │ gzip:   0.27 kB
static/dist/assets/ShapefileUploadModal-CMzmPyoZ.css                                       0.66 kB │ gzip:   0.32 kB
static/dist/assets/Preferences-DGkx-xES.css                                                0.68 kB │ gzip:   0.24 kB
static/dist/assets/Skeleton-DtMOdDsM.css                                                   0.88 kB │ gzip:   0.34 kB
static/dist/assets/TextWindowActions-aNefZur7.css                                          0.91 kB │ gzip:   0.38 kB
static/dist/assets/RelatedCollection-BaShQZdF.css                                          0.93 kB │ gzip:   0.40 kB
static/dist/assets/CollectionDetailsHighlights-CHDYEfjF.css                                1.24 kB │ gzip:   0.44 kB
static/dist/assets/GranuleResultsHighlights-BIY0O9bb.css                                   1.24 kB │ gzip:   0.41 kB
static/dist/assets/Subscriptions-CYrzsucf.css                                              1.26 kB │ gzip:   0.40 kB
static/dist/assets/EDSCModalContainer-D_JXXJBf.css                                         1.77 kB │ gzip:   0.59 kB
static/dist/assets/AdminProjects-CZeT2VXI.css                                              1.98 kB │ gzip:   0.46 kB
static/dist/assets/AdminRetrievals-DIdJ2AD-.css                                            2.02 kB │ gzip:   0.46 kB
static/dist/assets/DownloadHistory-C2TrZbdc.css                                            2.05 kB │ gzip:   0.47 kB
static/dist/assets/DeprecatedParameterModal-nutVvbLm.css                                   2.12 kB │ gzip:   0.93 kB
static/dist/assets/Projects-5m-RoZO0.css                                                   2.13 kB │ gzip:   0.51 kB
static/dist/assets/EchoForm-VVUehB8V.css                                                   3.47 kB │ gzip:   1.06 kB
static/dist/assets/SearchTour-AJompJPK.css                                                 4.82 kB │ gzip:   1.22 kB
static/dist/assets/index-BOElThXL.css                                                      6.47 kB │ gzip:   1.24 kB
static/dist/assets/OrderStatus-qyLNmnfS.css                                                8.49 kB │ gzip:   1.93 kB
static/dist/assets/createSpatialDisplay-CiT4b-tQ.css                                      10.62 kB │ gzip:   2.41 kB
static/dist/assets/MapContainer-GerI1QoD.css                                              17.00 kB │ gzip:   5.89 kB
static/dist/assets/Project-RbLZgqcX.css                                                   20.04 kB │ gzip:   4.07 kB
static/dist/assets/Search-DWJQ45Qd.css                                                    69.43 kB │ gzip:  10.66 kB
static/dist/assets/index-CgZEHIcM.css                                                    342.64 kB │ gzip: 110.16 kB
static/dist/assets/logo-BHeuky8i.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-C2M9lK3U.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-BbJQ0fWs.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-CW6PQqmQ.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-CM8gX-og.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-CGJHAKVD.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-DOLER09h.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-BXFnLkSI.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-J7t-4CBp.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-CxvnVTz2.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-C9HDQHSy.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-IHV3gtAZ.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-Dedvhxzp.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo--kH-hKRS.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-CBz1b7O8.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-nOuRrv94.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-DIxV4RPX.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/logo-uABdcgsF.js                                                        0.06 kB │ gzip:   0.08 kB
static/dist/assets/pluralize-49vSaAHF.js                                                   0.08 kB │ gzip:   0.09 kB
static/dist/assets/accessMethodTypes-CY5JnOnd.js                                           0.13 kB │ gzip:   0.14 kB
static/dist/assets/commafy-BfQYQOA4.js                                                     0.14 kB │ gzip:   0.14 kB
static/dist/assets/requestDebounceDuration-B92It3cW.js                                     0.16 kB │ gzip:   0.11 kB
static/dist/assets/subscriptions-BhNR4fdA.js                                               0.41 kB │ gzip:   0.21 kB
static/dist/assets/DownloadsLayout-DSJgf4OT.js                                             0.44 kB │ gzip:   0.25 kB
static/dist/assets/Table-BoPj-I59.js                                                       0.59 kB │ gzip:   0.38 kB
static/dist/assets/DefinitionList-D8Pb5mvr.js                                              0.63 kB │ gzip:   0.39 kB
static/dist/assets/AdminLayout-CtdDzEgW.js                                                 0.63 kB │ gzip:   0.36 kB
static/dist/assets/AdminPage-BFI0r8zk.js                                                   0.68 kB │ gzip:   0.36 kB
static/dist/assets/TooManyPointsModal-Do9GIMtR.js                                          0.74 kB │ gzip:   0.48 kB
static/dist/assets/humanizedQueryValueFormatters-z-QpfuHK.js                               1.00 kB │ gzip:   0.54 kB
static/dist/assets/KeyboardShortcutsModal-0U1FawjN.js                                      1.24 kB │ gzip:   0.72 kB
static/dist/assets/metricsDataAccess-B0dv9eSs.js                                           1.26 kB │ gzip:   0.35 kB
static/dist/assets/Skeleton-DJIiY4vq.js                                                    1.28 kB │ gzip:   0.58 kB
static/dist/assets/AdminIndex-emhlsLTR.js                                                  1.36 kB │ gzip:   0.71 kB
static/dist/assets/index-Zi8wnWhN.js                                                       1.64 kB │ gzip:   0.94 kB
static/dist/assets/AdminProject-zBdBaNWY.js                                                1.68 kB │ gzip:   0.85 kB
static/dist/assets/useLazyQuery-CONU0yKq.js                                                1.70 kB │ gzip:   0.89 kB
static/dist/assets/ShapefileUploadModal-VosUBOKz.js                                        1.83 kB │ gzip:   0.81 kB
static/dist/assets/DeprecatedParameterModal-D16IFqN0.js                                    2.07 kB │ gzip:   1.16 kB
static/dist/assets/EditSubscriptionModal-Du3UE_3q.js                                       2.23 kB │ gzip:   1.13 kB
static/dist/assets/EarthdataDownloadRedirect-DOKagHgW.js                                   2.24 kB │ gzip:   0.90 kB
static/dist/assets/AboutCSDAModal-Dgm5iTbf.js                                              2.25 kB │ gzip:   0.99 kB
static/dist/assets/ChunkedOrderModal-Bh_tU7tp.js                                           2.34 kB │ gzip:   1.20 kB
static/dist/assets/AdminPreferencesMetrics-Cbeu8Jak.js                                     2.41 kB │ gzip:   0.84 kB
static/dist/assets/useCreateRetrieval-neYRC9AE.js                                          3.26 kB │ gzip:   1.59 kB
static/dist/assets/DownloadHistory-9KMVTmYq.js                                             3.41 kB │ gzip:   1.42 kB
static/dist/assets/GranuleResultsHighlights-Dbq-I3Oh.js                                    3.66 kB │ gzip:   1.35 kB
static/dist/assets/CollectionDetailsHighlights-Cav3VxZq.js                                 3.77 kB │ gzip:   0.99 kB
static/dist/assets/EDSCModalContainer-Cbhn-CFK.js                                          4.24 kB │ gzip:   1.45 kB
static/dist/assets/AdminRetrieval-DDjh27g1.js                                              4.29 kB │ gzip:   1.78 kB
static/dist/assets/AdminProjects-jDdQnFzv.js                                               4.35 kB │ gzip:   1.59 kB
static/dist/assets/Projects-D8xUxnC8.js                                                    4.40 kB │ gzip:   1.72 kB
static/dist/assets/AdminRetrievals-Uz0KPBF6.js                                             4.60 kB │ gzip:   1.65 kB
static/dist/assets/AboutCwicModal-xS-nwcvL.js                                              4.69 kB │ gzip:   1.92 kB
static/dist/assets/ContactInfo-C6ALzRZS.js                                                 4.71 kB │ gzip:   1.55 kB
static/dist/assets/Subscriptions-Cd1jPozD.js                                               4.79 kB │ gzip:   1.71 kB
static/dist/assets/AdminRetrievalsMetrics-C336Evq6.js                                      4.82 kB │ gzip:   1.64 kB
static/dist/assets/useDeleteSubscription-Dvz5Gcle.js                                       6.35 kB │ gzip:   2.44 kB
static/dist/assets/RelatedCollection-BiCfco0E.js                                          10.41 kB │ gzip:   3.99 kB
static/dist/assets/Modal-BNBmEEBz.js                                                      10.74 kB │ gzip:   4.05 kB
static/dist/assets/GranuleFiltersContainer-tOEKMMK0.js                                    21.83 kB │ gzip:   5.91 kB
static/dist/assets/styles-BFxitya-.js                                                     32.69 kB │ gzip:  10.77 kB
static/dist/assets/index-DjlTaOgJ.js                                                      35.34 kB │ gzip:  12.82 kB
static/dist/assets/moment-BAtM24Ew.js                                                     60.92 kB │ gzip:  19.77 kB
static/dist/assets/createSpatialDisplay-BDzWmqrF.js                                       60.95 kB │ gzip:  17.02 kB
static/dist/assets/OrderStatus-BMn_0Opo.js                                                63.29 kB │ gzip:  17.62 kB
static/dist/assets/lodash-DR7EQ6YQ.js                                                     92.24 kB │ gzip:  31.91 kB
static/dist/assets/EchoForm-B0NVODWl.js                                                  108.53 kB │ gzip:  33.67 kB
static/dist/assets/SearchTour-BFQOs7mu.js                                                117.44 kB │ gzip:  35.77 kB
static/dist/assets/ShapefileDropzoneContainer-DwaSzqDw.js                                119.66 kB │ gzip:  40.21 kB
static/dist/assets/edscUtils-6LLLH5LD.js                                                 141.73 kB │ gzip:  46.95 kB
static/dist/assets/react-D1lqFcfa.js                                                     230.00 kB │ gzip:  74.34 kB
static/dist/assets/Project-CR4H34OY.js                                                   232.42 kB │ gzip:  83.87 kB
static/dist/assets/Preferences-D8HMWpoc.js                                               362.82 kB │ gzip: 115.23 kB
static/dist/assets/Search-B68RZnJG.js                                                    493.87 kB │ gzip: 143.93 kB
static/dist/assets/MapContainer-Booo7com.js                                            1,201.79 kB │ gzip: 233.91 kB
static/dist/assets/index-DDa3tCzN.js                                                   1,234.73 kB │ gzip: 386.34 kB
✓ built in 35.44s

The full bundle is larger than main by 2.27 kB. ❗

The index.js is larger than main by 0.19 kB. ❗

Run npx vite-bundle-visualizer to review the bundle in more detail.

File Main Branch Diff
Total 10227.59 kB 10229.86 kB 2.27 kB
index.js 1271.52 kB 1271.71 kB 0.19 kB
index.js (gzip) 399.99 kB 400.1 kB 0.11 kB
index.css 349.11 kB 349.11 kB 0 kB
index.css (gzip) 111.4 kB 111.4 kB 0 kB
Number of files 139 139 0
Build Time 36.15 s 35.44 s -0.71 s

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.03922% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.85%. Comparing base (33e07e1) to head (c9a8967).

Files with missing lines Patch % Lines
static/src/js/components/Map/Map.tsx 97.56% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2083      +/-   ##
==========================================
+ Coverage   95.84%   95.85%   +0.01%     
==========================================
  Files         756      756              
  Lines       17776    17867      +91     
  Branches     4978     5049      +71     
==========================================
+ Hits        17037    17127      +90     
- Misses        687      688       +1     
  Partials       52       52              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eudoroolivares2016 eudoroolivares2016 changed the title Edsc 4613 EDSC-4613 Aug 21, 2026
@eudoroolivares2016 eudoroolivares2016 changed the title EDSC-4613 EDSC-4613: Build metrics for how long it takes for the map to load Aug 21, 2026
@eudoroolivares2016
eudoroolivares2016 marked this pull request as ready for review August 24, 2026 14:23
Comment thread static/src/js/components/Map/Map.tsx Outdated
Comment thread static/src/js/util/metrics/metricsMap.ts Outdated
collectionId: string
) => {
dataLayer.push({
event: 'map',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We want:
zoomLevel, center

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

call imagery rather than "granule backgrounds"

windowDurationMs: number
}

export const metricsMapFramePerformance = (event: MapPerformanceEvent) => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

number of granules

Comment thread static/src/js/util/metrics/metricsMap.ts
Comment thread static/src/js/util/metrics/helpers.ts
Comment thread static/src/js/components/Map/Map.tsx
let previousGranulesKey: string
let previousProjectionCode: ProjectionCode
let layersAdded = false
const PERFORMANCE_WINDOW_MS = 3000

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This should be a bamboo var

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.

1 participant