#if Analytics import Elementary public extension MarkupContent where Self: _Attributed, Tag: MarkupTrait.AllowsAttributes { // MARK: Methods /// Tags the element with the event it reports to the analytics tracker. /// /// ```swift /// a(.href(url)) { "Listen" } /// .reporting(.init(name: "playlist")) /// ``` /// /// - Parameters: /// - event: the event the element reports. /// - trigger: what reports the event; a click by default. /// - Returns: the element, carrying the event's ``Analytics/Event/attributes(on:)``. func reporting( _ event: Analytics.Event, on trigger: Analytics.Event.Trigger = .click ) -> Self { attributes(contentsOf: event.tagging(on: trigger)) } } public extension MarkupContent where Tag: MarkupTrait.AllowsAttributes { // MARK: Methods /// Tags the content with the event it reports to the analytics tracker. /// /// The fallback for content that is not an element itself, mirroring Elementary's `attributes(contentsOf:)`. /// - Parameters: /// - event: the event the content reports. /// - trigger: what reports the event; a click by default. /// - Returns: the content, carrying the event's ``Analytics/Event/attributes(on:)``. @_disfavoredOverload func reporting( _ event: Analytics.Event, on trigger: Analytics.Event.Trigger = .click ) -> _AttributedContent { attributes(contentsOf: event.tagging(on: trigger)) } } #endif