Skip to content

Commit 12daa5c

Browse files
authored
Merge branch 'main' into DX-809
2 parents a16f882 + 827465b commit 12daa5c

File tree

18 files changed

+119
-11
lines changed

18 files changed

+119
-11
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## [5.2.0](https://github.com/customerio/customerio-reactnative/compare/5.1.1...5.2.0) (2025-11-20)
2+
3+
### Features
4+
5+
* add trackMetric method for manual push metric tracking ([#539](https://github.com/customerio/customerio-reactnative/issues/539)) ([43deefe](https://github.com/customerio/customerio-reactnative/commit/43deefef5afe66161ed954948c5f0388ba79be37))
6+
7+
## [5.1.1](https://github.com/customerio/customerio-reactnative/compare/5.1.0...5.1.1) (2025-11-14)
8+
9+
### Bug Fixes
10+
11+
* expose in-app listener for expo ([#538](https://github.com/customerio/customerio-reactnative/issues/538)) ([48687f0](https://github.com/customerio/customerio-reactnative/commit/48687f07556645f58c569fd11bea7720494da829))
12+
113
## [5.1.0](https://github.com/customerio/customerio-reactnative/compare/5.0.1...5.1.0) (2025-10-30)
214

315
### Features

android/src/main/java/io/customer/reactnative/sdk/NativeCustomerIOModuleImpl.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import io.customer.sdk.core.di.SDKComponent
1717
import io.customer.sdk.core.util.CioLogLevel
1818
import io.customer.sdk.core.util.Logger
1919
import io.customer.sdk.data.model.Region
20+
import io.customer.sdk.events.Metric
21+
import io.customer.sdk.events.TrackMetric
22+
import io.customer.sdk.events.serializedName
2023

2124
/**
2225
* Shared implementation logic for Customer.io Native SDK communication in React Native.
@@ -156,6 +159,28 @@ internal object NativeCustomerIOModuleImpl {
156159
requireSDKInstance()?.registerDeviceToken(deviceToken)
157160
}
158161

162+
fun trackMetric(deliveryId: String?, deviceToken: String?, eventName: String?) {
163+
try {
164+
if (deliveryId == null || deviceToken == null || eventName == null) {
165+
throw IllegalArgumentException("Missing required parameters")
166+
}
167+
168+
val event = Metric.values().find {
169+
it.serializedName.equals(eventName, true)
170+
} ?: throw IllegalArgumentException("Invalid metric event name")
171+
172+
requireSDKInstance()?.trackMetric(
173+
event = TrackMetric.Push(
174+
deliveryId = deliveryId,
175+
deviceToken = deviceToken,
176+
metric = event
177+
)
178+
)
179+
} catch (e: Exception) {
180+
logger.error("Error tracking push metric: ${e.message}")
181+
}
182+
}
183+
159184
fun deleteDeviceToken() {
160185
requireSDKInstance()?.deleteDeviceToken()
161186
}

android/src/main/java/io/customer/reactnative/sdk/messaginginapp/NativeMessagingInAppModuleImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object NativeMessagingInAppModuleImpl {
1919

2020
private val inAppMessagingModule: ModuleMessagingInApp?
2121
get() = kotlin.runCatching { CustomerIO.instance().inAppMessaging() }.getOrNull()
22-
internal val inAppEventListener = ReactInAppEventListener()
22+
val inAppEventListener = ReactInAppEventListener()
2323

2424
/**
2525
* Adds InAppMessaging module to native Android SDK based on configuration provided by customer

android/src/main/res/values/customer_io_config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
This will be updated by update-version script with React Native package version
1010
whenever new version of React Native package is released
1111
-->
12-
<string name="customer_io_react_native_sdk_client_version">5.1.0</string>
12+
<string name="customer_io_react_native_sdk_client_version">5.2.0</string>
1313
</resources>

android/src/newarch/io/customer/reactnative/sdk/NativeCustomerIOModule.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class NativeCustomerIOModule(
4848
NativeCustomerIOModuleImpl.registerDeviceToken(token)
4949
}
5050

51+
override fun trackMetric(deliveryID: String?, deviceToken: String?, event: String?) {
52+
NativeCustomerIOModuleImpl.trackMetric(deliveryID, deviceToken, event)
53+
}
54+
5155
override fun deleteDeviceToken() {
5256
NativeCustomerIOModuleImpl.deleteDeviceToken()
5357
}

android/src/oldarch/io/customer/reactnative/sdk/NativeCustomerIOModule.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class NativeCustomerIOModule(
6262
NativeCustomerIOModuleImpl.registerDeviceToken(token)
6363
}
6464

65+
@ReactMethod
66+
fun trackMetric(deliveryID: String, deviceToken: String, event: String) {
67+
NativeCustomerIOModuleImpl.trackMetric(deliveryID, deviceToken, event)
68+
}
69+
6570
@ReactMethod
6671
fun deleteDeviceToken() {
6772
NativeCustomerIOModuleImpl.deleteDeviceToken()

api-extractor-output/customerio-reactnative.api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ export class CustomerIO {
8787
static readonly setDeviceAttributes: (attributes: Record<string, any>) => Promise<any>;
8888
static readonly setProfileAttributes: (attributes: Record<string, any>) => Promise<any>;
8989
static readonly track: (name: string, properties?: Record<string, any>) => Promise<any>;
90+
static readonly trackMetric: ({ deliveryID, deviceToken, event, }: {
91+
deliveryID: string;
92+
deviceToken: string;
93+
event: MetricEvent;
94+
}) => Promise<void>;
9095
}
9196

9297
// Warning: (ae-forgotten-export) The symbol "NativeInAppSpec" needs to be exported by the entry point index.d.ts
@@ -172,6 +177,13 @@ export interface InlineInAppMessageViewProps extends Omit<NativeProps, 'onSizeCh
172177
onActionClick?: (message: InAppMessage, actionValue: string, actionName: string) => void;
173178
}
174179

180+
// @public
181+
export enum MetricEvent {
182+
Converted = "converted",
183+
Delivered = "delivered",
184+
Opened = "opened"
185+
}
186+
175187
// @public
176188
export enum PushClickBehaviorAndroid {
177189
ActivityNoFlags = "ACTIVITY_NO_FLAGS",

example/package-lock.json

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

ios/wrappers/NativeCustomerIO.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ - (void)registerDeviceToken:(NSString *)token {
8585
[_swiftBridge registerDeviceToken:token];
8686
}
8787

88+
- (void)trackMetric:(NSString *)deliveryID
89+
deviceToken:(NSString *)deviceToken
90+
event:(NSString *)event {
91+
[self assertBridgeAvailable:@"during trackMetric"];
92+
[_swiftBridge trackMetric:deliveryID deviceToken:deviceToken event:event];
93+
}
94+
8895
- (void)deleteDeviceToken {
8996
[self assertBridgeAvailable:@"during deleteDeviceToken"];
9097
[_swiftBridge deleteDeviceToken];
@@ -114,6 +121,7 @@ @interface RCT_EXTERN_REMAP_MODULE (NativeCustomerIO, NativeCustomerIO, NSObject
114121
RCT_EXTERN_METHOD(setProfileAttributes : (NSDictionary *)attributes)
115122
RCT_EXTERN_METHOD(setDeviceAttributes : (NSDictionary *)attributes)
116123
RCT_EXTERN_METHOD(registerDeviceToken : (NSString *)token)
124+
RCT_EXTERN_METHOD(trackMetric : (NSString *)deliveryID deviceToken : (NSString *)deviceToken event : (NSString *)event)
117125
RCT_EXTERN_METHOD(deleteDeviceToken)
118126

119127
// Module initialization can happen on background thread

ios/wrappers/NativeCustomerIO.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ public class NativeCustomerIO: NSObject {
126126
CustomerIO.shared.registerDeviceToken(token)
127127
}
128128

129+
@objc
130+
func trackMetric(_ deliveryId: String, deviceToken: String, event: String) {
131+
guard ensureInitialized() else { return }
132+
guard let metricEvent = Metric.getEvent(from: event) else {
133+
logger.error("Invalid metric event: \(event)")
134+
return
135+
}
136+
137+
CustomerIO.shared.trackMetric(deliveryID: deliveryId, event: metricEvent, deviceToken: deviceToken)
138+
}
139+
129140
@objc
130141
func deleteDeviceToken() {
131142
guard ensureInitialized() else { return }

0 commit comments

Comments
 (0)