Skip to content

Commit

Permalink
RUMM-1658 Remove RUMSwipeActionModifier
Browse files Browse the repository at this point in the history
  • Loading branch information
maxep committed Nov 22, 2021
1 parent 10b819a commit eab51e5
Showing 1 changed file with 0 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,6 @@ internal struct RUMTapActionModifier: SwiftUI.ViewModifier {
}
}

/// `SwiftUI.ViewModifier` for RUM which invoke `addUserAction` from the
/// global RUM Monitor when the modified view receives a swipe.
@available(iOS 13, *)
internal struct RUMSwipeActionModifier: SwiftUI.ViewModifier {
/// The minimum dragging distance before the gesture succeeds.
let minimumDistance: CGFloat

/// Action Name used for RUM Explorer.
let name: String

/// Custom attributes to attach to the Action.
let attributes: [AttributeKey: AttributeValue]

/// Start state of the drag gesture.
@State private var started = false

func body(content: Content) -> some View {
content.simultaneousGesture(
DragGesture(minimumDistance: minimumDistance, coordinateSpace: .local)
.onChanged { _ in
if !started {
started.toggle()
Global.rum.stopUserAction(type: .swipe, name: name, attributes: attributes)
}
}
.onEnded { _ in
if started {
Global.rum.stopUserAction(type: .swipe, name: name, attributes: attributes)
started.toggle()
}
}
)
}
}

@available(iOS 13, *)
public extension SwiftUI.View {
/// Monitor this view tap actions with Datadog RUM. An Action event will be logged after a number
Expand All @@ -81,23 +46,6 @@ public extension SwiftUI.View {
) -> some View {
return modifier(RUMTapActionModifier(count: count, name: name, attributes: attributes))
}

/// Monitor this view swipe actions with Datadog RUM. An Action event will be logged after the required
/// minimum dragging distance
///
/// - Parameters:
/// - name: The action name.
/// - attributes: custom attributes to attach to the View.
/// - minimumDistance: The minimum dragging distance for the action to
/// succeed.
/// - Returns: This view after applying a `ViewModifier` for monitoring the view.
func trackRUMSwipeAction(
name: String,
attributes: [AttributeKey: AttributeValue] = [:],
minimumDistance: CGFloat = 10
) -> some View {
return modifier(RUMSwipeActionModifier(minimumDistance: minimumDistance, name: name, attributes: attributes))
}
}

#endif

0 comments on commit eab51e5

Please sign in to comment.