Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import JSCookie from 'js-cookie';
/*
* This module provides utilities for managing click tracking data in a cookie
*/
export const COOKIE_NAME = 'click-track'; // must remain in sync with Meetup Classic implementation
const BrowserCookies = JSCookie.withConverter({
read: value => value,
write: value =>
encodeURIComponent(value).replace(
/[!'()*]/g,
c => `%${c.charCodeAt(0).toString(16)}`
),
});
export const setClickCookie = clickTracking => {
const domain = window.location.host.replace(/[^.]+/, ''); // strip leading subdomain, e.g. www or beta2
const cookieVal = JSON.stringify(clickTracking);
BrowserCookies.set(COOKIE_NAME, cookieVal, { domain });
};
export const getClickCookie = () => BrowserCookies.get(COOKIE_NAME);
export const appendClick = clickData =>
import JSCookie from 'js-cookie';
/*
* This module provides utilities for managing click tracking data in Redux
* state an saving that data to a browser cookie
*/
export const COOKIE_NAME = 'click-track'; // must remain in sync with Meetup Classic implementation
const BrowserCookies = JSCookie.withConverter({
read: value => value,
write: value =>
encodeURIComponent(value).replace(
/[!'()*]/g,
c => `%${c.charCodeAt(0).toString(16)}`
),
});
export const setClickCookie = clickTracking => {
const domain = window.location.host.replace(/[^.]+/, ''); // strip leading subdomain, e.g. www or beta2
const cookieVal = JSON.stringify(clickTracking);
BrowserCookies.set(COOKIE_NAME, cookieVal, { domain });
};
export const CLICK_TRACK_ACTION = 'CLICK_TRACK';
export const CLICK_TRACK_CLEAR_ACTION = 'CLICK_TRACK_CLEAR';