Skip to content

Commit 545f245

Browse files
authored
Merge pull request #463 from Countly/server_config
Server configuration
2 parents 5a30089 + 9a1b239 commit 545f245

36 files changed

+2064
-323
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* ! Minor breaking change ! Removed Secure.ANDROID_ID usage in device id generation. The SDK now exclusively uses random UUIDs for device id generation.
33

44
* Added a Content feature method "refreshContentZone" that does a manual refresh.
5+
* Extended server configuration capabilities of the SDK.
6+
* Added a config method to provide server config in the initialization "setSDKBehaviorSettings(String)".
57
* Added a new interface "CountlyNotificationButtonURLHandler" to allow custom handling of URLs when notification buttons are clicked. Could be set by "CountlyConfigPush.setNotificationButtonURLHandler"
68

79
* Mitigated an issue that caused PN message data collision if two message with same ID was received.

sdk/src/androidTest/java/ly/count/android/sdk/ConnectionProcessorTests.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,33 @@ public void setUp() {
7878
return true;
7979
}
8080

81+
@Override public boolean getSessionTrackingEnabled() {
82+
return false;
83+
}
84+
85+
@Override public boolean getViewTrackingEnabled() {
86+
return false;
87+
}
88+
89+
@Override public boolean getCustomEventTrackingEnabled() {
90+
return false;
91+
}
92+
93+
@Override public boolean getContentZoneEnabled() {
94+
return false;
95+
}
96+
8197
@Override public boolean getCrashReportingEnabled() {
8298
return true;
8399
}
100+
101+
@Override public boolean getLocationTrackingEnabled() {
102+
return true;
103+
}
104+
105+
@Override public boolean getRefreshContentZoneEnabled() {
106+
return true;
107+
}
84108
};
85109

86110
Countly.sharedInstance().setLoggingEnabled(true);

sdk/src/androidTest/java/ly/count/android/sdk/DeviceIdTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class DeviceIdTests {
2323

2424
@Before
2525
public void setUp() {
26-
store = TestUtils.getCountyStore();
26+
store = TestUtils.getCountlyStore();
2727
store.clear();
2828

2929
Countly.sharedInstance().halt();

sdk/src/androidTest/java/ly/count/android/sdk/ModuleAPMTests.java

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,46 @@ public void clearNetworkTraces() {
249249
Assert.assertEquals(0, mCountly.moduleAPM.networkTraces.size());
250250
}
251251

252+
/**
253+
* Test that custom trace key is truncated to the correct length
254+
* Max segmentation values limit is applied, with server config
255+
* Validate custom metrics are merged and truncated to the correct length
256+
* Validate that the custom trace is sent to the server with correct values
257+
*/
258+
@Test
259+
public void serverConfig_customTrace_keyLength_segmentationValues() throws JSONException {
260+
CountlyConfig mConfig = TestUtils.createBaseConfig();
261+
mConfig.immediateRequestGenerator = ModuleConfigurationTests.createIRGForSpecificResponse(new ServerConfigBuilder().keyLengthLimit(5).segmentationValuesLimit(3).build());
262+
mCountly = new Countly().init(mConfig);
263+
requestQueueProvider = TestUtils.setRequestQueueProviderToMock(mCountly, mock(RequestQueueProvider.class));
264+
265+
String key = "a_trace_to_track";
266+
mCountly.apm().startTrace(key);
267+
268+
Assert.assertTrue(mCountly.moduleAPM.codeTraces.containsKey(key));
269+
270+
Map<String, Integer> customMetrics = new HashMap<>();
271+
customMetrics.put("a_trace_to_look", 1);
272+
customMetrics.put("a_trace_to_inspect", 2);
273+
customMetrics.put("look_here", 3);
274+
customMetrics.put("microphone_show", 4);
275+
customMetrics.put("berserk", 5);
276+
277+
mCountly.apm().endTrace(key, customMetrics);
278+
279+
customMetrics.clear();
280+
if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT <= 25) {
281+
customMetrics.put("micro", 4);
282+
customMetrics.put("berse", 5);
283+
customMetrics.put("look_", 3);
284+
} else {
285+
customMetrics.put("look_", 3);
286+
customMetrics.put("a_tra", 2);
287+
customMetrics.put("micro", 4);
288+
}
289+
verify(requestQueueProvider).sendAPMCustomTrace(eq("a_tra"), anyLong(), anyLong(), anyLong(), eq(customMetricsToString(customMetrics)));
290+
}
291+
252292
/**
253293
* Test that custom trace key is truncated to the correct length
254294
* Max segmentation values limit is applied,
@@ -352,9 +392,13 @@ public void internalLimits_startNetworkTrace_keyLength() throws JSONException {
352392
validateNetworkRequest(0, "a_tra", -1, 200, 123, 456);
353393
}
354394

355-
private void validateNetworkRequest(int rqIdx, String key, long duration, int responseCode, int requestPayloadSize, int responsePayloadSize) throws JSONException {
395+
protected static void validateNetworkRequest(int rqIdx, String key, long duration, int responseCode, int requestPayloadSize, int responsePayloadSize) throws JSONException {
396+
validateNetworkRequest(rqIdx, rqIdx + 1, key, duration, responseCode, requestPayloadSize, responsePayloadSize);
397+
}
398+
399+
protected static void validateNetworkRequest(int rqIdx, int rqCount, String key, long duration, int responseCode, int requestPayloadSize, int responsePayloadSize) throws JSONException {
356400
Map<String, String>[] RQ = TestUtils.getCurrentRQ();
357-
Assert.assertEquals(rqIdx + 1, RQ.length);
401+
Assert.assertEquals(rqCount, RQ.length);
358402

359403
JSONObject apm = new JSONObject(RQ[rqIdx].get("apm"));
360404
Assert.assertEquals(key, apm.getString("name"));

0 commit comments

Comments
 (0)