Skip to content

Commit

Permalink
remove history stack implementation, go back to just accepting a path
Browse files Browse the repository at this point in the history
  • Loading branch information
MustafaHaddara committed Dec 4, 2024
1 parent 8f7d032 commit 578cbab
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
25 changes: 2 additions & 23 deletions Sources/Honeycomb/HoneycombNavigationSpanInstrumentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func getTracer() -> Tracer {
internal class HoneycombNavigationProcessor {
static let shared = HoneycombNavigationProcessor()
var currentNavigationPath: String? = nil
var uiKitPath: [String] = []

private init() {}

Expand Down Expand Up @@ -72,28 +71,8 @@ internal class HoneycombNavigationProcessor {
reportNavigation(path: unencodablePath)
}

func setCurrentNavigationPath(_ path: String) {
func setCurrentNavigationPath(_ path: String?) {
currentNavigationPath = path
uiKitPath.removeAll()
}

func pushUiKitPath(_ path: String) {
currentNavigationPath = nil
uiKitPath.append(path)
}

func popUiKitPath() {
uiKitPath.removeLast()
}

func getCurrentPath() -> String? {
if let currentNavigationPath {
return currentNavigationPath
}
if !uiKitPath.isEmpty {
return uiKitPath.joined(separator: "/")
}
return nil
}
}

Expand All @@ -120,7 +99,7 @@ public struct HoneycombNavigationPathSpanProcessor: SpanProcessor {
parentContext: SpanContext?,
span: any ReadableSpan
) {
if let currentPath = HoneycombNavigationProcessor.shared.getCurrentPath() {
if let currentPath = HoneycombNavigationProcessor.shared.currentNavigationPath {
span.setAttribute(
key: "screen.name",
value: currentPath
Expand Down
4 changes: 2 additions & 2 deletions Sources/Honeycomb/UIKit/UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
setAttributes(span: span, className: className, animated: animated)
span.end()

HoneycombNavigationProcessor.shared.pushUiKitPath(getScreenName())
HoneycombNavigationProcessor.shared.setCurrentNavigationPath(getScreenName())
}

traceViewDidAppear(animated)
Expand All @@ -49,7 +49,7 @@
setAttributes(span: span, className: className, animated: animated)
span.end()

HoneycombNavigationProcessor.shared.popUiKitPath()
HoneycombNavigationProcessor.shared.setCurrentNavigationPath(nil)
}

traceViewDidDisappear(animated)
Expand Down

0 comments on commit 578cbab

Please sign in to comment.