[WIP] Add new third-party logging integration for qbx_core#23
Draft
[WIP] Add new third-party logging integration for qbx_core#23
Conversation
Agent-Logs-Url: https://github.com/fivemanage/sdk/sessions/ee9de50a-03bb-46b8-a735-b7b4273e7749 Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
features/logs/server/third-party/qbx-core.tsfeatures/logs/server/logger.tsqbxCoreEventstoconfig.jsonqbxCoreEventsschema toconfig.schema.jsonqbxCoreEventstofeatures/utils/common/config.tsConfigSchemaOriginal prompt
Overview
Add a new third-party logging integration for
qbx_core— the Qbox FiveM framework core resource. This should follow the exact same pattern as the existingfeatures/logs/server/third-party/ox-inventory.tsintegration.Files to create/modify
1. Create
features/logs/server/third-party/qbx-core.tsThis file intercepts server-side events emitted by
qbx_coreand logs them via the SDK'singest()function. The integration must:config.logs.qbxCoreEvents.enabledbooleanconfig.logs.qbxCoreEvents.datasetas the dataset ID_internal_RESOURCE: "qbx_core"in the_internalOptsso logs appear attributed to qbx_core"qbx_core.playerLoaded") — lowercase dot-notation, no spacesEvents to intercept and their metadata:
QBCore:Server:OnPlayerLoaded(viaonNet)"qbx_core.player.loaded"{ playerSource, playerName: GetPlayerName(source) }QBCore:Server:OnPlayerUnload(viaon— server event, source is passed as argument)"qbx_core.player.unloaded"{ playerSource, playerName: GetPlayerName(source) }QBCore:ToggleDuty(viaonNet)"qbx_core.player.dutyToggled"{ playerSource, playerName: GetPlayerName(source) }QBCore:Server:OnJobUpdate(viaon)"qbx_core.player.jobUpdated"{ playerSource: source (first arg), job: the job table (second arg) }— the handler signature is(source, job)qbx_core:server:onJobUpdate(viaon) — emitted when a job definition itself is updated"qbx_core.job.updated"{ jobName, job }— handler signature is(jobName, job)qbx_core:server:onGangUpdate(viaon) — emitted when a gang definition is updated"qbx_core.gang.updated"{ gangName, gang }— handler signature is(gangName, gang)2. Modify
features/logs/server/logger.tsAdd the import for the new module, after the existing third-party import line:
3. Modify
config.jsonAdd the new config key inside
"logs":4. Modify
config.schema.jsonAdd the schema entry for
qbxCoreEventsinsideproperties.logs.properties, following the exact same pattern asoxInventoryEvents:Also add
"qbxCoreEvents"to therequiredarray inproperties.logs.Important notes
global.sourceto capture source inside event handlers (same pattern asplayer.tsandbaseevents.ts)onNetis used for RegisterNetEvent handlers (client-to-server),onfor AddEventHandler (server-to-server)GetPlayerNameLogMetadatatype is imported from~/logs/common/miscingestfunction is imported from../logger(relative to the third-party directory — but since this file IS in third-party, import from./loggerwon't work — look at how ox-inventory.ts imports:import { ingest } from "../logger")The following is the prior conversation context from the user's chat exploration (may be truncated):
User: How should I integrate these qbox FiveM resources into my fivemanage/sdk resource to handle logging for these qbox FiveM resources. I'm trying to create a large SDK that supports logging for different FiveM frameworks and I need to intercept FiveM events from other resources and log data.
Can you create a little plan of what's possible from what I just added of repos here?
Assistant: Now I have a thorough picture of all repos. Here's the integration plan:
Integration Plan: Qbox →
fivemanage/sdkLoggingHow the SDK Works (Key Architecture)
The
fivemanage/sdkis already a standalone FiveM resource (TypeScript → compileddist/server.js). It exposes:FivemanageTransportthat ships logs to Fivemanage's cloudexports.fmsdk.Log(...), `exports.fm...This pull request was created from Copilot chat.