Skip to content

New mechanism for usage data collection - #12381

Merged
pleku merged 21 commits into
masterfrom
feature/t-22
Nov 29, 2021
Merged

pleku merged 21 commits into
masterfrom
feature/t-22

Conversation

@samie

@samie samie commented Nov 17, 2021

Copy link
Copy Markdown
Member

Move client-side component usage statistics collection and data to server-side.

@caalador
caalador marked this pull request as draft November 18, 2021 08:25
@pleku
pleku marked this pull request as ready for review November 22, 2021 08:26
@pleku
pleku self-requested a review November 22, 2021 08:26
@Artur- Artur- self-assigned this Nov 25, 2021
@Artur-

Artur- commented Nov 25, 2021 •

Copy link
Copy Markdown
Member

I will do some cleanup for this

samie and others added 5 commits November 25, 2021 10:52
Collects usage statistics in development mode via DevModeHandler.
Can be opt out with devmode.usageStatistics.enabled configuration parameter.
// Send usage statistics asynchronously, if enough time has
// passed
if (isIntervalElapsed(json)) {
CompletableFuture.runAsync(() -> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FutureReturnValueIgnored: Return value of methods returning Future must be checked. Ignoring returned Futures suppresses exceptions thrown from the code that completes the Future.
(at-me in a reply with help or ignore)

@manolo

manolo commented Nov 29, 2021

Copy link
Copy Markdown
Member

Is this something that need to be in v22 ?

@Artur-

Artur- commented Nov 29, 2021

Copy link
Copy Markdown
Member

It's a bit late for 22.0.0

@Artur-

Artur- commented Nov 29, 2021

Copy link
Copy Markdown
Member

If you have earlier opted out from stats, you have run

npm config set @vaadin/vaadin-usage-statistics:disabled true

We could check this so that stats are disabled if

npm config get @vaadin/vaadin-usage-statistics:disabled

returns true

pleku
pleku previously approved these changes Nov 29, 2021
// Use default value in case of any problems
getLogger().debug(
FAILED_TO_READ + StatisticsConstants.FIELD_LAST_SENT, e);
private static ObjectNode getProjectData(ObjectNode fullJson,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: getOrCreateProjectData would be better so the side effect is easier to understand

/**
* Checks if the old npm opt-out mechanism is active.
*/
public boolean isOldNpmOptOutUsed() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
public boolean isOldNpmOptOutUsed() {
public boolean isOldNpmStatisticsOptOutUsed() {

// Initialize the usage statistics if enabled
if (config.isUsageStatisticsEnabled()) {
FrontendTools frontendTools = new FrontendTools(config, new File(baseDir));
if (config.isUsageStatisticsEnabled() && !frontendTools.isOldNpmOptOutUsed()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if (config.isUsageStatisticsEnabled() && !frontendTools.isOldNpmOptOutUsed()) {
if (config.isUsageStatisticsEnabled() && !frontendTools.isOldNpmStatisticsOptOutUsed()) {

@vaadin-bot

Copy link
Copy Markdown
Collaborator

SonarQube analysis reported 22 issues

  • MAJOR 13 major
  • MINOR 7 minor
  • INFO 2 info

Top 10 issues

  1. MAJOR FrontendTools.java#L163: Define and throw a dedicated exception instead of using a generic one. rule
  2. MAJOR FrontendTools.java#L408: Constructor has 8 parameters, which is greater than 7 authorized. rule
  3. MAJOR FrontendTools.java#L737: A "NullPointerException" could be thrown; "output" is nullable here. rule
  4. MAJOR FrontendTools.java#L757: A "NullPointerException" could be thrown; "removeLineBreaks" is nullable here. rule
  5. MAJOR AbstractDevServerRunner.java#L118: Make "devServerStartFuture" transient or serializable. rule
  6. MAJOR AbstractDevServerRunner.java#L195: Invoke method(s) only conditionally. rule
  7. MAJOR AbstractDevServerRunner.java#L306: Remove this unused method parameter "nodeVersion". rule
  8. MAJOR AbstractDevServerRunner.java#L391: Either re-interrupt this method or rethrow the "InterruptedException". rule
  9. MAJOR AbstractDevServerRunner.java#L618: Null passed for non-null parameter of java.util.concurrent.CompletableFuture.getNow(Object) in com.vaadin.base.devserver.AbstractDevServerRunner.handleRequest(VaadinSession, VaadinRequest, VaadinResponse) rule
  10. MAJOR AbstractDevServerRunner.java#L665: Refactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed. rule

@pleku
pleku merged commit 3990bb5 into master Nov 29, 2021
@github-actions

Copy link
Copy Markdown
Contributor

Unit Test Results

   717 files     717 suites   18m 56s ⏱️
5 615 tests 5 566 ✔️ 49 💤 0 ❌
5 631 runs  5 582 ✔️ 49 💤 0 ❌

Results for commit f079fb4.

vaadin-bot pushed a commit that referenced this pull request Dec 9, 2021
Collects usage statistics once a day in development mode.
Can be opt out with `devmode.usageStatistics.enabled` configuration parameter.

Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>
Co-authored-by: Artur Signell <artur@vaadin.com>
manolo pushed a commit that referenced this pull request Dec 9, 2021
Collects usage statistics once a day in development mode.
Can be opt out with `devmode.usageStatistics.enabled` configuration parameter.

Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>
Co-authored-by: Artur Signell <artur@vaadin.com>

Co-authored-by: Sami Ekblad <sami@vaadin.com>
Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>
Co-authored-by: Artur Signell <artur@vaadin.com>
@knoobie

knoobie commented Jan 5, 2022

Copy link
Copy Markdown
Contributor

I'm currently trying v23.alpha1 and I get the following in the JS log from a new starter project:

XML Parsing Error: not well-formed  (submit:1:7)
Location: https://tools.vaadin.com/usage-stats/submit
Line Number 1, Column 7: submit:1:7

Given URL (https://tools.vaadin.com/usage-stats/submit) returns 400 via browser as well.

@caalador
caalador deleted the feature/t-22 branch October 12, 2022 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants