Skip to content

Commit

Permalink
feat: session changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arifBurakDemiray committed Dec 19, 2023
1 parent f120c02 commit 428e6c6
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleViews.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> segmentation) {
if (segmentation == null) {
return;
Expand All @@ -73,11 +86,6 @@ public void resetFirstView() {

Map<String, Object> createViewEventSegmentation(@Nonnull ViewData vd, boolean firstView, boolean visit, Map<String, Object> customViewSegmentation) {
Map<String, Object> viewSegmentation = new ConcurrentHashMap<>();
if (customViewSegmentation != null) {
viewSegmentation.putAll(customViewSegmentation);
}

viewSegmentation.putAll(vd.viewSegmentation);

viewSegmentation.put("name", vd.viewName);
if (visit) {
Expand All @@ -87,6 +95,10 @@ Map<String, Object> 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;
}
Expand Down Expand Up @@ -307,11 +319,6 @@ private void addSegmentationToViewWithIDInternal(String viewID, Map<String, Obje
vd.viewSegmentation.putAll(viewSegmentation);
}

@Override
public void stop(InternalConfig config, boolean clear) {
viewsInterface = null;
}

/**
* Creates a crypto-safe SHA-256 hashed random value
*
Expand Down

0 comments on commit 428e6c6

Please sign in to comment.