Skip to content
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

Implement Observability #9

Merged
merged 41 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
54deb29
Add observability framework to the project
DevAgani Feb 7, 2024
5896ced
Add ScreenViewEvent and UserActionEvent
DevAgani Feb 7, 2024
7088d82
Test events emission
DevAgani Feb 7, 2024
3cebbed
Rename test file, add tests to verify that events are published
DevAgani Feb 8, 2024
a8f3da7
Add a scanfile and a test lane
DevAgani Feb 8, 2024
7e6e925
Add a github workflow to build and test the app
DevAgani Feb 8, 2024
c6ce12a
Remove coverage data step
DevAgani Feb 8, 2024
5643b44
Add another supported platform
DevAgani Feb 8, 2024
d76b7e4
Add a setup environment step
DevAgani Feb 8, 2024
fbda336
Force installation of gem
DevAgani Feb 8, 2024
2aec0be
Add a bundle exec statement to specify source
DevAgani Feb 8, 2024
b450b9c
Fix closure requirement of explicit use of self
DevAgani Feb 8, 2024
e4c1ea6
Add an explicit return
DevAgani Feb 8, 2024
0756305
fulfill capture semantics requirements
DevAgani Feb 8, 2024
04a123c
Add explicit return statement
DevAgani Feb 8, 2024
7643480
Update journey name
DevAgani Feb 8, 2024
a65583d
Add step to publish code coverage to codecov
DevAgani Feb 8, 2024
d9cc125
Update runner to macos-13
DevAgani Feb 12, 2024
0f9a5ea
Fix version of xcode
DevAgani Feb 12, 2024
dd721bc
Merge branch 'main' into feat/add-observability
DevAgani Feb 12, 2024
77ee5aa
Comment out failing UITests
DevAgani Feb 12, 2024
0bc998e
Remove explicit requirements by the compiler
DevAgani Feb 12, 2024
f84098b
Rever to macos 12
DevAgani Feb 12, 2024
598ab04
Fix xcode version
DevAgani Feb 12, 2024
57e7a08
Revert to macos-12
DevAgani Feb 12, 2024
1e1a122
remove return statements
DevAgani Feb 12, 2024
b3bf495
Fix o11y event name
DevAgani Feb 12, 2024
8078a4b
Remove self
DevAgani Feb 12, 2024
b40c1af
Fix failing test
DevAgani Feb 12, 2024
fcbe64b
Switch to macos-14
DevAgani Feb 12, 2024
38e102a
add platfomr
DevAgani Feb 12, 2024
0ff1dec
Revert to macos-13
DevAgani Feb 12, 2024
59e612d
Add prebuild phase for usecase and app:
DevAgani Feb 14, 2024
b658e5f
Rename observabilityTracker to tracker
DevAgani Feb 19, 2024
4009512
Update observability event publishing to use PassthroughSubjects
DevAgani Feb 20, 2024
f633e2d
Remove slather step for now
DevAgani Feb 20, 2024
f3956b3
Revert to camelCase
DevAgani Feb 20, 2024
e926604
Remove the variable and scope them to the test run
DevAgani Feb 20, 2024
ff7d482
Update AccountsJourneyObservabilityTests.swift
tibor-is-back Feb 20, 2024
dbb0a45
Simplify tests as this is to be used a guide
DevAgani Feb 20, 2024
768cd15
Fix event names, and test for hardcorded strings
DevAgani Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
DevAgani marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,24 @@ final class AccountsJourneyObservabilityTests: XCTestCase {

func test_accountsScreenEventIsPublished_whenTheAccountsViewLoads() {
screenViewEventsSpy = TrackerSpy<ScreenViewEvent>()
let event = AccountsJourney.Tracker.event(forScreen: .accounts_list)

expect(screenViewEventsSpy!, toReceive: [event], when: {
expect(screenViewEventsSpy!, toReceive: [ScreenViewEvent(.accounts_list)], when: {
AccountsListViewModel().onEvent(.getAccounts)
})
}

func test_refresh_accountsUserActionEvent_isPublished_whenTheRefreshEventIsEmitted() {
userActionSpy = TrackerSpy<UserActionEvent>()
let event = AccountsJourney.Tracker.event(forUserAction: .refresh_accounts)

expect(userActionSpy!, toReceive: [event], when: {
expect(userActionSpy!, toReceive: [UserActionEvent(.refresh_accounts)], when: {
AccountsListViewModel().onEvent(.refresh)
})
}

func test_search_accountsUserActionEvent_isPublished_whenTheSearchEventIsEmitted() {
userActionSpy = TrackerSpy<UserActionEvent>()
let event = AccountsJourney.Tracker.event(forUserAction: .search_accounts)

expect(userActionSpy!, toReceive: [event], when: {
expect(userActionSpy!, toReceive: [UserActionEvent(.search_accounts)], when: {
AccountsListViewModel().onEvent(.search(""))
})
}
Expand All @@ -83,8 +80,8 @@ final class AccountsJourneyObservabilityTests: XCTestCase {

func test_accountsDetailsScreenEventIsPublished_whenTheAccountsDetailsViewLoads() {
screenViewEventsSpy = TrackerSpy<ScreenViewEvent>()
let event = AccountsJourney.Tracker.event(forScreen: .account_details)
expect(screenViewEventsSpy!, toReceive: [event], when: {

expect(screenViewEventsSpy!, toReceive: [ScreenViewEvent(.account_details)], when: {
AccountDetailsViewModel().onEvent(.getAccountDetails(""))
})
}
Expand Down
31 changes: 31 additions & 0 deletions accounts-journey/Extensions/O11YEvents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// O11YEvents.swift
// AccountsJourney
//
// Created by George Nyakundi on 07/02/2024.
//

import Foundation
import BackbaseObservability

extension ScreenViewEvent {
enum ScreenName: String {
case accounts_list = "accounts-list"
case account_details = "account-details"
DevAgani marked this conversation as resolved.
Show resolved Hide resolved
}

init(_ screenName: ScreenName, addition: String? = nil) {
self.init(name: screenName.rawValue, journey: "accounts-transactions", addition: addition)
}
}

extension UserActionEvent {

enum EventName: String {
case refresh_accounts = "refresh-accounts"
DevAgani marked this conversation as resolved.
Show resolved Hide resolved
case search_accounts = "search-accounts"
}
convenience init(_ eventName: EventName, attributes: [String : BackbaseObservability.BasicEventData] = [:]) {
DevAgani marked this conversation as resolved.
Show resolved Hide resolved
self.init(name: eventName.rawValue, journey: "accounts-transactions", attributes: attributes)
}
}
43 changes: 0 additions & 43 deletions accounts-journey/Extensions/Tracker.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ final class AccountDetailsViewModel: NSObject {
return useCase
}()

private var observabilityTracker: BackbaseObservability.Tracker? = Resolver.optional()
private var tracker: BackbaseObservability.Tracker? = Resolver.optional()

// MARK: - Methods
func onEvent(_ event: AccountDetailsEvent) {
switch event {
case let .getAccountDetails(id):

observabilityTracker?.publish(event: AccountsJourney.Tracker.event(forScreen: .account_details))
tracker?.publish(event: ScreenViewEvent(.account_details))

getAccountDetail(id: id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class AccountsListViewModel: NSObject {

var didSelectProduct: ((String) -> Void)?

private var observabilityTracker: BackbaseObservability.Tracker? = Resolver.optional()
private var tracker: BackbaseObservability.Tracker? = Resolver.optional()

// MARK: - Private

Expand Down Expand Up @@ -48,11 +48,11 @@ final class AccountsListViewModel: NSObject {
private func publishObservabilityEvents(for event: AccountListScreenEvent) {
switch event {
case .getAccounts:
observabilityTracker?.publish(event: AccountsJourney.Tracker.event(forScreen: .accounts_list))
tracker?.publish(event: ScreenViewEvent(.accounts_list))
case .refresh:
observabilityTracker?.publish(event: AccountsJourney.Tracker.event(forUserAction: .refresh_accounts))
tracker?.publish(event: UserActionEvent(.refresh_accounts))
case .search:
observabilityTracker?.publish(event: AccountsJourney.Tracker.event(forUserAction: .search_accounts))
tracker?.publish(event: UserActionEvent(.search_accounts))
}
}

Expand Down
Loading