groups: Set browserId in local state on mount of app
@@ -5,6 +5,7 @@ import * as React from 'react';
import Helmet from 'react-helmet';
import { Router, withRouter } from 'react-router-dom';
import styled, { ThemeProvider } from 'styled-components';
+import FingerprintJS from '@fingerprintjs/fingerprintjs';
import gcpManager from '~/logic/lib/gcpManager';
import { svgDataURL } from '~/logic/lib/util';
import history from '~/logic/lib/history';
@@ -36,6 +37,13 @@ function ensureValidHex(color) {
return parsedColor.startsWith('#') ? parsedColor : `#${parsedColor}`;
}
+const getId = async () => {
+ const fpPromise = FingerprintJS.load();
+ const fp = await fpPromise;
+ const result = await fp.get();
+ return result.visitorId;
+};
+
interface RootProps {
display: SettingsState['display'];
}
@@ -97,6 +105,10 @@ const App: React.FunctionComponent = () => {
bootstrapApi();
getShallowChildren(`~${window.ship}`, 'dm-inbox');
+ getId().then((value) => {
+ useLocalState.setState({ browserId: value });
+ });
+
getAll();
gcpManager.start();
Mousetrap.bindGlobal(['command+/', 'ctrl+/'], (e) => {
