Skip to content

feat: add qbx_management event logging integration#26

Open
Copilot wants to merge 2 commits intomainfrom
copilot/add-qbx-management-logging
Open

feat: add qbx_management event logging integration#26
Copilot wants to merge 2 commits intomainfrom
copilot/add-qbx-management-logging

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 2, 2026

Adds a passive server-side logging integration for qbx_management (Qbox job/gang management), following the same pattern as ox-inventory.ts. Intercepts framework events via on/onNet and pipes them through ingest() — no modifications to any Qbox resource required.

New file: features/logs/server/third-party/qbx-management.ts

Six events intercepted:

Event Type Log message
QBCore:Server:OnPlayerLoaded onNet qbx_management.player.loaded
QBCore:Server:OnPlayerUnload on qbx_management.player.unloaded
QBCore:Server:SetDuty on qbx_management.player.clockedIn / .clockedOut
QBCore:Server:OnJobUpdate on qbx_management.player.jobUpdated
qbx_core:server:onJobUpdate on qbx_management.job.definitionUpdated
qbx_core:server:onGangUpdate on qbx_management.gang.definitionUpdated

All events include rich metadata (player source, name, job/gang payload) for dashboard filtering. onNet handlers capture global.source immediately; on handlers with a source param use it directly.

Config changes

  • config.jsonqbxManagementEvents: { enabled: false, dataset: "default" }
  • config.schema.json — schema + required entry for qbxManagementEvents
  • features/utils/common/config.tsqbxManagementEvents: EventConfigSchema added to valibot schema
  • features/logs/server/logger.tsimport './third-party/qbx-management'
Original prompt

Overview

Add a new third-party logging integration for qbx_management — the Qbox job/gang management resource. This follows the exact same pattern as features/logs/server/third-party/ox-inventory.ts.

Files to create/modify

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

Intercepts server-side events from qbx_management and logs them through the SDK's ingest() function.

Rules:

  • Gated behind config.logs.qbxManagementEvents.enabled
  • Uses config.logs.qbxManagementEvents.dataset
  • Uses _internal_RESOURCE: "qbx_management" in _internalOpts
  • Log messages are lowercase dot-notation (e.g. "qbx_management.player.clockedIn") — simple and searchable
  • Metadata is rich — include every contextually available field for dashboard filtering
  • Use global.source to capture source inside onNet handlers
  • Import ingest from "../logger" and config from "~/utils/common/config"

Events to intercept:

QBCore:Server:OnPlayerLoaded (via onNet) — no params, source is the player

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

QBCore:Server:OnPlayerUnload (via on) — source is available via global.source

  • message: "qbx_management.player.unloaded"
  • metadata: { playerSource: source }

QBCore:Server:SetDuty (via on) — handler receives (source: number, duty: boolean)

  • message: duty ? "qbx_management.player.clockedIn" : "qbx_management.player.clockedOut"
  • metadata: { playerSource: source, playerName: GetPlayerName(source.toString()), onDuty: duty }

QBCore:Server:OnJobUpdate (via on) — handler receives (source: number, job: unknown)

  • message: "qbx_management.player.jobUpdated"
  • metadata: { playerSource: source, playerName: GetPlayerName(source.toString()), job }

qbx_core:server:onJobUpdate (via on) — handler receives (jobName: string, job: unknown) — job definition updated

  • message: "qbx_management.job.definitionUpdated"
  • metadata: { jobName, job }

qbx_core:server:onGangUpdate (via on) — handler receives (gangName: string, gang: unknown) — gang definition updated

  • message: "qbx_management.gang.definitionUpdated"
  • metadata: { gangName, gang }

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

Add the import after existing third-party imports:

import './third-party/qbx-management'

3. Modify config.json

Add inside "logs":

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

4. Modify config.schema.json

Add schema entry for qbxManagementEvents in properties.logs.properties and in the required array:

"qbxManagementEvents": {
    "description": "qbx_management job/gang management events configuration.",
    "type": "object",
    "properties": {
        "enabled": {
            "description": "Enable qbx_management events to be logged.",
            "type": "boolean",
            "default": false
        },
        "dataset": {
            "description": "Dataset to use for qbx_management events.",
            "type": "string",
            "default": "default"
        }
    },
    "default": { "enabled": false, "dataset": "default" }
}

Notes

  • onNet = RegisterNetEvent (client triggers server), on = AddEventHandler (server-side)
  • For on handlers that receive source as a parameter (like QBCore:Server:SetDuty), use the parameter directly — do NOT use global.source
  • For onNet handlers, capture with const _source = global.source at the top of the handler (same pattern as player.ts)
  • QBCore:Server:OnPlayerUnload is an AddEventHandler where source is global.source (no parameters)
  • Do NOT import anything from qbx_management — only listen to events passively
  • Follow the existing code style from ox-inventory.ts

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.fmsdk.Info(...), etc.) that any Lua resource can call
  • A third-party integration pattern in features/logs/server/third-party/ — ox-inventory is the onl...

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Add third-party logging integration for qbx_management feat: add qbx_management event logging integration Apr 2, 2026
Copilot AI requested a review from itschip April 2, 2026 01:12
@itschip itschip marked this pull request as ready for review April 18, 2026 21:06
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