Skip to content

Commit

Permalink
Merge pull request prebid#12 from nathan-pubx/PTOW-2-fix-linting-errors
Browse files Browse the repository at this point in the history
PTOW-2-fix-linting-errors
  • Loading branch information
pnhegde authored May 12, 2024
2 parents e74d1a6 + 924a6c6 commit 8cc7a9c
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 127 deletions.
116 changes: 58 additions & 58 deletions modules/pubxaiAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import {
getWindowLocation,
buildUrl,
cyrb53Hash,
} from "../src/utils.js";
import adapter from "../libraries/analyticsAdapter/AnalyticsAdapter.js";
import adapterManager from "../src/adapterManager.js";
import { EVENTS } from "../src/constants.js";
import { getGlobal } from "../src/prebidGlobal.js";
} from '../src/utils.js';
import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
import adapterManager from '../src/adapterManager.js';
import { EVENTS } from '../src/constants.js';
import { getGlobal } from '../src/prebidGlobal.js';
import {
getGptSlotInfoForAdUnitCode,
getGptSlotForAdUnitCode,
} from "../libraries/gptUtils/gptUtils.js";
} from '../libraries/gptUtils/gptUtils.js';

let initOptions;

const emptyUrl = "";
const analyticsType = "endpoint";
const pubxaiAnalyticsVersion = "v2.0.0";
const defaultHost = "api.pbxai.com";
const auctionPath = "/analytics/auction";
const winningBidPath = "/analytics/bidwon";
const emptyUrl = '';
const analyticsType = 'endpoint';
const pubxaiAnalyticsVersion = 'v2.0.0';
const defaultHost = 'api.pbxai.com';
const auctionPath = '/analytics/auction';
const winningBidPath = '/analytics/bidwon';

/**
* The sendCache is a global cache object which tracks the pending sends
Expand Down Expand Up @@ -75,7 +75,7 @@ export const auctionCache = new Proxy(
consentDetail: {
consentTypes: Object.keys(getGlobal().getConsentMetadata?.() || {}),
},
pmacDetail: JSON.parse(getStorage()?.getItem("pubx:pmac")) || {}, // {auction_1: {floor:0.23,maxBid:0.34,bidCount:3},auction_2:{floor:0.13,maxBid:0.14,bidCount:2}
pmacDetail: JSON.parse(getStorage()?.getItem('pubx:pmac')) || {}, // {auction_1: {floor:0.23,maxBid:0.34,bidCount:3},auction_2:{floor:0.13,maxBid:0.14,bidCount:2}
initOptions: {
...initOptions,
auctionId: name, // back-compat
Expand Down Expand Up @@ -112,8 +112,8 @@ const getAdServerDataForBid = (bid) => {
.getTargetingKeys()
.filter(
(key) =>
key.startsWith("pubx-") ||
(key.startsWith("hb_") && (key.match(/_/g) || []).length === 1)
key.startsWith('pubx-') ||
(key.startsWith('hb_') && (key.match(/_/g) || []).length === 1)
)
.map((key) => [key, gptSlot.getTargeting(key)])
);
Expand Down Expand Up @@ -162,7 +162,7 @@ const extractBid = (bidResponse) => {
transactionId: bidResponse.transactionId,
bidId: bidResponse.bidId || bidResponse.requestId,
placementId: bidResponse.params
? deepAccess(bidResponse, "params.0.placementId")
? deepAccess(bidResponse, 'params.0.placementId')
: null,
};
};
Expand Down Expand Up @@ -244,56 +244,56 @@ export const getDeviceType = () => {
navigator.userAgent.toLowerCase()
)
) {
return "tablet";
return 'tablet';
}
if (
/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(
navigator.userAgent.toLowerCase()
)
) {
return "mobile";
return 'mobile';
}
return "desktop";
return '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 'Microsoft 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 'Chrome';
} else if (navigator.userAgent.match('CriOS')) return 'Chrome';
else if (/Firefox/.test(navigator.userAgent)) return 'Firefox';
else if (
/Safari/.test(navigator.userAgent) &&
/Apple Computer/.test(navigator.vendor)
) {
return "Safari";
return 'Safari';
} else if (
/Trident/.test(navigator.userAgent) ||
/MSIE/.test(navigator.userAgent)
) {
return "Internet Explorer";
} else return "Others";
return 'Internet Explorer';
} else return 'Others';
};

/**
* 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 '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';
};

/**
Expand All @@ -319,32 +319,32 @@ const prepareSend = (auctionId) => {
{
path: winningBidPath,
requiredKeys: [
"winningBid",
"pageDetail",
"deviceDetail",
"floorDetail",
"auctionDetail",
"userDetail",
"consentDetail",
"pmacDetail",
"initOptions",
'winningBid',
'pageDetail',
'deviceDetail',
'floorDetail',
'auctionDetail',
'userDetail',
'consentDetail',
'pmacDetail',
'initOptions',
],
eventType: "win",
eventType: 'win',
},
{
path: auctionPath,
requiredKeys: [
"bids",
"pageDetail",
"deviceDetail",
"floorDetail",
"auctionDetail",
"userDetail",
"consentDetail",
"pmacDetail",
"initOptions",
'bids',
'pageDetail',
'deviceDetail',
'floorDetail',
'auctionDetail',
'userDetail',
'consentDetail',
'pmacDetail',
'initOptions',
],
eventType: "auction",
eventType: 'auction',
},
].forEach(({ path, requiredKeys, eventType }) => {
const data = Object.fromEntries(
Expand All @@ -357,7 +357,7 @@ const prepareSend = (auctionId) => {
return;
}
const pubxaiAnalyticsRequestUrl = buildUrl({
protocol: "https",
protocol: 'https',
hostname:
(auctionData.initOptions && auctionData.initOptions.hostName) ||
defaultHost,
Expand All @@ -374,7 +374,7 @@ const prepareSend = (auctionId) => {
};

const send = () => {
const toBlob = (d) => new Blob([JSON.stringify(d)], { type: "text/json" });
const toBlob = (d) => new Blob([JSON.stringify(d)], { type: 'text/json' });

Object.entries(sendCache).forEach(([requestUrl, events]) => {
let payloadStart = 0;
Expand All @@ -398,8 +398,8 @@ const send = () => {

// register event listener to send logs when user leaves page
if (hasSendBeaconSupport()) {
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "hidden") {
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
send();
}
});
Expand All @@ -423,7 +423,7 @@ pubxaiAnalyticsAdapter.enableAnalytics = (config) => {

adapterManager.registerAnalyticsAdapter({
adapter: pubxaiAnalyticsAdapter,
code: "pubxai",
code: 'pubxai',
});

export default pubxaiAnalyticsAdapter;
Loading

0 comments on commit 8cc7a9c

Please sign in to comment.