Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: tracking push metrics from js (#152)
- Loading branch information
Showing
7 changed files
with
147 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#import <React/RCTBridgeModule.h> | ||
|
||
@interface RCT_EXTERN_MODULE(CustomerioPushMessaging, NSObject) | ||
|
||
RCT_EXTERN_METHOD(trackNotificationResponseReceived : (nonnull NSDictionary *) payload]) | ||
|
||
RCT_EXTERN_METHOD(trackNotificationReceived : (nonnull NSDictionary *) payload]) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Foundation | ||
import CioInternalCommon | ||
import CioMessagingPush | ||
|
||
|
||
@objc(CustomerioPushMessaging) | ||
class CustomerioPushMessaging: NSObject { | ||
|
||
@objc static func requiresMainQueueSetup() -> Bool { | ||
false /// false because our native module's initialization does not require access to UIKit | ||
} | ||
|
||
// Tracks `opened` push metrics when a push notification is interacted with. | ||
@objc(trackNotificationResponseReceived:) | ||
func trackNotificationResponseReceived(payload: NSDictionary) { | ||
trackPushMetrics(payload: payload, event: .opened) | ||
} | ||
|
||
// Tracks `delivered` push metrics when a push notification is received. | ||
@objc(trackNotificationReceived:) | ||
func trackNotificationReceived(payload: NSDictionary) { | ||
|
||
trackPushMetrics(payload: payload, event: .delivered) | ||
} | ||
|
||
private func trackPushMetrics(payload: NSDictionary, event : Metric) { | ||
guard let deliveryId = payload[CustomerioConstants.CioDeliveryId] as? String, let deviceToken = payload[CustomerioConstants.CioDeliveryToken] as? String else | ||
{return} | ||
|
||
MessagingPush.shared.trackMetric(deliveryID: deliveryId, event: event, deviceToken: deviceToken) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
struct CustomerioConstants { | ||
// InApp Messaging | ||
static let inAppEventListener = "InAppEventListener" | ||
static let eventType = "eventType" | ||
static let messageId = "messageId" | ||
static let deliveryId = "deliveryId" | ||
static let actionValue = "actionValue" | ||
static let actionName = "actionName" | ||
static let messageShown = "messageShown" | ||
static let messageDismissed = "messageDismissed" | ||
static let errorWithMessage = "errorWithMessage" | ||
static let messageActionTaken = "messageActionTaken" | ||
|
||
// Push Messaging | ||
static let CioDeliveryId = "CIO-Delivery-ID" | ||
static let CioDeliveryToken = "CIO-Delivery-Token" | ||
|
||
// Tracking | ||
static let siteId = "siteId" | ||
static let apiKey = "apiKey" | ||
static let region = "region" | ||
static let version = "version" | ||
static let source = "source" | ||
static let expo = "expo" | ||
|
||
static let autoTrackDeviceAttributes = "autoTrackDeviceAttributes" | ||
static let logLevel = "logLevel" | ||
static let autoTrackPushEvents = "autoTrackPushEvents" | ||
static let bgQMinTasks = "backgroundQueueMinNumberOfTasks" | ||
static let bgQSecondsDelay = "backgroundQueueSecondsDelay" | ||
static let trackingApiUrl = "trackingApiUrl" | ||
static let enableInApp = "enableInApp" | ||
|
||
static let cioTag = "[CIO]" | ||
static let showPromptFailureError = "Error requesting push notification permission." | ||
|
||
static let platformiOS = "ios" | ||
static let sound = "sound" | ||
static let badge = "badge" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters