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

feat: add Klarna Shopping Browser UA parser #669

Merged

Conversation

darasus
Copy link
Contributor

@darasus darasus commented Sep 20, 2023

Klarna App with 150 million users is rather popular shopping browser.

Adding support for Klarna UA parser.

@darasus darasus changed the title add Klarna Shopping Browser UA parser feat: add Klarna Shopping Browser UA parser Sep 20, 2023
Copy link
Owner

@faisalman faisalman left a comment

Choose a reason for hiding this comment

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

The detection for Apps that's not primarily used as a browser will be migrated here forward:

https://github.com/faisalman/ua-parser-js/blob/master/src/extensions/ua-parser-extensions.js#L20

@darasus
Copy link
Contributor Author

darasus commented Oct 2, 2023

@faisalman hm but Klarna app is positioned as Shopping Browser, it has URL address bar etc. Attached a screenshot of how it looks. Would that still count as non browser?

IMG_B39C6BA29679-1

Copy link
Owner

@faisalman faisalman left a comment

Choose a reason for hiding this comment

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

I see.. with an address bar it surely looks like a browser

@faisalman faisalman merged commit 177a496 into faisalman:master Oct 2, 2023
5 checks passed
@darasus darasus deleted the add-klarna-shopping-browser-ua-parser branch October 2, 2023 12:09
@darasus
Copy link
Contributor Author

darasus commented Oct 2, 2023

Hey @faisalman, thanks for merging this PR! Is this going to v1 or v2?

@faisalman
Copy link
Owner

v2, but might as well backported to v1 later

@darasus
Copy link
Contributor Author

darasus commented Oct 10, 2023

@faisalman how can we add this to v1?

@faisalman
Copy link
Owner

In the mean time, you can pass it as an extension when instantiating UAParser

const browsers = [
    [/(klarna)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]
];
const parser = new UAParser({ browser: browsers });

const ua = 'Mozilla/5.0 (Linux; Android 12; moto g(60)s Build/S3RLS32.114-25-13; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 Klarna/23.36.215';

uap.setUA(ua).getBrowser(); // { name: 'Klarna', version: '23.36.215', major: '23'} 

More details at https://docs.uaparser.js.org/v2/intro/extending-regex.html

faisalman added a commit that referenced this pull request Oct 27, 2023
…d from commit 177a496)

Co-authored-by: Ilya Daraseliya <ilya.daraseliya@klarna.com>
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.

None yet

2 participants