From 588979e62f41bdb65425363812c6bdf48e66cc2f Mon Sep 17 00:00:00 2001 From: Steve Larson <9larsons@gmail.com> Date: Fri, 22 Nov 2024 18:25:18 -0600 Subject: [PATCH] Added Sentry logging in editor for incorrectly untitled slug values (#21682) ref https://linear.app/ghost/issue/ONC-548/ We seem to occasionally get into a state where draft posts are stuck with an untitled slug, which has been difficult to reproduce. It would be helpful to gather some data on how frequently this is happening. --- ghost/admin/app/controllers/lexical-editor.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ghost/admin/app/controllers/lexical-editor.js b/ghost/admin/app/controllers/lexical-editor.js index 84a1bcb650..f6a3373cb3 100644 --- a/ghost/admin/app/controllers/lexical-editor.js +++ b/ghost/admin/app/controllers/lexical-editor.js @@ -790,7 +790,6 @@ export default class LexicalEditorController extends Controller { } serverSlug = yield this.slugGenerator.generateSlug('post', newSlug); - // If after getting the sanitized and unique slug back from the API // we end up with a slug that matches the existing slug, abort the change if (serverSlug === slug) { @@ -1229,6 +1228,25 @@ export default class LexicalEditorController extends Controller { } } + // Capture posts with untitled slugs and a title set; ref https://linear.app/ghost/issue/ONC-548/ + if (this.post) { + const slug = this.post.get('slug'); + const title = this.post.get('title'); + const isDraft = this.post.get('status') === 'draft'; + const slugContainsUntitled = slug.includes('untitled'); + const isTitleSet = title && title.trim() !== '' && title !== DEFAULT_TITLE; + + if (isDraft && slugContainsUntitled && isTitleSet) { + Sentry.captureException(new Error('Draft post has title set with untitled slug'), { + extra: { + slug: slug, + title: title, + titleScratch: this.post.get('titleScratch') + } + }); + } + } + // the transition is now certain to complete so cleanup and reset if // we're exiting the editor. new->edit keeps everything around and // edit->edit will call reset in the setPost method if necessary