-
Notifications
You must be signed in to change notification settings - Fork 1
feat: SQDSDKS-7423 - Add event mapping functionality and new MPRoktEventMapper class #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2a6e164
2a38817
55c17ed
a6514a1
04c2453
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -8,10 +8,12 @@ | |||
|
|
||||
| /* Begin PBXBuildFile section */ | ||||
| 2502325C2D7A7BF3004794A2 /* Rokt-Widget in Frameworks */ = {isa = PBXBuildFile; productRef = 2502325B2D7A7BF3004794A2 /* Rokt-Widget */; }; | ||||
| 536803952B7BAE11000A10BE /* mParticle-Apple-SDK in Frameworks */ = {isa = PBXBuildFile; productRef = 536803942B7BAE11000A10BE /* mParticle-Apple-SDK */; }; | ||||
| 7E15B2092D9AE82000C1FF3E /* mParticle-Apple-SDK in Frameworks */ = {isa = PBXBuildFile; productRef = 7E15B2082D9AE82000C1FF3E /* mParticle-Apple-SDK */; }; | ||||
| 7E15B20B2D9AE82600C1FF3E /* Rokt-Widget in Frameworks */ = {isa = PBXBuildFile; productRef = 7E15B20A2D9AE82600C1FF3E /* Rokt-Widget */; }; | ||||
| 7EDDAAB02E05A88E00D089CF /* mParticle-Apple-SDK in Frameworks */ = {isa = PBXBuildFile; productRef = 7EDDAAAF2E05A88E00D089CF /* mParticle-Apple-SDK */; }; | ||||
| 7EDDAAB22E05A89B00D089CF /* mParticle-Apple-SDK in Frameworks */ = {isa = PBXBuildFile; productRef = 7EDDAAB12E05A89B00D089CF /* mParticle-Apple-SDK */; }; | ||||
| 7EE7F13E2DA95BEE006C5440 /* OCMock in Frameworks */ = {isa = PBXBuildFile; productRef = 7EE7F13D2DA95BEE006C5440 /* OCMock */; }; | ||||
| B34CE55A2E04356F00712DE1 /* MPRoktEventMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D778512E02845700D887A4 /* MPRoktEventMapper.swift */; }; | ||||
| B3D778532E02845700D887A4 /* MPRoktEventMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D778512E02845700D887A4 /* MPRoktEventMapper.swift */; }; | ||||
| DBB01A601DC1478A00A7B188 /* mParticle_Rokt.h in Headers */ = {isa = PBXBuildFile; fileRef = DBB01A5E1DC1478A00A7B188 /* mParticle_Rokt.h */; settings = {ATTRIBUTES = (Public, ); }; }; | ||||
| DBB01A681DC1480700A7B188 /* MPKitRokt.h in Headers */ = {isa = PBXBuildFile; fileRef = DBB01A661DC1480700A7B188 /* MPKitRokt.h */; }; | ||||
| DBB01A691DC1480700A7B188 /* MPKitRokt.m in Sources */ = {isa = PBXBuildFile; fileRef = DBB01A671DC1480700A7B188 /* MPKitRokt.m */; }; | ||||
|
|
@@ -30,6 +32,7 @@ | |||
| /* End PBXContainerItemProxy section */ | ||||
|
|
||||
| /* Begin PBXFileReference section */ | ||||
| B3D778512E02845700D887A4 /* MPRoktEventMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPRoktEventMapper.swift; sourceTree = "<group>"; }; | ||||
| DBB01A5B1DC1478A00A7B188 /* mParticle_Rokt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = mParticle_Rokt.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | ||||
| DBB01A5E1DC1478A00A7B188 /* mParticle_Rokt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mParticle_Rokt.h; sourceTree = "<group>"; }; | ||||
| DBB01A5F1DC1478A00A7B188 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | ||||
|
|
@@ -45,18 +48,18 @@ | |||
| isa = PBXFrameworksBuildPhase; | ||||
| buildActionMask = 2147483647; | ||||
| files = ( | ||||
| 7EDDAAB02E05A88E00D089CF /* mParticle-Apple-SDK in Frameworks */, | ||||
| 2502325C2D7A7BF3004794A2 /* Rokt-Widget in Frameworks */, | ||||
| 536803952B7BAE11000A10BE /* mParticle-Apple-SDK in Frameworks */, | ||||
| ); | ||||
| runOnlyForDeploymentPostprocessing = 0; | ||||
| }; | ||||
| FF0BB638217A84E800B0556C /* Frameworks */ = { | ||||
| isa = PBXFrameworksBuildPhase; | ||||
| buildActionMask = 2147483647; | ||||
| files = ( | ||||
| 7E15B2092D9AE82000C1FF3E /* mParticle-Apple-SDK in Frameworks */, | ||||
| FF0BB640217A84E800B0556C /* mParticle_Rokt.framework in Frameworks */, | ||||
| 7EE7F13E2DA95BEE006C5440 /* OCMock in Frameworks */, | ||||
| 7EDDAAB22E05A89B00D089CF /* mParticle-Apple-SDK in Frameworks */, | ||||
| 7E15B20B2D9AE82600C1FF3E /* Rokt-Widget in Frameworks */, | ||||
| ); | ||||
| runOnlyForDeploymentPostprocessing = 0; | ||||
|
|
@@ -86,6 +89,7 @@ | |||
| DBB01A5D1DC1478A00A7B188 /* mParticle-Rokt */ = { | ||||
| isa = PBXGroup; | ||||
| children = ( | ||||
| B3D778512E02845700D887A4 /* MPRoktEventMapper.swift */, | ||||
| DBB01A661DC1480700A7B188 /* MPKitRokt.h */, | ||||
| DBB01A671DC1480700A7B188 /* MPKitRokt.m */, | ||||
| DBB01A5E1DC1478A00A7B188 /* mParticle_Rokt.h */, | ||||
|
|
@@ -140,8 +144,8 @@ | |||
| ); | ||||
| name = "mParticle-Rokt"; | ||||
| packageProductDependencies = ( | ||||
| 536803942B7BAE11000A10BE /* mParticle-Apple-SDK */, | ||||
| 2502325B2D7A7BF3004794A2 /* Rokt-Widget */, | ||||
| 7EDDAAAF2E05A88E00D089CF /* mParticle-Apple-SDK */, | ||||
| ); | ||||
| productName = "mParticle-Rokt"; | ||||
| productReference = DBB01A5B1DC1478A00A7B188 /* mParticle_Rokt.framework */; | ||||
|
|
@@ -176,10 +180,12 @@ | |||
| TargetAttributes = { | ||||
| DBB01A5A1DC1478A00A7B188 = { | ||||
| CreatedOnToolsVersion = 8.0; | ||||
| LastSwiftMigration = 1640; | ||||
| ProvisioningStyle = Automatic; | ||||
| }; | ||||
| FF0BB63A217A84E800B0556C = { | ||||
| CreatedOnToolsVersion = 10.0; | ||||
| LastSwiftMigration = 1640; | ||||
| ProvisioningStyle = Automatic; | ||||
| }; | ||||
| }; | ||||
|
|
@@ -194,9 +200,9 @@ | |||
| ); | ||||
| mainGroup = DBB01A511DC1478A00A7B188; | ||||
| packageReferences = ( | ||||
| 536803932B7BAE11000A10BE /* XCRemoteSwiftPackageReference "mparticle-apple-sdk" */, | ||||
| 2502325A2D7A7BF3004794A2 /* XCRemoteSwiftPackageReference "rokt-sdk-ios" */, | ||||
| 7EE7F13C2DA95BEE006C5440 /* XCRemoteSwiftPackageReference "ocmock" */, | ||||
| 7EDDAAAE2E05A88E00D089CF /* XCRemoteSwiftPackageReference "mparticle-apple-sdk" */, | ||||
| ); | ||||
| productRefGroup = DBB01A5C1DC1478A00A7B188 /* Products */; | ||||
| projectDirPath = ""; | ||||
|
|
@@ -230,6 +236,7 @@ | |||
| isa = PBXSourcesBuildPhase; | ||||
| buildActionMask = 2147483647; | ||||
| files = ( | ||||
| B34CE55A2E04356F00712DE1 /* MPRoktEventMapper.swift in Sources */, | ||||
| DBB01A691DC1480700A7B188 /* MPKitRokt.m in Sources */, | ||||
| ); | ||||
| runOnlyForDeploymentPostprocessing = 0; | ||||
|
|
@@ -238,6 +245,7 @@ | |||
| isa = PBXSourcesBuildPhase; | ||||
| buildActionMask = 2147483647; | ||||
| files = ( | ||||
| B3D778532E02845700D887A4 /* MPRoktEventMapper.swift in Sources */, | ||||
|
||||
| B3D778532E02845700D887A4 /* MPRoktEventMapper.swift in Sources */, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import Foundation | ||
| import mParticle_Apple_SDK | ||
| import Rokt_Widget | ||
|
|
||
| /// Utility class for mapping Rokt events to mParticle events | ||
| @objc(MPRoktEventMapper) | ||
| @objcMembers | ||
| public class MPRoktEventMapper: NSObject { | ||
|
|
||
| /// Maps a RoktEvent to the corresponding MPRoktEvent | ||
| /// - Parameter event: The RoktEvent to map | ||
| /// - Returns: The mapped MPRoktEvent, or nil if mapping fails | ||
| @objc(mapEvent:) | ||
| public static func mapEvent(_ event: RoktEvent) -> MPRoktEvent? { | ||
| switch event { | ||
| case let initComplete as RoktEvent.InitComplete: | ||
| return MPRoktEvent.MPRoktInitComplete(success: initComplete.success) | ||
|
|
||
| case is RoktEvent.ShowLoadingIndicator: | ||
| return MPRoktEvent.MPRoktShowLoadingIndicator() | ||
|
|
||
| case is RoktEvent.HideLoadingIndicator: | ||
| return MPRoktEvent.MPRoktHideLoadingIndicator() | ||
|
|
||
| case let placementInteractive as RoktEvent.PlacementInteractive: | ||
| return MPRoktEvent.MPRoktPlacementInteractive(placementId: placementInteractive.placementId) | ||
|
|
||
| case let placementReady as RoktEvent.PlacementReady: | ||
| return MPRoktEvent.MPRoktPlacementReady(placementId: placementReady.placementId) | ||
|
|
||
| case let offerEngagement as RoktEvent.OfferEngagement: | ||
| return MPRoktEvent.MPRoktOfferEngagement(placementId: offerEngagement.placementId) | ||
|
|
||
| case let openUrl as RoktEvent.OpenUrl: | ||
| return MPRoktEvent.MPRoktOpenUrl(placementId: openUrl.placementId, url: openUrl.url) | ||
|
|
||
| case let positiveEngagement as RoktEvent.PositiveEngagement: | ||
| return MPRoktEvent.MPRoktPositiveEngagement(placementId: positiveEngagement.placementId) | ||
|
|
||
| case let placementClosed as RoktEvent.PlacementClosed: | ||
| return MPRoktEvent.MPRoktPlacementClosed(placementId: placementClosed.placementId) | ||
|
|
||
| case let placementCompleted as RoktEvent.PlacementCompleted: | ||
| return MPRoktEvent.MPRoktPlacementCompleted(placementId: placementCompleted.placementId) | ||
|
|
||
| case let placementFailure as RoktEvent.PlacementFailure: | ||
| return MPRoktEvent.MPRoktPlacementFailure(placementId: placementFailure.placementId) | ||
|
|
||
| case let firstPositiveEngagement as RoktEvent.FirstPositiveEngagement: | ||
| return MPRoktEvent.MPRoktFirstPositiveEngagement( | ||
| placementId: firstPositiveEngagement.placementId | ||
| ) | ||
|
|
||
| case let cartItemInstantPurchase as RoktEvent.CartItemInstantPurchase: | ||
| return MPRoktEvent.MPRoktCartItemInstantPurchase( | ||
| placementId: cartItemInstantPurchase.placementId, | ||
| name: cartItemInstantPurchase.name ?? "", | ||
| cartItemId: cartItemInstantPurchase.cartItemId, | ||
| catalogItemId: cartItemInstantPurchase.catalogItemId, | ||
| currency: cartItemInstantPurchase.currency, | ||
| description: cartItemInstantPurchase.description, | ||
| linkedProductId: cartItemInstantPurchase.linkedProductId, | ||
| providerData: cartItemInstantPurchase.providerData, | ||
| quantity: cartItemInstantPurchase.quantity, | ||
| totalPrice: cartItemInstantPurchase.totalPrice, | ||
| unitPrice: cartItemInstantPurchase.unitPrice | ||
| ) | ||
|
|
||
| default: | ||
| return nil | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,9 +2,3 @@ | |
|
|
||
| FOUNDATION_EXPORT double mParticle_RoktVersionNumber; | ||
| FOUNDATION_EXPORT const unsigned char mParticle_RoktVersionString[]; | ||
|
|
||
| #if defined(__has_include) && __has_include(<mParticle_Appboy/MPKitAppboy.h>) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please test this in an app that uses cocaopods to integrate the frameworks. I know this isn't need when clients use SPM but it is for cocaopods clients |
||
| #import <mParticle_Rokt/MPKitRokt.h> | ||
| #else | ||
| #import "MPKitRokt.h" | ||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The podspec declares Swift version '5.3' but the Xcode project is set to Swift 6.0. Align the podspec
swift_versionwith the project to avoid compatibility issues.