Skip to content

Commit 695527b

Browse files
Merge pull request #266 from Countly/staging
Release 24.4.0
2 parents 406ffa1 + 0955718 commit 695527b

File tree

96 files changed

+3655
-1561
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+3655
-1561
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
46+
uses: github/codeql-action/init@v3
4747
with:
4848
languages: ${{ matrix.language }}
4949
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
5454
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5555
# If this step fails, then you should remove it and run the build manually (see below)
5656
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v1
57+
uses: github/codeql-action/autobuild@v3
5858

5959
# ℹ️ Command-line programs to run using the OS shell.
6060
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
6868
# make release
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v1
71+
uses: github/codeql-action/analyze@v3

.idea/inspectionProfiles/Countly.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## 24.4.0
2+
* ! Minor breaking change ! If a manual session is already started, it will not be possible to call "BeginSession" without stopping the previous one
3+
* ! Minor breaking change ! If a manual session has not been started, it will not be possible to call "UpdateSession"
4+
* ! Minor breaking change ! If a manual session has not been started, it will not be possible to call "EndSession"
5+
* ! Minor breaking change ! Setting for enabling/disabling for native crash dumps will be always enabled
6+
7+
* Added an extended way of crash filtering
8+
* Added SDK internal limits configuration interface
9+
10+
* Deprecated the following calls from "CountlyConfig":
11+
* "setMaxSegmentationValues(maxSegmentationValues)" instead use "sdkInternalLimits.setMaxSegmentationValues(maxSegmentationValues)"
12+
* "setMaxBreadcrumbCount(maxBreadcrumbCount)" instead use "sdkInternalLimits.setMaxBreadcrumbCount(maxBreadcrumbCount)"
13+
* "setCrashFilterCallback(crashFilterCallback)" instead use "crashes.setGlobalCrashFilterCallback(globalCrashFilterCallback)"
14+
* "enableCrashReporting()" instead use "crashes.enableCrashReporting()"
15+
* "setCustomCrashSegment(crashSegmentation)" instead use "crashes.setCustomCrashSegmentation(crashSegmentation)"
16+
* "setRecordAllThreadsWithCrash()" instead use "crashes.enableRecordAllThreadsWithCrash()"
17+
* "checkForNativeCrashDumps(checkForDumps)", it will be removed in the future, there is no replacement
18+
119
## 24.1.1
220
* Added a new metric for detecting whether or not a device has a hinge
321

app-benchmark/src/main/AndroidManifest.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
33

4-
<uses-permission android:name="android.permission.INTERNET"/>
5-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
6-
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
7-
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
8-
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"/>
9-
<uses-permission android:name="android.permission.WAKE_LOCK"/>
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
7+
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
8+
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
9+
<uses-permission android:name="android.permission.WAKE_LOCK" />
1010

1111
<application
1212
android:name=".App"
1313
android:allowBackup="false"
14+
android:usesCleartextTraffic="true"
1415
android:icon="@mipmap/icon"
1516
android:label="@string/app_name"
1617
android:theme="@style/AppTheme">
@@ -20,9 +21,9 @@
2021
android:configChanges="orientation|screenSize"
2122
android:exported="true">
2223
<intent-filter>
23-
<action android:name="android.intent.action.MAIN"/>
24+
<action android:name="android.intent.action.MAIN" />
2425

25-
<category android:name="android.intent.category.LAUNCHER"/>
26+
<category android:name="android.intent.category.LAUNCHER" />
2627
</intent-filter>
2728
</activity>
2829
</application>

app-benchmark/src/main/java/ly/count/android/benchmark/App.java

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,54 @@ public class App extends Application {
1818
public void onCreate() {
1919
super.onCreate();
2020

21-
CountlyConfig config = (new CountlyConfig(this, COUNTLY_APP_KEY, COUNTLY_SERVER_URL))
21+
CountlyConfig config = new CountlyConfig(this, COUNTLY_APP_KEY, COUNTLY_SERVER_URL)
2222
.setDeviceId(DEVICE_ID)
2323
.setLoggingEnabled(true)
2424
.giveAllConsents()
2525
.setRequestDropAgeHours(10)//to trigger the age blocks
26-
.setEventQueueSizeToSend(10)//for testing the main use case
26+
.setEventQueueSizeToSend(100)//for testing the main use case
2727
.setParameterTamperingProtectionSalt("test-benchmark-salt");
2828

2929
appPcc = new PerformanceCounterCollector();
3030
config.pcc = appPcc;
3131

3232
Countly.sharedInstance().init(config);
33+
34+
//clear initial state to erase past data
35+
Countly.sharedInstance().requestQueue().flushQueues();
36+
3337
Benchmark.countlyStore = new CountlyStore(this, new ModuleLog());
3438
}
3539

3640
/**
3741
* Benchmark scenario - 1
38-
* EQ size 10
39-
* 5 segm values
42+
* Generate events and not requests: yes
43+
* wait: yes
44+
* EQ threshold: 10
45+
* segm values per event: 5
46+
* Generated request count: value doesn't matter
47+
* Event count: 10000
4048
* Fill to 1000 requests which equals to 10000 events generated
49+
*
50+
* steps:
51+
* 1) turn off internet
52+
* 2) clear counters
53+
* 3) Fill RQ/EQ
54+
* 4) turn on internet
55+
* 5) send requests
56+
* 6) wait till all sent
57+
* 7) print counters
58+
*/
59+
60+
/**
61+
* Scenario 2
62+
* RQ size 1000
63+
* Generate a mix of 1200 requests
64+
* EQ threshold 100
65+
* 4 direct requests : 1 event request
66+
* direct requests - 960
67+
* event requests - 240
68+
* events generated - 24000
69+
* segm values per event: 6
4170
*/
4271
}

