Closed mshabarov closed 2 months ago
Vite does not preserve the comment inside the maybeGatherAndSendStats
function so when it tries to uncomment and execute at runtime, it only runs function maybeGatherAndSendStats() {\n }
This may fix it - https://github.com/vaadin/vaadin-usage-statistics/pull/79, needs to be tested with the next platform release.
That fix is not enough as the problem still reproducible with 24.5.0.alpha14. But we'll investigate further why the vaadin-usage-statistics
doesn't run.
UPD: re-tested with another fresh Hilla applications and can see the stats data in the local storage and json file.
Tested with 24.5.0.alpha15 and it seems to work as expected. Both local storage and JSON file are populated.
@jojule could you please test on your local with Vaadin 24.5.0.alpha15 ?
Describe the bug
This ticket is a follow up for https://github.com/vaadin/platform/issues/6488.
Vaadin usage statistics tools (they involve few modules), that work in the browser, do not collect stats for Hilla and hybrid applications (Hilla + Flow) and do not send the stats to the stats server.
More precisely, the Local Storage
vaadin.statistics.basket
does not exist even after several reruns of Hilla applications, however thewindow.Vaadin.registrations
array gets all the expected stats parameters. This leads also to~/.vaadin/usage-statistics.json
to not having any statistics (only some general fields, like timestamps, system info etc.).Once the bundle mode (
vaadin.frontend.hotdeploy=false
) is enforced for Hilla and hybrid apps, the Local Storage gets populated as expected.Taking into account these observations, I'd say the problem is somewhere in the Vite configuration, where the
vaadin-udage-statistics.js
module is generated (uncommented). So it's not generated, or it's not uncommented, or it's not loaded, or it's loaded in the wrong order in the browser, i.e. beforewindow.Vaadin.registrations
are populated with the data.This fix was aimed to fix this anomaly, but looks like it's not enough.
The diagram below describes the data flows and possible problematic place:
Expected-behavior
Vaadin application should record the statistics to
~/.vaadin/usage-statistics.json
after shutdown.Reproduction
Can be reproduced with the branch in hybrid app example, where I've put extra code to trigger all the stats parameters listed in https://github.com/vaadin/platform/issues/6488.
~/.vaadin/usage-statistics.json
and delete it.vaadin.statistics.basket
in browser under "Application" tab in dev tools../mvnw
Results:
usage-statistics.json
does not containhas-flow-route
orhas-endpoint
orhas-hilla-fs-route
or@vaadin/hilla-file-router/createMenuItems
parameters, it basically doesn't have any records.local storages in Safari, Firefox, and Chrome have no
vaadin.statistics.basket
storages.References
Vaadin Statistics Tool (browser part) - https://github.com/vaadin/vaadin-usage-statistics/blob/master/src/vaadin-usage-statistics.js Web-components part that collect stats - https://github.com/vaadin/web-components/blob/1a9fc33a212642bbd9862e5cf9b89bbf55dd150d/packages/component-base/src/element-mixin.js#L22 Vaadin Dev Tools that sends stats to server - https://github.com/vaadin/flow/blob/main/vaadin-dev-server/src/main/frontend/vaadin-dev-tools.ts
System Info
Vaadin 24.4.x and pre 24.5.x