{"record":{"id":"6c8b943dd78bb4af","repo":"RocketChat/Rocket.Chat","slug":"saving-page-history-without-room-id-for-visitor","errorCode":null,"errorMessage":"Saving page history without room id for visitor","messagePattern":"Saving page history without room id for visitor","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"apps/meteor/server/lib/omnichannel/tracking.ts","lineNumber":42,"sourceCode":"\n\tconst pageTitle = pageInfo.title;\n\tconst pageUrl = pageInfo.location.href;\n\tconst extraData: {\n\t\tnavigation: {\n\t\t\tpage: PageInfo;\n\t\t\ttoken: string;\n\t\t};\n\t\texpireAt?: number;\n\t\t_hidden?: boolean;\n\t} = {\n\t\tnavigation: {\n\t\t\tpage: pageInfo,\n\t\t\ttoken,\n\t\t},\n\t};\n\n\tif (!roomId) {\n\t\tlivechatLogger.warn({ msg: 'Saving page history without room id for visitor', token });\n\t\t// keep history of unregistered visitors for 1 month\n\t\tconst keepHistoryMiliseconds = 2592000000;\n\t\textraData.expireAt = new Date().getTime() + keepHistoryMiliseconds;\n\t}\n\n\tif (!settings.get('Livechat_Visitor_navigation_as_a_message')) {\n\t\textraData._hidden = true;\n\t}\n\n\t// @ts-expect-error: Investigating on which case we won't receive a roomId and where that history is supposed to be stored\n\treturn Message.saveSystemMessage('livechat_navigation_history', roomId, `${pageTitle} - ${pageUrl}`, user, extraData);\n}\n","sourceCodeStart":24,"sourceCodeEnd":55,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/omnichannel/tracking.ts#L24-L55","documentation":"savePageHistory records a livechat visitor's page navigation as a 'livechat_navigation_history' system message inside the chat room. When roomId is falsy — visitor browsing before any conversation started, or the caller did not resolve a room — the message cannot be attached to a room; it is still saved but tagged with a 30-day TTL (2592000000 ms) so orphan records expire automatically.","triggerScenarios":"Omnichannel page-tracking events arriving with no roomId: visitor landed on a tracked page but never opened a chat, or an integration fired tracking events without resolving the room first.","commonSituations":"Websites with the Livechat monitoring script on all pages; visitors who browse but never start a conversation; custom widgets that send page.visited before room creation.","solutions":["No action if you intentionally keep navigation history of unregistered visitors — records auto-expire after 1 month","If these records are unwanted, restrict the pages where the Livechat monitoring script runs","To attach history to rooms, ensure the visitor has an open room before sending page events (start the chat first)","Audit orphan volume by querying messages with t='livechat_navigation_history' and expireAt set"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!roomId) {\n  // skip persisting, or defer until the visitor opens a room — do not save room-less history silently\n  livechatLogger.debug({ msg: 'Skipping page history — no room for visitor', token });\n  return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve the visitor's room before emitting page-tracking events","Only load the Livechat monitoring script on pages where you want tracked history","Remember room-less records expire after 30 days — do not treat them as durable analytics"],"tags":["omnichannel","livechat","navigation-history","tracking"],"backgroundTag":"missing-room-reference","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}