Skip to content

Commit

Permalink
Merge pull request #29 from avohq/update-dependencies-and-tools
Browse files Browse the repository at this point in the history
Update dependencies and tools
  • Loading branch information
aleks-tpom6oh authored Aug 14, 2024
2 parents ad8d5be + 74cfb41 commit 66cf24f
Show file tree
Hide file tree
Showing 25 changed files with 165 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Android Java project environment
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 17

- name: Run tests
run: ./gradlew --warning-mode=none testDevelopmentReleaseUnitTest
47 changes: 31 additions & 16 deletions avoinspector/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'

android {
compileSdkVersion 32
buildToolsVersion "29.0.3"
compileSdk 34
buildToolsVersion = "35.0.0"

defaultConfig {
minSdkVersion 14
targetSdkVersion 32
minSdkVersion 21
targetSdkVersion 34
versionCode 4
versionName "2.0.4"
versionName "2.1.0"

testInstrumentationRunner "AndroidJUnit4"
consumerProguardFiles 'consumer-rules.pro'

buildConfigField 'int', 'VERSION_CODE', "${versionCode}"
buildConfigField 'String', 'VERSION_NAME', "\"${versionName}\""

aarMetadata {
minCompileSdk = 21
}
}

buildTypes {
Expand All @@ -25,9 +30,7 @@ android {
}
}

defaultPublishConfig "developmentRelease"

flavorDimensions "avoEnvironment"
flavorDimensions += "avoEnvironment"

productFlavors {
production {
Expand All @@ -41,17 +44,29 @@ android {
testOptions {
unitTests.returnDefaultValues = true
}

buildFeatures {
buildConfig true
}

publishing {
multipleVariants {
allVariants()
withJavadocJar()
}
}

namespace 'app.avo.inspector'
}

dependencies {
developmentApi 'com.github.avohq:android-analytics-debugger:1.0.6'
implementation 'androidx.annotation:annotation-jvm:1.8.2'
developmentApi 'com.github.avohq:android-analytics-debugger:1.2.0'

compileOnly 'androidx.appcompat:appcompat:1.2.0'
testCompileOnly 'androidx.appcompat:appcompat:1.2.0'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
// for a specific test case with segment
testImplementation 'com.segment.analytics.android:analytics:4.8.2'
testImplementation 'org.json:json:20190722'
testImplementation 'com.segment.analytics.android:analytics:4.10.1'
testImplementation 'org.json:json:20240303'
testImplementation "org.mockito:mockito-core:2.28.2"
}

Expand All @@ -63,15 +78,15 @@ afterEvaluate {

groupId = 'com.github.avohq'
artifactId = 'prod'
version = '2.0.4'
version = '2.1.0'
}

development(MavenPublication) {
from components.developmentRelease

groupId = 'com.github.avohq'
artifactId = 'dev'
version = '2.0.4'
version = '2.1.0'
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions avoinspector/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.avo.inspector" />
<manifest />
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AvoBatcher {

volatile long batchFlushAttemptMillis = System.currentTimeMillis();

private SharedPreferences sharedPrefs;
private final SharedPreferences sharedPrefs;

AvoNetworkCallsHandler networkCallsHandler;

Expand Down
18 changes: 7 additions & 11 deletions avoinspector/src/main/java/app/avo/inspector/AvoDeduplicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

class AvoDeduplicator {

private static ConcurrentHashMap<Long, String> avoFunctionsEvents = new ConcurrentHashMap<>();
private static ConcurrentHashMap<Long, String> manualEvents = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<Long, String> avoFunctionsEvents = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<Long, String> manualEvents = new ConcurrentHashMap<>();

private static ConcurrentHashMap<String, Map<String, ?>> avoFunctionsEventsParams = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, Map<String, ?>> manualEventsParams = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, Map<String, ?>> avoFunctionsEventsParams = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, Map<String, ?>> manualEventsParams = new ConcurrentHashMap<>();

private static AvoSchemaExtractor avoSchemaExtractor = new AvoSchemaExtractor();
private static final AvoSchemaExtractor avoSchemaExtractor = new AvoSchemaExtractor();

static boolean shouldRegisterEvent(String eventName, Map<String, ?> params, boolean fromAvoFunction) {
clearOldEvents();
Expand Down Expand Up @@ -102,13 +102,9 @@ static boolean shouldRegisterSchemaFromManually(String eventName, Map<String, Av
}

private static boolean hasSameShapeInAvoFunctionsAs(String eventName, Map<String, AvoEventSchemaType> shapes) {
boolean result = false;

if (lookForEventSchemaIn(eventName, shapes, avoFunctionsEventsParams)) {
result = true;
}
boolean result = lookForEventSchemaIn(eventName, shapes, avoFunctionsEventsParams);

if (result) {
if (result) {
avoFunctionsEventsParams.remove(eventName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static app.avo.inspector.Util.handleException;

@SuppressWarnings("unchecked")
public class AvoInspector implements Inspector {

private static boolean logsEnabled = false;
Expand All @@ -41,15 +42,16 @@ public class AvoInspector implements Inspector {

AvoInspector(String apiKey, Application application, String envString, @Nullable Activity rootActivityForVisualInspector) {
this(apiKey, application,
envString.toLowerCase().equals("prod") ? AvoInspectorEnv.Prod :
envString.toLowerCase().equals("staging") ? AvoInspectorEnv.Staging : AvoInspectorEnv.Dev,
envString.equalsIgnoreCase("prod") ? AvoInspectorEnv.Prod :
envString.equalsIgnoreCase("staging") ? AvoInspectorEnv.Staging : AvoInspectorEnv.Dev,
rootActivityForVisualInspector);
}

public AvoInspector(@NonNull String apiKey, @NonNull Application application, @NonNull AvoInspectorEnv env) {
this(apiKey, application, env, null);
}

@SuppressWarnings("deprecation")
public AvoInspector(@NonNull String apiKey, @NonNull Application application, @NonNull AvoInspectorEnv env, @Nullable Activity rootActivityForVisualInspector) {
String appVersionString = "";
try {
Expand All @@ -58,6 +60,7 @@ public AvoInspector(@NonNull String apiKey, @NonNull Application application, @N
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
appVersion = pInfo.getLongVersionCode();
} else {
//noinspection deprecation
appVersion = (long) pInfo.versionCode;
}
appVersionString = pInfo.versionName;
Expand Down Expand Up @@ -222,7 +225,7 @@ public void hideVisualInspector(@NonNull Activity rootActivity) {

private void logPreExtract(@NonNull String eventName, @Nullable Object eventProperties) {
if (isLogging() && eventProperties != null) {
Log.d("Avo Inspector", "Supplied event " + eventName + " with params \n" + eventProperties.toString());
Log.d("Avo Inspector", "Supplied event " + eventName + " with params \n" + eventProperties);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public enum AvoInspectorEnv {
Dev("dev"),
Staging("staging");

private String name;
private final String name;

AvoInspectorEnv(String name) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AvoSessionTracker {
static final String sessionStartKey = "avo_inspector_session_start_key";
static final String sessionIdKey = "avo_inspector_session_id_key";

private SharedPreferences sharedPreferences;
private AvoBatcher avoBatcher;
private final SharedPreferences sharedPreferences;
private final AvoBatcher avoBatcher;

AvoSessionTracker(Context context, AvoBatcher avoBatcher) {
this.sharedPreferences = context.getSharedPreferences(Util.AVO_SHARED_PREFS_KEY, Context.MODE_PRIVATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void clearsCacheOnForegroundWithoutTypedEvents() throws InterruptedExcept
Thread.sleep(500);

// Then
verify(mockNetworkCallsHandler, never()).reportInspectorWithBatchBody(ArgumentMatchers.<Map<String, Object>>anyList(),
verify(mockNetworkCallsHandler, never()).reportInspectorWithBatchBody(ArgumentMatchers.anyList(),
any(AvoNetworkCallsHandler.Callback.class));
assertEquals(0, sut.events.size());

Expand Down Expand Up @@ -324,7 +324,7 @@ public void doesNotAttemptToMakeNetworkCallIdNoTypedEvents() throws InterruptedE
Thread.sleep(500);

// Then
verify(mockNetworkCallsHandler, never()).reportInspectorWithBatchBody(ArgumentMatchers.<Map<String, Object>>anyList(),
verify(mockNetworkCallsHandler, never()).reportInspectorWithBatchBody(ArgumentMatchers.anyList(),
any(AvoNetworkCallsHandler.Callback.class));
assertEquals(0, sut.events.size());
assertEquals(0, sut.batchFlushAttemptMillis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public class DeduplicatorTests {
@Mock
SharedPreferences.Editor mockEditor;

private Map<String, Map<String, Number>> testMap = new ConcurrentHashMap<>();
private Map<String, AvoEventSchemaType> testSchema = new HashMap<>();
private final Map<String, Map<String, Number>> testMap = new ConcurrentHashMap<>();
private final Map<String, AvoEventSchemaType> testSchema = new HashMap<>();

@Before
public void setUp() throws Exception {
Expand All @@ -56,7 +56,7 @@ public void setUp() throws Exception {
when(mockApplication.getApplicationInfo()).thenReturn(mockApplicationInfo);
when(mockApplication.getSharedPreferences(anyString(), anyInt())).thenReturn(mockSharedPrefs);
when(mockSharedPrefs.edit()).thenReturn(mockEditor);
when(mockSharedPrefs.getString(anyString(), (String) eq(null))).thenReturn("");
when(mockSharedPrefs.getString(anyString(), eq(null))).thenReturn("");
when(mockEditor.putLong(anyString(), anyLong())).thenReturn(mockEditor);
when(mockEditor.putString(anyString(), anyString())).thenReturn(mockEditor);
when(mockApplication.getApplicationContext()).thenReturn(mockApplication);
Expand All @@ -67,13 +67,13 @@ public void setUp() throws Exception {
Map<String, Number> nestedMap = new ConcurrentHashMap<>();
short sh = 1;
byte bt = 2;
nestedMap.put("v0", new Integer(3));
nestedMap.put("v0", Integer.valueOf(3));
nestedMap.put("v1", 4);
nestedMap.put("v2", 5L);
nestedMap.put("v3", new Long(6));
nestedMap.put("v4", new Short("7"));
nestedMap.put("v3", Long.valueOf(6));
nestedMap.put("v4", Short.valueOf("7"));
nestedMap.put("v5", sh);
nestedMap.put("v6", new Byte("8"));
nestedMap.put("v6", Byte.valueOf("8"));
nestedMap.put("v7", bt);

testMap.put("nested", nestedMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void setUp() throws Exception {
when(mockApplication.getApplicationInfo()).thenReturn(mockApplicationInfo);
when(mockApplication.getSharedPreferences(anyString(), anyInt())).thenReturn(mockSharedPrefs);
when(mockSharedPrefs.getString(eq(AvoInstallationId.cacheKey), anyString())).thenReturn("testInstallationId");
when(mockSharedPrefs.getString(eq(AvoSessionTracker.sessionIdKey), (String) eq(null))).thenReturn("");
when(mockSharedPrefs.getString(eq(AvoSessionTracker.sessionIdKey), eq(null))).thenReturn("");
when(mockApplication.getApplicationContext()).thenReturn(mockApplication);
when(mockApplication.getContentResolver()).thenReturn(mock(ContentResolver.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setUp() throws Exception {
when(mockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(mockPackageInfo);
when(mockApplication.getApplicationInfo()).thenReturn(mockApplicationInfo);
when(mockApplication.getSharedPreferences(anyString(), anyInt())).thenReturn(mockSharedPrefs);
when(mockSharedPrefs.getString(anyString(), (String) eq(null))).thenReturn("");
when(mockSharedPrefs.getString(anyString(), eq(null))).thenReturn("");
when(mockApplication.getApplicationContext()).thenReturn(mockApplication);
when(mockApplication.getContentResolver()).thenReturn(mock(ContentResolver.class));
when(mockApplication.getApplicationContext()).thenReturn(mockApplication);
Expand All @@ -68,13 +68,13 @@ public void canExtractInt() {
try {
short sh = 1;
byte bt = 2;
testJsonObj.put("v0", new Integer(3));
testJsonObj.put("v0", Integer.valueOf(3));
testJsonObj.put("v1", 4);
testJsonObj.put("v2", 5L);
testJsonObj.put("v3", new Long(6));
testJsonObj.put("v4", new Short("7"));
testJsonObj.put("v3", Long.valueOf(6));
testJsonObj.put("v4", Short.valueOf("7"));
testJsonObj.put("v5", sh);
testJsonObj.put("v6", new Byte("8"));
testJsonObj.put("v6", Byte.valueOf("8"));
testJsonObj.put("v7", bt);
} catch (JSONException e) {
e.printStackTrace();
Expand Down Expand Up @@ -117,7 +117,7 @@ public void canExtractFloat() {
public void canExtractBoolean() {
JSONObject testJsonObj = new JSONObject();
try {
testJsonObj.put("v0", new Boolean(true));
testJsonObj.put("v0", Boolean.TRUE);
testJsonObj.put("v1", false);
} catch (JSONException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void setUp() throws Exception {
when(mockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(mockPackageInfo);
when(mockApplication.getApplicationInfo()).thenReturn(mockApplicationInfo);
when(mockApplication.getSharedPreferences(anyString(), anyInt())).thenReturn(mockSharedPrefs);
when(mockSharedPrefs.getString(anyString(), (String) eq(null))).thenReturn("");
when(mockSharedPrefs.getString(anyString(), eq(null))).thenReturn("");
when(mockSharedPrefs.edit()).thenReturn(mockEditor);
when(mockEditor.putLong(anyString(), anyLong())).thenReturn(mockEditor);
when(mockEditor.putString(anyString(), anyString())).thenReturn(mockEditor);
Expand All @@ -74,13 +74,13 @@ public void canExtractJSONArrayOfIntsAndStrings() {

short sh = 1;
byte bt = 2;
items.put(new Integer(3));
items.put(Integer.valueOf(3));
items.put(4);
items.put(5L);
items.put(new Long(6));
items.put( new Short("7"));
items.put(Long.valueOf(6));
items.put(Short.valueOf("7"));
items.put(sh);
items.put(new Byte("8"));
items.put(Byte.valueOf("8"));
items.put(bt);
items.put("Str");
items.put(new Character('b'));
Expand Down Expand Up @@ -111,13 +111,13 @@ public void canExtractListOfIntsAndStrings() {

short sh = 1;
byte bt = 2;
items.add(new Integer(3));
items.add(Integer.valueOf(3));
items.add(4);
items.add(5L);
items.add(new Long(6));
items.add( new Short("7"));
items.add(Long.valueOf(6));
items.add(Short.valueOf("7"));
items.add(sh);
items.add(new Byte("8"));
items.add(Byte.valueOf("8"));
items.add(bt);
items.add("Str");
items.add(new Character('b'));
Expand Down Expand Up @@ -145,7 +145,7 @@ public void canExtractArrayOfInts() {
int[] items = new int[3];
testJsonObj.put("array_key", items);

items[0] = new Integer(3);
items[0] = Integer.valueOf(3);
items[1] = (short)1;
items[2] = 5;
} catch (JSONException e) {
Expand Down
Loading

0 comments on commit 66cf24f

Please sign in to comment.