Skip to content

Commit

Permalink
Merge pull request #924 from Microsoft/develop
Browse files Browse the repository at this point in the history
Release version 1.11.1
  • Loading branch information
chethanreddyvelverti committed Jan 14, 2019
2 parents 23644ac + 539948b commit 47aa108
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 166 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# App Center SDK for Android Change Log

## Version 1.11.1

### AppCenterAnalytics

* **[Fix]** Extend the current session instead of starting a new session when sending events from the background. Sessions are also no longer started in background by sending an event or a log from another service such as push, as a consequence the push registration information will be missing from crash events information.

### AppCenterDistribute

* **[Fix]** Fix issue with forcing Chrome to open links when other browsers are the default.

___

## Version 1.11.0

### AppCenter
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ You must sign a [Contributor License Agreement](https://cla.microsoft.com/) befo

## 3. Contact

### 3.1 Intercom
### 3.1 Support

If you have further questions, want to provide feedback or you are running into issues, log in to the [App Center portal](https://appcenter.ms) and use the blue Intercom button on the bottom right to start a conversation with us.
App Center SDK support is provided directly within the App Center portal. Any time you need help, just log in to [App Center](https://appcenter.ms), then click the blue chat button in the lower-right corner of any page and our dedicated support team will respond to your questions and feedback. For additional information, see the [App Center Help Center](https://intercom.help/appcenter/getting-started/welcome-to-app-center-support).

### 3.2 Twitter
We're on Twitter as [@vsappcenter](https://www.twitter.com/vsappcenter).
4 changes: 2 additions & 2 deletions apps/sasquatch/src/projectDependency/res/values/env.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes">
<string name="app_secret" tools:ignore="MissingTranslation">9e0d97c1-7838-46d0-9dab-1a0ef66aec6e</string>
<string name="log_url" tools:ignore="MissingTranslation">https://in-integration.dev.avalanch.es</string>
<string name="install_url" tools:ignore="MissingTranslation">https://install.asgard-int.trafficmanager.net</string>
<string name="api_url" tools:ignore="MissingTranslation">https://appcenter-int.trafficmanager.net/api/v0.1</string>
<string name="install_url" tools:ignore="MissingTranslation">https://install.portal-server-core-integration.dev.avalanch.es</string>
<string name="api_url" tools:ignore="MissingTranslation">https://api-gateway-core-integration.dev.avalanch.es/v0.1</string>
<string name="rum_key" tools:ignore="MissingTranslation">0123456789abcdef0123456789abcdff</string>
</resources>
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ buildscript {
repositories {
google()
jcenter()
maven {
url 'https://dl.bintray.com/android/android-tools'
}
maven {
url 'https://plugins.gradle.org/m2/'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ public void onPreparingLog(@NonNull Log log, @NonNull String groupName) {
/* If the log does not have a timestamp yet, then we just correlate with current session. */
else {

/* Send a new start session log if needed. */
sendStartSessionIfNeeded();

/* Set current session identifier. */
log.setSid(mSid);

Expand All @@ -110,7 +107,7 @@ public void onPreparingLog(@NonNull Log log, @NonNull String groupName) {

/**
* Generate a new session identifier if the first time or
* we went in background for more X seconds or
* we went in background for more X seconds before resume or
* if enough time has elapsed since the last background usage of the API.
* <p>
* Indeed the API can be used for events or crashes only for example, we need to renew
Expand Down Expand Up @@ -174,28 +171,20 @@ public void clearSessions() {
*/
private boolean hasSessionTimedOut() {

/* Compute how long we have not sent a log. */
long now = SystemClock.elapsedRealtime();
boolean noLogSentForLong = now - mLastQueuedLogTime >= SESSION_TIMEOUT;

/* Corner case: we have not been paused yet, typically we stayed on the first activity or we are called from background (for example a broadcast intent that wakes up application, new process). */
/*
* Corner case: we have not been paused yet, typically we stayed on the first activity or
* we are called from background (for example a broadcast intent that wakes up application,
* new process).
*/
if (mLastPausedTime == null) {

/* If we saw a resume in event, we are in foreground, so no expiration. If we are in background, check how long. */
return mLastResumedTime == null && noLogSentForLong;
}

/* Corner case 2: we saw a pause but not a resume event: we are in background, check how long. */
if (mLastResumedTime == null) {

/* Note that this corner case is likely an integration issue. It's not supposed to happen. Likely the SDK has been configured too late. */
return noLogSentForLong;
return false;
}

/* Normal case: we saw both resume and paused events, compare all times. */
boolean isBackgroundForLong = mLastPausedTime >= mLastResumedTime && now - mLastPausedTime >= SESSION_TIMEOUT;
long now = SystemClock.elapsedRealtime();
boolean noLogSentForLong = now - mLastQueuedLogTime >= SESSION_TIMEOUT;
boolean wasBackgroundForLong = mLastResumedTime - Math.max(mLastPausedTime, mLastQueuedLogTime) >= SESSION_TIMEOUT;
AppCenterLog.debug(Analytics.LOG_TAG, "noLogSentForLong=" + noLogSentForLong + " isBackgroundForLong=" + isBackgroundForLong + " wasBackgroundForLong=" + wasBackgroundForLong);
return noLogSentForLong && (isBackgroundForLong || wasBackgroundForLong);
AppCenterLog.debug(Analytics.LOG_TAG, "noLogSentForLong=" + noLogSentForLong + " wasBackgroundForLong=" + wasBackgroundForLong);
return noLogSentForLong && wasBackgroundForLong;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ public void longSessionStartingFromBackground() {
UUID expectedSid;
StartSessionLog expectedStartSessionLog = new StartSessionLog();
{
Log log = newEvent();
mSessionTracker.onPreparingLog(log, TEST_GROUP);
mSessionTracker.onPreparingLog(expectedStartSessionLog, TEST_GROUP);
assertNull(log.getSid());
verify(mChannel, never()).enqueue(expectedStartSessionLog, TEST_GROUP, DEFAULTS);
}

/* Start session. */
{
mSessionTracker.onActivityResumed();
Log log = newEvent();
mSessionTracker.onPreparingLog(log, TEST_GROUP);
mSessionTracker.onPreparingLog(expectedStartSessionLog, TEST_GROUP);
Expand All @@ -131,15 +141,14 @@ public void longSessionStartingFromBackground() {
verify(mChannel).enqueue(expectedStartSessionLog, TEST_GROUP, DEFAULTS);
}

/* No usage from background for a long time: new session. */
/* No usage from background for a long time: same session. */
{
mSessionTracker.onActivityPaused();
spendTime(30000);
Log log = newEvent();
mSessionTracker.onPreparingLog(log, TEST_GROUP);
mSessionTracker.onPreparingLog(expectedStartSessionLog, TEST_GROUP);
assertNotEquals(expectedSid, log.getSid());
expectedSid = log.getSid();
expectedStartSessionLog.setSid(expectedSid);
assertEquals(expectedSid, log.getSid());
verify(mChannel).enqueue(expectedStartSessionLog, TEST_GROUP, DEFAULTS);
}

Expand Down Expand Up @@ -220,19 +229,6 @@ public void longSessionStartingFromBackground() {
expectedStartSessionLog.setSid(expectedSid);
verify(mChannel).enqueue(expectedStartSessionLog, TEST_GROUP, DEFAULTS);
}

/* Background for a long time sending a log: new session. */
{
mSessionTracker.onActivityPaused();
spendTime(30000);
Log log = newEvent();
mSessionTracker.onPreparingLog(log, TEST_GROUP);
mSessionTracker.onPreparingLog(expectedStartSessionLog, TEST_GROUP);
assertNotEquals(expectedSid, log.getSid());
expectedSid = log.getSid();
expectedStartSessionLog.setSid(expectedSid);
verify(mChannel).enqueue(expectedStartSessionLog, TEST_GROUP, DEFAULTS);
}
}

@Test
Expand Down Expand Up @@ -362,6 +358,16 @@ public void sdkConfiguredBetweenPauseAndResume() {
UUID expectedSid;
StartSessionLog expectedStartSessionLog = new StartSessionLog();
{
Log log = newEvent();
mSessionTracker.onPreparingLog(log, TEST_GROUP);
mSessionTracker.onPreparingLog(expectedStartSessionLog, TEST_GROUP);
assertNull(log.getSid());
verify(mChannel, never()).enqueue(expectedStartSessionLog, TEST_GROUP, DEFAULTS);
}

/* Start session. */
{
mSessionTracker.onActivityResumed();
Log log = newEvent();
mSessionTracker.onPreparingLog(log, TEST_GROUP);
mSessionTracker.onPreparingLog(expectedStartSessionLog, TEST_GROUP);
Expand All @@ -380,15 +386,14 @@ public void sdkConfiguredBetweenPauseAndResume() {
verify(mChannel).enqueue(expectedStartSessionLog, TEST_GROUP, DEFAULTS);
}

/* No usage from background for a long time: new session. */
/* No usage from background for a long time: same session. */
{
mSessionTracker.onActivityPaused();
spendTime(30000);
Log log = newEvent();
mSessionTracker.onPreparingLog(log, TEST_GROUP);
mSessionTracker.onPreparingLog(expectedStartSessionLog, TEST_GROUP);
assertNotEquals(expectedSid, log.getSid());
expectedSid = log.getSid();
expectedStartSessionLog.setSid(expectedSid);
assertEquals(expectedSid, log.getSid());
verify(mChannel).enqueue(expectedStartSessionLog, TEST_GROUP, DEFAULTS);
}

Expand Down Expand Up @@ -421,19 +426,22 @@ public void maxOutStoredSessions() {
assertNotNull(sessions);
assertEquals(1, sessions.size());
String firstSession = sessions.iterator().next();
mSessionTracker.onPreparingLog(newEvent(), TEST_GROUP);
mSessionTracker.onActivityResumed();
mSessionTracker.onActivityPaused();
sessions = SharedPreferencesManager.getStringSet("sessions");
assertNotNull(sessions);
assertEquals(2, sessions.size());
spendTime(30000);
for (int i = 3; i <= 10; i++) {
mSessionTracker.onPreparingLog(newEvent(), TEST_GROUP);
mSessionTracker.onActivityResumed();
mSessionTracker.onActivityPaused();
Set<String> intermediateSessions = SharedPreferencesManager.getStringSet("sessions");
assertNotNull(intermediateSessions);
assertEquals(i, intermediateSessions.size());
spendTime(30000);
}
mSessionTracker.onPreparingLog(newEvent(), TEST_GROUP);
mSessionTracker.onActivityResumed();
mSessionTracker.onActivityPaused();
Set<String> finalSessions = SharedPreferencesManager.getStringSet("sessions");
assertNotNull(finalSessions);
assertEquals(10, finalSessions.size());
Expand All @@ -443,6 +451,9 @@ public void maxOutStoredSessions() {
@Test
public void pastSessions() {

/* Start session. */
mSessionTracker.onActivityResumed();

/* Get a current session. */
UUID firstSid, currentSid;
long firstSessionTime = mMockTime;
Expand All @@ -468,20 +479,11 @@ public void pastSessions() {
assertNull(log.getSid());
}

/* No usage from background for a long time, should produce a new session but we'll correlate, correlation does not trigger a new session. */
{
spendTime(30000);
Log log = newEvent();
log.setTimestamp(new Date(firstSessionTime + 1));
mSessionTracker.onPreparingLog(log, TEST_GROUP);
assertEquals(currentSid, log.getSid());
Set<String> sessions = SharedPreferencesManager.getStringSet("sessions");
assertNotNull(sessions);
assertEquals(1, sessions.size());
}

/* Trigger a second session. */
{
mSessionTracker.onActivityPaused();
spendTime(30000);
mSessionTracker.onActivityResumed();
Log log = newEvent();
mSessionTracker.onPreparingLog(log, TEST_GROUP);
assertNotEquals(currentSid, log.getSid());
Expand Down Expand Up @@ -548,7 +550,7 @@ public void partiallyInvalidStorage() {
mSessionTracker = new SessionTracker(mChannel, TEST_GROUP);

/* Generate a current session. */
mSessionTracker.onPreparingLog(newEvent(), TEST_GROUP);
mSessionTracker.onActivityResumed();

/* Check sessions in store. */
sessions = SharedPreferencesManager.getStringSet("sessions");
Expand Down Expand Up @@ -596,6 +598,7 @@ public void correlateLogAfterRestartBeforeNewSession() {
/* Init app launch time within session storage. */
long appLaunchTime = mMockTime;
SessionContext.getInstance();
mSessionTracker.onActivityResumed();

/* Make a log later so that times are different in the test and verify basics. */
spendTime(1000);
Expand Down
Loading

0 comments on commit 47aa108

Please sign in to comment.