AP-5389 Split FUS metadata files per product version

derive metadata url from product major/minor version

GitOrigin-RevId: 9fe44f0179ab30cbbb0428b8f555197e2fd99c85
This commit is contained in:
Daniil.Bubnov
2023-08-30 17:14:22 +02:00
committed by intellij-monorepo-bot
parent d5bdeef716
commit c1bb1e043e
7 changed files with 27 additions and 8 deletions

View File

@@ -58,6 +58,12 @@ public class EventLogInternalApplicationInfo implements EventLogApplicationInfo
return info.getMajorVersion() + "." + info.getMinorVersion();
}
@Override
public int getBaselineVersion() {
final ApplicationInfo info = ApplicationInfo.getInstance();
return info.getBuild().getBaselineVersion();
}
@NotNull
@Override
public EventLogConnectionSettings getConnectionSettings() {

View File

@@ -150,6 +150,7 @@ object EventLogExternalUploader {
addArgument(args, URL_OPTION, applicationInfo.templateUrl)
addArgument(args, PRODUCT_OPTION, applicationInfo.productCode)
addArgument(args, PRODUCT_VERSION_OPTION, applicationInfo.productVersion)
addArgument(args, BASELINE_VERSION, applicationInfo.baselineVersion.toString())
addArgument(args, USER_AGENT_OPTION, applicationInfo.connectionSettings.getUserAgent())
addArgument(args, EXTRA_HEADERS, ExtraHTTPHeadersParser.serialize(applicationInfo.connectionSettings.getExtraHeaders()))

View File

@@ -16,6 +16,8 @@ public interface EventLogApplicationInfo {
@NotNull
String getProductVersion();
int getBaselineVersion();
@NotNull
EventLogConnectionSettings getConnectionSettings();

View File

@@ -9,6 +9,9 @@ import org.jetbrains.annotations.Nullable;
import java.util.Map;
/**
* External version of the EventLogApplicationInfo, which is provided to an 'external' uploader process (not IDEA) via arguments
*/
public class EventLogExternalApplicationInfo implements EventLogApplicationInfo {
private final DataCollectorDebugLogger myLogger;
private final DataCollectorSystemEventLogger myEventLogger;
@@ -16,6 +19,7 @@ public class EventLogExternalApplicationInfo implements EventLogApplicationInfo
private final String myTemplateUrl;
private final String myProductCode;
private final String myProductVersion;
private final int myBaselineVersion;
private final EventLogBasicConnectionSettings myConnectionSettings;
private final boolean myIsInternal;
@@ -27,10 +31,12 @@ public class EventLogExternalApplicationInfo implements EventLogApplicationInfo
boolean isInternal, boolean isTest, boolean isEAP,
@NotNull Map<String, String> extraHeaders,
@NotNull DataCollectorDebugLogger logger,
@NotNull DataCollectorSystemEventLogger eventLogger) {
@NotNull DataCollectorSystemEventLogger eventLogger,
int baselineVersion) {
myTemplateUrl = templateUrl;
myProductCode = productCode;
myProductVersion = productVersion;
myBaselineVersion = baselineVersion;
String externalUserAgent = (userAgent == null ? "IntelliJ": userAgent) + "(External)";
myConnectionSettings = new EventLogBasicConnectionSettings(externalUserAgent, extraHeaders);
myIsInternal = isInternal;
@@ -56,6 +62,11 @@ public class EventLogExternalApplicationInfo implements EventLogApplicationInfo
return myProductVersion;
}
@Override
public int getBaselineVersion() {
return myBaselineVersion;
}
@NotNull
@Override
public EventLogConnectionSettings getConnectionSettings() {

View File

@@ -10,10 +10,7 @@ import com.intellij.internal.statistic.eventLog.EventLogBuild;
import com.intellij.internal.statistic.eventLog.connection.metadata.EventGroupsFilterRules;
import com.intellij.internal.statistic.eventLog.connection.metadata.EventLogMetadataUtils;
import com.intellij.internal.statistic.eventLog.filters.*;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.*;
import java.util.concurrent.TimeUnit;
@@ -118,6 +115,6 @@ public class EventLogUploadSettingsService extends SettingsConnectionService imp
public String getMetadataProductUrl() {
String baseMetadataUrl = getEndpointValue(METADATA);
if (baseMetadataUrl == null) return null;
return baseMetadataUrl + myApplicationInfo.getProductCode() + ".json";
return baseMetadataUrl + myApplicationInfo.getBaselineVersion() + "/" + myApplicationInfo.getProductCode() + ".json";
}
}

View File

@@ -130,13 +130,14 @@ public final class EventLogUploader {
String userAgent = options.get(EventLogUploaderOptions.USER_AGENT_OPTION);
String headersString = options.get(EventLogUploaderOptions.EXTRA_HEADERS);
Map<String, String> extraHeaders = ExtraHTTPHeadersParser.parse(headersString);
int baselineVersion = Integer.parseInt(options.get(EventLogUploaderOptions.BASELINE_VERSION));
if (url != null && productCode != null) {
boolean isInternal = options.containsKey(EventLogUploaderOptions.INTERNAL_OPTION);
boolean isTest = options.containsKey(EventLogUploaderOptions.TEST_OPTION);
boolean isEAP = options.containsKey(EventLogUploaderOptions.EAP_OPTION);
return new EventLogExternalApplicationInfo(
url, productCode, productVersion, userAgent, isInternal, isTest, isEAP, extraHeaders, logger, eventLogger
);
url, productCode, productVersion, userAgent, isInternal, isTest, isEAP, extraHeaders, logger, eventLogger,
baselineVersion);
}
return null;
}

View File

@@ -15,6 +15,7 @@ public interface EventLogUploaderOptions {
String URL_OPTION = "--url";
String PRODUCT_OPTION = "--product";
String PRODUCT_VERSION_OPTION = "--product-version";
String BASELINE_VERSION = "--baseline-version";
String USER_AGENT_OPTION = "--user-agent";
String EXTRA_HEADERS = "--extra-headers";
String INTERNAL_OPTION = "--internal";