Skip to content

[WIP] Add new third-party logging integration for qbx_core#23

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-qbx-core-logging-integration
Draft

[WIP] Add new third-party logging integration for qbx_core#23
Copilot wants to merge 2 commits intomainfrom
copilot/add-qbx-core-logging-integration

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 2, 2026

  • Plan created
  • Create features/logs/server/third-party/qbx-core.ts
  • Add import to features/logs/server/logger.ts
  • Add qbxCoreEvents to config.json
  • Add qbxCoreEvents schema to config.schema.json
  • Add qbxCoreEvents to features/utils/common/config.ts ConfigSchema
Original 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 existing features/logs/server/third-party/ox-inventory.ts integration.

Files to create/modify

1. Create features/logs/server/third-party/qbx-core.ts

This file intercepts server-side events emitted by qbx_core and logs them via the SDK's ingest() function. The integration must:

  • Be gated behind a config.logs.qbxCoreEvents.enabled boolean
  • Use config.logs.qbxCoreEvents.dataset as the dataset ID
  • Use _internal_RESOURCE: "qbx_core" in the _internalOpts so logs appear attributed to qbx_core
  • Have simple, consistent, searchable log messages (e.g. "qbx_core.playerLoaded") — lowercase dot-notation, no spaces
  • Have rich metadata on every log so dashboards can filter/aggregate easily

Events to intercept and their metadata:

QBCore:Server:OnPlayerLoaded (via onNet)

  • message: "qbx_core.player.loaded"
  • metadata: { playerSource, playerName: GetPlayerName(source) }

QBCore:Server:OnPlayerUnload (via on — server event, source is passed as argument)

  • message: "qbx_core.player.unloaded"
  • metadata: { playerSource, playerName: GetPlayerName(source) }

QBCore:ToggleDuty (via onNet)

  • message: "qbx_core.player.dutyToggled"
  • metadata: { playerSource, playerName: GetPlayerName(source) }
  • Note: We can't know the new duty state from this event alone without calling exports, keep it simple

QBCore:Server:OnJobUpdate (via on)

  • message: "qbx_core.player.jobUpdated"
  • metadata: { playerSource: source (first arg), job: the job table (second arg) } — the handler signature is (source, job)

qbx_core:server:onJobUpdate (via on) — emitted when a job definition itself is updated

  • message: "qbx_core.job.updated"
  • metadata: { jobName, job } — handler signature is (jobName, job)

qbx_core:server:onGangUpdate (via on) — emitted when a gang definition is updated

  • message: "qbx_core.gang.updated"
  • metadata: { gangName, gang } — handler signature is (gangName, gang)

2. Modify features/logs/server/logger.ts

Add the import for the new module, after the existing third-party import line:

import './third-party/ox-inventory'
import './third-party/qbx-core'  // add this line

3. Modify config.json

Add the new config key inside "logs":

"qbxCoreEvents": {
    "enabled": false,
    "dataset": "default"
}

4. Modify config.schema.json

Add the schema entry for qbxCoreEvents inside properties.logs.properties, following the exact same pattern as oxInventoryEvents:

"qbxCoreEvents": {
    "description": "qbx_core framework events configuration.",
    "type": "object",
    "properties": {
        "enabled": {
            "description": "Enable qbx_core events to be logged.",
            "type": "boolean",
            "default": false
        },
        "dataset": {
            "description": "Dataset to use for qbx_core events.",
            "type": "string",
            "default": "default"
        }
    },
    "default": { "enabled": false, "dataset": "default" }
}

Also add "qbxCoreEvents" to the required array in properties.logs.

Important notes

  • Use global.source to capture source inside event handlers (same pattern as player.ts and baseevents.ts)
  • onNet is used for RegisterNetEvent handlers (client-to-server), on for AddEventHandler (server-to-server)
  • Do NOT import anything from qbx_core — only listen to events and use native FiveM globals like GetPlayerName
  • Follow existing code style (no semicolons on imports, consistent spacing)
  • The LogMetadata type is imported from ~/logs/common/misc
  • The ingest function is imported from ../logger (relative to the third-party directory — but since this file IS in third-party, import from ./logger won'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/sdk Logging

How the SDK Works (Key Architecture)

The fivemanage/sdk is already a standalone FiveM resource (TypeScript → compiled dist/server.js). It exposes:

  • A Winston-based logger with a FivemanageTransport that ships logs to Fivemanage's cloud
  • Exported functions (exports.fmsdk.Log(...), `exports.fm...

This pull request was created from Copilot chat.

Agent-Logs-Url: https://github.com/fivemanage/sdk/sessions/ee9de50a-03bb-46b8-a735-b7b4273e7749

Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants