Skip to content

Commit 8284162

Browse files
committed
Merge branch 'staging' of github.com:Countly/countly-sdk-react-native-bridge into staging-np
2 parents bb92e3d + 047037c commit 8284162

Some content is hidden

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

43 files changed

+1273
-334
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
## 25.4.1-np
2+
* Improved Content display mechanics.
3+
* Added "setRequestTimeoutDuration" init config parameter to change request timeout duration in seconds.
4+
* Added a new function "recordMetrics(metricsOverride)" to send a manual metrics requests.
5+
* Added a new Consent option "metrics" for controlling "recordMetrics" method. (This has no effect on Session metrics.)
6+
* Added event listener calls for new architecture (thanks @j-q-in-berlin)
7+
8+
* Mitigated an issue in SDK limits config class initialization (thanks @albertlaiuste)
9+
10+
* Android specific changes:
11+
* Improved disk size calculation in crash reports.
12+
* Mitigated an issue that could have happened when navigating back from a Content.
13+
* Mitigated a persistency issue with init configuration provided SBS and its initial state.
14+
* Mitigated an issue where SBS could have been fetched twice.
15+
16+
* iOS specific changes:
17+
* Improved CPU architecture detection capabilities.
18+
* Added the ability to record reserved events.
19+
* Changed default log level from "Debug" to "Verbose".
20+
* Mitigated an SBS issue while in temporary ID mode.
21+
* Mitigated a possible Health Check network log recording issue.
22+
23+
* Updated the underlying Android SDK version to 25.4.4
24+
* Updated the underlying iOS SDK version to 25.4.6
25+
126
## 25.4.0-np
227
* ! Minor breaking change ! The SDK now exclusively uses random UUIDs for device id generation instead of platform specific OpenUDID or IDFV
328
* ! Minor breaking change ! Server Configuration is now enabled by default. Changes made on SDK Manager > SDK Configuration on your server will affect SDK behavior directly

Countly.d.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,13 @@ declare module "countly-sdk-react-native-bridge-np" {
520520
*/
521521
export function addCrashLog(crashLog: string): string | void;
522522

523+
524+
/**
525+
* Record a metrics request to be sent to the server
526+
* @param {Record<string, string>} [metricsOverride] - optional metrics override map
527+
*/
528+
export function recordMetrics(metricsOverride?: Record<string, string>): void;
529+
523530
/**
524531
*
525532
* Log exception for Countly
@@ -1356,8 +1363,8 @@ declare module "countly-sdk-react-native-bridge-np/CountlyConfig" {
13561363
* Method to give consent for specific features before init
13571364
*
13581365
* @param {string[]} consents consents e.g ['location', 'sessions',
1359-
* 'attribution', 'push', 'events', 'views', 'crashes', 'users',
1360-
* 'star-rating', 'apm', 'feedback', 'remote-config']
1366+
* 'attribution', 'events', 'views', 'crashes', 'users',
1367+
* 'star-rating', 'apm', 'feedback', 'remote-config', 'metrics']
13611368
*/
13621369
giveConsent(consents: readonly string[]): CountlyConfig;
13631370

@@ -1494,6 +1501,14 @@ declare module "countly-sdk-react-native-bridge-np/CountlyConfig" {
14941501
* @return {CountlyConfig}
14951502
*/
14961503
setSDKBehaviorSettings(settingsObject: object): CountlyConfig;
1504+
1505+
/**
1506+
* Method to set the request timeout duration
1507+
*
1508+
* @param {number} requestTimeoutDuration - request timeout duration in seconds
1509+
* @return {CountlyConfig}
1510+
*/
1511+
setRequestTimeoutDuration(requestTimeoutDuration: number): CountlyConfig;
14971512
}
14981513

14991514
export default CountlyConfig;

Countly.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,29 @@ Countly.addCrashLog = function (crashLog) {
642642
CountlyNativeModule.addCrashLog([crashLog]);
643643
};
644644

645+
/**
646+
* Record a metrics request to be sent to the server
647+
*
648+
* @param {object} [metricsOverride] - optional metrics override map
649+
*/
650+
Countly.recordMetrics = function (metricsOverride = {}) {
651+
if (!_state.isInitialized) {
652+
L.e(`recordMetrics, 'init' must be called before 'recordMetrics'`);
653+
}
654+
L.d(`recordMetrics, Sending metrics request with override: [${JSON.stringify(metricsOverride)}]`);
655+
if (metricsOverride && typeof metricsOverride !== "object") {
656+
L.w(`recordMetrics, ignoring non-object metricsOverride of type '${typeof metricsOverride}'`);
657+
metricsOverride = {};
658+
}
659+
660+
const args = [];
661+
for (const key in metricsOverride) {
662+
args.push(key.toString());
663+
args.push(metricsOverride[key].toString());
664+
}
665+
CountlyNativeModule.recordMetrics(args);
666+
};
667+
645668
/**
646669
*
647670
* Log exception for Countly

CountlyConfig.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class CountlyConfig {
2929

3030
#sdkBehaviorSettings;
3131

32+
#requestTimeoutDuration;
33+
3234
constructor(serverURL, appKey) {
3335
this.serverURL = serverURL;
3436
this.appKey = appKey;
@@ -94,6 +96,10 @@ class CountlyConfig {
9496
return this.#sdkBehaviorSettings;
9597
}
9698

99+
get _requestTimeoutDuration() {
100+
return this.#requestTimeoutDuration;
101+
}
102+
97103
/**
98104
* Method to set the server url
99105
*
@@ -124,6 +130,17 @@ class CountlyConfig {
124130
return this;
125131
}
126132

133+
/**
134+
* Method to set the request timeout duration
135+
*
136+
* @param {Number} timeout - request timeout duration in seconds
137+
* @returns {CountlyConfig} this
138+
*/
139+
setRequestTimeoutDuration(timeout) {
140+
this.#requestTimeoutDuration = timeout;
141+
return this;
142+
}
143+
127144
/**
128145
* Method to enable countly internal debugging logs
129146
*

CountlyReactNative.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'CountlyReactNative'
3-
s.version = '25.4.0'
3+
s.version = '25.4.1'
44
s.license = {
55
:type => 'COMMUNITY',
66
:text => <<-LICENSE

Utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ function configToJson(config) {
172172
json.campaignData = config.campaignData;
173173
L.i(`init configuration, Campaign type: ${config.campaignType}, Campaign data: ${config.campaignData}`);
174174
}
175+
if (config._requestTimeoutDuration) {
176+
json.requestTimeoutDuration = config._requestTimeoutDuration;
177+
L.i(`init configuration, Request timeout duration: ${config._requestTimeoutDuration}`);
178+
}
175179
if (config.attributionValues) {
176180
json.attributionValues = config.attributionValues;
177181
L.i(`init configuration, Attribution values: ${config.attributionValues}`);

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ repositories {
6565

6666
dependencies {
6767
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
68-
implementation 'ly.count.android:sdk:25.4.2'
68+
implementation 'ly.count.android:sdk:25.4.4'
6969
}

android/src/main/java/ly/count/android/sdk/react/CountlyReactNativeImpl.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class CountlyReactNativeImpl extends ReactContextBaseJavaModule implement
8888

8989
public static final String NAME = "CountlyReactNative";
9090
public static final String TAG = "CountlyRNPlugin";
91-
private String COUNTLY_RN_SDK_VERSION_STRING = "25.4.0";
91+
private String COUNTLY_RN_SDK_VERSION_STRING = "25.4.1";
9292
private String COUNTLY_RN_SDK_NAME = "js-rnb-android-np";
9393

9494
private static final CountlyConfig config = new CountlyConfig();
@@ -360,6 +360,14 @@ public void onContentCallback(ContentStatus contentStatus,Map<String, Object> co
360360
log("RecordIndirectAttribution: failure, no attribution values provided", LogLevel.DEBUG);
361361
}
362362
}
363+
if (_config.has("requestTimeoutDuration")) {
364+
int timeout = _config.getInt("requestTimeoutDuration");
365+
if (timeout > 0) {
366+
config.setRequestTimeoutDuration(timeout);
367+
} else {
368+
log("setRequestTimeoutDuration: failure, timeout value must be greater than 0", LogLevel.DEBUG);
369+
}
370+
}
363371
if (_config.has("disableSDKBehaviorSettingsUpdates")) {
364372
boolean disableUpdates = _config.getBoolean("disableSDKBehaviorSettingsUpdates");
365373
if (disableUpdates) {
@@ -723,6 +731,16 @@ public void addCrashLog(ReadableArray args) {
723731
Countly.sharedInstance().crashes().addCrashBreadcrumb(record);
724732
}
725733

734+
public void recordMetrics(ReadableArray args) {
735+
Map<String, String> metricsMap = new HashMap<>();
736+
for (int i = 0; i < args.size(); i += 2) {
737+
String key = args.getString(i);
738+
String value = args.getString(i + 1);
739+
metricsMap.put(key, value);
740+
}
741+
Countly.sharedInstance().requestQueue().recordMetrics(metricsMap);
742+
}
743+
726744

727745
public void logException(ReadableArray args) {
728746
String exceptionString = args.getString(0);
@@ -1750,4 +1768,12 @@ public void onHostPause() {
17501768
public void onHostDestroy() {
17511769

17521770
}
1771+
1772+
public void addListener(String eventType) {
1773+
log("addListener", LogLevel.ERROR);
1774+
}
1775+
1776+
public void removeListeners(double id) {
1777+
log("removeListeners", LogLevel.ERROR);
1778+
}
17531779
}

android/src/newarch/java/ly/count/android/sdk/react/CountlyReactNative.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ public void logException(ReadableArray args) {
201201
this.impl.logException(args);
202202
}
203203

204+
@Override
205+
public void recordMetrics(ReadableArray args) {
206+
this.impl.recordMetrics(args);
207+
}
208+
204209
@Override
205210
public void logJSException(String err, String message, String stack) {
206211
this.impl.logJSException(err, message, stack);
@@ -568,4 +573,14 @@ public void setID(String newDeviceID) {
568573
public void setCustomMetrics(ReadableArray args) {
569574
this.impl.setCustomMetrics(args);
570575
}
576+
577+
@Override
578+
public void addListener(String eventType) {
579+
this.impl.addListener(eventType);
580+
}
581+
582+
@Override
583+
public void removeListeners(double id) {
584+
this.impl.removeListeners(id);
585+
}
571586
}

android/src/oldarch/java/ly/count/android/sdk/react/CountlyReactNative.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ public void addCrashLog(ReadableArray args) {
102102
this.impl.addCrashLog(args);
103103
}
104104

105+
@ReactMethod
106+
public void recordMetrics(ReadableArray args) {
107+
this.impl.recordMetrics(args);
108+
}
109+
105110
@ReactMethod
106111
public void logException(ReadableArray args) {
107112
this.impl.logException(args);
@@ -476,4 +481,14 @@ public void setID(String newDeviceID) {
476481
public void setCustomMetrics(ReadableArray args) {
477482
this.impl.setCustomMetrics(args);
478483
}
484+
485+
@ReactMethod
486+
public void addListener(String eventType) {
487+
this.impl.addListener(eventType);
488+
}
489+
490+
@ReactMethod
491+
public void removeListeners(double id) {
492+
this.impl.removeListeners(id);
493+
}
479494
}

0 commit comments

Comments
 (0)