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

PubxAi Analytics Adapter : code cleanup and additional data collection #11425

Merged
merged 41 commits into from
Jul 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7fb4d9a
PTOW-2; updates to the pubx analytics adapter
Mar 20, 2024
741a8a0
PTOW-2 review actions
Apr 2, 2024
96b0f36
PTOW-2 Review actions
Apr 30, 2024
a5c3f46
PTOW-2 updating pubx.ai analytics version
tej656 Apr 22, 2024
9abb6ae
Merge pull request #5 from nathan-pubx/PTOW-2-pubx.ai-analytics-adapter
pnhegde Apr 30, 2024
53f687c
Merge branch 'master' into master
pnhegde Apr 30, 2024
490029d
remove empty line
tej656 May 7, 2024
f394949
Merge pull request #9 from tej656/patch-1
pnhegde May 7, 2024
96baeb0
linting changes
tej656 May 7, 2024
8eabf25
Merge pull request #11 from tej656/master
pnhegde May 7, 2024
ca04584
PTOW-2; updates to the pubx analytics adapter
Mar 20, 2024
d0b0848
PTOW-2 review actions
Apr 2, 2024
db4e603
PTOW-2 Review actions
Apr 30, 2024
41bdd89
PTOW-2 updating pubx.ai analytics version
tej656 Apr 22, 2024
b8e79ea
PTOW-2 resolving conflicts
May 7, 2024
e74d1a6
Merge pull request #10 from nathan-pubx/PTOW-2-pubx.ai-analytics-adapter
pnhegde May 10, 2024
924a6c6
PTOW-2-fix-linting-errors
May 11, 2024
8cc7a9c
Merge pull request #12 from nathan-pubx/PTOW-2-fix-linting-errors
pnhegde May 12, 2024
cbc15a2
PTOW-2 fixing tests
May 12, 2024
0425632
Merge pull request #13 from nathan-pubx/PTOW-2-fix-linting-errors
pnhegde May 13, 2024
902d241
fixing bugs, modifying blob behaviour, addressing browser compatibility
May 14, 2024
b973cd5
Merge pull request #14 from nathan-pubx/PTOW-2-fix-linting-errors
pnhegde May 15, 2024
6490a99
add source field
tej656 Jun 11, 2024
85c0b2b
switching from sessionStorage to localStorage
Jun 11, 2024
2be6c09
fixing tests
Jun 11, 2024
f0ab6c0
Merge pull request #15 from tej656/master
pnhegde Jun 11, 2024
89ae0b3
Merge pull request #16 from nathan-pubx/PTOW-2-review-actions
pnhegde Jun 11, 2024
4db2d4b
modifying functions to avoid prebid duplication checker
Jun 12, 2024
1e2d790
implementing enums
Jun 17, 2024
5187c77
Merge pull request #17 from nathan-pubx/PTOW-2-review-actions
pnhegde Jun 18, 2024
f10ab08
moving user agent code to libraries
Jun 20, 2024
5f24f74
updated return types
Jun 20, 2024
a33ff8d
Merge pull request #18 from nathan-pubx/PTOW-2-moving-core-functions-…
pnhegde Jun 20, 2024
6aebb14
switching to macro substitution for prebid version
Jun 20, 2024
08a9a24
adding centralised sendBeacon wrapper
Jul 1, 2024
ef5ac02
Merge branch 'master' into PTOW-2-moving-core-functions-to-libraries
nathan-pubx Jul 2, 2024
9099930
Merge pull request #19 from nathan-pubx/PTOW-2-moving-core-functions-…
pnhegde Jul 3, 2024
9ad1b8f
Merge remote-tracking branch 'prebid/master' into PTOW-2-resolving-co…
Jul 3, 2024
4bee0d5
Merge pull request #21 from nathan-pubx/PTOW-2-resolving-conflicts
pnhegde Jul 3, 2024
acdb5b6
'fixing' tests
Jul 3, 2024
636970b
Merge pull request #22 from nathan-pubx/PTOW-2-resolving-conflicts
pnhegde Jul 4, 2024
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
76 changes: 43 additions & 33 deletions modules/pubxaiAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ const auctionPath = '/analytics/auction';
const winningBidPath = '/analytics/bidwon';
const storage = getStorageManager({ moduleType: MODULE_TYPE_ANALYTICS, moduleName: adapterCode })

