-
Notifications
You must be signed in to change notification settings - Fork 53
feat: Add user agent to all requests #363
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
base: master
Are you sure you want to change the base?
Conversation
…t test for User-Agent validation
…er-Agent versioning
Generated by 🚫 Danger Swift against 2096890 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #363 +/- ##
==========================================
- Coverage 71.27% 71.04% -0.22%
==========================================
Files 133 133
Lines 6239 6263 +24
==========================================
+ Hits 4446 4449 +3
- Misses 1793 1814 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull request overview
This pull request adds user agent headers to all network requests made by the Crowdin SDK and introduces automation for version management.
Changes:
- Added
User-Agentheader to all HTTP/WebSocket requests with SDK version and platform information (iOS, tvOS, watchOS, macOS) - Created version synchronization automation that keeps Swift code version in sync with podspec version
- Improved CI/CD simulator selection logic to use dynamically available simulators instead of hardcoded device names
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/CrowdinSDK/CrowdinSDK/CrowdinSDK+Version.swift | New file containing SDK version constant sourced from podspec |
| Sources/CrowdinSDK/CrowdinAPI/CrowdinAPI.swift | Made versioned() method static and added platform-specific user agent generation for all platforms |
| Sources/CrowdinSDK/CrowdinAPI/LoginAPI/LoginAPI.swift | Added user agent headers to OAuth token requests |
| Sources/CrowdinSDK/CrowdinAPI/ProjectsAPI/ProjectsAPI.swift | Added user agent header to file download requests |
| Sources/CrowdinSDK/CrowdinAPI/ContentDeliveryAPI/CrowdinContentDeliveryAPI.swift | Added user agent headers to manifest and content delivery requests |
| Sources/CrowdinSDK/Features/RealtimeUpdateFeature/SocketAPI/SocketAPI.swift | Added user agent header to WebSocket connection requests |
| Sources/Tests/CrowdinAPI/CrowdinAPITests.swift | Added test coverage for user agent header generation |
| sync_pod_version.sh | New script to sync version from podspec to Swift code |
| install_hooks.sh | New script to install git hooks and make scripts executable |
| pre-commit | Updated to run version sync before SwiftLint |
| .github/workflows/build.yml | Improved simulator selection with dynamic detection |
| CONTRIBUTING.md | Added documentation for development setup |
| .gitignore | Added buildServer.json to ignored files |
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.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ocalizationProviderTests
…ests for concurrent downloads
Sources/CrowdinSDK/Providers/Crowdin/LocalizationDownloader/CrowdinLocalizationDownloader.swift
Show resolved
Hide resolved
Sources/CrowdinSDK/Providers/Crowdin/LocalizationDownloader/CrowdinLocalizationDownloader.swift
Show resolved
Hide resolved
…r ManifestManager in tests
andrii-bodnar
left a comment
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.
@serhii-londar let's remove this part with git hook and syncing the version. It's overcomplicated. There is a risk that the CrowdinSDK+Version.swift file content will change without changing the hardcoded content in the sync script.
We can just manually increase the version number when creating a release. It's not a big deal. We could also use release automation tools that are already able to update the version number in the file content.
…s for improved performance
… completion callbacks
| } else if supportedLanguages == nil { | ||
| let error = NSError(domain: "Unknown error while downloading supported languages", code: defaultCrowdinErrorCode, userInfo: nil) | ||
| callbacks.errors.forEach({ $0(error) }) | ||
| callbacks.completions.forEach({ $0() }) |
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.
Completion callbacks now always fire on download errors
Medium Severity
The downloadSupportedLanguages callback behavior changed: previously, when an error occurred, only error callbacks were called (returning ([], self._errors)). Now both completion AND error callbacks are called (returning (self._completions, self._errors)). Additionally, when supportedLanguages is nil, the old code returned ([], []) calling nothing, while the new code now calls both callbacks. This API contract change could break callers expecting either completion OR error, but not both.
Note
Adds versioned request headers
CrowdinAPI.versionedand applies it toContentDeliveryAPI(files/manifest),ProjectsAPI.downloadFileData,LoginAPI(token/refresh), andSocketAPI(WebSocket), usingCrowdinSDK.currentVersion.Thread-safety and stability
CrowdinLocalizationDownloaderwith a lockedDownloadContext, cancels overlapping operations, validates manifest presence, and centralizes completion.RUFilesDownloaderandCrowdinMappingDownloaderto prevent overlaps.CrowdinSupportedLanguagesqueueing and callbacks to avoid races; adds comprehensive concurrency unit tests and adjusts timeouts/iterations for reliability.CI/CD improvements
Dev tooling
CrowdinSDK+Version.swiftand git hooks (install_hooks.sh,pre-commit,sync_pod_version.sh) to auto-sync Podspec version; updates CONTRIBUTING and.gitignore.Written by Cursor Bugbot for commit 2096890. This will update automatically on new commits. Configure here.