From 3eb82128708a73b9174d36e62943ec518d30e03d Mon Sep 17 00:00:00 2001 From: Vladimir Espinola Date: Wed, 10 Jul 2024 17:20:15 -0400 Subject: [PATCH] added deeplink property to events --- .../Extension/ATTNAddToCartEvent+Extension.swift | 5 +++++ .../Extension/ATTNProductViewEvent+Extension.swift | 5 +++++ Sources/Public/Events/ATTNAddToCartEvent.swift | 3 +++ Sources/Public/Events/ATTNDeeplinkHandling.swift | 12 ++++++++++++ Sources/Public/Events/ATTNProductViewEvent.swift | 3 +++ attentive-ios-sdk.xcodeproj/project.pbxproj | 4 ++++ 6 files changed, 32 insertions(+) create mode 100644 Sources/Public/Events/ATTNDeeplinkHandling.swift diff --git a/Sources/Helpers/Extension/ATTNAddToCartEvent+Extension.swift b/Sources/Helpers/Extension/ATTNAddToCartEvent+Extension.swift index 86678e5..f4c7a1c 100644 --- a/Sources/Helpers/Extension/ATTNAddToCartEvent+Extension.swift +++ b/Sources/Helpers/Extension/ATTNAddToCartEvent+Extension.swift @@ -19,6 +19,11 @@ extension ATTNAddToCartEvent: ATTNEventRequestProvider { for item in items { var metadata = [String: Any]() item.addItem(toDictionary: &metadata, with: priceFormatter) + + if let deeplink { + metadata["requestURL"] = deeplink + } + eventRequests.append(.init(metadata: metadata, eventNameAbbreviation: ATTNEventTypes.addToCart)) } diff --git a/Sources/Helpers/Extension/ATTNProductViewEvent+Extension.swift b/Sources/Helpers/Extension/ATTNProductViewEvent+Extension.swift index c77c347..be59244 100644 --- a/Sources/Helpers/Extension/ATTNProductViewEvent+Extension.swift +++ b/Sources/Helpers/Extension/ATTNProductViewEvent+Extension.swift @@ -19,6 +19,11 @@ extension ATTNProductViewEvent: ATTNEventRequestProvider { for item in items { var metadata = [String: Any]() item.addItem(toDictionary: &metadata, with: priceFormatter) + + if let deeplink { + metadata["requestURL"] = deeplink + } + eventRequests.append(.init(metadata: metadata, eventNameAbbreviation: ATTNEventTypes.productView)) } diff --git a/Sources/Public/Events/ATTNAddToCartEvent.swift b/Sources/Public/Events/ATTNAddToCartEvent.swift index c72c0b1..4323338 100644 --- a/Sources/Public/Events/ATTNAddToCartEvent.swift +++ b/Sources/Public/Events/ATTNAddToCartEvent.swift @@ -10,6 +10,7 @@ import Foundation @objc(ATTNAddToCartEvent) public final class ATTNAddToCartEvent: NSObject, ATTNEvent { @objc public let items: [ATTNItem] + @objc public var deeplink: String? @objc public init(items: [ATTNItem]) { @@ -21,3 +22,5 @@ public final class ATTNAddToCartEvent: NSObject, ATTNEvent { fatalError("init() has not been implemented") } } + +extension ATTNAddToCartEvent: ATTNDeeplinkHandling { } diff --git a/Sources/Public/Events/ATTNDeeplinkHandling.swift b/Sources/Public/Events/ATTNDeeplinkHandling.swift new file mode 100644 index 0000000..a2d7d17 --- /dev/null +++ b/Sources/Public/Events/ATTNDeeplinkHandling.swift @@ -0,0 +1,12 @@ +// +// ATTNDeeplinkHandling.swift +// attentive-ios-sdk-framework +// +// Created by Vladimir - Work on 2024-07-10. +// + +import Foundation + +protocol ATTNDeeplinkHandling { + var deeplink: String? { get set } +} diff --git a/Sources/Public/Events/ATTNProductViewEvent.swift b/Sources/Public/Events/ATTNProductViewEvent.swift index 23af889..22b0cb6 100644 --- a/Sources/Public/Events/ATTNProductViewEvent.swift +++ b/Sources/Public/Events/ATTNProductViewEvent.swift @@ -10,6 +10,7 @@ import Foundation @objc(ATTNProductViewEvent) public final class ATTNProductViewEvent: NSObject, ATTNEvent { @objc public let items: [ATTNItem] + @objc public var deeplink: String? @objc(initWithItems:) public init(items: [ATTNItem]) { @@ -21,3 +22,5 @@ public final class ATTNProductViewEvent: NSObject, ATTNEvent { fatalError("init() has not been implemented") } } + +extension ATTNProductViewEvent: ATTNDeeplinkHandling { } diff --git a/attentive-ios-sdk.xcodeproj/project.pbxproj b/attentive-ios-sdk.xcodeproj/project.pbxproj index a8bf9b0..ae17bc1 100644 --- a/attentive-ios-sdk.xcodeproj/project.pbxproj +++ b/attentive-ios-sdk.xcodeproj/project.pbxproj @@ -52,6 +52,7 @@ FB60AF0B2C1211C700C61537 /* ATTNEventURLProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB60AF0A2C1211C700C61537 /* ATTNEventURLProvider.swift */; }; FB65536A2C1B72D4008DB3B1 /* ATTNSDKTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB6553692C1B72D4008DB3B1 /* ATTNSDKTests.swift */; }; FB65536C2C1B74A9008DB3B1 /* ATTNAPIProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB65536B2C1B74A9008DB3B1 /* ATTNAPIProtocol.swift */; }; + FB84E3032C3F30FF0011936B /* ATTNDeeplinkHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB84E3022C3F30FF0011936B /* ATTNDeeplinkHandling.swift */; }; FB90EF0B2C109CB4004DFC4A /* ATTNAPIITTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB90EF0A2C109CB4004DFC4A /* ATTNAPIITTests.swift */; }; FB90EF0D2C10A7F7004DFC4A /* NSURLSessionDataTaskMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB90EF0C2C10A7F7004DFC4A /* NSURLSessionDataTaskMock.swift */; }; FB90EF0F2C10A81E004DFC4A /* NSURLSessionMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB90EF0E2C10A81E004DFC4A /* NSURLSessionMock.swift */; }; @@ -156,6 +157,7 @@ FB6553692C1B72D4008DB3B1 /* ATTNSDKTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNSDKTests.swift; sourceTree = ""; }; FB65536B2C1B74A9008DB3B1 /* ATTNAPIProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNAPIProtocol.swift; sourceTree = ""; }; FB65536D2C1B7747008DB3B1 /* ATTNAPISpy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNAPISpy.swift; sourceTree = ""; }; + FB84E3022C3F30FF0011936B /* ATTNDeeplinkHandling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNDeeplinkHandling.swift; sourceTree = ""; }; FB90EF0A2C109CB4004DFC4A /* ATTNAPIITTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNAPIITTests.swift; sourceTree = ""; }; FB90EF0C2C10A7F7004DFC4A /* NSURLSessionDataTaskMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSURLSessionDataTaskMock.swift; sourceTree = ""; }; FB90EF0E2C10A81E004DFC4A /* NSURLSessionMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSURLSessionMock.swift; sourceTree = ""; }; @@ -437,6 +439,7 @@ FBA9F9F72C0A77AB00C65024 /* ATTNPrice.swift */, FBA9F9F82C0A77AB00C65024 /* ATTNProductViewEvent.swift */, FBA9F9F92C0A77AB00C65024 /* ATTNPurchaseEvent.swift */, + FB84E3022C3F30FF0011936B /* ATTNDeeplinkHandling.swift */, ); path = Events; sourceTree = ""; @@ -680,6 +683,7 @@ FB4E3FE72C372C54004B8FF0 /* ATTNWebViewProviding.swift in Sources */, FBA9FA0A2C0A77AB00C65024 /* ATTNCreativeUrlProvider.swift in Sources */, FB65536C2C1B74A9008DB3B1 /* ATTNAPIProtocol.swift in Sources */, + FB84E3032C3F30FF0011936B /* ATTNDeeplinkHandling.swift in Sources */, FB35C17D2C0E039E009FA048 /* ATTNConstants.swift in Sources */, FB56D4DC2C208D6100AF7530 /* Boolean+Extension.swift in Sources */, FBA9FA082C0A77AB00C65024 /* Dictionary+Extension.swift in Sources */,