Skip to content

Commit

Permalink
remove AdStatisticsLink feature toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
jjtg-nav committed Apr 9, 2021
1 parent e161715 commit b2049ff
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 57 deletions.
20 changes: 0 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"request-promise": "^4.2.6",
"ua-parser-js": "^0.7.24",
"universal-cookie": "^4.0.4",
"unleash-client": "^3.4.0",
"whatwg-fetch": "^2.0.4"
},
"devDependencies": {
Expand Down
27 changes: 3 additions & 24 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const compression = require('compression');
const searchApiConsumer = require('./api/searchApiConsumer');
const htmlMeta = require('./common/htmlMeta');
const locationApiConsumer = require('./api/locationApiConsumer');
const { initialize } = require('unleash-client');

/* eslint no-console: 0 */

Expand Down Expand Up @@ -130,38 +129,18 @@ const renderSok = (htmlPages) => (
})
);

const unleash = initialize({
url: fasitProperties.UNLEASH_URL,
appName: 'pam-stillingsok'
})

const oneWeek = 604800;
const newCvRollbackFeatureToggle = `pam-cv.new-cv-rollback${process.env.NAIS_CLUSTER_NAME.includes('dev') ? '-dev' : ''}`;
const showAdStatisticsLinkToggle = `pam-stillingsok.show-add-statistics-link${process.env.NAIS_CLUSTER_NAME.includes('dev') ? '-dev' : ''}`;


const startServer = (htmlPages) => {
writeEnvironmentVariablesToFile();

server.use((req, res, next) => {
const oneWeek = 604800;

if (req.path.includes('internal')) {
return next();
}

if ((req && req.headers.cookie && !req.headers.cookie.includes('amplitudeIsEnabled')) || !req.headers.cookie){
res.cookie('amplitudeIsEnabled', true, { maxAge: oneWeek * 2, domain: '.nav.no' });
}
if ((req && req.headers.cookie && !req.headers.cookie.includes('showAdStatisticsLink'))) {
res.cookie('showAdStatisticsLink', unleash.isEnabled(showAdStatisticsLinkToggle, {}), { maxAge: oneWeek * 4, domain: '.nav.no' });
}

if ((req && req.headers.cookie
&& req.headers.cookie.includes('newCvRolloutGroup'))
// NOTE: Using pam-cv's feature toggle, since the rollback happens on both apps.
&& unleash.isEnabled(newCvRollbackFeatureToggle, {})) {

res.cookie('newCvRolloutGroup', false, { maxAge: oneWeek * 4, domain: '.nav.no' });
res.cookie('useNewCv', false, { maxAge: oneWeek * 4, domain: '.nav.no' })
}
next();
});

Expand Down
12 changes: 0 additions & 12 deletions src/common/components/AdStatisticsLink.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import * as React from "react";
import './AdStatisticsLink.less';
import logAmplitudeEvent from "../../amplitudeTracker";
import {useEffect, useState} from "react";
import Cookies from "universal-cookie";

const AD_STATISTICS_URL = 'https://data.nav.no/datapakke/703bc2e74c271ee895609ebd93c52460';

const AdStatisticsLink = () => {
const [showAdStatistics, setShowAdStatistics] = useState(false);

useEffect(() => {
const cookies = new Cookies();
setShowAdStatistics(cookies.get('showAdStatisticsLink') === 'true')
}, []);

const logAmplitudeEventAndRedirect = (event) => {
event.preventDefault();
Expand All @@ -22,10 +14,6 @@ const AdStatisticsLink = () => {
window.open(AD_STATISTICS_URL, "_blank")
};

if (!showAdStatistics) {
return null;
}

return (<a
href={AD_STATISTICS_URL}
className="AdStatisticsLink"
Expand Down

0 comments on commit b2049ff

Please sign in to comment.