-
- {item.title}
-
- { listingMode === "normal" ?
- <>
-
- {format(item.date)}
- {item.location}
-
-
-
-
-
- > :
-
- {item.location}
-
- }
- >
- )}
- />
- )
-}
-
-function JobsCard({ analyticsTag, label, icon, withAds }) {
- const preferences = useContext(PreferencesContext)
-
- const { userSelectedTags } = preferences
-
- const [refresh, setRefresh] = useState(true)
-
- const fetchJobs = async () => {
- const promises = userSelectedTags.map((tag) => {
- if (tag['stackoverflowValues']) {
- return stackoverflowApi.getJobs(tag['stackoverflowValues'][0])
- }
- return []
- })
- const results = await Promise.allSettled(promises)
-
- return results
- .map((res, index) => {
- let value = res.value
- if (res.status === 'rejected') {
- value = []
- }
- return value.map((c) => ({
- ...c,
- tag: userSelectedTags[index],
- date: new Date(c.isoDate),
- }))
- })
- .flat()
- .sort((a, b) => b.date - a.date)
- }
-
- useEffect(() => {
- setRefresh(!refresh)
- }, [userSelectedTags])
-
- const renderItem = (item, index) => (
-
- )
-
- return (
- {icon}}
- link="https://stackoverflow.com/jobs"
- title={label}>
-
-
- )
-}
-
-export default JobsCard
\ No newline at end of file
diff --git a/src/components/CarbonAd.js b/src/components/CarbonAd.js
index 89ae7d7a..de7997af 100644
--- a/src/components/CarbonAd.js
+++ b/src/components/CarbonAd.js
@@ -1,20 +1,70 @@
-import React, { Component } from 'react';
-import './CarbonAd.css';
+import axios from 'axios'
+import React, { useEffect, useState } from 'react'
+import './CarbonAd.css'
+import { getBaseApi } from '../utils/DataUtils'
-class CarbonAd extends Component {
- componentDidMount() {
- const carbon_wrapper = document.querySelector('.carbon-ad-wrapper')
- const script = document.createElement('script')
- script.src = process.env.PUBLIC_URL + '/carbon.js?serve=CESDP23I&placement=hackertabdev'
- script.async = true
- script.id = '_carbonads_js'
+export default function CarbonAd() {
+ const [ad, setAd] = useState()
- carbon_wrapper.appendChild(script)
- }
+ useEffect(() => {
+ const setup = async () => {
+ const userAgent = new URLSearchParams(navigator.userAgent).toString()
+ const request = await axios.get(`${getBaseApi('')}/monetization/?useragent=${userAgent}`)
+ if (request.data) {
+ setAd(request.data.ads[0])
+ }
+ }
+ setup()
+ }, [])
- render() {
- return
+ const prependHTTP = (url) => {
+ url = decodeURIComponent(url)
+ if (!/^(?:f|ht)tps?\:\/\//.test(url)) {
+ url = 'https://' + url
+ }
+ return url
}
-}
-export default CarbonAd;
+ return (
+
+ )
+}
diff --git a/src/configuration/AppWrapper.js b/src/configuration/AppWrapper.js
index 30c7208c..c0c849e0 100644
--- a/src/configuration/AppWrapper.js
+++ b/src/configuration/AppWrapper.js
@@ -34,6 +34,7 @@ export default function AppWrapper({ children }) {
userSelectedTags: configuration.supportedTags.filter((tag) =>
preferences.userSelectedTags.includes(tag.value)
),
+ cards: preferences.cards.filter((card) => card.name != 'stackoverflow'),
}
return {
...initialState,
diff --git a/src/configuration/ConfigurationContext.js b/src/configuration/ConfigurationContext.js
index 78ecafa6..29024812 100644
--- a/src/configuration/ConfigurationContext.js
+++ b/src/configuration/ConfigurationContext.js
@@ -7,7 +7,6 @@ const ConfigurationContext = React.createContext({
label: 'Javascript',
githubValues: ['javascript'],
confsValues: ['javascript'],
- stackoverflowValues: ['javascript'],
devtoValues: ['javascript'],
hashnodeValues: ['javascript'],
},
diff --git a/src/services/cachedRequest.js b/src/services/cachedRequest.js
index 68ae70c4..91d56a21 100644
--- a/src/services/cachedRequest.js
+++ b/src/services/cachedRequest.js
@@ -1,11 +1,10 @@
import axios from 'axios';
import AppStorage from "./localStorage";
-
-var packageFile = require("../../package.json");
+import { getBaseApi } from '../utils/DataUtils'
const axiosInstance = axios.create({
- baseURL: process.env.NODE_ENV === "production" ? packageFile.proxy : null,
-});
+ baseURL: getBaseApi(null),
+})
const isWebVersion = !!+process.env.REACT_APP_WEB_BUILD
const cachedRequest = async (url) => {
diff --git a/src/services/stackoverflow.js b/src/services/stackoverflow.js
deleted file mode 100644
index 976b0fc3..00000000
--- a/src/services/stackoverflow.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import cachedRequest from './cachedRequest';
-
-const getJobs = async (tag) => {
- const url = `/data/stackoverflow/${tag}.json`;
- const data = await cachedRequest(url);
- return data
-}
-
-export default {
- getJobs: getJobs,
-}
diff --git a/src/utils/Analytics.js b/src/utils/Analytics.js
index de546cdf..2359279f 100644
--- a/src/utils/Analytics.js
+++ b/src/utils/Analytics.js
@@ -90,8 +90,8 @@ const trackException = (exceptionMessage, fatal) => {
console.log('Analytics debug payload', payload.toString())
return
}
-
- navigator.sendBeacon('https://www.google-analytics.com/collect', payload.toString())
+ // Disabled
+ //navigator.sendBeacon('https://www.google-analytics.com/collect', payload.toString())
}
const getResolution = () => {
const realWidth = window.screen.width
@@ -133,8 +133,8 @@ const trackEvent = (category, action, label) => {
console.log('Analytics debug payload', payload.toString())
return
}
-
- navigator.sendBeacon('https://www.google-analytics.com/collect', payload.toString())
+ // Disabled
+ //navigator.sendBeacon('https://www.google-analytics.com/collect', payload.toString())
}
const getRandomUserId = () => {
diff --git a/src/utils/DataUtils.js b/src/utils/DataUtils.js
index f4c9c9c9..d7ea61fc 100644
--- a/src/utils/DataUtils.js
+++ b/src/utils/DataUtils.js
@@ -1,3 +1,5 @@
+const packageFile = require('../../package.json')
+
export const mergeMultipleDataSources = async (promises, maxCount) => {
let promisesRequests = await Promise.allSettled(promises)
let promisesValues = promisesRequests
@@ -20,3 +22,7 @@ export const mergeMultipleDataSources = async (promises, maxCount) => {
}
return data
}
+
+export const getBaseApi = (fallback) => {
+ return process.env.NODE_ENV === 'production' ? packageFile.proxy : fallback
+}