From 428e6c6e1a477380ba1c34411ee70dfe60f4b734 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Tue, 19 Dec 2023 11:06:47 +0300 Subject: [PATCH] feat: session changes --- .../count/sdk/java/internal/ModuleViews.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleViews.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleViews.java index 2baa8863..587ab3fb 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleViews.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleViews.java @@ -9,6 +9,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import ly.count.sdk.java.Countly; +import ly.count.sdk.java.Session; public class ModuleViews extends ModuleBase { String currentViewID = null; @@ -51,6 +52,18 @@ public void init(InternalConfig config) { viewsInterface = new Views(); } + @Override + public void onSessionBegan(Session session, InternalConfig config) { + super.onSessionBegan(session, config); + resetFirstView(); + } + + @Override + public void stop(InternalConfig config, boolean clear) { + viewsInterface = null; + viewDataMap.clear(); + } + private void removeReservedKeysFromViewSegmentation(Map segmentation) { if (segmentation == null) { return; @@ -73,11 +86,6 @@ public void resetFirstView() { Map createViewEventSegmentation(@Nonnull ViewData vd, boolean firstView, boolean visit, Map customViewSegmentation) { Map viewSegmentation = new ConcurrentHashMap<>(); - if (customViewSegmentation != null) { - viewSegmentation.putAll(customViewSegmentation); - } - - viewSegmentation.putAll(vd.viewSegmentation); viewSegmentation.put("name", vd.viewName); if (visit) { @@ -87,6 +95,10 @@ Map createViewEventSegmentation(@Nonnull ViewData vd, boolean fi viewSegmentation.put("start", "1"); } viewSegmentation.put("segment", internalConfig.getSdkPlatform()); + if (customViewSegmentation != null) { + viewSegmentation.putAll(customViewSegmentation); + } + viewSegmentation.putAll(vd.viewSegmentation); return viewSegmentation; } @@ -307,11 +319,6 @@ private void addSegmentationToViewWithIDInternal(String viewID, Map