Add navigate method to Analytics provider (#5367)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-04-16 11:55:19 +05:00 committed by GitHub
parent bb1abdc8cc
commit d3fa4908ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 2 deletions

View File

@ -13,6 +13,7 @@ export interface AnalyticProvider {
setWorkspace: (ws: string) => void
handleEvent: (event: string) => void
handleError: (error: Error) => void
navigate: (path: string) => void
}
export const Analytics = {
@ -51,6 +52,12 @@ export const Analytics = {
providers.forEach((provider) => {
provider.handleError(error)
})
},
navigate (path: string): void {
providers.forEach((provider) => {
provider.navigate(path)
})
}
}

View File

@ -13,6 +13,7 @@
// limitations under the License.
//
import { Analytics } from '@hcengineering/analytics'
import { clone } from '@hcengineering/core'
import { derived, get, writable } from 'svelte/store'
import { closePopup } from './popups'
@ -177,6 +178,7 @@ export function navigate (location: PlatformLocation, replace = false): boolean
if (cur !== url) {
const data = !embeddedPlatform ? null : { location }
const _url = !embeddedPlatform ? url : undefined
Analytics.navigate(url)
if (replace) {
history.replaceState(data, '', _url)
} else {

View File

@ -250,7 +250,7 @@ export function start (
lastNameFirst?: string
},
port: number,
extraConfig?: Record<string, string>
extraConfig?: Record<string, string | undefined>
): () => void {
const app = express()

View File

@ -21,7 +21,7 @@ import { StorageConfiguration } from '@hcengineering/server-core'
import serverToken from '@hcengineering/server-token'
import { start } from '.'
export function startFront (ctx: MeasureContext, extraConfig?: Record<string, string>): void {
export function startFront (ctx: MeasureContext, extraConfig?: Record<string, string | undefined>): void {
const defaultLanguage = process.env.DEFAULT_LANGUAGE ?? 'en'
const languages = process.env.LANGUAGES ?? 'en,ru'
const SERVER_PORT = parseInt(process.env.SERVER_PORT ?? '8080')