Skip to content

Commit

Permalink
added deeplink property to events
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Espinola committed Jul 10, 2024
1 parent 91dc14c commit 3eb8212
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/Helpers/Extension/ATTNAddToCartEvent+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
3 changes: 3 additions & 0 deletions Sources/Public/Events/ATTNAddToCartEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand All @@ -21,3 +22,5 @@ public final class ATTNAddToCartEvent: NSObject, ATTNEvent {
fatalError("init() has not been implemented")
}
}

extension ATTNAddToCartEvent: ATTNDeeplinkHandling { }
12 changes: 12 additions & 0 deletions Sources/Public/Events/ATTNDeeplinkHandling.swift
Original file line number Diff line number Diff line change
@@ -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 }
}
3 changes: 3 additions & 0 deletions Sources/Public/Events/ATTNProductViewEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand All @@ -21,3 +22,5 @@ public final class ATTNProductViewEvent: NSObject, ATTNEvent {
fatalError("init() has not been implemented")
}
}

extension ATTNProductViewEvent: ATTNDeeplinkHandling { }
4 changes: 4 additions & 0 deletions attentive-ios-sdk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -156,6 +157,7 @@
FB6553692C1B72D4008DB3B1 /* ATTNSDKTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNSDKTests.swift; sourceTree = "<group>"; };
FB65536B2C1B74A9008DB3B1 /* ATTNAPIProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNAPIProtocol.swift; sourceTree = "<group>"; };
FB65536D2C1B7747008DB3B1 /* ATTNAPISpy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNAPISpy.swift; sourceTree = "<group>"; };
FB84E3022C3F30FF0011936B /* ATTNDeeplinkHandling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNDeeplinkHandling.swift; sourceTree = "<group>"; };
FB90EF0A2C109CB4004DFC4A /* ATTNAPIITTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTNAPIITTests.swift; sourceTree = "<group>"; };
FB90EF0C2C10A7F7004DFC4A /* NSURLSessionDataTaskMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSURLSessionDataTaskMock.swift; sourceTree = "<group>"; };
FB90EF0E2C10A81E004DFC4A /* NSURLSessionMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSURLSessionMock.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -437,6 +439,7 @@
FBA9F9F72C0A77AB00C65024 /* ATTNPrice.swift */,
FBA9F9F82C0A77AB00C65024 /* ATTNProductViewEvent.swift */,
FBA9F9F92C0A77AB00C65024 /* ATTNPurchaseEvent.swift */,
FB84E3022C3F30FF0011936B /* ATTNDeeplinkHandling.swift */,
);
path = Events;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down

0 comments on commit 3eb8212

Please sign in to comment.