Skip to content
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

🐞[Bug] Force UserAgent value in AJAX requests #782

Merged
merged 3 commits into from
Aug 5, 2019

Conversation

justinswart
Copy link
Contributor

@justinswart justinswart commented Aug 4, 2019

📲 What

Forces the user agent for all requests to be our custom user agent which has the format:

"\(app)/\(bundleVersion) (\(model); iOS \(systemVersion) Scale/\(scale))"

As defined here.

🤔 Why

Our Completed Checkout tracking event has been broken on iOS for some time due to that call being made in a webview via an AJAX request rather than a standard request which we could modify by intercepting the NSURLRequest object.

By injecting the custom user agent the back-end will track the request as being a native app request.

🛠 How

Added what appears to be a common workaround for this which is to set a value in UserDefaults for UserAgent (note: no hyphen).

👀 See

Charles Proxy screenshots testing on simulator:

Before 🐛 After 🦋
headers-before headers-after

✅ Acceptance criteria

  • Verify using Charles Proxy that the correct header is being sent.
  • Confirm with backend engineers that the request is being seen as native.

@justinswart
Copy link
Contributor Author

KsApi/Service.swift Outdated Show resolved Hide resolved
Co-Authored-By: Philippe Creux <pcreux@gmail.com>
Copy link
Contributor

@ifbarrera ifbarrera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in production with @jamielynnroth

@ifbarrera ifbarrera merged commit 5c7c76a into master Aug 5, 2019
@ifbarrera ifbarrera deleted the fix-ajax-user-agent branch August 5, 2019 20:27
@garbles
Copy link

garbles commented Aug 6, 2019

Well that was easy.

justinswart added a commit that referenced this pull request Aug 7, 2019
* Force UserAgent value in UserDefaults

* Update KsApi/Service.swift

Co-Authored-By: Philippe Creux <pcreux@gmail.com>

* SwiftFormat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants