Skip to content

Commit

Permalink
Releasing 4.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rover Release Bot 🤖 committed Jan 10, 2024
1 parent d218807 commit ea3493f
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import Foundation

public struct ClassicExperienceModel {
public var id: String
public var name: String
public var homeScreen: ClassicScreen
public var screens: [ClassicScreen]
public var keys: [String: String]
public var tags: [String]
public var sourceUrl: URL?

public init(id: String, name: String, homeScreen: ClassicScreen, screens: [ClassicScreen], keys: [String: String], tags: [String]) {
self.id = id
Expand Down
152 changes: 47 additions & 105 deletions Sources/Experiences/ClassicExperiences/Services/RoverObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,12 @@ public class RoverObserver {
return
}

let campaignID = userInfo[RenderClassicExperienceViewController.campaignIDUserInfoKey] as? String

let attributes: Attributes = [
"experience": [
"id": experience.id,
"name": experience.name,
"keys": experience.keys,
"tags": experience.tags
]
"experience": experienceAttributes(experience, campaignID: campaignID)
]

if let campaignID = userInfo[RenderClassicExperienceViewController.campaignIDUserInfoKey] as? String {
(attributes["experience"] as? Attributes)?["campaignID"] = campaignID
}

let eventInfo = EventInfo(
name: "Classic Experience Presented",
namespace: "rover",
Expand All @@ -170,18 +163,12 @@ public class RoverObserver {
return
}

let campaignID = userInfo[RenderClassicExperienceViewController.campaignIDUserInfoKey] as? String

let attributes: Attributes = [
"experience": [
"id": experience.id,
"name": experience.name,
"keys": experience.keys,
"tags": experience.tags
]
"experience": experienceAttributes(experience, campaignID: campaignID)
]

if let campaignID = userInfo[RenderClassicExperienceViewController.campaignIDUserInfoKey] as? String {
(attributes["experience"] as? Attributes)?["campaignID"] = campaignID
}

let eventInfo = EventInfo(
name: "Classic Experience Dismissed",
Expand All @@ -199,20 +186,13 @@ public class RoverObserver {
return
}

let campaignID = userInfo[RenderClassicExperienceViewController.campaignIDUserInfoKey] as? String

let attributes: Attributes = [
"experience": [
"id": experience.id,
"name": experience.name,
"keys": experience.keys,
"tags": experience.tags
],
"experience": experienceAttributes(experience, campaignID: campaignID),
"duration": duration
]

if let campaignID = userInfo[RenderClassicExperienceViewController.campaignIDUserInfoKey] as? String {
(attributes["experience"] as? Attributes)?["campaignID"] = campaignID
}

let eventInfo = EventInfo(
name: "Classic Experience Viewed",
namespace: "rover",
Expand All @@ -231,23 +211,9 @@ public class RoverObserver {

let campaignID = userInfo[ClassicScreenViewController.campaignIDUserInfoKey] as? String

var experienceAttributes: [String : Any] = ["id": experience.id,
"name": experience.name,
"keys": experience.keys,
"tags": experience.tags]

if campaignID != nil {
experienceAttributes["campaignID"] = campaignID
}

let attributes: Attributes = [
"experience": experienceAttributes,
"screen": [
"id": screen.id,
"name": screen.name,
"keys": screen.keys,
"tags": screen.tags
]
"experience": experienceAttributes(experience, campaignID: campaignID),
"screen": screenAttributes(screen)
]

let eventInfo = EventInfo(
Expand Down Expand Up @@ -284,25 +250,13 @@ public class RoverObserver {
return
}

let campaignID = userInfo[ClassicScreenViewController.campaignIDUserInfoKey] as? String

let attributes: Attributes = [
"experience": [
"id": experience.id,
"name": experience.name,
"keys": experience.keys,
"tags": experience.tags
],
"screen": [
"id": screen.id,
"name": screen.name,
"keys": screen.keys,
"tags": screen.tags
]
"experience": experienceAttributes(experience, campaignID: campaignID),
"screen": screenAttributes(screen)
]

if let campaignID = userInfo[ClassicScreenViewController.campaignIDUserInfoKey] as? String {
(attributes["experience"] as? Attributes)?["campaignID"] = campaignID
}

let eventInfo = EventInfo(
name: "Classic Screen Dismissed",
namespace: "rover",
Expand All @@ -320,26 +274,14 @@ public class RoverObserver {
return
}

let campaignID = userInfo[ClassicScreenViewController.campaignIDUserInfoKey] as? String

let attributes: Attributes = [
"experience": [
"id": experience.id,
"name": experience.name,
"keys": experience.keys,
"tags": experience.tags
],
"screen": [
"id": screen.id,
"name": screen.name,
"keys": screen.keys,
"tags": screen.tags
],
"experience": experienceAttributes(experience, campaignID: campaignID),
"screen": screenAttributes(screen),
"duration": duration
]

if let campaignID = userInfo[ClassicScreenViewController.campaignIDUserInfoKey] as? String {
(attributes["experience"] as? Attributes)?["campaignID"] = campaignID
}

let eventInfo = EventInfo(
name: "Classic Screen Viewed",
namespace: "rover",
Expand All @@ -357,19 +299,11 @@ public class RoverObserver {
return
}

let campaignID = userInfo[ClassicScreenViewController.campaignIDUserInfoKey] as? String

let attributes: Attributes = [
"experience": [
"id": experience.id,
"name": experience.name,
"keys": experience.keys,
"tags": experience.tags
],
"screen": [
"id": screen.id,
"name": screen.name,
"keys": screen.keys,
"tags": screen.tags
],
"experience": experienceAttributes(experience, campaignID: campaignID),
"screen": screenAttributes(screen),
"block": [
"id": block.id,
"name": block.name,
Expand All @@ -378,10 +312,6 @@ public class RoverObserver {
]
]

if let campaignID = userInfo[ClassicScreenViewController.campaignIDUserInfoKey] as? String {
(attributes["experience"] as? Attributes)?["campaignID"] = campaignID
}

let eventInfo = EventInfo(
name: "Classic Block Tapped",
namespace: "rover",
Expand Down Expand Up @@ -411,18 +341,8 @@ public class RoverObserver {
}

let attributes: Attributes = [
"experience": [
"id": experience.id,
"name": experience.name,
"keys": experience.keys,
"tags": experience.tags
],
"screen": [
"id": screen.id,
"name": screen.name,
"keys": screen.keys,
"tags": screen.tags
],
"experience": experienceAttributes(experience),
"screen": screenAttributes(screen),
"block": [
"id": block.id,
"name": block.name,
Expand Down Expand Up @@ -488,4 +408,26 @@ public class RoverObserver {
conversionsTracker.track(tag)
}
}

private func experienceAttributes(_ experience: ClassicExperienceModel, campaignID: String? = nil) -> [String: Any] {
let experienceAttributes: [String: Any?] = [
"id": experience.id,
"name": experience.name,
"keys": experience.keys,
"tags": experience.tags,
"campaignId" : campaignID,
"url": experience.sourceUrl?.absoluteString
]

return experienceAttributes.compactMapValues { $0 }
}

private func screenAttributes(_ screen: ClassicScreen) -> [String: Any] {
return [
"id": screen.id,
"name": screen.name,
"keys": screen.keys,
"tags": screen.tags
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ extension EventInfo {
) -> EventInfo {
let experienceAttributes = ["id": experience.id,
"name": experience.name ?? "Name",
"campaignID": campaignID]
"campaignID": campaignID,
"url": experience.sourceUrl?.absoluteString]
.compactMapValues { $0 }

return EventInfo(
Expand All @@ -45,7 +46,8 @@ extension EventInfo {
) -> EventInfo {
let experienceAttributes = ["id": experience.id,
"name": experience.name,
"campaignID": campaignID]
"campaignID": campaignID,
"url": experience.sourceUrl?.absoluteString]
.compactMapValues { $0 }

let screenAttributes = ["id": screen.id,
Expand Down
2 changes: 2 additions & 0 deletions Sources/Experiences/Experiences/Model/ExperienceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ final class ExperienceModel: Decodable {
var initialScreenID: Screen.ID {
return initialScreen!.id
}

var sourceUrl: URL?

/// Initialize Experience from data (JSON)
/// - Parameter data: Experience data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@


import SwiftUI
import Combine
import os.log

internal struct ExperienceViewControllerHolder {
Expand Down Expand Up @@ -99,6 +100,14 @@ internal struct CollectionIndexKey: EnvironmentKey {
static var defaultValue = 0
}

internal struct PageDidDisappearKey: EnvironmentKey {
static var defaultValue: AnyPublisher<Void, Never> = PassthroughSubject<Void, Never>().eraseToAnyPublisher()
}

internal struct PageDidAppearKey: EnvironmentKey {
static var defaultValue: AnyPublisher<Void, Never> = PassthroughSubject<Void, Never>().eraseToAnyPublisher()
}


internal extension EnvironmentValues {
var experience: ExperienceModel? {
Expand Down Expand Up @@ -220,4 +229,24 @@ internal extension EnvironmentValues {
self[CollectionIndexKey.self] = newValue
}
}

var pageDidDisappear: AnyPublisher<Void, Never> {
get {
return self[PageDidDisappearKey.self]
}

set {
self[PageDidDisappearKey.self] = newValue
}
}

var pageDidAppear: AnyPublisher<Void, Never> {
get {
return self[PageDidAppearKey.self]
}

set {
self[PageDidAppearKey.self] = newValue
}
}
}
Loading

0 comments on commit ea3493f

Please sign in to comment.