Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion packages/app/src/app/overmind/internalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ export const handleError: Action<{
});
};

export const trackCurrentTeams: AsyncAction = async ({ state, effects }) => {
export const trackCurrentTeams: AsyncAction = async ({ effects }) => {
const { me } = await effects.gql.queries.teams({});
if (me) {
effects.analytics.setGroup(
Expand All @@ -526,3 +526,33 @@ export const trackCurrentTeams: AsyncAction = async ({ state, effects }) => {
);
}
};

const seenTermsKey = 'ACCEPTED_TERMS_CODESANDBOX';
export const showPrivacyPolicyNotification: Action = ({ effects, state }) => {
if (effects.browser.storage.get(seenTermsKey)) {
return;
}

if (!state.isFirstVisit) {
effects.analytics.track('Saw Privacy Policy Notification');
effects.notificationToast.add({
message:
'Hello, our privacy policy has been updated recently. What’s new? CodeSandbox emails. Please read and reach out.',
title: 'Updated Privacy',
status: NotificationStatus.NOTICE,
sticky: true,
actions: {
primary: [
{
label: 'Open Privacy Policy',
run: () => {
window.open('https://codesandbox.io/legal/privacy', '_blank');
},
},
],
},
});
}

effects.browser.storage.set(seenTermsKey, true);
};
25 changes: 1 addition & 24 deletions packages/app/src/app/overmind/onInitialize.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { NotificationStatus } from '@codesandbox/notifications';
import { OnInitialize } from '.';

export const onInitialize: OnInitialize = async (
{ state, effects, actions },
overmindInstance
) => {
const provideJwtToken = () => state.jwt || effects.jwt.get();
const seenTermsKey = 'ACCEPTED_TERMS_CODESANDBOX';

state.isFirstVisit = Boolean(
!effects.jwt.get() && !effects.browser.storage.get('hasVisited')
Expand Down Expand Up @@ -107,26 +105,5 @@ export const onInitialize: OnInitialize = async (

effects.preview.initialize(overmindInstance.reaction);

// show terms message on first visit since new terms
if (!effects.browser.storage.get(seenTermsKey) && !state.isFirstVisit) {
effects.analytics.track('Saw Privacy Policy Notification');
effects.notificationToast.add({
message:
'Hello, our privacy policy has been updated recently. What’s new? CodeSandbox emails. Please read and reach out.',
title: 'Updated Privacy',
status: NotificationStatus.NOTICE,
sticky: true,
actions: {
primary: [
{
label: 'Open Privacy Policy',
run: () => {
window.open('https://codesandbox.io/legal/privacy', '_blank');
},
},
],
},
});
}
effects.browser.storage.set(seenTermsKey, true);
actions.internal.showPrivacyPolicyNotification();
};
7 changes: 3 additions & 4 deletions packages/homepage/src/components/Toast/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/* eslint-disable jsx-a11y/control-has-associated-label */
import React, { useState, useEffect } from 'react';
import track from '@codesandbox/common/lib/utils/analytics';
import { Link } from 'gatsby';
import { AnimatePresence } from 'framer-motion';

import { ToastContainer } from './elements';

const key = 'ACCEPTED_TERMS_CODESANDBOX';
const Privacy = () => {
const key = 'ACCEPTED_TERMS_CODESANDBOX';
const [show, setShow] = useState(false);

useEffect(() => {
const hasSeen = !!window.localStorage.getItem(key);
const hasSeen = Boolean(window.localStorage.getItem(key));
if (!hasSeen) {
setShow(true);
window.localStorage.setItem(key, true);
Expand All @@ -33,7 +32,7 @@ const Privacy = () => {
<Link to="/legal/privacy">Privacy Policy</Link>
<button
type="button"
ariaLabel="Close"
aria-label="Close"
onClick={() => setShow(false)}
/>
</ToastContainer>
Expand Down