This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Cookies and privacy policy (#3517)
* feat: link Beamer with the analytics cookies. Display different CookieBanner warning messages. * refactor: extract to an object cookie warning messages * refactor: clean up cookies reducer Co-authored-by: Aaron Cook <iamacook@users.noreply.github.com> * fix: update Beamer cookie alert copy * fix: handle Beamer with update cookies Co-authored-by: Aaron Cook <iamacook@users.noreply.github.com>
- Loading branch information
1 parent
60449bd
commit db20b66
Showing
7 changed files
with
97 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
export const COOKIES_KEY = 'COOKIES' | ||
export const COOKIES_KEY_INTERCOM = `${COOKIES_KEY}_INTERCOM` | ||
|
||
export enum COOKIE_IDS { | ||
INTERCOM = 'INTERCOM', | ||
BEAMER = 'BEAMER', | ||
} | ||
|
||
export const COOKIE_ALERTS: Record<COOKIE_IDS, string> = { | ||
INTERCOM: 'You attempted to open the customer support chat. Please accept the community support & updates cookies', | ||
BEAMER: "You attempted to open the What's New section. Please accept the community support & updates cookies.", | ||
} | ||
|
||
export type BannerCookiesType = { | ||
acceptedNecessary: boolean | ||
acceptedIntercom: boolean | ||
acceptedSupportAndUpdates: boolean | ||
acceptedAnalytics: boolean | ||
} | ||
export type IntercomCookieType = { | ||
userId: string | ||
} | ||
export const COOKIES_KEY = 'COOKIES' | ||
export const COOKIES_KEY_INTERCOM = `${COOKIES_KEY}_INTERCOM` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
import { Map } from 'immutable' | ||
import { handleActions } from 'redux-actions' | ||
import { OPEN_COOKIE_BANNER } from 'src/logic/cookies/store/actions/openCookieBanner' | ||
|
||
import { COOKIE_IDS } from 'src/logic/cookies/model/cookie' | ||
import { COOKIE_ACTIONS } from 'src/logic/cookies/store/actions/openCookieBanner' | ||
|
||
export const COOKIES_REDUCER_ID = 'cookies' | ||
|
||
type CookieState = Map<string, any> | ||
export type CookieState = { | ||
cookieBannerOpen: boolean | ||
key?: COOKIE_IDS | ||
} | ||
|
||
const initialState: CookieState = { | ||
cookieBannerOpen: false, | ||
key: undefined, | ||
} | ||
|
||
export type OpenCookieBannerPayload = { cookieBannerOpen: boolean; intercomAlertDisplayed?: boolean } | ||
export type OpenCookieBannerPayload = CookieState | ||
|
||
const cookiesReducer = handleActions<CookieState, OpenCookieBannerPayload>( | ||
{ | ||
[OPEN_COOKIE_BANNER]: (state, action) => { | ||
const { intercomAlertDisplayed = false, cookieBannerOpen } = action.payload | ||
return state.set('cookieBannerOpen', { intercomAlertDisplayed, cookieBannerOpen }) | ||
[COOKIE_ACTIONS.OPEN_BANNER]: (_, action) => { | ||
return action.payload | ||
}, | ||
[COOKIE_ACTIONS.CLOSE_BANNER]: () => { | ||
return initialState | ||
}, | ||
}, | ||
Map(), | ||
initialState, | ||
) | ||
|
||
export default cookiesReducer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { COOKIES_REDUCER_ID } from 'src/logic/cookies/store/reducer/cookies' | ||
import { CookieState, COOKIES_REDUCER_ID } from 'src/logic/cookies/store/reducer/cookies' | ||
import { AppReduxState } from 'src/store' | ||
|
||
export const cookieBannerOpen = (state) => state[COOKIES_REDUCER_ID].get('cookieBannerOpen') | ||
export const cookieBannerState = (state: AppReduxState): CookieState => state[COOKIES_REDUCER_ID] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters