-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Extensive Logging #25005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kean
wants to merge
15
commits into
trunk
Choose a base branch
from
task/add-pulse-logger
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Extensive Logging #25005
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5c130c5
Add Pulse as a dependency
kean 5bf5136
Add FF
kean cdd57b7
Integrate PulseUI.MainViewController
kean 12c2e0f
Disable Pulse Pro prompts
kean 74b788e
Add Bolt to enable super-experimental features
kean 01c88de
Add Pulse to super experimental features
kean 088284b
Bootstrap the logging system
kean fd76949
Rename flag
kean 0b0e05b
Update copy
kean 942aeec
Rename to Developer Tools
kean e849f5d
Add Pulse Middleware
jkmassel 22ca14a
Integration WIP
jkmassel 51e6c64
build: Update GutenbergKit version
dcalhoun 02d0e76
build: Upgrade GutenbergKit version
dcalhoun b2ed5de
task: Reset GutenbergKit environment variable to default: `NO`
dcalhoun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import Pulse | ||
| import WordPressAPI | ||
| import WordPressAPIInternal | ||
|
|
||
| final class PulseMiddleware: Middleware { | ||
|
|
||
| private static let errorStatusCodes: [UInt16] = [ | ||
| 400, 401, 402, 403, 404, 419, 429, | ||
| 500 | ||
| ] | ||
|
|
||
| func process( | ||
| requestExecutor: any RequestExecutor, | ||
| response: WpNetworkResponse, | ||
| request: WpNetworkRequest, | ||
| context: RequestContext? | ||
| ) async throws -> WpNetworkResponse { | ||
|
|
||
| LoggerStore.shared.storeRequest( | ||
| convertToUrlRequest(request), | ||
| response: try convertToUrlResponse(response), | ||
| error: Self.errorStatusCodes.contains(response.statusCode) ? parseBodyAsError(response.body) : nil, | ||
| data: response.body | ||
| ) | ||
| return response | ||
| } | ||
|
|
||
| private func convertToUrlRequest(_ original: WpNetworkRequest) -> URLRequest { | ||
| let url = URL(string: original.url())! | ||
| var request = URLRequest(url: url) | ||
| request.httpMethod = "\(original.method())" | ||
| request.allHTTPHeaderFields = original.headerMap().toFlatMap() | ||
| request.httpBody = original.body()?.contents() | ||
| return request | ||
| } | ||
|
|
||
| private func convertToUrlResponse(_ original: WpNetworkResponse) throws -> URLResponse? { | ||
| HTTPURLResponse( | ||
| url: try original.requestUrl.asURL(), | ||
| statusCode: Int(original.statusCode), | ||
| httpVersion: nil, | ||
| headerFields: original.responseHeaderMap.toFlatMap() | ||
| ) | ||
| } | ||
|
|
||
| // TODO: This implementation should probably use the underlying Rust implementation | ||
|
Check warning on line 46 in WordPress/Classes/Networking/PulseMiddleware.swift
|
||
| private func parseBodyAsError(_ data: Data) -> Error? { | ||
| try? JSONDecoder().decode(WpError.self, from: data) | ||
| } | ||
|
|
||
| struct WpError: Codable, Error { | ||
| let code: Int | ||
| let message: String | ||
|
|
||
| var description: String { | ||
| message | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
onTapGesture(count: 5) { isDeveloperModeEnabled = true }work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to change it and try it.
I generated all the original code.