Skip to content

Commit 78460aa

Browse files
feat: send orientation after every begin session
1 parent abba26b commit 78460aa

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

sdk/src/main/java/ly/count/android/sdk/ModuleSessions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ void beginSessionInternal() {
5757
sessionRunning = true;
5858
prevSessionDurationStartTime_ = System.currentTimeMillis();
5959
requestQueueProvider.beginSession(_cly.moduleLocation.locationDisabled, _cly.moduleLocation.locationCountryCode, _cly.moduleLocation.locationCity, _cly.moduleLocation.locationGpsCoordinates, _cly.moduleLocation.locationIpAddress, preparedMetrics);
60+
61+
if (_cly.moduleViews.trackOrientationChanges) {
62+
_cly.moduleViews.updateOrientation(_cly.context_.getResources().getConfiguration().orientation, true);
63+
}
6064
}
6165

6266
void updateSessionInternal() {

sdk/src/main/java/ly/count/android/sdk/ModuleViews.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,14 @@ void stopAllViewsInternal(Map<String, Object> viewSegmentation) {
436436
autoCloseRequiredViews(true, viewSegmentation);
437437
}
438438

439-
void updateOrientation(int newOrientation) {
439+
void updateOrientation(int newOrientation, boolean forceSend) {
440+
L.d("[ModuleViews] updateOrientation, forceSend: [" + forceSend + "]");
440441
if (!consentProvider.getConsent(Countly.CountlyFeatureNames.users)) {
441442
L.d("[ModuleViews] updateOrientation, no consent given for users, skipping orientation tracking");
442443
return;
443444
}
444445

445-
if (currentOrientation == newOrientation) {
446+
if (!forceSend && currentOrientation == newOrientation) {
446447
L.d("[ModuleViews] updateOrientation, orientation did not change, skipping");
447448
return;
448449
}
@@ -462,6 +463,10 @@ void updateOrientation(int newOrientation) {
462463
eventProvider.recordEventInternal(ORIENTATION_EVENT_KEY, segm, 1, 0, 0, null, null);
463464
}
464465

466+
void updateOrientation(int newOrientation) {
467+
updateOrientation(newOrientation, false);
468+
}
469+
465470
void pauseRunningViewsAndSend() {
466471
L.d("[ModuleViews] pauseRunningViewsAndSend, going to the background and pausing");
467472
for (Map.Entry<String, ViewData> entry : viewDataMap.entrySet()) {

0 commit comments

Comments
 (0)