mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 08:20:39 +00:00
fix: report invalid content errors to analytics (#6699)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
ba5a7525d3
commit
daf4247b07
@ -42,6 +42,7 @@
|
||||
"@hcengineering/platform": "^0.6.11",
|
||||
"svelte": "^4.2.12",
|
||||
"@hcengineering/ui": "^0.6.15",
|
||||
"@hcengineering/analytics": "^0.6.0",
|
||||
"@hcengineering/presentation": "^0.6.3",
|
||||
"@hcengineering/core": "^0.6.32",
|
||||
"@hcengineering/view": "^0.6.13",
|
||||
|
@ -15,6 +15,7 @@
|
||||
//
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Analytics } from '@hcengineering/analytics'
|
||||
import { type Space, type Class, type CollaborativeDoc, type Doc, type Ref } from '@hcengineering/core'
|
||||
import { IntlString, translate } from '@hcengineering/platform'
|
||||
import { getFileUrl, getImageSize, imageSizeToRatio } from '@hcengineering/presentation'
|
||||
@ -116,11 +117,12 @@
|
||||
objectAttr
|
||||
})
|
||||
|
||||
let contentError = false
|
||||
let localSynced = false
|
||||
let remoteSynced = false
|
||||
|
||||
$: loading = !localSynced && !remoteSynced
|
||||
$: editable = !readonly && remoteSynced
|
||||
$: editable = !readonly && !contentError && remoteSynced
|
||||
|
||||
void localProvider.loaded.then(() => (localSynced = true))
|
||||
void remoteProvider.loaded.then(() => (remoteSynced = true))
|
||||
@ -218,7 +220,10 @@
|
||||
}
|
||||
|
||||
$: if (editor !== undefined) {
|
||||
editor.setEditable(editable, true)
|
||||
// When the content is invalid, we don't want to emit an update
|
||||
// Preventing synchronization of the invalid content
|
||||
const emitUpdate = !contentError
|
||||
editor.setEditable(editable, emitUpdate)
|
||||
}
|
||||
|
||||
// TODO: should be inside the editor
|
||||
@ -364,6 +369,7 @@
|
||||
await ph
|
||||
|
||||
editor = new Editor({
|
||||
enableContentCheck: true,
|
||||
element,
|
||||
editorProps: { attributes: mergeAttributes(defaultEditorAttributes, editorAttributes, { class: 'flex-grow' }) },
|
||||
extensions: [
|
||||
@ -432,6 +438,11 @@
|
||||
|
||||
throttle.call(updateLastUpdateTime)
|
||||
dispatch('update')
|
||||
},
|
||||
onContentError: ({ error, disableCollaboration }) => {
|
||||
disableCollaboration()
|
||||
contentError = true
|
||||
Analytics.handleError(error)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Analytics } from '@hcengineering/analytics'
|
||||
import { Markup } from '@hcengineering/core'
|
||||
import { IntlString, translate } from '@hcengineering/platform'
|
||||
import { EmptyMarkup, getMarkup, markupToJSON } from '@hcengineering/text'
|
||||
@ -150,6 +151,7 @@
|
||||
onMount(() => {
|
||||
void ph.then(async () => {
|
||||
editor = new Editor({
|
||||
enableContentCheck: true,
|
||||
element,
|
||||
editorProps: {
|
||||
attributes: mergeAttributes(defaultEditorAttributes, editorAttributes),
|
||||
@ -197,6 +199,9 @@
|
||||
content = getContent()
|
||||
dispatch('value', content)
|
||||
dispatch('update', content)
|
||||
},
|
||||
onContentError: ({ error }) => {
|
||||
Analytics.handleError(error)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user