-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: Include version in all requests #37551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
b28d4b0
chore: Include version in server responses
sharat87 0da70ce
chore: fix tests and have client also send version
sharat87 ae0cb0e
chore: merge release branch
sharat87 868140b
Make version check on server optional for now
sharat87 dd9aff7
fix header in fake responses
sharat87 206dca9
chore: merge release branch
sharat87 e6478ce
fix response structure again
sharat87 7046104
remove console log
sharat87 db8d9c2
chore: merge release branch
sharat87 c026e7e
Merge branch 'release' into chore/versioned-responses
sharat87 4d5e3e9
Merge branch 'release' into chore/versioned-responses
sharat87 e231045
Show version in header in response as well
sharat87 c2c5a35
chore: merge release branch
sharat87 259ce4e
fix unit tests
sharat87 70a3fd6
only request sends version
sharat87 cf6e760
Discard changes to app/client/cypress/e2e/Regression/ClientSide/Templ…
sharat87 a01546a
Discard changes to app/client/cypress/e2e/Regression/ClientSide/Templ…
sharat87 fd6f7b0
Discard changes to app/client/cypress/e2e/Regression/ServerSide/Gener…
sharat87 cf17e9e
Discard changes to app/client/cypress/e2e/Regression/ServerSide/Gener…
sharat87 9e389e4
Discard changes to app/client/cypress/e2e/Sanity/Datasources/ArangoDa…
sharat87 d3db3d2
Discard changes to app/client/cypress/e2e/Sanity/Datasources/MsSQLDat…
sharat87 fbd9bba
Discard changes to app/client/cypress/e2e/Sanity/Datasources/MySQLDat…
sharat87 fdf799b
Discard changes to app/client/cypress/e2e/Sanity/Datasources/Redshift…
sharat87 b16aeca
Discard changes to app/client/cypress/support/Objects/FeatureFlags.ts
sharat87 7f378b5
Discard changes to app/client/cypress/support/Pages/DataSources.ts
sharat87 6483646
Discard changes to app/client/cypress/support/dataSourceCommands.js
sharat87 fc634f1
Discard changes to app/client/cypress/support/index.d.ts
sharat87 f6b9269
Discard changes to app/client/src/api/__tests__/apiSucessResponseInte…
sharat87 690b2be
Include expected version in error message
sharat87 66a653d
Handle showing toast when needed
sharat87 1095757
remove todo
sharat87 35d9ba6
No version update state
sharat87 3311cd2
Fix imports and error handling
sharat87 260e039
Fix type error
sharat87 d8244c9
Merge branch 'release' into chore/versioned-responses
sharat87 c4321f7
refactor interceptor
jsartisan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/client/src/api/interceptors/request/addVersionHeader.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { InternalAxiosRequestConfig } from "axios"; | ||
|
|
||
| export const addVersionHeader = ( | ||
| config: InternalAxiosRequestConfig, | ||
| options: { version: string }, | ||
| ) => { | ||
| const { version } = options; | ||
|
|
||
| config.headers = config.headers || {}; | ||
| config.headers["X-Appsmith-Version"] = version; | ||
|
|
||
| return config; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/client/src/api/interceptors/response/failureHandlers/handleBadRequestError.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import type { AxiosError } from "axios"; | ||
| import type { ApiResponse } from "../../../ApiResponses"; | ||
| import { handleVersionMismatch } from "sagas/WebsocketSagas/versionUpdatePrompt"; | ||
| import { getAppsmithConfigs } from "ee/configs"; | ||
| import { SERVER_ERROR_CODES } from "ee/constants/ApiConstants"; | ||
|
|
||
| export const handleBadRequestError = async (error: AxiosError<ApiResponse>) => { | ||
| const errorCode = error?.response?.data?.responseMeta.error?.code; | ||
|
|
||
| if ( | ||
| error?.response?.status === 400 && | ||
| SERVER_ERROR_CODES.VERSION_MISMATCH.includes("" + errorCode) | ||
| ) { | ||
| const responseData = error?.response?.data; | ||
| const message = responseData?.responseMeta.error?.message; | ||
| const serverVersion = (responseData?.data as { serverVersion: string }) | ||
| .serverVersion; | ||
|
|
||
| handleVersionMismatch(getAppsmithConfigs().appVersion.id, serverVersion); | ||
|
|
||
| return Promise.reject({ | ||
| ...error, | ||
| clientDefinedError: true, | ||
| statusCode: errorCode, | ||
| message, | ||
| }); | ||
| } | ||
|
|
||
| return null; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 18 additions & 92 deletions
110
app/client/src/sagas/WebsocketSagas/versionUpdatePrompt.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,111 +1,37 @@ | ||
| // Check if user is updating the app when toast is shown | ||
| // Check how many times does the user see a toast before updating | ||
|
|
||
| import { toast } from "@appsmith/ads"; | ||
| import { | ||
| createMessage, | ||
| INFO_VERSION_MISMATCH_FOUND_RELOAD_REQUEST, | ||
| } from "ee/constants/messages"; | ||
| import type { AppVersionData } from "ee/configs/types"; | ||
| import { | ||
| getVersionUpdateState, | ||
| removeVersionUpdateState, | ||
| setVersionUpdateState, | ||
| } from "utils/storage"; | ||
| import AnalyticsUtil from "ee/utils/AnalyticsUtil"; | ||
|
|
||
| enum UpdateStateEvent { | ||
| PROMPT_SHOWN = "PROMPT_SHOWN", | ||
| UPDATE_REQUESTED = "UPDATE_REQUESTED", | ||
| function handleUpdateRequested(fromVersion: string, toVersion: string) { | ||
| AnalyticsUtil.logEvent("VERSION_UPDATE_REQUESTED", { | ||
| fromVersion, | ||
| toVersion, | ||
| }); | ||
| // Reload to fetch the latest app version | ||
| location.reload(); | ||
| } | ||
|
|
||
| export interface VersionUpdateState { | ||
| currentVersion: string; | ||
| upgradeVersion: string; | ||
| timesShown: number; | ||
| event: UpdateStateEvent; | ||
| } | ||
| export async function handleVersionMismatch( | ||
| currentVersion: string, | ||
| serverVersion: string, | ||
| ) { | ||
| // If no version is set, ignore | ||
| if (!currentVersion) return; | ||
|
|
||
| let timesShown = 0; | ||
| AnalyticsUtil.logEvent("VERSION_UPDATE_SHOWN", { | ||
| fromVersion: currentVersion, | ||
| toVersion: serverVersion, | ||
| }); | ||
|
|
||
| function showPrompt(newUpdateState: VersionUpdateState) { | ||
| toast.show(createMessage(INFO_VERSION_MISMATCH_FOUND_RELOAD_REQUEST), { | ||
| kind: "info", | ||
| autoClose: false, | ||
| action: { | ||
| text: "refresh", | ||
| effect: () => handleUpdateRequested(newUpdateState), | ||
| effect: () => handleUpdateRequested(currentVersion, serverVersion), | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| function handleUpdateRequested(newUpdateState: VersionUpdateState) { | ||
| // store version update with timesShown counter | ||
| setVersionUpdateState({ | ||
| ...newUpdateState, | ||
| event: UpdateStateEvent.UPDATE_REQUESTED, | ||
| }).then(() => { | ||
| AnalyticsUtil.logEvent("VERSION_UPDATE_REQUESTED", { | ||
| fromVersion: newUpdateState.currentVersion, | ||
| toVersion: newUpdateState.upgradeVersion, | ||
| timesShown, | ||
| }); | ||
| // Reload to fetch the latest app version | ||
| location.reload(); | ||
| }); | ||
| } | ||
|
|
||
| export async function handleVersionUpdate( | ||
| currentVersionData: AppVersionData, | ||
| serverVersion: string, | ||
| ) { | ||
| const { edition, id: currentVersion } = currentVersionData; | ||
|
|
||
| // If no version is set, ignore | ||
| if (!currentVersion) return; | ||
|
|
||
| const versionState: VersionUpdateState | null = await getVersionUpdateState(); | ||
|
|
||
| if (currentVersion === serverVersion) { | ||
| if (versionState) { | ||
| AnalyticsUtil.logEvent("VERSION_UPDATE_SUCCESS", { | ||
| fromVersion: versionState.currentVersion, | ||
| toVersion: versionState.upgradeVersion, | ||
| edition, | ||
| }); | ||
| await removeVersionUpdateState(); | ||
| } | ||
| } | ||
|
|
||
| if (currentVersion !== serverVersion) { | ||
| if (versionState) { | ||
| timesShown = versionState.timesShown; | ||
|
|
||
| if ( | ||
| currentVersion === versionState.currentVersion && | ||
| versionState.event === UpdateStateEvent.UPDATE_REQUESTED | ||
| ) { | ||
| AnalyticsUtil.logEvent("VERSION_UPDATED_FAILED", { | ||
| fromVersion: versionState.currentVersion, | ||
| toVersion: versionState.upgradeVersion, | ||
| edition, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| const newUpdateState: VersionUpdateState = { | ||
| currentVersion, | ||
| upgradeVersion: serverVersion, | ||
| // Increment the timesShown counter | ||
| timesShown: timesShown + 1, | ||
| event: UpdateStateEvent.PROMPT_SHOWN, | ||
| }; | ||
|
|
||
| AnalyticsUtil.logEvent("VERSION_UPDATE_SHOWN", { | ||
| fromVersion: currentVersion, | ||
| toVersion: serverVersion, | ||
| timesShown, | ||
| }); | ||
| showPrompt(newUpdateState); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.