-
Notifications
You must be signed in to change notification settings - Fork 7
Add metadata to SDK ready #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
api/src/main/java/io/split/android/client/events/SdkReadyFromCacheMetadata.java
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
api/src/main/java/io/split/android/client/events/SdkReadyMetadata.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package io.split.android.client.events; | ||
|
|
||
| import androidx.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Typed metadata for SDK_READY and SDK_READY_FROM_CACHE events. | ||
| * <p> | ||
| * Contains information about the cache state when the SDK becomes ready. | ||
| */ | ||
| public final class SdkReadyMetadata { | ||
|
|
||
| @Nullable | ||
| private final Boolean mInitialCacheLoad; | ||
|
|
||
| @Nullable | ||
| private final Long mLastUpdateTimestamp; | ||
|
|
||
| /** | ||
| * Creates a new SdkReadyMetadata instance. | ||
| * | ||
| * @param initialCacheLoad true if this is an initial cache load with no usable cache, or null if not available | ||
| * @param lastUpdateTimestamp the last successful cache timestamp in milliseconds since epoch, or null if not available | ||
| */ | ||
| public SdkReadyMetadata(@Nullable Boolean initialCacheLoad, @Nullable Long lastUpdateTimestamp) { | ||
| mInitialCacheLoad = initialCacheLoad; | ||
| mLastUpdateTimestamp = lastUpdateTimestamp; | ||
| } | ||
|
|
||
| /** | ||
| * Returns whether this is an initial cache load with no usable cache. | ||
| * <p> | ||
| * This is true when the SDK starts without any prior cached data (fresh install), | ||
| * meaning data was fetched from the server for the first time. | ||
| * | ||
| * @return true if initial cache load, false otherwise, or null if not available | ||
| */ | ||
| @Nullable | ||
| public Boolean isInitialCacheLoad() { | ||
| return mInitialCacheLoad; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the last successful cache timestamp in milliseconds since epoch. | ||
| * | ||
| * @return the timestamp, or null if not available | ||
| */ | ||
| @Nullable | ||
| public Long getLastUpdateTimestamp() { | ||
| return mLastUpdateTimestamp; | ||
| } | ||
| } | ||
|
|
66 changes: 0 additions & 66 deletions
66
api/src/test/java/io/split/android/client/events/SdkReadyFromCacheMetadataTest.java
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
api/src/test/java/io/split/android/client/events/SdkReadyMetadataTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package io.split.android.client.events; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertNull; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| public class SdkReadyMetadataTest { | ||
|
|
||
| @Test | ||
| public void isInitialCacheLoadReturnsNullWhenConstructedWithNull() { | ||
| SdkReadyMetadata metadata = new SdkReadyMetadata(null, null); | ||
|
|
||
| assertNull(metadata.isInitialCacheLoad()); | ||
| } | ||
|
|
||
| @Test | ||
| public void isInitialCacheLoadReturnsTrueWhenConstructedWithTrue() { | ||
| SdkReadyMetadata metadata = new SdkReadyMetadata(true, null); | ||
|
|
||
| assertTrue(metadata.isInitialCacheLoad()); | ||
| } | ||
|
|
||
| @Test | ||
| public void isInitialCacheLoadReturnsFalseWhenConstructedWithFalse() { | ||
| SdkReadyMetadata metadata = new SdkReadyMetadata(false, null); | ||
|
|
||
| assertFalse(metadata.isInitialCacheLoad()); | ||
| } | ||
|
|
||
| @Test | ||
| public void getLastUpdateTimestampReturnsNullWhenConstructedWithNull() { | ||
| SdkReadyMetadata metadata = new SdkReadyMetadata(null, null); | ||
|
|
||
| assertNull(metadata.getLastUpdateTimestamp()); | ||
| } | ||
|
|
||
| @Test | ||
| public void getLastUpdateTimestampReturnsValueWhenConstructedWithValue() { | ||
| long timestamp = 1704067200000L; | ||
| SdkReadyMetadata metadata = new SdkReadyMetadata(null, timestamp); | ||
|
|
||
| assertEquals(Long.valueOf(timestamp), metadata.getLastUpdateTimestamp()); | ||
| } | ||
|
|
||
| @Test | ||
| public void bothValuesReturnCorrectlyWhenBothAreSet() { | ||
| long timestamp = 1704067200000L; | ||
| SdkReadyMetadata metadata = new SdkReadyMetadata(true, timestamp); | ||
|
|
||
| assertTrue(metadata.isInitialCacheLoad()); | ||
| assertEquals(Long.valueOf(timestamp), metadata.getLastUpdateTimestamp()); | ||
| } | ||
|
|
||
| @Test | ||
| public void bothValuesReturnCorrectlyWhenInitialCacheLoadIsFalse() { | ||
| long timestamp = 1704067200000L; | ||
| SdkReadyMetadata metadata = new SdkReadyMetadata(false, timestamp); | ||
|
|
||
| assertFalse(metadata.isInitialCacheLoad()); | ||
| assertEquals(Long.valueOf(timestamp), metadata.getLastUpdateTimestamp()); | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we are using "Split" name? I thought it suppose to be ISdkEventsManager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, we already had
SplitInternalEventso I kept it to reduce changes. But we could rename it, it's not breaking.