Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,13 @@ public final class Constants implements Serializable {
*/
public static final boolean DEFAULT_REQUIRE_HOME_NODE_EXECUTABLE = false;

public static final String TELEMETRY_OPT_OUT_ENV_VARIABLE = "VAADIN_TELEMETRY_OPT_OUT";

/**
* The default value for whether usage statistics is enabled.
*/
public static final boolean DEFAULT_DEVMODE_STATS = true;
public static final boolean DEFAULT_DEVMODE_STATS =
System.getenv(Constants.TELEMETRY_OPT_OUT_ENV_VARIABLE) == null;

/**
* Internal parameter which prevent validation for annotations which are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
package com.vaadin.base.devserver.stats;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Instant;

import com.fasterxml.jackson.databind.JsonNode;
import com.vaadin.flow.server.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -87,6 +93,25 @@ public static DevModeUsageStatistics init(File projectFolder,

getLogger().debug("Telemetry enabled");

final Path statisticDirPath = storage.getUsageStatisticsFile().getParentFile().toPath();
final Path firstSeenPath = statisticDirPath.resolve("telemetry-notice-seen.txt");
if(!Files.exists(firstSeenPath)) {
// Inspired by https://learn.microsoft.com/en-us/dotnet/core/tools/telemetry#disclosure
getLogger().info("Telemetry");
getLogger().info("---------");
getLogger().info("Vaadin collects usage data in oder to help us improve your experience. "
+ "You can opt-out of telemetry by setting the {} environment variable.",
Constants.TELEMETRY_OPT_OUT_ENV_VARIABLE);
getLogger().info("Read more about Vaadin telemetry at: PUT_YOUR_LINK_HERE");

try {
Files.createDirectories(statisticDirPath);
Files.writeString(firstSeenPath, Instant.now().toString());
} catch (IOException ioe) {
getLogger().warn("Failed to create telemetry notice first seen file", ioe);
}
}

storage.access(() -> {
instance = new DevModeUsageStatistics(projectFolder, storage);
// Make sure we are tracking the right project
Expand Down
Loading