Skip to content

Commit

Permalink
chore: Implement console warning if LogEvent is called before Registe…
Browse files Browse the repository at this point in the history
…rPreference (RMCCX-7109)
  • Loading branch information
SoumenRautray committed Aug 19, 2024
1 parent 98aecaf commit 86cff62
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Redirect user to App Notification Permission Settings if permission was denied previously in Push Primer [RMCCX-6710]
- Send RMC impression event to RAT [RMCCX-6939]
- Send RMC push primer event to RAT [RMCCX-6938]
- Implement console warning if LogEvent is called before calling RegisterPreference [RMCCX-7109]

### 8.3.0 (2024-05-13)
- Improvements:
Expand Down
5 changes: 5 additions & 0 deletions Sources/RInAppMessaging/RInAppMessaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import RSDKUtils
internal static var isInitialized: Bool {
interactor.iamModule != nil
}
internal static var isUserRegistered: Bool = false
internal static let interactor = InAppMessagingInteractor()

/// Returns `true` when RMC module is integrated in the host app
Expand Down Expand Up @@ -124,6 +125,9 @@ import RSDKUtils
/// Log the event name passed in and also pass the event name to the view controller to display a matching campaign.
/// - Parameter event: The Event object to log.
@objc public static func logEvent(_ event: Event) {
if !isUserRegistered {
Logger.debug("⚠️ Warning: RegisterPreference should be called before logging any Events.")
}
inAppQueue.async {
interactor.logEvent(event)
}
Expand All @@ -136,6 +140,7 @@ import RSDKUtils
/// - Note: This method creates a strong reference to provided object.
/// - Parameter provider: object that will always contain up-to-date user information.
@objc public static func registerPreference(_ provider: UserInfoProvider) {
isUserRegistered = true
inAppQueue.async {
interactor.userPerference = provider
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/RInAppMessaging/Utilities/AnalyticsTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ internal struct AnalyticsTracker {
if let customAccNumber = BundleInfo.rmcRATAccountId, RInAppMessaging.isRMCEnvironment {
let rmcEventName = name.rawValue == Constants.RAnalytics.impressionsEventName.rawValue ? Constants.RAnalytics.rmcImpressionsEventName : Constants.RAnalytics.rmcPushPrimerEventName
AnalyticsBroadcaster.sendEventName(rmcEventName.rawValue, dataObject: eventData, customAccountNumber: customAccNumber)
AnalyticsBroadcaster.sendEventName(rmcEventName.rawValue, dataObject: eventData)
} else {
AnalyticsBroadcaster.sendEventName(name.rawValue, dataObject: eventData)
}
AnalyticsBroadcaster.sendEventName(name.rawValue, dataObject: eventData)
}
}

0 comments on commit 86cff62

Please sign in to comment.