-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix: set client-engine version in events #410
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3b4de14
clean up
jaeopt 056f277
fix client-sdk name/version override
jaeopt 20f10cd
fix copyright year
jaeopt 59810bd
upgrade java-sdk to 3.10.2
jaeopt 8fdcd7e
Merge branch 'master' into jae/event-version
jaeopt e36be44
log SDK version
jaeopt 127d748
specify BuildConfig path
jaeopt 064cbcf
add guard for CLIENT_VERSION
jaeopt 5756668
testing
jaeopt 1a03b71
testing
jaeopt 556fef4
clean up
jaeopt c42f362
testing
jaeopt 8eaa6d1
fix gradle to avoid undetermistic version in travis
jaeopt f348e83
testing
jaeopt ed4dda1
add null and empty check for client version in gradle
jaeopt a41fa3d
clean up
jaeopt 238445a
Merge branch 'master' into jae/event-version
jaeopt 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 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
68 changes: 68 additions & 0 deletions
68
...src/androidTest/java/com/optimizely/ab/android/sdk/OptimizelyManagerEventHandlerTest.java
This file contains 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,68 @@ | ||
/**************************************************************************** | ||
* Copyright 2022, Optimizely, Inc. and contributors * | ||
* * | ||
* Licensed under the Apache License, Version 2.0 (the "License"); * | ||
* you may not use this file except in compliance with the License. * | ||
* You may obtain a copy of the License at * | ||
* * | ||
* http://www.apache.org/licenses/LICENSE-2.0 * | ||
* * | ||
* Unless required by applicable law or agreed to in writing, software * | ||
* distributed under the License is distributed on an "AS IS" BASIS, * | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * | ||
* See the License for the specific language governing permissions and * | ||
* limitations under the License. * | ||
***************************************************************************/ | ||
|
||
package com.optimizely.ab.android.sdk; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.timeout; | ||
import static org.mockito.Mockito.verify; | ||
import android.content.Context; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import com.optimizely.ab.event.EventHandler; | ||
import com.optimizely.ab.event.LogEvent; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.ArgumentCaptor; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class OptimizelyManagerEventHandlerTest { | ||
|
||
private String minDatafileWithEvent = "{\n" + | ||
"experiments: [ ],\n" + | ||
"version: \"2\",\n" + | ||
"audiences: [ ],\n" + | ||
"groups: [ ],\n" + | ||
"attributes: [ ],\n" + | ||
"projectId: \"123\",\n" + | ||
"accountId: \"6365361536\",\n" + | ||
"events: [{\"experimentIds\": [\"8509139139\"], \"id\": \"8505434668\", \"key\": \"test_event\"}],\n" + | ||
"revision: \"1\"\n" + | ||
"}"; | ||
|
||
@Test | ||
public void eventClientNameAndVersion() throws Exception { | ||
EventHandler mockEventHandler = mock(EventHandler.class); | ||
|
||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
OptimizelyManager optimizelyManager = OptimizelyManager.builder() | ||
.withSDKKey("any-sdk-key") | ||
.withEventDispatchInterval(0, TimeUnit.SECONDS) | ||
.withEventHandler(mockEventHandler) | ||
.build(context); | ||
|
||
OptimizelyClient optimizelyClient = optimizelyManager.initialize(context, minDatafileWithEvent); | ||
optimizelyClient.track("test_event", "tester"); | ||
|
||
ArgumentCaptor<LogEvent> argument = ArgumentCaptor.forClass(LogEvent.class); | ||
verify(mockEventHandler, timeout(5000)).dispatchEvent(argument.capture()); | ||
assertEquals(argument.getValue().getEventBatch().getClientName(), "android-sdk"); | ||
assertEquals(argument.getValue().getEventBatch().getClientVersion(), BuildConfig.CLIENT_VERSION); | ||
} | ||
|
||
} |
This file contains 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 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
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.
what is it for?
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.
@msohailhussain We get the sdk release version from a git tag forwarded by travis (TRAVIS_TAG). This change is to make it work for testing in travis as well (which fails to override with test version).