Skip to content

Commit

Permalink
Fixed a bug where view duration was reported in ms and not s. (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtursKadikis authored Mar 7, 2023
1 parent 59b1589 commit c6d0061
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* ! Minor breaking change ! The module override functionality is being removed from the SDK.
* ! Minor breaking change ! It is not possible to set the logging tag anymore.
* Fixed a bug where the wrong platform field value was being sent in the view request.
* Fixed a bug where view duration was reported in ms and not s.
* Updated JSON library version from "20180813" to "20230227".

20.11.5
Expand Down
8 changes: 8 additions & 0 deletions app-java/src/main/java/ly/count/java/demo/Sample.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public void LogHappened(String logMessage, Config.LoggingLevel logLevel) {
System.out.println("9) Set user profile");
System.out.println("10) Set user custom profile");
System.out.println("11) Record an exception");
System.out.println("12) Start a view called 'example_view'");
System.out.println("13) End a view called 'example_view'");
System.out.println("0) Exit ");


Expand Down Expand Up @@ -189,6 +191,12 @@ public void LogHappened(String logMessage, Config.LoggingLevel logLevel) {
case 11:
recordCrash();
break;
case 12:
Countly.session().view("example_view").start(true);
break;
case 13:
Countly.session().view("example_view").stop(false);
break;
default:
break;
}
Expand Down
11 changes: 5 additions & 6 deletions sdk-java/src/main/java/ly/count/sdk/java/internal/ViewImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,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, Device.dev.getOS());

if (firstView) {
start.addSegment(START, START_VALUE);
Expand Down Expand Up @@ -79,10 +77,11 @@ public void stop(boolean lastView) {
}
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, SEGMENT_VALUE);

event.setDuration(Device.dev.uniqueTimestamp() - start.getTimestamp());
long viewDurationSeconds = (Device.dev.uniqueTimestamp() - start.getTimestamp()) / 1000;

event.setDuration(viewDurationSeconds);

if (lastView) {
event.addSegment(EXIT, EXIT_VALUE);
Expand Down

0 comments on commit c6d0061

Please sign in to comment.