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

ADS-3448 Add browser type to Hummingbird data #18

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions modules/mavenAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ let mavenAnalytics = Object.assign(adapter({hummingbirdUrl, analyticsType}), {
// information only once per batch.)
auctionObj = {
auctionId: id,
browserType: options.browserType,
contentItemId: options.contentItemId,
correlator: window.hummingbirdCorrelator,
countryCode: options.countryCode,
Expand Down Expand Up @@ -194,12 +195,39 @@ mavenAnalytics.enableAnalytics = function (config) {
return;
}
options = config.options;
options.browserType = this.generateBrowserType();
mavenAnalytics.originEnableAnalytics(config); // call the base class function
initialized = true;
hummingbirdUrl = options.url;
verbose = !!options.verbose;
};

mavenAnalytics.generateBrowserType = function() {
// Browser sniffing -- this gets us all browser families with >1% of
// traffic, according to the 2019 Wikimedia report.
let ua = navigator.userAgent;
if (ua.includes('Chrome/')) {
if (ua.includes('Edg/') || ua.includes('Edge')) {
return 'edge';
} else if (ua.includes('SamsungBrowser')) {
return 'samsung';
} else if (!ua.includes('Chromium/')) {
return 'chrome';
}
} else if (ua.includes('Safari/')) {
return 'safari';
} else if (ua.includes('Firefox/')) {
if (!ua.includes('Seamonkey/')) {
return 'firefox';
}
} else if (ua.includes('Trident/') || ua.includes('MSIE')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

IE doesn't support String.prototype.includes. I don't think we polyfill for that one, either.

return 'ie';
} else if (ua.includes('OPR/') || ua.includes('Opera/')) {
return 'opera';
}
return 'other';
}

adaptermanager.registerAnalyticsAdapter({
adapter: mavenAnalytics,
code: 'maven'
Expand Down