Skip to content

Commit

Permalink
Merge branch 'main' into 2982-add-namespace-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
yitsushi authored Dec 19, 2022
2 parents f906700 + 31c5679 commit 05969ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
23 changes: 20 additions & 3 deletions ui/components/Pendo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ declare global {
}
}

const key = "VyzGoWoKvtJHyTnU+GVhDe+wU9bwZDH87bp505/0f/2UIpHzB+tmyZmfsH8/iJoH";
const pendoKey = "pendo";
const hashKey =
"VyzGoWoKvtJHyTnU+GVhDe+wU9bwZDH87bp505/0f/2UIpHzB+tmyZmfsH8/iJoH";

export interface Props {
/** Value to use as default if the telemetry flag cannot be read. */
Expand All @@ -33,12 +35,27 @@ export default function Pendo({ defaultTelemetryFlag }: Props) {
return;
}

let visitorId = "";
let pendoKeys: string[] = [];

if (!window.localStorage) {
console.warn("no local storage found");
} else {
pendoKeys = Object.keys(window.localStorage).filter(
(key) => key.toLowerCase().indexOf(pendoKey) != -1
);
}

const userEmail = userInfo?.email;

if (!userEmail && pendoKeys.length == 0) {
return;
}

let visitorId = "";

if (userEmail) {
const hasher = shake128.create(128);
hasher.update(key);
hasher.update(hashKey);
hasher.update(userEmail);
visitorId = Mnemonic.fromHex(hasher.hex()).toWords().join("-");
}
Expand Down
15 changes: 0 additions & 15 deletions ui/pages/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { useFeatureFlags } from "../hooks/featureflags";
import images from "../lib/images";
import { theme } from "../lib/theme";

const pendoKey = "pendo";

const SignInBackgroundAnimation = React.lazy(
() => import("../components/Animations/SignInBackground")
);
Expand Down Expand Up @@ -84,19 +82,6 @@ function SignIn() {

const handleUserPassSubmit = () => signIn({ username, password });

React.useEffect(() => {
if (!window.localStorage) {
console.warn("no local storage found");
return;
}

const pendoKeys = Object.keys(window.localStorage).filter(
(key) => key.toLowerCase().indexOf(pendoKey) != -1
);

pendoKeys.forEach((key) => window.localStorage.removeItem(key));
}, []);

return (
<Flex
tall
Expand Down

0 comments on commit 05969ad

Please sign in to comment.