Skip to content

Commit 0f939c5

Browse files
authored
Merge pull request #455 from Countly/content-callback
Content callback
2 parents d8273ec + 4d4574a commit 0f939c5

23 files changed

+309
-46
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 25.1.1
2+
3+
* Updated the underlying Android SDK version to 25.1.1
4+
* Updated the underlying iOS SDK version to 25.1.1
5+
16
## 25.1.0
27
* ! Minor breaking change ! `Countly.userDataBulk.save()` method is now optional. SDK will save the cached data with internal triggers regularly.
38

Countly.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,20 @@ declare module "countly-sdk-react-native-bridge/CountlyConfig" {
11801180
enableVisibilityTracking(): this;
11811181
}
11821182

1183+
interface content {
1184+
/**
1185+
*
1186+
* @param zoneTimerInterval - the interval in seconds to check for new content
1187+
*/
1188+
setZoneTimerInterval(zoneTimerInterval: number): this;
1189+
1190+
/**
1191+
*
1192+
* @param callback - callback to be called when new content is available
1193+
*/
1194+
setGlobalContentCallback(callback: Function): this;
1195+
}
1196+
11831197
/**
11841198
*
11851199
* This class holds APM specific configurations to be used with
@@ -1277,6 +1291,11 @@ declare module "countly-sdk-react-native-bridge/CountlyConfig" {
12771291
*/
12781292
experimental: experimental;
12791293

1294+
/**
1295+
* getter for content features
1296+
*/
1297+
content: content;
1298+
12801299
/**
12811300
* Method to set the server url
12821301
*

Countly.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ Countly.initWithConfig = async function (countlyConfig) {
9191
return;
9292
}
9393
L.d("initWithConfig, Initializing Countly");
94+
if (countlyConfig.content.contentCallback) {
95+
eventEmitter.addListener("globalContentCallback", (data) => {
96+
L.d(`init configuration, Global content callback called with data: ${data}`);
97+
try {
98+
data = JSON.parse(data);
99+
countlyConfig.content.contentCallback(data.status, data.data);
100+
} catch (error) {
101+
L.e(`init configuration, Error parsing global content callback data: ${error}`);
102+
}
103+
});
104+
}
94105
const args = [];
95106
const argsMap = Utils.configToJson(countlyConfig);
96107
const argsString = JSON.stringify(argsMap);

CountlyConfig.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { initialize } from "./Logger.js";
22
import CountlyConfigApm from "./lib/configuration_interfaces/countly_config_apm.js";
33
import CountlyConfigSDKInternalLimits from "./lib/configuration_interfaces/countly_config_limits.js";
44
import CountlyConfigExp from "./lib/configuration_interfaces/countly_config_experimental.js";
5+
import CountlyConfigContent from "./lib/configuration_interfaces/countly_config_content.js";
56
/**
67
* Countly SDK React Native Bridge
78
* https://github.com/Countly/countly-sdk-react-native-bridge
@@ -25,6 +26,7 @@ class CountlyConfig {
2526
this._countlyConfigApmInstance = new CountlyConfigApm();
2627
this._countlyConfigSDKLimitsInstance = new CountlyConfigSDKInternalLimits();
2728
this._countlyConfigExpInstance = new CountlyConfigExp();
29+
this._countlyConfigContentInstance = new CountlyConfigContent();
2830
}
2931

3032
/**
@@ -48,6 +50,13 @@ class CountlyConfig {
4850
return this._countlyConfigExpInstance;
4951
}
5052

53+
/**
54+
* Getter to get the content specific configurations
55+
*/
56+
get content() {
57+
return this._countlyConfigContentInstance;
58+
}
59+
5160
get _crashReporting() {
5261
return this.#crashReporting;
5362
}

Utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ function configToJson(config) {
117117
json.enableVisibilityTracking = true;
118118
L.i(`init configuration, Enabled visibility tracking`)
119119
}
120+
if (config.content.timerInterval) {
121+
json.setZoneTimerInterval = config.content.timerInterval;
122+
L.i(`init configuration, Set zone timer interval to ${config.content.timerInterval}`)
123+
}
124+
if (config.content.contentCallback) {
125+
json.setGlobalContentCallback = true;
126+
L.i(`init configuration, Set global content callback`)
127+
}
120128
if (config._disableIntentRedirectionCheck) {
121129
json.disableAdditionalIntentRedirectionChecks = true;
122130
L.i(`init configuration, Disabled additional intent redirection checks`)

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repositories {
4141

4242
dependencies {
4343
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
44-
implementation 'ly.count.android:sdk:24.7.8'
44+
implementation 'ly.count.android:sdk:25.1.1'
4545

4646
// Import the BoM for the Firebase platform
4747
// The BoM version of 28.4.2 is the newest release that will target firebase-messaging version 22

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import ly.count.android.sdk.RCDownloadCallback;
2828
import ly.count.android.sdk.RemoteConfigCallback;
2929
import ly.count.android.sdk.FeedbackRatingCallback;
30+
import ly.count.android.sdk.ContentCallback;
31+
import ly.count.android.sdk.ContentStatus;
3032

3133
import java.io.BufferedReader;
3234
import java.io.IOException;
@@ -242,6 +244,27 @@ private void populateConfig(JSONObject _config) {
242244
if (_config.has("enableVisibilityTracking")) {
243245
config.experimental.enableVisibilityTracking();
244246
}
247+
if (_config.has("setZoneTimerInterval")) {
248+
config.content.setZoneTimerInterval(_config.getInt("setZoneTimerInterval"));
249+
}
250+
if (_config.has("setGlobalContentCallback")) {
251+
config.content.setGlobalContentCallback(new ContentCallback() {
252+
@Override
253+
public void onContentCallback(ContentStatus contentStatus,Map<String, Object> contentData) {
254+
JSONObject contentMap = new JSONObject();
255+
try {
256+
contentMap.put("status", contentStatus.toString());
257+
contentMap.put("data", new JSONObject(contentData));
258+
} catch (JSONException e) {
259+
log("onContentCallback, JSON exception: ", e, LogLevel.ERROR);
260+
}
261+
262+
((ReactApplicationContext) _reactContext)
263+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
264+
.emit("globalContentCallback", contentMap.toString());
265+
}
266+
});
267+
}
245268
// Limits -----------------------------------------------
246269
if(_config.has("maxKeyLength")) {
247270
config.sdkInternalLimits.setMaxKeyLength(_config.getInt("maxKeyLength"));

example/CountlyRNExample/Configuration.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ const countlyConfig = new CountlyConfig(COUNTLY_SERVER_KEY, COUNTLY_APP_KEY).set
4343
// .enablePreviousNameRecording()
4444
// .enableVisibilityTracking();
4545

46+
// countlyConfig.content.setZoneTimerInterval(120);
47+
// countlyConfig.content.setGlobalContentCallback((status: string, data: object) => {
48+
// console.log("Global content callback", status, data);
49+
// });
50+
4651
export default countlyConfig;

ios/src/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 25.1.1
2+
* Mitigated an issue while setting zone timer interval for content.
3+
4+
## 25.1.0
5+
* Added dynamic resizing functionality for the content zone
6+
* Added a config option to content (setZoneTimerInterval) to set content zone timer. (Experimental!)
7+
8+
* Improved management of content zone size for better responsiveness
9+
* Fixed an issue where the build UUID and executable name were missing from crash reports
10+
111
## 24.7.9
212
* Improved view tracking capabilities
313

ios/src/Countly-PL.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 = 'Countly-PL'
3-
s.version = '24.7.9'
3+
s.version = '25.1.1'
44
s.license = { :type => 'MIT', :file => 'LICENSE' }
55
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
66
s.homepage = 'https://github.com/Countly/countly-sdk-ios'

0 commit comments

Comments
 (0)