-
Notifications
You must be signed in to change notification settings - Fork 3
Add logging and analytics support #107
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
Closed
Closed
Conversation
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
Adds a new network logging module using OSLog, providing configurable privacy levels, custom data decoding, and analytics callbacks for network requests and responses.
Introduces privacy masking for `LogEntry` objects sent to analytics callbacks, preventing sensitive data leakage. Centralizes log message building within `LogEntry` for improved code organization and maintainability.
This refactoring separates network logging from analytics tracking, introducing a dedicated analytics system with its own privacy configuration and data handling, and updating `URLServer` to support distinct logger and analytics components.
Removes the unused NoOpAnalytics implementation and its corresponding test.
Introduces a new analytics module for network requests and responses, featuring configurable privacy levels to mask sensitive data in URLs, headers, and body. Includes comprehensive documentation and examples.
Refactors AnalyticEntry and LogEntry to use an associated value EntryType enum, ensuring relevant data (method, url, statusCode, error) is explicitly tied to each entry type, enhancing type safety and data consistency.
Removes external Markdown files (ANALYTICS.md, LOGGING.md) and integrates their content as inline DocC documentation within the source code for improved discoverability and consistency.
Moved analytics-related tests from `LoggingTests.swift` to a new `AnalyticsTests.swift` file for better organization and separation of concerns.
Introduces structured logging with aligned fields, sorted headers, and timestamps for improved clarity and consistency across request, response, and error entries.
…nd category Moved subsystem and category parameters from LoggerConfiguration to DefaultLogger's initializer for better flexibility and clearer separation of concerns.
Moves os.log calls from DefaultLogger to URLServer+Task and updates LoggerProtocol to provide the underlying os.Logger and its configuration. This simplifies the logging protocol and centralizes the os.log integration.
Removed LoggerProtocol and DefaultLogger by embedding the os.Logger instance directly within LoggerConfiguration. This simplifies the logging setup and reduces abstraction.
…ternal Encapsulate internal logging details by restricting access to LogEntry struct and LoggerConfiguration properties.
Removed redundant usage examples and requirements from various documentation comments. Updated the list of key logging components in README and main documentation.
…rs and recursive body masking Refactors the analytics privacy configuration to provide more granular control over data masking by specifying unmasked parameters instead of sensitive ones. Introduces recursive masking for JSON body content and removes the 'auto' privacy level for clearer definitions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces a comprehensive logging and analytics system with a strong focus on privacy. It enables automatic tracking of network activity, including requests, responses, and errors, with configurable data masking to protect sensitive information. The implementation leverages native
OSLogfor logging and provides a flexible protocol for analytics integration.Key Features
OSLogto automatically log network activity with configurable privacy levels (.none,.auto,.private,.sensitive).AnalyticsProtocolfor tracking network events, featuring robust data masking for URLs, headers, and bodies to ensure user privacy.EntryTypeEnum: A newEntryTypeenum provides a consistent, type-safe data structure for both logging and analytics.LoggerConfigurationandAnalyticsConfigurationallow for detailed control over logging behavior and analytics data masking.URLServertask lifecycle.AnalyticsTests,LoggingTests, andURLServerLoggingTeststo validate the new functionality.README.mdandDocCto cover the new features.Logging vs. Analytics
LogEntry)AnalyticEntry)OSLog.AnalyticsProtocolimplementation.LogPrivacyenum (.none,.auto,.private,.sensitive).AnalyticsPrivacyenum (.none,.private,.sensitive).LoggerConfiguration(subsystem, category, privacy).AnalyticsConfiguration(privacy, unmasked keys).