Implemented the "tagging()" method for the the AnalyticsEvent+Tagging extension in the Infrastructure package.

This commit is contained in:
2026-08-30 09:15:59 +02:00
parent cf58b97de1
commit 8bf6e86ffb
4 changed files with 76 additions and 3 deletions
@@ -0,0 +1,24 @@
import Elementary
public extension Analytics.Event {
// MARK: Methods
/// The event's ``attributes`` as attributes of the tag reporting it.
///
/// ```swift
/// a(.href(url)) { "Listen" }
/// .attributes(contentsOf: Analytics.Event(name: "playlist").tagging())
/// ```
///
/// - Returns: one HTML attribute per event attribute, applied verbatim.
func tagging<Tag: HTMLTrait.Attributes.Global>() -> [HTMLAttribute<Tag>] {
attributes.map {
.custom(
name: $0.name,
value: $0.value
)
}
}
}