Skip to content

Commit

Permalink
chore: Add usage stats (#62)
Browse files Browse the repository at this point in the history
Co-authored-by: Giovanni Lovato <[email protected]>
  • Loading branch information
tarekoraby and heruan authored Jan 16, 2023
1 parent b5e0601 commit c2f1d41
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.io.IOException;

import com.vaadin.flow.internal.UsageStatistics;
import com.vaadin.flow.server.ServiceInitEvent;
import com.vaadin.flow.server.VaadinServiceInitListener;
import com.vaadin.pro.licensechecker.BuildType;
Expand All @@ -36,19 +37,21 @@ public class LicenseCheckerServiceInitListener
public void serviceInit(ServiceInitEvent event) {
final var service = event.getSource();

// Check the license at runtime if in development mode
if (!service.getDeploymentConfiguration().isProductionMode()) {
try {
final var properties = loadAllProperties(PROPERTIES_RESOURCE);
final var version = properties.getProperty(VERSION_PROPERTY);
try {
final var properties = loadAllProperties(PROPERTIES_RESOURCE);
final var version = properties.getProperty(VERSION_PROPERTY);

UsageStatistics.markAsUsed(PRODUCT_NAME, version);

// Check the license at runtime if in development mode
if (!service.getDeploymentConfiguration().isProductionMode()) {
// Using a null BuildType to allow trial licensing builds
// The variable is defined to avoid method signature ambiguity
BuildType buildType = null;
LicenseChecker.checkLicense(PRODUCT_NAME, version, buildType);
} catch (IOException e) {
throw new ExceptionInInitializerError(e);
}
} catch (IOException e) {
throw new ExceptionInInitializerError(e);
}
}
}

0 comments on commit c2f1d41

Please sign in to comment.