⚠️ Potential issue | 🟠 Major
Expose the new optional event headers through Plausible.
The generated client now supports X-Forwarded-For and X-Debug-Request, but this wrapper still hardcodes only User-Agent. As shipped, callers cannot use two of the new POST /event features from the public API.
Suggested direction
- public func postEvent(_ event: Event) async throws {
+ public func postEvent(
+ _ event: Event,
+ forwardedFor: String? = nil,
+ debugRequest: Bool? = nil
+ ) async throws {
_ = try await client.post_sol_event(
- headers: .init(User_hyphen_Agent: userAgent),
+ headers: .init(
+ User_hyphen_Agent: userAgent,
+ X_hyphen_Forwarded_hyphen_For: forwardedFor,
+ X_hyphen_Debug_hyphen_Request: debugRequest
+ ),
body: .init(event: event, defaultDomain: defaultDomain)
).accepted
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public func postEvent(
_ event: Event,
forwardedFor: String? = nil,
debugRequest: Bool? = nil
) async throws {
_ = try await client.post_sol_event(
headers: .init(
User_hyphen_Agent: userAgent,
X_hyphen_Forwarded_hyphen_For: forwardedFor,
X_hyphen_Debug_hyphen_Request: debugRequest
),
body: .init(event: event, defaultDomain: defaultDomain)
).accepted
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@Sources/AviaryInsights/Plausible.swift` around lines 186 - 189, The
Plausible.postEvent wrapper currently hardcodes only the User-Agent header when
calling client.post_sol_event, so add optional parameters to Plausible.postEvent
(e.g., xForwardedFor: String? and xDebugRequest: String?) or a single optional
headers struct, surface them in the public API, and pass them into the generated
client's headers initializer alongside User_hyphen_Agent; update the
Plausible.postEvent signature and call to client.post_sol_event to include
X-Forwarded-For and X-Debug-Request when non-nil so callers can supply those new
optional event headers.
Originally posted by @coderabbitai[bot] in #26 (comment)
Expose the new optional event headers through
Plausible.The generated client now supports
X-Forwarded-ForandX-Debug-Request, but this wrapper still hardcodes onlyUser-Agent. As shipped, callers cannot use two of the newPOST /eventfeatures from the public API.Suggested direction
📝 Committable suggestion
🤖 Prompt for AI Agents
Originally posted by @coderabbitai[bot] in #26 (comment)