2020-03-03 07:02:53 +00:00
|
|
|
|
// Events
|
2020-04-10 08:48:00 +00:00
|
|
|
|
import * as log from "loglevel";
|
2020-08-27 12:54:03 +00:00
|
|
|
|
import smartlookClient from "smartlook-client";
|
2022-01-07 06:08:17 +00:00
|
|
|
|
import { getAppsmithConfigs } from "@appsmith/configs";
|
2020-08-28 08:34:01 +00:00
|
|
|
|
import * as Sentry from "@sentry/react";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
|
import type { User } from "constants/userConstants";
|
|
|
|
|
|
import { ANONYMOUS_USERNAME } from "constants/userConstants";
|
2020-11-04 10:53:15 +00:00
|
|
|
|
import { sha256 } from "js-sha256";
|
2020-04-10 08:48:00 +00:00
|
|
|
|
|
2022-07-11 10:18:24 +00:00
|
|
|
|
declare global {
|
|
|
|
|
|
interface Window {
|
|
|
|
|
|
// Zipy is added via script tags in index.html
|
|
|
|
|
|
zipy: {
|
|
|
|
|
|
identify: (uid: string, userInfo: Record<string, string>) => void;
|
|
|
|
|
|
anonymize: () => void;
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-06 15:10:21 +00:00
|
|
|
|
export type EventLocation =
|
|
|
|
|
|
| "LIGHTNING_MENU"
|
|
|
|
|
|
| "API_PANE"
|
|
|
|
|
|
| "QUERY_PANE"
|
2021-07-07 03:46:16 +00:00
|
|
|
|
| "QUERY_TEMPLATE"
|
2022-01-29 07:26:19 +00:00
|
|
|
|
| "QUICK_COMMANDS"
|
2022-07-13 13:54:05 +00:00
|
|
|
|
| "OMNIBAR"
|
2022-09-14 15:34:10 +00:00
|
|
|
|
| "SUBMENU"
|
|
|
|
|
|
| "ACTION_SELECTOR"
|
|
|
|
|
|
| "ENTITY_EXPLORER"
|
|
|
|
|
|
| "KEYBOARD_SHORTCUT"
|
|
|
|
|
|
| "JS_OBJECT_GUTTER_RUN_BUTTON" // Gutter: https://codemirror.net/examples/gutter/
|
|
|
|
|
|
| "JS_OBJECT_MAIN_RUN_BUTTON"
|
|
|
|
|
|
| "JS_OBJECT_RESPONSE_RUN_BUTTON";
|
2020-10-06 15:10:21 +00:00
|
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
|
export type EventName =
|
2022-06-22 10:30:33 +00:00
|
|
|
|
| "APP_CRASH"
|
2022-03-08 13:54:48 +00:00
|
|
|
|
| "SWITCH_DATASOURCE"
|
2020-03-11 13:59:46 +00:00
|
|
|
|
| "LOGIN_CLICK"
|
|
|
|
|
|
| "SIGNUP_CLICK"
|
2019-09-09 09:08:54 +00:00
|
|
|
|
| "PAGE_VIEW"
|
|
|
|
|
|
| "ADD_COMPONENT"
|
|
|
|
|
|
| "DELETE_COMPONENT"
|
2020-03-03 07:02:53 +00:00
|
|
|
|
| "RESIZE_COMPONENT"
|
|
|
|
|
|
| "WIDGET_DRAG"
|
|
|
|
|
|
| "WIDGET_DROP"
|
|
|
|
|
|
| "WIDGET_DELETE"
|
|
|
|
|
|
| "WIDGET_RESIZE_START"
|
|
|
|
|
|
| "WIDGET_RESIZE_END"
|
|
|
|
|
|
| "WIDGET_PROPERTY_UPDATE"
|
|
|
|
|
|
| "WIDGET_TOGGLE_JS_PROP"
|
|
|
|
|
|
| "WIDGET_CARD_DRAG"
|
|
|
|
|
|
| "WIDGET_CARD_DROP"
|
|
|
|
|
|
| "CREATE_PAGE"
|
|
|
|
|
|
| "PAGE_RENAME"
|
|
|
|
|
|
| "PAGE_SWITCH"
|
2020-03-06 04:59:24 +00:00
|
|
|
|
| "DELETE_PAGE"
|
|
|
|
|
|
| "SIDEBAR_NAVIGATION"
|
|
|
|
|
|
| "PUBLISH_APP"
|
|
|
|
|
|
| "PREVIEW_APP"
|
|
|
|
|
|
| "EDITOR_OPEN"
|
2020-10-06 15:10:21 +00:00
|
|
|
|
| "CREATE_ACTION"
|
2021-04-22 03:30:09 +00:00
|
|
|
|
| "SAVE_SAAS"
|
|
|
|
|
|
| "DELETE_SAAS"
|
|
|
|
|
|
| "RUN_SAAS_API"
|
2020-03-06 04:59:24 +00:00
|
|
|
|
| "SAVE_API"
|
2020-03-11 13:59:46 +00:00
|
|
|
|
| "SAVE_API_CLICK"
|
2020-03-06 04:59:24 +00:00
|
|
|
|
| "RUN_API"
|
2020-03-11 13:59:46 +00:00
|
|
|
|
| "RUN_API_CLICK"
|
2021-05-31 15:40:21 +00:00
|
|
|
|
| "RUN_API_SHORTCUT"
|
2020-03-06 04:59:24 +00:00
|
|
|
|
| "DELETE_API"
|
2020-03-11 13:59:46 +00:00
|
|
|
|
| "DELETE_API_CLICK"
|
2020-05-05 13:21:17 +00:00
|
|
|
|
| "IMPORT_API"
|
|
|
|
|
|
| "EXPAND_API"
|
|
|
|
|
|
| "IMPORT_API_CLICK"
|
|
|
|
|
|
| "MOVE_API_CLICK"
|
|
|
|
|
|
| "ADD_API_PAGE"
|
2020-03-06 04:59:24 +00:00
|
|
|
|
| "DUPLICATE_API"
|
2020-05-05 07:50:30 +00:00
|
|
|
|
| "DUPLICATE_API_CLICK"
|
|
|
|
|
|
| "RUN_QUERY"
|
2020-09-28 05:12:23 +00:00
|
|
|
|
| "RUN_QUERY_CLICK"
|
2021-05-31 15:40:21 +00:00
|
|
|
|
| "RUN_QUERY_SHORTCUT"
|
2020-05-05 07:50:30 +00:00
|
|
|
|
| "DELETE_QUERY"
|
|
|
|
|
|
| "SAVE_QUERY"
|
2020-03-06 04:59:24 +00:00
|
|
|
|
| "MOVE_API"
|
2020-05-05 13:21:17 +00:00
|
|
|
|
| "3P_PROVIDER_CLICK"
|
2020-03-06 04:59:24 +00:00
|
|
|
|
| "API_SELECT"
|
|
|
|
|
|
| "CREATE_API_CLICK"
|
2021-07-07 03:46:16 +00:00
|
|
|
|
| "AUTO_COMPLETE_SHOW"
|
2020-03-06 04:59:24 +00:00
|
|
|
|
| "AUTO_COMPLETE_SELECT"
|
|
|
|
|
|
| "CREATE_APP_CLICK"
|
|
|
|
|
|
| "CREATE_APP"
|
|
|
|
|
|
| "CREATE_DATA_SOURCE_CLICK"
|
2020-03-11 13:59:46 +00:00
|
|
|
|
| "SAVE_DATA_SOURCE"
|
2020-10-06 15:10:21 +00:00
|
|
|
|
| "SAVE_DATA_SOURCE_CLICK"
|
2022-09-04 11:58:05 +00:00
|
|
|
|
| "CONSOLE_LOG_CREATED"
|
2020-10-06 15:10:21 +00:00
|
|
|
|
| "TEST_DATA_SOURCE_SUCCESS"
|
|
|
|
|
|
| "TEST_DATA_SOURCE_CLICK"
|
2023-01-03 15:17:25 +00:00
|
|
|
|
| "UPDATE_DATASOURCE"
|
2020-05-05 07:50:30 +00:00
|
|
|
|
| "CREATE_QUERY_CLICK"
|
2020-03-11 13:59:46 +00:00
|
|
|
|
| "NAVIGATE"
|
|
|
|
|
|
| "PAGE_LOAD"
|
2020-03-18 14:31:30 +00:00
|
|
|
|
| "NAVIGATE_EDITOR"
|
|
|
|
|
|
| "PROPERTY_PANE_OPEN"
|
|
|
|
|
|
| "PROPERTY_PANE_CLOSE"
|
|
|
|
|
|
| "PROPERTY_PANE_OPEN_CLICK"
|
2020-09-16 10:28:01 +00:00
|
|
|
|
| "WIDGET_DELETE_UNDO"
|
|
|
|
|
|
| "WIDGET_COPY_VIA_SHORTCUT"
|
|
|
|
|
|
| "WIDGET_COPY"
|
2020-12-10 07:33:43 +00:00
|
|
|
|
| "WIDGET_CUT_VIA_SHORTCUT"
|
2020-09-16 10:28:01 +00:00
|
|
|
|
| "WIDGET_PASTE"
|
|
|
|
|
|
| "WIDGET_DELETE_VIA_SHORTCUT"
|
2020-09-10 07:26:55 +00:00
|
|
|
|
| "OPEN_HELP"
|
|
|
|
|
|
| "INVITE_USER"
|
2020-10-12 12:56:03 +00:00
|
|
|
|
| "ROUTE_CHANGE"
|
2020-10-06 15:10:21 +00:00
|
|
|
|
| "PROPERTY_PANE_CLOSE_CLICK"
|
2020-10-07 11:19:56 +00:00
|
|
|
|
| "APPLICATIONS_PAGE_LOAD"
|
2020-12-30 07:31:20 +00:00
|
|
|
|
| "EXECUTE_ACTION"
|
2021-02-11 06:36:07 +00:00
|
|
|
|
| "WELCOME_TOUR_CLICK"
|
2022-01-25 13:56:52 +00:00
|
|
|
|
| "GUIDED_TOUR_RATING"
|
|
|
|
|
|
| "GUIDED_TOUR_REACHED_STEP"
|
|
|
|
|
|
| "END_GUIDED_TOUR_CLICK"
|
2021-03-08 08:24:12 +00:00
|
|
|
|
| "OPEN_OMNIBAR"
|
|
|
|
|
|
| "CLOSE_OMNIBAR"
|
2021-03-08 10:28:20 +00:00
|
|
|
|
| "NAVIGATE_TO_ENTITY_FROM_OMNIBAR"
|
|
|
|
|
|
| "PAGE_SAVE"
|
2021-04-23 13:50:55 +00:00
|
|
|
|
| "CORRECT_BAD_BINDING"
|
|
|
|
|
|
| "OPEN_DEBUGGER"
|
|
|
|
|
|
| "DEBUGGER_TAB_SWITCH"
|
2022-09-04 11:58:05 +00:00
|
|
|
|
| "DEBUGGER_FILTER_CHANGED"
|
2021-05-03 12:13:37 +00:00
|
|
|
|
| "DEBUGGER_ENTITY_NAVIGATION"
|
|
|
|
|
|
| "GSHEET_AUTH_INIT"
|
2021-05-05 11:21:15 +00:00
|
|
|
|
| "GSHEET_AUTH_COMPLETE"
|
2021-06-07 13:14:35 +00:00
|
|
|
|
| "CYCLICAL_DEPENDENCY_ERROR"
|
2021-06-21 11:09:51 +00:00
|
|
|
|
| "DISCORD_LINK_CLICK"
|
2022-03-24 09:17:17 +00:00
|
|
|
|
| "INTERCOM_CLICK"
|
2021-07-07 03:46:16 +00:00
|
|
|
|
| "BINDING_SUCCESS"
|
2023-03-24 10:15:11 +00:00
|
|
|
|
| "ENTITY_BINDING_SUCCESS"
|
2021-07-15 10:56:18 +00:00
|
|
|
|
| "APP_MENU_OPTION_CLICK"
|
2021-07-08 05:31:08 +00:00
|
|
|
|
| "SLASH_COMMAND"
|
|
|
|
|
|
| "DEBUGGER_NEW_ERROR"
|
2021-07-22 07:55:13 +00:00
|
|
|
|
| "DEBUGGER_RESOLVED_ERROR"
|
2021-08-16 11:03:27 +00:00
|
|
|
|
| "DEBUGGER_NEW_ERROR_MESSAGE"
|
|
|
|
|
|
| "DEBUGGER_RESOLVED_ERROR_MESSAGE"
|
2023-03-14 13:47:06 +00:00
|
|
|
|
| "DEBUGGER_LOG_ITEM_EXPAND"
|
|
|
|
|
|
| "DEBUGGER_HELP_CLICK"
|
2021-10-20 11:40:29 +00:00
|
|
|
|
| "DEBUGGER_CONTEXT_MENU_CLICK"
|
2021-08-02 03:00:56 +00:00
|
|
|
|
| "ADD_MOCK_DATASOURCE_CLICK"
|
2021-07-29 08:13:10 +00:00
|
|
|
|
| "GEN_CRUD_PAGE_CREATE_NEW_DATASOURCE"
|
|
|
|
|
|
| "GEN_CRUD_PAGE_FORM_SUBMIT"
|
|
|
|
|
|
| "GEN_CRUD_PAGE_EDIT_DATASOURCE_CONFIG"
|
|
|
|
|
|
| "GEN_CRUD_PAGE_SELECT_DATASOURCE"
|
|
|
|
|
|
| "GEN_CRUD_PAGE_SELECT_TABLE"
|
|
|
|
|
|
| "GEN_CRUD_PAGE_SELECT_SEARCH_COLUMN"
|
2021-08-10 09:49:39 +00:00
|
|
|
|
| "BUILD_FROM_SCRATCH_ACTION_CARD_CLICK"
|
|
|
|
|
|
| "GEN_CRUD_PAGE_ACTION_CARD_CLICK"
|
|
|
|
|
|
| "GEN_CRUD_PAGE_DATA_SOURCE_CLICK"
|
2021-07-29 08:13:10 +00:00
|
|
|
|
| "DATASOURCE_CARD_GEN_CRUD_PAGE_ACTION"
|
|
|
|
|
|
| "DATASOURCE_CARD_DELETE_ACTION"
|
|
|
|
|
|
| "DATASOURCE_CARD_EDIT_ACTION"
|
|
|
|
|
|
| "UNSUPPORTED_PLUGIN_DIALOG_BACK_ACTION"
|
|
|
|
|
|
| "UNSUPPORTED_PLUGIN_DIALOG_CONTINUE_ACTION"
|
2021-07-26 16:44:10 +00:00
|
|
|
|
| "SELECT_IN_CANVAS_CLICK"
|
|
|
|
|
|
| "WIDGET_SELECTED_VIA_SNIPING_MODE"
|
|
|
|
|
|
| "SUGGESTED_WIDGET_CLICK"
|
|
|
|
|
|
| "ASSOCIATED_ENTITY_CLICK"
|
2021-07-26 10:59:15 +00:00
|
|
|
|
| "CREATE_DATA_SOURCE_AUTH_API_CLICK"
|
|
|
|
|
|
| "CONNECT_DATA_CLICK"
|
|
|
|
|
|
| "RESPONSE_TAB_RUN_ACTION_CLICK"
|
2021-08-13 11:38:26 +00:00
|
|
|
|
| "ASSOCIATED_ENTITY_DROPDOWN_CLICK"
|
2021-08-25 05:00:31 +00:00
|
|
|
|
| "PAGES_LIST_LOAD"
|
|
|
|
|
|
| "WIDGET_GROUP"
|
2021-08-16 18:04:54 +00:00
|
|
|
|
| "CLOSE_GEN_PAGE_INFO_MODAL"
|
2021-08-23 09:25:16 +00:00
|
|
|
|
| "COMMENTS_TOGGLE_MODE"
|
|
|
|
|
|
| "COMMENTS_ONBOARDING_SKIP_BUTTON_CLICK"
|
|
|
|
|
|
| "COMMENTS_ONBOARDING_STEP_CHANGE"
|
|
|
|
|
|
| "COMMENTS_ONBOARDING_SUBMIT_BUTTON_CLICK"
|
|
|
|
|
|
| "COMMENTS_ONBOARDING_MODAL_DISMISSED"
|
2021-09-05 18:10:38 +00:00
|
|
|
|
| "COMMENTS_ONBOARDING_MODAL_TRIGGERED"
|
2021-09-21 07:55:56 +00:00
|
|
|
|
| "REPLAY_UNDO"
|
|
|
|
|
|
| "REPLAY_REDO"
|
2022-04-12 10:50:01 +00:00
|
|
|
|
| "URL_COPIED"
|
2021-09-05 18:10:38 +00:00
|
|
|
|
| "SNIPPET_CUSTOMIZE"
|
|
|
|
|
|
| "SNIPPET_EXECUTE"
|
|
|
|
|
|
| "SNIPPET_FILTER"
|
|
|
|
|
|
| "SNIPPET_COPIED"
|
2021-09-30 03:31:50 +00:00
|
|
|
|
| "SNIPPET_LOOKUP"
|
2021-09-13 07:22:51 +00:00
|
|
|
|
| "SIGNPOSTING_SKIP"
|
|
|
|
|
|
| "SIGNPOSTING_CREATE_DATASOURCE_CLICK"
|
|
|
|
|
|
| "SIGNPOSTING_CREATE_QUERY_CLICK"
|
|
|
|
|
|
| "SIGNPOSTING_ADD_WIDGET_CLICK"
|
|
|
|
|
|
| "SIGNPOSTING_CONNECT_WIDGET_CLICK"
|
|
|
|
|
|
| "SIGNPOSTING_PUBLISH_CLICK"
|
|
|
|
|
|
| "SIGNPOSTING_BUILD_APP_CLICK"
|
2021-12-14 16:30:59 +00:00
|
|
|
|
| "SIGNPOSTING_WELCOME_TOUR_CLICK"
|
2022-04-13 10:03:23 +00:00
|
|
|
|
| "GS_BRANCH_MORE_MENU_OPEN"
|
2022-05-06 04:44:24 +00:00
|
|
|
|
| "GIT_DISCARD_WARNING"
|
|
|
|
|
|
| "GIT_DISCARD_CANCEL"
|
|
|
|
|
|
| "GIT_DISCARD"
|
2022-02-08 16:16:16 +00:00
|
|
|
|
| "GS_OPEN_BRANCH_LIST_POPUP"
|
|
|
|
|
|
| "GS_CREATE_NEW_BRANCH"
|
|
|
|
|
|
| "GS_SYNC_BRANCHES"
|
2022-01-07 09:16:29 +00:00
|
|
|
|
| "GS_CONNECT_GIT_CLICK"
|
2022-02-08 16:16:16 +00:00
|
|
|
|
| "GS_SETTING_CLICK"
|
2022-01-07 09:16:29 +00:00
|
|
|
|
| "GS_DISCONNECT_GIT_CLICK"
|
2022-02-08 16:16:16 +00:00
|
|
|
|
| "GS_COMMIT_AND_PUSH_BUTTON_CLICK"
|
|
|
|
|
|
| "GS_LAST_DEPLOYED_PREVIEW_LINK_CLICK"
|
2022-01-07 09:16:29 +00:00
|
|
|
|
| "GS_PULL_GIT_CLICK"
|
|
|
|
|
|
| "GS_DEPLOY_GIT_CLICK"
|
|
|
|
|
|
| "GS_DEPLOY_GIT_MODAL_TRIGGERED"
|
|
|
|
|
|
| "GS_MERGE_GIT_MODAL_TRIGGERED"
|
|
|
|
|
|
| "GS_REPO_LIMIT_ERROR_MODAL_TRIGGERED"
|
|
|
|
|
|
| "GS_GIT_DOCUMENTATION_LINK_CLICK"
|
2022-02-08 16:16:16 +00:00
|
|
|
|
| "GS_MERGE_CHANGES_BUTTON_CLICK"
|
2022-01-07 09:16:29 +00:00
|
|
|
|
| "GS_REPO_URL_EDIT"
|
|
|
|
|
|
| "GS_MATCHING_REPO_NAME_ON_GIT_DISCONNECT_MODAL"
|
|
|
|
|
|
| "GS_GENERATE_KEY_BUTTON_CLICK"
|
|
|
|
|
|
| "GS_COPY_SSH_KEY_BUTTON_CLICK"
|
|
|
|
|
|
| "GS_DEFAULT_CONFIGURATION_EDIT_BUTTON_CLICK"
|
|
|
|
|
|
| "GS_DEFAULT_CONFIGURATION_CHECKBOX_TOGGLED"
|
|
|
|
|
|
| "GS_CONNECT_BUTTON_ON_GIT_SYNC_MODAL_CLICK"
|
2022-05-19 06:46:38 +00:00
|
|
|
|
| "GS_IMPORT_VIA_GIT_CARD_CLICK"
|
2022-01-13 13:21:57 +00:00
|
|
|
|
| "GS_CONTACT_SALES_CLICK"
|
2022-02-16 10:15:35 +00:00
|
|
|
|
| "GS_REGENERATE_SSH_KEY_CONFIRM_CLICK"
|
|
|
|
|
|
| "GS_REGENERATE_SSH_KEY_MORE_CLICK"
|
2022-04-13 10:03:23 +00:00
|
|
|
|
| "GS_SWITCH_BRANCH"
|
2022-12-10 09:26:29 +00:00
|
|
|
|
| "ADMIN_SETTINGS_CLICK"
|
2022-04-28 09:16:38 +00:00
|
|
|
|
| "ADMIN_SETTINGS_RESET"
|
2022-04-27 17:46:24 +00:00
|
|
|
|
| "ADMIN_SETTINGS_SAVE"
|
|
|
|
|
|
| "ADMIN_SETTINGS_ERROR"
|
|
|
|
|
|
| "ADMIN_SETTINGS_DISCONNECT_AUTH_METHOD"
|
|
|
|
|
|
| "ADMIN_SETTINGS_UPGRADE_AUTH_METHOD"
|
|
|
|
|
|
| "ADMIN_SETTINGS_EDIT_AUTH_METHOD"
|
|
|
|
|
|
| "ADMIN_SETTINGS_ENABLE_AUTH_METHOD"
|
2022-10-17 13:09:09 +00:00
|
|
|
|
| "ADMIN_SETTINGS_UPGRADE_HOOK"
|
2023-02-03 04:18:50 +00:00
|
|
|
|
| "BILLING_UPGRADE_ADMIN_SETTINGS"
|
2023-02-20 16:59:06 +00:00
|
|
|
|
| "AUDIT_LOGS_UPGRADE_ADMIN_SETTINGS"
|
|
|
|
|
|
| "GAC_UPGRADE_CLICK_ADMIN_SETTINGS"
|
2022-01-14 06:31:54 +00:00
|
|
|
|
| "REFLOW_BETA_FLAG"
|
2022-04-13 14:57:44 +00:00
|
|
|
|
| "CONTAINER_JUMP"
|
2022-01-14 06:31:54 +00:00
|
|
|
|
| "CONNECT_GIT_CLICK"
|
|
|
|
|
|
| "REPO_URL_EDIT"
|
|
|
|
|
|
| "GENERATE_KEY_BUTTON_CLICK"
|
|
|
|
|
|
| "COPY_SSH_KEY_BUTTON_CLICK"
|
|
|
|
|
|
| "LEARN_MORE_LINK_FOR_REMOTEURL_CLICK"
|
|
|
|
|
|
| "LEARN_MORE_LINK_FOR_SSH_CLICK"
|
|
|
|
|
|
| "DEFAULT_CONFIGURATION_EDIT_BUTTON_CLICK"
|
|
|
|
|
|
| "DEFAULT_CONFIGURATION_CHECKBOX_TOGGLED"
|
|
|
|
|
|
| "CONNECT_BUTTON_ON_GIT_SYNC_MODAL_CLICK"
|
2022-03-17 10:28:54 +00:00
|
|
|
|
| "DATASOURCE_AUTH_COMPLETE"
|
2022-05-04 09:45:57 +00:00
|
|
|
|
| "APP_THEMING_CHOOSE_THEME"
|
|
|
|
|
|
| "APP_THEMING_APPLY_THEME"
|
|
|
|
|
|
| "APP_THEMING_CUSTOMIZE_THEME"
|
|
|
|
|
|
| "APP_THEMING_SAVE_THEME_START"
|
|
|
|
|
|
| "APP_THEMING_SAVE_THEME_SUCCESS"
|
|
|
|
|
|
| "APP_THEMING_DELETE_THEME"
|
2022-03-17 10:28:54 +00:00
|
|
|
|
| "RECONNECTING_DATASOURCE_ITEM_CLICK"
|
|
|
|
|
|
| "ADD_MISSING_DATASOURCE_LINK_CLICK"
|
2022-03-31 05:16:04 +00:00
|
|
|
|
| "RECONNECTING_SKIP_TO_APPLICATION_BUTTON_CLICK"
|
2022-04-08 14:57:19 +00:00
|
|
|
|
| "TEMPLATE_FILTER_SELECTED"
|
|
|
|
|
|
| "MANUAL_UPGRADE_CLICK"
|
2022-04-28 16:51:02 +00:00
|
|
|
|
| "PAGE_NOT_FOUND"
|
2022-04-29 10:09:16 +00:00
|
|
|
|
| "SIMILAR_TEMPLATE_CLICK"
|
2023-02-28 10:13:23 +00:00
|
|
|
|
| "TEMPLATES_TAB_CLICK"
|
2022-07-14 05:00:30 +00:00
|
|
|
|
| "PROPERTY_PANE_KEYPRESS"
|
2022-06-22 04:01:49 +00:00
|
|
|
|
| "PAGE_NAME_CLICK"
|
|
|
|
|
|
| "BACK_BUTTON_CLICK"
|
|
|
|
|
|
| "WIDGET_TAB_CLICK"
|
2022-07-20 07:13:23 +00:00
|
|
|
|
| "ENTITY_EXPLORER_CLICK"
|
2022-07-28 08:38:37 +00:00
|
|
|
|
| "ADMIN_SETTINGS_UPGRADE_WATERMARK"
|
|
|
|
|
|
| "ADMIN_SETTINGS_UPGRADE"
|
2022-07-20 07:13:23 +00:00
|
|
|
|
| "PRETTIFY_CODE_MANUAL_TRIGGER"
|
2022-09-14 15:34:10 +00:00
|
|
|
|
| "PRETTIFY_CODE_KEYBOARD_SHORTCUT"
|
|
|
|
|
|
| "JS_OBJECT_CREATED"
|
|
|
|
|
|
| "JS_OBJECT_FUNCTION_ADDED"
|
2022-09-29 08:43:30 +00:00
|
|
|
|
| "JS_OBJECT_FUNCTION_RUN"
|
2022-11-21 07:40:35 +00:00
|
|
|
|
| "JS_OBJECT_SETTINGS_CHANGED"
|
2022-09-29 08:43:30 +00:00
|
|
|
|
| "SHOW_BINDINGS_TRIGGERED"
|
2022-09-29 09:19:29 +00:00
|
|
|
|
| "BINDING_COPIED"
|
2022-11-23 09:48:23 +00:00
|
|
|
|
| "AUTO_HEIGHT_OVERLAY_HANDLES_UPDATE"
|
2022-12-12 04:42:17 +00:00
|
|
|
|
| "ENTITY_EXPLORER_ADD_PAGE_CLICK"
|
|
|
|
|
|
| "CANVAS_BLANK_PAGE_CTA_CLICK"
|
2022-12-08 12:16:41 +00:00
|
|
|
|
| AUDIT_LOGS_EVENT_NAMES
|
2022-12-24 10:23:34 +00:00
|
|
|
|
| GAC_EVENT_NAMES
|
2022-12-09 14:43:47 +00:00
|
|
|
|
| "BRANDING_UPGRADE_CLICK"
|
|
|
|
|
|
| "BRANDING_PROPERTY_UPDATE"
|
|
|
|
|
|
| "BRANDING_SUBMIT_CLICK"
|
2022-12-11 14:42:32 +00:00
|
|
|
|
| "Cmd+Click Navigation"
|
2022-12-21 17:14:47 +00:00
|
|
|
|
| "WIDGET_PROPERTY_SEARCH"
|
2023-02-17 16:03:34 +00:00
|
|
|
|
| "PEEK_OVERLAY_OPENED"
|
|
|
|
|
|
| "PEEK_OVERLAY_COLLAPSE_EXPAND_CLICK"
|
|
|
|
|
|
| "PEEK_OVERLAY_VALUE_COPIED"
|
2023-03-23 11:41:58 +00:00
|
|
|
|
| LIBRARY_EVENTS
|
|
|
|
|
|
| "APP_SETTINGS_SECTION_CLICK"
|
|
|
|
|
|
| APP_NAVIGATION_EVENT_NAMES;
|
2022-12-21 17:14:47 +00:00
|
|
|
|
|
|
|
|
|
|
export type LIBRARY_EVENTS =
|
|
|
|
|
|
| "INSTALL_LIBRARY"
|
|
|
|
|
|
| "DEFINITIONS_GENERATION"
|
|
|
|
|
|
| "UNINSTALL_LIBRARY"
|
|
|
|
|
|
| "EDIT_LIBRARY_URL";
|
2022-09-29 09:19:29 +00:00
|
|
|
|
|
|
|
|
|
|
export type AUDIT_LOGS_EVENT_NAMES =
|
|
|
|
|
|
| "AUDIT_LOGS_CLEAR_FILTERS"
|
|
|
|
|
|
| "AUDIT_LOGS_FILTER_BY_RESOURCE_ID"
|
|
|
|
|
|
| "AUDIT_LOGS_FILTER_BY_EMAIL"
|
|
|
|
|
|
| "AUDIT_LOGS_FILTER_BY_EVENT"
|
|
|
|
|
|
| "AUDIT_LOGS_FILTER_BY_DATE"
|
|
|
|
|
|
| "AUDIT_LOGS_COLLAPSIBLE_ROW_OPENED"
|
|
|
|
|
|
| "AUDIT_LOGS_COLLAPSIBLE_ROW_CLOSED";
|
2020-03-03 07:02:53 +00:00
|
|
|
|
|
2022-12-24 10:23:34 +00:00
|
|
|
|
export type GAC_EVENT_NAMES =
|
|
|
|
|
|
| "GAC_USER_CLICK"
|
|
|
|
|
|
| "GAC_USER_ROLE_UPDATE"
|
|
|
|
|
|
| "GAC_USER_GROUP_UPDATE"
|
|
|
|
|
|
| "GAC_GROUP_ROLE_UPDATE"
|
|
|
|
|
|
| "GAC_INVITE_USER_CLICK"
|
|
|
|
|
|
| "GAC_ADD_USER_CLICK";
|
|
|
|
|
|
|
2023-03-23 11:41:58 +00:00
|
|
|
|
export type APP_NAVIGATION_EVENT_NAMES =
|
|
|
|
|
|
| "APP_NAVIGATION_SHOW_NAV"
|
|
|
|
|
|
| "APP_NAVIGATION_ORIENTATION"
|
|
|
|
|
|
| "APP_NAVIGATION_VARIANT"
|
|
|
|
|
|
| "APP_NAVIGATION_BACKGROUND_COLOR"
|
|
|
|
|
|
| "APP_NAVIGATION_SHOW_SIGN_IN";
|
|
|
|
|
|
|
2020-03-09 05:46:32 +00:00
|
|
|
|
function getApplicationId(location: Location) {
|
|
|
|
|
|
const pathSplit = location.pathname.split("/");
|
|
|
|
|
|
const applicationsIndex = pathSplit.findIndex(
|
2020-12-24 04:32:25 +00:00
|
|
|
|
(path) => path === "applications",
|
2020-03-09 05:46:32 +00:00
|
|
|
|
);
|
|
|
|
|
|
const appId = pathSplit[applicationsIndex + 1];
|
|
|
|
|
|
|
|
|
|
|
|
return appId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-30 11:23:42 +00:00
|
|
|
|
class AnalyticsUtil {
|
2020-11-06 06:27:36 +00:00
|
|
|
|
static cachedAnonymoustId: string;
|
|
|
|
|
|
static cachedUserId: string;
|
2020-09-05 07:28:29 +00:00
|
|
|
|
static user?: User = undefined;
|
2023-01-10 12:09:33 +00:00
|
|
|
|
static blockTrackEvent: boolean | undefined;
|
2022-10-04 11:18:35 +00:00
|
|
|
|
|
2020-08-27 12:54:03 +00:00
|
|
|
|
static initializeSmartLook(id: string) {
|
|
|
|
|
|
smartlookClient.init(id);
|
2019-09-09 09:08:54 +00:00
|
|
|
|
}
|
2019-08-30 11:23:42 +00:00
|
|
|
|
|
2023-01-10 12:09:33 +00:00
|
|
|
|
static initializeSegmentWithoutTracking(key: string) {
|
|
|
|
|
|
AnalyticsUtil.blockTrackEvent = true;
|
|
|
|
|
|
return AnalyticsUtil.initializeSegment(key);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-06 08:14:59 +00:00
|
|
|
|
static initializeSegment(key: string) {
|
2023-01-06 14:09:38 +00:00
|
|
|
|
const initPromise = new Promise<boolean>((resolve) => {
|
|
|
|
|
|
(function init(window: any) {
|
|
|
|
|
|
const analytics = (window.analytics = window.analytics || []);
|
|
|
|
|
|
if (!analytics.initialize) {
|
|
|
|
|
|
if (analytics.invoked) {
|
|
|
|
|
|
log.error("Segment snippet included twice.");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
analytics.invoked = !0;
|
|
|
|
|
|
analytics.methods = [
|
|
|
|
|
|
"trackSubmit",
|
|
|
|
|
|
"trackClick",
|
|
|
|
|
|
"trackLink",
|
|
|
|
|
|
"trackForm",
|
|
|
|
|
|
"pageview",
|
|
|
|
|
|
"identify",
|
|
|
|
|
|
"reset",
|
|
|
|
|
|
"group",
|
|
|
|
|
|
"track",
|
|
|
|
|
|
"ready",
|
|
|
|
|
|
"alias",
|
|
|
|
|
|
"debug",
|
|
|
|
|
|
"page",
|
|
|
|
|
|
"once",
|
|
|
|
|
|
"off",
|
|
|
|
|
|
"on",
|
|
|
|
|
|
];
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
|
analytics.factory = function (t: any) {
|
|
|
|
|
|
return function () {
|
2023-01-06 14:09:38 +00:00
|
|
|
|
const e = Array.prototype.slice.call(arguments); //eslint-disable-line prefer-rest-params
|
|
|
|
|
|
e.unshift(t);
|
|
|
|
|
|
analytics.push(e);
|
|
|
|
|
|
return analytics;
|
|
|
|
|
|
};
|
2019-09-09 09:08:54 +00:00
|
|
|
|
};
|
2023-01-06 14:09:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
for (let t: any = 0; t < analytics.methods.length; t++) {
|
|
|
|
|
|
const e = analytics.methods[t];
|
|
|
|
|
|
analytics[e] = analytics.factory(e);
|
|
|
|
|
|
}
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
|
analytics.load = function (t: any, e: any) {
|
2023-01-06 14:09:38 +00:00
|
|
|
|
const n = document.createElement("script");
|
|
|
|
|
|
n.type = "text/javascript";
|
|
|
|
|
|
n.async = !0;
|
|
|
|
|
|
// Ref: https://www.notion.so/appsmith/530051a2083040b5bcec15a46121aea3
|
|
|
|
|
|
n.src = "https://a.appsmith.com/reroute/" + t + "/main.js";
|
|
|
|
|
|
const a: any = document.getElementsByTagName("script")[0];
|
|
|
|
|
|
a.parentNode.insertBefore(n, a);
|
|
|
|
|
|
analytics._loadOptions = e;
|
2019-09-09 09:08:54 +00:00
|
|
|
|
};
|
2023-01-06 14:09:38 +00:00
|
|
|
|
analytics.ready(() => {
|
|
|
|
|
|
resolve(true);
|
|
|
|
|
|
});
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
resolve(false);
|
|
|
|
|
|
}, 2000);
|
|
|
|
|
|
analytics.SNIPPET_VERSION = "4.1.0";
|
2023-02-08 08:56:46 +00:00
|
|
|
|
// Ref: https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#batching
|
|
|
|
|
|
analytics.load(key, {
|
|
|
|
|
|
integrations: {
|
|
|
|
|
|
"Segment.io": {
|
|
|
|
|
|
deliveryStrategy: {
|
|
|
|
|
|
strategy: "batching", // The delivery strategy used for sending events to Segment
|
|
|
|
|
|
config: {
|
|
|
|
|
|
size: 100, // The batch size is the threshold that forces all batched events to be sent once it’s reached.
|
|
|
|
|
|
timeout: 1000, // The number of milliseconds that forces all events queued for batching to be sent, regardless of the batch size, once it’s reached
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2023-02-15 13:46:04 +00:00
|
|
|
|
if (!AnalyticsUtil.blockTrackEvent) {
|
|
|
|
|
|
analytics.page();
|
|
|
|
|
|
}
|
2019-09-09 09:08:54 +00:00
|
|
|
|
}
|
2023-01-06 14:09:38 +00:00
|
|
|
|
})(window);
|
|
|
|
|
|
});
|
|
|
|
|
|
return initPromise;
|
2019-09-09 09:08:54 +00:00
|
|
|
|
}
|
2019-08-30 11:23:42 +00:00
|
|
|
|
|
2020-10-07 11:19:56 +00:00
|
|
|
|
static logEvent(eventName: EventName, eventData: any = {}) {
|
2023-01-10 12:09:33 +00:00
|
|
|
|
if (AnalyticsUtil.blockTrackEvent) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
|
const windowDoc: any = window;
|
2020-03-06 04:59:24 +00:00
|
|
|
|
let finalEventData = eventData;
|
|
|
|
|
|
const userData = AnalyticsUtil.user;
|
2020-03-09 05:46:32 +00:00
|
|
|
|
const appId = getApplicationId(windowDoc.location);
|
2020-03-06 04:59:24 +00:00
|
|
|
|
if (userData) {
|
2020-11-05 15:02:25 +00:00
|
|
|
|
const { segment } = getAppsmithConfigs();
|
2020-11-04 10:53:15 +00:00
|
|
|
|
let user: any = {};
|
2021-12-03 05:38:18 +00:00
|
|
|
|
if (segment.apiKey) {
|
2020-11-04 10:53:15 +00:00
|
|
|
|
user = {
|
|
|
|
|
|
userId: userData.username,
|
|
|
|
|
|
email: userData.email,
|
|
|
|
|
|
appId: appId,
|
2020-11-23 13:17:12 +00:00
|
|
|
|
source: "cloud",
|
|
|
|
|
|
};
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const userId = userData.username;
|
|
|
|
|
|
if (userId !== AnalyticsUtil.cachedUserId) {
|
|
|
|
|
|
AnalyticsUtil.cachedAnonymoustId = sha256(userId);
|
|
|
|
|
|
AnalyticsUtil.cachedUserId = userId;
|
|
|
|
|
|
}
|
|
|
|
|
|
user = {
|
|
|
|
|
|
userId: AnalyticsUtil.cachedAnonymoustId,
|
|
|
|
|
|
source: "ce",
|
2020-11-04 10:53:15 +00:00
|
|
|
|
};
|
|
|
|
|
|
}
|
2020-03-06 04:59:24 +00:00
|
|
|
|
finalEventData = {
|
2020-10-19 11:06:44 +00:00
|
|
|
|
...eventData,
|
|
|
|
|
|
userData: user.userId === ANONYMOUS_USERNAME ? undefined : user,
|
2020-03-06 04:59:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
}
|
2020-12-30 07:31:20 +00:00
|
|
|
|
|
2021-12-03 05:38:18 +00:00
|
|
|
|
if (windowDoc.analytics) {
|
2020-11-05 16:51:22 +00:00
|
|
|
|
log.debug("Event fired", eventName, finalEventData);
|
2020-03-06 04:59:24 +00:00
|
|
|
|
windowDoc.analytics.track(eventName, finalEventData);
|
2021-04-27 12:53:08 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
log.debug("Event fired locally", eventName, finalEventData);
|
2020-03-03 07:02:53 +00:00
|
|
|
|
}
|
2019-09-09 09:08:54 +00:00
|
|
|
|
}
|
2019-08-30 11:23:42 +00:00
|
|
|
|
|
2020-11-04 09:53:26 +00:00
|
|
|
|
static identifyUser(userData: User) {
|
2021-12-03 05:38:18 +00:00
|
|
|
|
const { segment, sentry, smartLook } = getAppsmithConfigs();
|
2019-09-09 09:08:54 +00:00
|
|
|
|
const windowDoc: any = window;
|
2020-11-06 06:27:36 +00:00
|
|
|
|
const userId = userData.username;
|
2020-03-03 07:02:53 +00:00
|
|
|
|
if (windowDoc.analytics) {
|
2020-11-04 12:20:14 +00:00
|
|
|
|
// This flag is only set on Appsmith Cloud. In this case, we get more detailed analytics of the user
|
2020-11-05 06:11:29 +00:00
|
|
|
|
if (segment.apiKey) {
|
2020-11-04 10:53:15 +00:00
|
|
|
|
const userProperties = {
|
2020-11-04 09:53:26 +00:00
|
|
|
|
email: userData.email,
|
|
|
|
|
|
name: userData.name,
|
|
|
|
|
|
userId: userId,
|
2020-11-23 13:17:12 +00:00
|
|
|
|
source: "cloud",
|
2020-11-04 09:53:26 +00:00
|
|
|
|
};
|
2020-11-04 10:53:15 +00:00
|
|
|
|
AnalyticsUtil.user = userData;
|
2020-11-05 16:51:22 +00:00
|
|
|
|
log.debug("Identify User " + userId);
|
2020-11-04 10:53:15 +00:00
|
|
|
|
windowDoc.analytics.identify(userId, userProperties);
|
2020-11-05 16:51:22 +00:00
|
|
|
|
} else if (segment.ceKey) {
|
2020-11-04 12:20:14 +00:00
|
|
|
|
// This is a self-hosted instance. Only send data if the analytics are NOT disabled by the user
|
2020-11-06 06:27:36 +00:00
|
|
|
|
if (userId !== AnalyticsUtil.cachedUserId) {
|
|
|
|
|
|
AnalyticsUtil.cachedAnonymoustId = sha256(userId);
|
|
|
|
|
|
AnalyticsUtil.cachedUserId = userId;
|
|
|
|
|
|
}
|
2020-11-23 13:17:12 +00:00
|
|
|
|
const userProperties = {
|
2021-10-04 17:36:31 +00:00
|
|
|
|
userId: AnalyticsUtil.cachedAnonymoustId,
|
2020-11-23 13:17:12 +00:00
|
|
|
|
source: "ce",
|
|
|
|
|
|
};
|
2020-11-06 06:27:36 +00:00
|
|
|
|
log.debug(
|
|
|
|
|
|
"Identify Anonymous User " + AnalyticsUtil.cachedAnonymoustId,
|
|
|
|
|
|
);
|
2020-11-23 13:17:12 +00:00
|
|
|
|
windowDoc.analytics.identify(
|
|
|
|
|
|
AnalyticsUtil.cachedAnonymoustId,
|
|
|
|
|
|
userProperties,
|
|
|
|
|
|
);
|
2020-11-04 09:53:26 +00:00
|
|
|
|
}
|
2020-03-03 07:02:53 +00:00
|
|
|
|
}
|
2021-12-03 05:38:18 +00:00
|
|
|
|
|
|
|
|
|
|
if (sentry.enabled) {
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
|
Sentry.configureScope(function (scope) {
|
2021-12-03 05:38:18 +00:00
|
|
|
|
scope.setUser({
|
|
|
|
|
|
id: userId,
|
|
|
|
|
|
username: userData.username,
|
|
|
|
|
|
email: userData.email,
|
|
|
|
|
|
});
|
2020-08-28 08:34:01 +00:00
|
|
|
|
});
|
2021-12-03 05:38:18 +00:00
|
|
|
|
}
|
2020-11-05 02:31:01 +00:00
|
|
|
|
|
2020-08-27 12:54:03 +00:00
|
|
|
|
if (smartLook.enabled) {
|
2020-09-05 07:36:12 +00:00
|
|
|
|
smartlookClient.identify(userId, { email: userData.email });
|
2020-08-21 08:13:59 +00:00
|
|
|
|
}
|
2022-07-11 10:18:24 +00:00
|
|
|
|
|
|
|
|
|
|
// If zipy was included, identify this user on the platform
|
|
|
|
|
|
if (window.zipy && userId) {
|
|
|
|
|
|
window.zipy.identify(userId, {
|
|
|
|
|
|
email: userData.email,
|
|
|
|
|
|
username: userData.username,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2023-01-10 12:09:33 +00:00
|
|
|
|
|
|
|
|
|
|
AnalyticsUtil.blockTrackEvent = false;
|
2019-09-09 09:08:54 +00:00
|
|
|
|
}
|
2020-04-08 08:43:56 +00:00
|
|
|
|
|
2023-01-06 14:09:38 +00:00
|
|
|
|
static getAnonymousId() {
|
|
|
|
|
|
const windowDoc: any = window;
|
|
|
|
|
|
const { segment } = getAppsmithConfigs();
|
|
|
|
|
|
if (windowDoc.analytics && windowDoc.analytics.user) {
|
|
|
|
|
|
return windowDoc.analytics.user().anonymousId();
|
|
|
|
|
|
} else if (segment.enabled) {
|
|
|
|
|
|
return localStorage.getItem("ajs_anonymous_id")?.replaceAll('"', "");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-08 08:43:56 +00:00
|
|
|
|
static reset() {
|
|
|
|
|
|
const windowDoc: any = window;
|
2020-09-09 05:18:36 +00:00
|
|
|
|
if (windowDoc.Intercom) {
|
|
|
|
|
|
windowDoc.Intercom("shutdown");
|
|
|
|
|
|
}
|
2020-04-15 14:19:39 +00:00
|
|
|
|
windowDoc.analytics && windowDoc.analytics.reset();
|
|
|
|
|
|
windowDoc.mixpanel && windowDoc.mixpanel.reset();
|
2022-07-11 10:18:24 +00:00
|
|
|
|
window.zipy && window.zipy.anonymize();
|
2020-04-08 08:43:56 +00:00
|
|
|
|
}
|
2023-01-10 12:09:33 +00:00
|
|
|
|
|
|
|
|
|
|
static removeAnalytics() {
|
|
|
|
|
|
AnalyticsUtil.blockTrackEvent = false;
|
|
|
|
|
|
(window as any).analytics = undefined;
|
|
|
|
|
|
}
|
2019-08-30 11:23:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
|
export default AnalyticsUtil;
|