removed duplicate user object (#513)

removed id field which is never populated
added help modal in applications page and intercom to load in help modal
shutdown intercom on signout to clear existing chats

Co-authored-by: Nikhil Nandagopal <nikhil@appsmith.com>
This commit is contained in:
Nikhil Nandagopal 2020-09-09 10:48:36 +05:30 committed by GitHub
parent 34ff72b505
commit c421ab12b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 88 additions and 85 deletions

View File

@ -16,8 +16,8 @@
"@craco/craco": "^5.6.1",
"@manaflair/redux-batch": "^1.0.0",
"@optimizely/optimizely-sdk": "^4.0.0",
"@sentry/react": "^5.22.2",
"@sentry/tracing": "^5.22.2",
"@sentry/react": "^5.22.3",
"@sentry/tracing": "^5.22.3",
"@sentry/webpack-plugin": "^1.12.1",
"@types/chance": "^1.0.7",
"@types/lodash": "^4.14.120",

View File

@ -13,8 +13,10 @@ import { getAppsmithConfigs } from "configs";
import { LayersContext } from "constants/Layers";
import { connect } from "react-redux";
import { AppState } from "reducers";
import { getCurrentUser } from "selectors/usersSelectors";
import { User } from "constants/userConstants";
const { algolia } = getAppsmithConfigs();
const { algolia, cloudHosting, intercomAppID } = getAppsmithConfigs();
const HelpButton = styled.button<{
highlight: boolean;
layer: number;
@ -54,10 +56,28 @@ const HelpIcon = HelpIcons.HELP_ICON;
type Props = {
isHelpModalOpen: boolean;
dispatch: any;
user?: User;
};
class HelpModal extends React.Component<Props> {
static contextType = LayersContext;
componentDidMount() {
const { user } = this.props;
if (cloudHosting && intercomAppID && window.Intercom) {
window.Intercom("boot", {
// eslint-disable-next-line @typescript-eslint/camelcase
app_id: intercomAppID,
// eslint-disable-next-line @typescript-eslint/camelcase
user_id: user?.username,
// eslint-disable-next-line @typescript-eslint/camelcase
custom_launcher_selector: "#intercom-trigger",
name: user?.name,
email: user?.email,
});
}
}
render() {
const { dispatch, isHelpModalOpen } = this.props;
const layers = this.context;
@ -104,6 +124,7 @@ class HelpModal extends React.Component<Props> {
const mapStateToProps = (state: AppState) => ({
isHelpModalOpen: getHelpModalOpen(state),
user: getCurrentUser(state),
});
export default connect(mapStateToProps)(HelpModal);

View File

@ -1,12 +1,15 @@
export const ANONYMOUS_USERNAME = "anonymousUser";
type Gender = "MALE" | "FEMALE";
export type User = {
id: string;
email: string;
currentOrganizationId: string;
organizationIds: string[];
applications: UserApplication[];
username: string;
name: string;
gender: Gender;
};
export interface UserApplication {

View File

@ -39,6 +39,7 @@ import {
import { Directions } from "utils/helpers";
import { HeaderIcons } from "icons/HeaderIcons";
import { duplicateApplication } from "actions/applicationActions";
import HelpModal from "components/designSystems/appsmith/help/HelpModal";
const OrgDropDown = styled.div`
display: flex;
@ -337,6 +338,7 @@ class Applications extends Component<
</OrgSection>
);
})}
<HelpModal />
</PageWrapper>
);
}

View File

@ -34,14 +34,11 @@ import {
WIDGETS_SEARCH_ID,
} from "constants/Explorer";
import CenteredWrapper from "components/designSystems/appsmith/CenteredWrapper";
import { getAppsmithConfigs } from "configs";
import { getCurrentUser } from "selectors/usersSelectors";
import { User } from "constants/userConstants";
import ConfirmRunModal from "pages/Editor/ConfirmRunModal";
import * as Sentry from "@sentry/react";
const { cloudHosting, intercomAppID } = getAppsmithConfigs();
type EditorProps = {
currentApplicationId?: string;
currentPageId?: string;
@ -85,7 +82,6 @@ class Editor extends Component<Props> {
};
componentDidMount() {
const { user } = this.props;
editorInitializer().then(() => {
this.setState({ registered: true });
});
@ -93,21 +89,8 @@ class Editor extends Component<Props> {
if (applicationId && pageId) {
this.props.initEditor(applicationId, pageId);
}
if (cloudHosting && intercomAppID && window.Intercom) {
window.Intercom("boot", {
// eslint-disable-next-line @typescript-eslint/camelcase
app_id: intercomAppID,
// eslint-disable-next-line @typescript-eslint/camelcase
custom_launcher_selector: "#intercom-trigger",
name: user?.username,
email: user?.email,
});
}
}
componentDidUpdate(previously: Props) {
if (cloudHosting && intercomAppID && window.Intercom) {
window.Intercom("update");
}
if (
previously.isPublishing &&
!(this.props.isPublishing || this.props.errorPublishing)

View File

@ -33,7 +33,7 @@ const usersReducer = createReducer(initialState, {
action: ReduxAction<User>,
) => {
const users = [...state.users];
const userIndex = _.findIndex(users, { id: action.payload.id });
const userIndex = _.findIndex(users, { username: action.payload.username });
if (userIndex > -1) {
users[userIndex] = action.payload;
} else {
@ -54,7 +54,7 @@ const usersReducer = createReducer(initialState, {
action: ReduxAction<User>,
) => {
const users = [...state.list];
const userIndex = _.findIndex(users, { id: action.payload.id });
const userIndex = _.findIndex(users, { username: action.payload.username });
if (userIndex > -1) {
users[userIndex] = action.payload;
} else {

View File

@ -4,6 +4,7 @@ import FeatureFlag from "./featureFlags";
import smartlookClient from "smartlook-client";
import { getAppsmithConfigs } from "configs";
import * as Sentry from "@sentry/react";
import { User } from "../constants/userConstants";
export type EventName =
| "LOGIN_CLICK"
@ -65,16 +66,6 @@ export type EventName =
| "PROPERTY_PANE_OPEN_CLICK"
| "PROPERTY_PANE_CLOSE_CLICK";
export type Gender = "MALE" | "FEMALE";
export interface User {
username: string;
name: string;
email: string;
gender: Gender;
currentOrganizationId?: string;
applications: any[];
}
function getApplicationId(location: Location) {
const pathSplit = location.pathname.split("/");
const applicationsIndex = pathSplit.findIndex(
@ -204,6 +195,9 @@ class AnalyticsUtil {
static reset() {
const windowDoc: any = window;
if (windowDoc.Intercom) {
windowDoc.Intercom("shutdown");
}
windowDoc.analytics && windowDoc.analytics.reset();
windowDoc.mixpanel && windowDoc.mixpanel.reset();
}

View File

@ -2719,14 +2719,14 @@
dependencies:
any-observable "^0.3.0"
"@sentry/browser@5.22.2":
version "5.22.2"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.22.2.tgz#c37c61c8612a169059ddcd8c08cd09441da7776c"
integrity sha512-kkNRFMcNErtWvz9WI0bG5Va2W+mRWhk5CxaJKWUMdMcGR2rIrl3D+kcMdpYDi9tNYPHUdUzTCb3vJQfO8o6TbA==
"@sentry/browser@5.22.3":
version "5.22.3"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.22.3.tgz#7a64bd1cf01bf393741a3e4bf35f82aa927f5b4e"
integrity sha512-2TzE/CoBa5ZkvxJizDdi1Iz1ldmXSJpFQ1mL07PIXBjCt0Wxf+WOuFSj5IP4L40XHfJE5gU8wEvSH0VDR8nXtA==
dependencies:
"@sentry/core" "5.22.2"
"@sentry/types" "5.22.2"
"@sentry/utils" "5.22.2"
"@sentry/core" "5.22.3"
"@sentry/types" "5.22.3"
"@sentry/utils" "5.22.3"
tslib "^1.9.3"
"@sentry/cli@^1.55.0":
@ -2740,69 +2740,69 @@
progress "^2.0.3"
proxy-from-env "^1.1.0"
"@sentry/core@5.22.2":
version "5.22.2"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.22.2.tgz#3b57300d92c13163c26174311ad82482a08b9266"
integrity sha512-Tj3FlHiqK8uveKh56QP3PhNNrH13LTWqN1TwRwE2B2FLiqwIHGmJsCQNfyslQdBAkNeGRnnQrQxqH53KeuJGGA==
"@sentry/core@5.22.3":
version "5.22.3"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.22.3.tgz#030f435f2b518f282ba8bd954dac90cd70888bd7"
integrity sha512-eGL5uUarw3o4i9QUb9JoFHnhriPpWCaqeaIBB06HUpdcvhrjoowcKZj1+WPec5lFg5XusE35vez7z/FPzmJUDw==
dependencies:
"@sentry/hub" "5.22.2"
"@sentry/minimal" "5.22.2"
"@sentry/types" "5.22.2"
"@sentry/utils" "5.22.2"
"@sentry/hub" "5.22.3"
"@sentry/minimal" "5.22.3"
"@sentry/types" "5.22.3"
"@sentry/utils" "5.22.3"
tslib "^1.9.3"
"@sentry/hub@5.22.2":
version "5.22.2"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.22.2.tgz#812c8250970e44c63ee2bf1f779777d32dd88f54"
integrity sha512-6McBsonfpOY5hzlowzDfdLZklFQ1wWTGtiA0eByKxS/H1GePJc+UUSsu6D3bZJG0bIjFoq5vxLQFSZq6C7BPlQ==
"@sentry/hub@5.22.3":
version "5.22.3"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.22.3.tgz#08309a70d2ea8d5e313d05840c1711f34f2fffe5"
integrity sha512-INo47m6N5HFEs/7GMP9cqxOIt7rmRxdERunA3H2L37owjcr77MwHVeeJ9yawRS6FMtbWXplgWTyTIWIYOuqVbw==
dependencies:
"@sentry/types" "5.22.2"
"@sentry/utils" "5.22.2"
"@sentry/types" "5.22.3"
"@sentry/utils" "5.22.3"
tslib "^1.9.3"
"@sentry/minimal@5.22.2":
version "5.22.2"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.22.2.tgz#bb050a49158c48596094184cff2806ce8cb63c9d"
integrity sha512-jfth6bY19FXE/kQc6hLBCKg5CjfX1MG+weyEXnPFstCb5JFMvSt6YPRI3OsY1hG3rQLxTX0mVSbe2YrBJE5kXA==
"@sentry/minimal@5.22.3":
version "5.22.3"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.22.3.tgz#706e4029ae5494123d3875c658ba8911aa5cc440"
integrity sha512-HoINpYnVYCpNjn2XIPIlqH5o4BAITpTljXjtAftOx6Hzj+Opjg8tR8PWliyKDvkXPpc4kXK9D6TpEDw8MO0wZA==
dependencies:
"@sentry/hub" "5.22.2"
"@sentry/types" "5.22.2"
"@sentry/hub" "5.22.3"
"@sentry/types" "5.22.3"
tslib "^1.9.3"
"@sentry/react@^5.22.2":
version "5.22.2"
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-5.22.2.tgz#8a0f9ee475659faf780080569ca7c7c5cb92b218"
integrity sha512-DgpLWZV5htumjXaE13E/KMODwKyr56bNtk1gaTOPbm368b6zdcM/bwutdNQSTuNlhkJ4bhnhpVs7OzErJkcDLw==
"@sentry/react@^5.22.3":
version "5.22.3"
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-5.22.3.tgz#ed692f9e2aff718da6cd15d2941ddda4f1d63385"
integrity sha512-Or/tLayuxpOJhIWOXiDKdaJQZ981uRS9NT0QcPvU+Si1qTElSqtH1zB94GlwhgpglkbmLPiYq6VPrG2HOiZ79Q==
dependencies:
"@sentry/browser" "5.22.2"
"@sentry/minimal" "5.22.2"
"@sentry/types" "5.22.2"
"@sentry/utils" "5.22.2"
"@sentry/browser" "5.22.3"
"@sentry/minimal" "5.22.3"
"@sentry/types" "5.22.3"
"@sentry/utils" "5.22.3"
hoist-non-react-statics "^3.3.2"
tslib "^1.9.3"
"@sentry/tracing@^5.22.2":
version "5.22.2"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-5.22.2.tgz#6a326bf43b3491c3e462330f8e7d6cd52a975a2d"
integrity sha512-M4F4CN85luWoHBuBiQMk2/dtpn5L2CriBTcLsKQNkA/fk6lv8CbE1WZ/SkCMWzK4hxo5I2vSyzLlb2OwcMHmdQ==
"@sentry/tracing@^5.22.3":
version "5.22.3"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-5.22.3.tgz#9b5a376e3164c007a22e8642ec094104468cac0c"
integrity sha512-Zp59kMCk5v56ZAyErqjv/QvGOWOQ5fRltzeVQVp8unIDTk6gEFXfhwPsYHOokJe1mfkmrgPDV6xAkYgtL3KCDQ==
dependencies:
"@sentry/hub" "5.22.2"
"@sentry/minimal" "5.22.2"
"@sentry/types" "5.22.2"
"@sentry/utils" "5.22.2"
"@sentry/hub" "5.22.3"
"@sentry/minimal" "5.22.3"
"@sentry/types" "5.22.3"
"@sentry/utils" "5.22.3"
tslib "^1.9.3"
"@sentry/types@5.22.2":
version "5.22.2"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.22.2.tgz#32d7f82537afe7712971fd6222c7744f0d8a27fe"
integrity sha512-Ko9pri0D0TNaSHocLVLQQZlnTtMXrBhP5AZYjB193aYqc1x52dFchQlhiKLEgyFCKjTEIlD/J9ZD7QkQoeYT+A==
"@sentry/types@5.22.3":
version "5.22.3"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.22.3.tgz#d1d547b30ee8bd7771fa893af74c4f3d71f0fd18"
integrity sha512-cv+VWK0YFgCVDvD1/HrrBWOWYG3MLuCUJRBTkV/Opdy7nkdNjhCAJQrEyMM9zX0sac8FKWKOHT0sykNh8KgmYw==
"@sentry/utils@5.22.2":
version "5.22.2"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.22.2.tgz#7296cd9036e8d34638743a27fe8c6fe0e70db902"
integrity sha512-HGpPohNgwRhR+7bf2OlziX84JVdwQAauesqcL4Y78e+U09+E06cQAEQkRIQJfn2Ai2NvVmMVhdj51v+AqmaAWQ==
"@sentry/utils@5.22.3":
version "5.22.3"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.22.3.tgz#e3bda3e789239eb16d436f768daa12829f33d18f"
integrity sha512-AHNryXMBvIkIE+GQxTlmhBXD0Ksh+5w1SwM5qi6AttH+1qjWLvV6WB4+4pvVvEoS8t5F+WaVUZPQLmCCWp6zKw==
dependencies:
"@sentry/types" "5.22.2"
"@sentry/types" "5.22.3"
tslib "^1.9.3"
"@sentry/webpack-plugin@^1.12.1":