diff --git a/sdk-java/src/main/java/ly/count/sdk/java/Config.java b/sdk-java/src/main/java/ly/count/sdk/java/Config.java index 9fceca8b5..45db43efe 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/Config.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/Config.java @@ -14,7 +14,6 @@ import java.util.Set; import ly.count.sdk.java.internal.Byteable; import ly.count.sdk.java.internal.CoreFeature; -import ly.count.sdk.java.internal.ImmediateRequestGenerator; import ly.count.sdk.java.internal.Log; import ly.count.sdk.java.internal.LogCallback; import ly.count.sdk.java.internal.ModuleBase; @@ -467,7 +466,10 @@ public boolean restore(byte[] data, Log L) { */ File sdkStorageRootDirectory = null; - protected ImmediateRequestGenerator immediateRequestGenerator = null; + /** + * If sdk used across multiple platforms + */ + protected String sdkPlatform = System.getProperty("os.name"); // /** // * Maximum size of all string keys @@ -1522,5 +1524,26 @@ public Config setMetricOverride(Map metricOverride) { this.metricOverride.putAll(metricOverride); return this; } + + /** + * Default sdk platform is os name + * If you want to override it, you can use this method + * + * @param platform sdk platform + * @return {@code this} instance for method chaining + */ + public Config setSdkPlatform(String platform) { + this.sdkPlatform = platform; + return this; + } + + /** + * Getter for {@link #sdkPlatform} + * + * @return {@link #sdkPlatform} value + */ + public String getSdkPlatform() { + return sdkPlatform; + } } diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/ViewImpl.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/ViewImpl.java index ec80953f4..587ad4d7c 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/ViewImpl.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/ViewImpl.java @@ -9,13 +9,11 @@ class ViewImpl implements View { private Log L = null; - static final String EVENT = "[CLY]_view"; static final String NAME = "name"; static final String VISIT = "visit"; static final String VISIT_VALUE = "1"; static final String SEGMENT = "segment"; - static final String SEGMENT_VALUE = System.getProperty("os.name"); static final String START = "start"; static final String START_VALUE = "1"; static final String EXIT = "exit"; @@ -49,7 +47,7 @@ public void start(boolean firstView) { this.started = true; this.firstView = firstView; - start = (EventImpl) session.event(EVENT).addSegments(NAME, this.name, VISIT, VISIT_VALUE, SEGMENT, Device.dev.getOS()); + start = (EventImpl) session.event(EVENT).addSegments(NAME, this.name, VISIT, VISIT_VALUE, SEGMENT, SDKCore.instance.config.getSdkPlatform()); if (firstView) { start.addSegment(START, START_VALUE); @@ -76,8 +74,7 @@ public void stop(boolean lastView) { return; } ended = true; - - EventImpl event = (EventImpl) session.event(EVENT).addSegments(NAME, this.name, SEGMENT, SEGMENT_VALUE); + EventImpl event = (EventImpl) session.event(EVENT).addSegments(NAME, this.name, SEGMENT, SDKCore.instance.config.getSdkPlatform()); long startTs = Device.dev.uniqueTimestamp(); long endTs = start.getTimestamp(); diff --git a/sdk-java/src/test/java/ly/count/sdk/java/internal/TestUtils.java b/sdk-java/src/test/java/ly/count/sdk/java/internal/TestUtils.java index b44bbdc2c..6fd2976e3 100644 --- a/sdk-java/src/test/java/ly/count/sdk/java/internal/TestUtils.java +++ b/sdk-java/src/test/java/ly/count/sdk/java/internal/TestUtils.java @@ -185,18 +185,4 @@ private static Map parseRequestParams(File file) throws IOExcept return paramMap; } } - - static File getSdkStorageRootDirectory() { - // System specific folder structure - String[] sdkStorageRootPath = { System.getProperty("user.home"), "__COUNTLY", "java_test" }; - return new File(String.join(File.separator, sdkStorageRootPath)); - } - - static void checkSdkStorageRootDirectoryExist(File directory) { - if (!(directory.exists() && directory.isDirectory())) { - if (!directory.mkdirs()) { - throw new RuntimeException("Directory creation failed"); - } - } - } } \ No newline at end of file