app-benchmark/src/main/java/ly/count/android/benchmark/Benchmark.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.concurrent.ConcurrentHashMap;
55
import ly.count.android.sdk.Countly;
66
import ly.count.android.sdk.CountlyStore;
7+
import ly.count.android.sdk.UtilsTime;
78
import org.json.JSONException;
89

910
public class Benchmark {
@@ -15,7 +16,7 @@ protected Benchmark() {
1516
}
1617

1718
public void fillRequestQueue(int rqSize, int eventSize, int segmentSize) {
18-
Countly.sharedInstance().requestQueue().flushQueues();
19+
//Countly.sharedInstance().requestQueue().flushQueues();
1920
print("[Benchmark] fillRequestQueue, Filling request queue, rq is flushed");
2021
for (int i = 0; i < rqSize; i++) {
2122
Map<String, String> additionalParams = null;
@@ -34,11 +35,47 @@ public void fillRequestQueue(int rqSize, int eventSize, int segmentSize) {
3435
}
3536

3637
public void fillEventQueue(int eventSize, int segmentSize) {
37-
Countly.sharedInstance().requestQueue().flushQueues();
38+
//Countly.sharedInstance().requestQueue().flushQueues();
39+
3840
print("[Benchmark] fillEventQueue, Filling event queue, rq is flushed");
3941
for (int i = 0; i < eventSize; i++) {
42+
long tsStartGen = UtilsTime.getNanoTime();
4043
Object[] randomEvent = benchmarkUtil.generateRandomEventBase(segmentSize);
44+
App.appPcc.TrackCounterTimeNs("Benchmark_genTime", UtilsTime.getNanoTime() - tsStartGen);
45+
46+
long tsStartAction = UtilsTime.getNanoTime();
4147
Countly.sharedInstance().events().recordEvent(randomEvent[0].toString(), (Map<String, Object>) randomEvent[1], (int) randomEvent[2], (double) randomEvent[3], (double) randomEvent[4]);
48+
App.appPcc.TrackCounterTimeNs("Benchmark_recordEventTime", UtilsTime.getNanoTime() - tsStartAction);
49+
}
50+
print("[Benchmark] fillEventQueue, Request queue size: " + countlyStore.getRequests().length);
51+
}
52+
53+
public void GenerateBenchmarkDataset(int eventSize, int segmentSize) {
54+
Countly.sharedInstance().requestQueue().flushQueues();
55+
56+
int eventsPerChunk = 100;
57+
//int eventChunks = eventSize / eventsPerChunk;
58+
59+
int eventsRecorded = 0;
60+
61+
print("[Benchmark] fillEventQueue, Filling event queue, rq is flushed");
62+
while (eventsRecorded < eventSize) {
63+
//larger RQ filler
64+
long tsStartGenDRequests = UtilsTime.getNanoTime();
65+
fillRequestQueue(4, 2, 2);
66+
App.appPcc.TrackCounterTimeNs("Benchmark_recordDirectRequests", UtilsTime.getNanoTime() - tsStartGenDRequests);
67+
68+
//filling it up by individual events
69+
for (int i = 0; i < eventsPerChunk; i++) {
70+
long tsStartGen = UtilsTime.getNanoTime();
71+
Object[] randomEvent = benchmarkUtil.generateRandomEventBase(segmentSize);
72+
App.appPcc.TrackCounterTimeNs("Benchmark_genTime", UtilsTime.getNanoTime() - tsStartGen);
73+
74+
long tsStartAction = UtilsTime.getNanoTime();
75+
Countly.sharedInstance().events().recordEvent(randomEvent[0].toString(), (Map<String, Object>) randomEvent[1], (int) randomEvent[2], (double) randomEvent[3], (double) randomEvent[4]);
76+
App.appPcc.TrackCounterTimeNs("Benchmark_recordEventTime", UtilsTime.getNanoTime() - tsStartAction);
77+
eventsRecorded++;
78+
}
4279
}
4380
print("[Benchmark] fillEventQueue, Request queue size: " + countlyStore.getRequests().length);
4481
}

app-benchmark/src/main/java/ly/count/android/benchmark/BenchmarkUtil.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.List;
55
import java.util.Map;
66
import java.util.concurrent.ConcurrentHashMap;
7-
import ly.count.android.sdk.RandomUtil;
87
import ly.count.android.sdk.UtilsTime;
98
import org.json.JSONArray;
109
import org.json.JSONException;
@@ -17,10 +16,6 @@ protected BenchmarkUtil() {
1716
random = new RandomUtil();
1817
}
1918

20-
protected Map<String, String> generateRequest(int eventSize, int segmentSize) throws JSONException {
21-
return generateRequest(eventSize, segmentSize, null);
22-
}
23-
2419
protected Map<String, String> generateRequest(int eventSize, int segmentSize, Map<String, String> additionalParams) throws JSONException {
2520
Map<String, String> request = new ConcurrentHashMap<>();
2621
List<JSONObject> events = new ArrayList<>();
@@ -43,7 +38,12 @@ protected Map<String, Object> generateSegmentationMap(int segmentSize) {
4338
Map<String, Object> segment = new ConcurrentHashMap<>();
4439

4540
for (int i = 0; i < segmentSize; i++) {
46-
segment.put(random.generateRandomString(8), random.generateRandomObject());
41+
String key = random.generateRandomString(8);
42+
43+
while (segment.containsKey(key)) {
44+
key = random.generateRandomString(8);
45+
}
46+
segment.put(key, random.generateRandomImmutable());
4747
}
4848

4949
return segment;

app-benchmark/src/main/java/ly/count/android/benchmark/MainActivity.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ public void onPrintCounters(View v) {
7878
benchmark.print(res);
7979
}
8080

81+
public void onClearStorage(View v) {
82+
benchmark.print("[MainActivity] Clear Storage");
83+
Countly.sharedInstance().requestQueue().flushQueues();
84+
}
85+
86+
public void onGenerateBenchmarkData(View v) {
87+
benchmark.print("[MainActivity] Generate benchmark data");
88+
89+
readLoopSegmentEventSize();
90+
91+
futureWrapper(() -> benchmark.GenerateBenchmarkDataset(eventSize, segmentSize));
92+
93+
if (getSwitchValue(R.id.wait)) {
94+
futureWrapper(this::standByForOnTimer);
95+
}
96+
}
97+
8198
protected void BENCHMARK(int loop, Runnable runnable) {
8299
benchmark.print("------------------------------------------------------------");
83100
benchmark.print("[MainActivity] BENCHMARK");
@@ -94,6 +111,9 @@ protected void BENCHMARK(int loop, Runnable runnable) {
94111
long endTime = System.currentTimeMillis();
95112
benchmark.print("[MainActivity] BENCHMARK, SENDING TOOK: " + (endTime - startTime) + "MS");
96113
benchmark.print("------------------------------------------------------------");
114+
115+
String res = App.appPcc.ReturnResults();
116+
benchmark.print(res);
97117
}
98118

99119
private void readLoopSegmentEventSize() {

sdk/src/main/java/ly/count/android/sdk/RandomUtil.java renamed to app-benchmark/src/main/java/ly/count/android/benchmark/RandomUtil.java

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ly.count.android.sdk;
1+
package ly.count.android.benchmark;
22

33
import java.util.Random;
44

@@ -38,8 +38,10 @@ protected Object generateRandomImmutable() {
3838
value = random.nextBoolean();
3939
break;
4040
case 2:
41+
//todo put back in when there is long support
4142
//value = random.nextLong();
42-
//break;
43+
value = generateRandomImmutable();
44+
break;
4345
case 3:
4446
value = random.nextFloat();
4547
break;
@@ -55,43 +57,4 @@ protected Object generateRandomImmutable() {
5557

5658
return value;
5759
}
58-
59-
public Object generateRandomObject() {
60-
int randomInt = random.nextInt(8);
61-
Object value;
62-
63-
//to give it a more chance to create a simple object rather than an array
64-
switch (randomInt) {
65-
case 0:
66-
case 1:
67-
case 2:
68-
case 3:
69-
case 4:
70-
case 5:
71-
case 6:
72-
value = generateRandomImmutable();
73-
break;
74-
//case 7:
75-
// value = generateRandomArray(this::generateRandomImmutable, random.nextInt(10) + 1);
76-
// break;
77-
default:
78-
value = generateRandomObject();
79-
}
80-
81-
return value;
82-
}
83-
84-
protected Object[] generateRandomArray(Supplier valueSupplier, int times) {
85-
Object[] array = new Object[times];
86-
87-
for (int i = 0; i < times; i++) {
88-
array[i] = valueSupplier.get();
89-
}
90-
91-
return array;
92-
}
93-
94-
protected interface Supplier {
95-
Object get();
96-
}
9760
}

0 commit comments

Comments
 (0)