const deviceTypes = Object.freeze({
DESKTOP: 0,
MOBILE: 1,
TABLET: 2,
})

const browserTypes = Object.freeze({
CHROME: 0,
FIREFOX: 1,
SAFARI: 2,
EDGE: 3,
INTERNET_EXPLORER: 4,
OTHER: 5
})

const osTypes = Object.freeze({
WINDOWS: 0,
MAC: 1,
LINUX: 2,
UNIX: 3,
IOS: 4,
ANDROID: 5,
OTHER: 6
})

/**
* The sendCache is a global cache object which tracks the pending sends
* back to pubx.ai. The data may be removed from this cache, post send.
Expand Down Expand Up @@ -235,65 +260,50 @@ export const getDeviceType = () => {
/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(
navigator.userAgent.toLowerCase()
)
) return 'tablet';
) return deviceTypes.TABLET;
if (
/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(
navigator.userAgent.toLowerCase()
)
) return 'mobile';
return 'desktop';
) return deviceTypes.MOBILE;
return deviceTypes.DESKTOP;
};

/**
* Get the approximate browser type from the user agent (or vendor if available)
* @returns {string}
*/
export const getBrowser = () => {
if (/Edg/.test(navigator.userAgent)) return 'Microsoft Edge';
if (/Edg/.test(navigator.userAgent)) return browserTypes.EDGE;
else if (
/Chrome/.test(navigator.userAgent) &&
/Google Inc/.test(navigator.vendor)
) {
return 'Chrome';
} else if (navigator.userAgent.match('CriOS')) return 'Chrome';
else if (/Firefox/.test(navigator.userAgent)) return 'Firefox';
) return browserTypes.CHROME;
else if (navigator.userAgent.match('CriOS')) return browserTypes.CHROME;
else if (/Firefox/.test(navigator.userAgent)) return browserTypes.FIREFOX;
else if (
/Safari/.test(navigator.userAgent) &&
/Apple Computer/.test(navigator.vendor)
) {
return 'Safari';
} else if (
) return browserTypes.SAFARI
else if (
/Trident/.test(navigator.userAgent) ||
/MSIE/.test(navigator.userAgent)
) {
return 'Internet Explorer';
} else return 'Others';
) return browserTypes.INTERNET_EXPLORER
else return browserTypes.OTHER;
};

/**
* Get the approximate OS from the user agent (or app version, if available)
* @returns {string}
*/
export const getOS = () => {
if (navigator.userAgent.indexOf('Android') != -1) {
return 'Android';
}
if (navigator.userAgent.indexOf('like Mac') != -1) {
return 'iOS';
}
if (navigator.userAgent.indexOf('Win') != -1) {
return 'Windows';
}
if (navigator.userAgent.indexOf('Mac') != -1) {
return 'Macintosh';
}
if (navigator.userAgent.indexOf('Linux') != -1) {
return 'Linux';
}
if (navigator.appVersion.indexOf('X11') != -1) {
return 'Unix';
}
return 'Others';
if (navigator.userAgent.indexOf('Android') != -1) return osTypes.ANDROID
patmmccann marked this conversation as resolved.
Show resolved Hide resolved
if (navigator.userAgent.indexOf('like Mac') != -1) return osTypes.IOS
if (navigator.userAgent.indexOf('Win') != -1) return osTypes.WINDOWS
if (navigator.userAgent.indexOf('Mac') != -1) return osTypes.MAC
if (navigator.userAgent.indexOf('Linux') != -1) return osTypes.LINUX
if (navigator.appVersion.indexOf('X11') != -1) return osTypes.UNIX
return osTypes.OTHER;
};

/**
Expand Down