fix: remove survery cookie (#937)

This commit is contained in:
Attiya Ishaque
2023-06-08 18:56:00 +05:00
committed by GitHub
parent 5aec091156
commit 5ebd22f088
10 changed files with 5 additions and 45 deletions

1
.env
View File

@@ -16,7 +16,6 @@ SITE_NAME=null
INFO_EMAIL=''
# ***** Cookies *****
REGISTER_CONVERSION_COOKIE_NAME=null
USER_SURVEY_COOKIE_NAME=null
# ***** Links *****
LOGIN_ISSUE_SUPPORT_LINK=''
AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK=null

View File

@@ -23,7 +23,6 @@ INFO_EMAIL='info@example.com'
REGISTER_CONVERSION_COOKIE_NAME='openedx-user-register-conversion'
SESSION_COOKIE_DOMAIN='localhost'
USER_INFO_COOKIE_NAME='edx-user-info'
USER_SURVEY_COOKIE_NAME='openedx-user-survey-type'
# ***** Links *****
LOGIN_ISSUE_SUPPORT_LINK='http://localhost:18000/login-issue-support-url'
TOS_AND_HONOR_CODE='http://localhost:18000/honor'

View File

@@ -16,7 +16,6 @@ ORDER_HISTORY_URL='http://localhost:1996/orders'
REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh'
SEGMENT_KEY=''
SITE_NAME='Your Platform Name Here'
USER_SURVEY_COOKIE_NAME='openedx-user-survey-type'
REGISTER_CONVERSION_COOKIE_NAME='openedx-user-register-conversion'
APP_ID=''
MFE_CONFIG_API_URL=''

View File

@@ -2,7 +2,6 @@ const configuration = {
// Cookies related configs
SESSION_COOKIE_DOMAIN: process.env.SESSION_COOKIE_DOMAIN,
REGISTER_CONVERSION_COOKIE_NAME: process.env.REGISTER_CONVERSION_COOKIE_NAME || null,
USER_SURVEY_COOKIE_NAME: process.env.USER_SURVEY_COOKIE_NAME || null,
// Features
DISABLE_ENTERPRISE_LOGIN: process.env.DISABLE_ENTERPRISE_LOGIN || '',
ENABLE_DYNAMIC_REGISTRATION_FIELDS: process.env.ENABLE_DYNAMIC_REGISTRATION_FIELDS || false,

View File

@@ -1,7 +1,7 @@
import { getConfig } from '@edx/frontend-platform';
import Cookies from 'universal-cookie';
export function setCookie(cookieName, cookieValue, cookieExpiry) {
export default function setCookie(cookieName, cookieValue, cookieExpiry) {
const cookies = new Cookies();
const options = { domain: getConfig().SESSION_COOKIE_DOMAIN, path: '/' };
if (cookieExpiry) {
@@ -9,13 +9,3 @@ export function setCookie(cookieName, cookieValue, cookieExpiry) {
}
cookies.set(cookieName, cookieValue, options);
}
export default function setSurveyCookie(surveyType) {
const cookieName = getConfig().USER_SURVEY_COOKIE_NAME;
if (cookieName) {
const signupTimestamp = (new Date()).getTime();
// set expiry to exactly 24 hours from now
const cookieExpiry = new Date(signupTimestamp + 1 * 864e5);
setCookie(cookieName, surveyType, cookieExpiry);
}
}

View File

@@ -7,4 +7,4 @@ export {
windowScrollTo,
} from './dataUtils';
export { default as AsyncActionType } from './reduxUtils';
export { default as setSurveyCookie, setCookie } from './cookies';
export { default as setCookie } from './cookies';

View File

@@ -36,7 +36,6 @@ import {
getAllPossibleQueryParams,
getTpaHint,
getTpaProvider,
setSurveyCookie,
updatePathWithQueryParams,
windowScrollTo,
} from '../data/utils';
@@ -230,9 +229,6 @@ class LoginPage extends React.Component {
};
tpaAuthenticationError.errorCode = TPA_AUTHENTICATION_FAILURE;
}
if (this.props.loginResult.success) {
setSurveyCookie('login');
}
return (
<>

View File

@@ -30,9 +30,6 @@ const IntlLoginPage = injectIntl(LoginPage);
const mockStore = configureStore();
describe('LoginPage', () => {
mergeConfig({
USER_SURVEY_COOKIE_NAME: process.env.USER_SURVEY_COOKIE_NAME,
});
let props = {};
let store = {};
let loginFormData = {};
@@ -685,21 +682,6 @@ describe('LoginPage', () => {
expect(loginPage.find('LoginPage').state('isSubmitted')).toEqual(true);
});
it('should set login survey cookie', () => {
store = mockStore({
...initialState,
login: {
...initialState.login,
loginResult: {
success: true,
},
},
});
renderer.create(reduxWrapper(<IntlLoginPage {...props} />));
expect(document.cookie).toMatch(`${getConfig().USER_SURVEY_COOKIE_NAME}=login`);
});
it('should reset login form errors', () => {
const errorState = { emailOrUsername: '', password: '' };
store.dispatch = jest.fn(store.dispatch);

View File

@@ -50,7 +50,7 @@ import {
DEFAULT_STATE, INVALID_NAME_REGEX, LETTER_REGEX, NUMBER_REGEX, PENDING_STATE, REGISTER_PAGE, VALID_EMAIL_REGEX,
} from '../data/constants';
import {
getAllPossibleQueryParams, getTpaHint, getTpaProvider, setCookie, setSurveyCookie,
getAllPossibleQueryParams, getTpaHint, getTpaProvider, setCookie,
} from '../data/utils';
const emailRegex = new RegExp(VALID_EMAIL_REGEX, 'i');
@@ -224,10 +224,8 @@ const RegistrationPage = (props) => {
useEffect(() => {
if (registrationResult.success) {
// TODO: Do we still need this cookie?
setSurveyCookie('register');
// This was added to fire social media conversion pixels through Google tag manager.
setCookie(getConfig().REGISTER_CONVERSION_COOKIE_NAME, true);
setCookie('authn-returning-user');
// Fire GTM event used for integration with impact.com
window.dataLayer = window.dataLayer || [];

View File

@@ -46,7 +46,6 @@ describe('RegistrationPage', () => {
mergeConfig({
PRIVACY_POLICY: 'https://privacy-policy.com',
TOS_AND_HONOR_CODE: 'https://tos-and-honot-code.com',
USER_SURVEY_COOKIE_NAME: process.env.USER_SURVEY_COOKIE_NAME,
REGISTER_CONVERSION_COOKIE_NAME: process.env.REGISTER_CONVERSION_COOKIE_NAME,
});
@@ -624,7 +623,7 @@ describe('RegistrationPage', () => {
expect(registrationPage.find('input#password').length).toEqual(0);
});
it('should set registration survey cookie', () => {
it('should check registration conversion cookie', () => {
store = mockStore({
...initialState,
register: {
@@ -636,7 +635,6 @@ describe('RegistrationPage', () => {
});
renderer.create(reduxWrapper(<IntlRegistrationPage {...props} />));
expect(document.cookie).toMatch(`${getConfig().USER_SURVEY_COOKIE_NAME}=register`);
expect(document.cookie).toMatch(`${getConfig().REGISTER_CONVERSION_COOKIE_NAME}=true`);
});