Skip to content

Add ESX Core (es_extended) logging integration#27

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

Add ESX Core (es_extended) logging integration#27
Copilot wants to merge 2 commits intomainfrom
copilot/add-esx-core-logging-integration

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 7, 2026

Adds a new third-party logging integration for es_extended (ESX Legacy core), following the existing pattern established by ox-inventory.ts. When enabled, the SDK listens to core ESX server events and ships structured logs with rich metadata to Fivemanage.

New file: features/logs/server/third-party/esx-core.ts

Covers 8 ESX core events across four categories, all gated by config.logs.esxCoreEvents?.enabled:

  • Player lifecycleesx:playerLoaded, esx:playerSpawned
  • Job changesesx:setJob (includes new job + previous job metadata)
  • Inventoryesx:addInventoryItem, esx:removeInventoryItem (built-in esx_inventory only, not ox_inventory)
  • Account moneyesx:addAccountMoney, esx:removeAccountMoney, esx:setAccountMoney

All events pass { _internal_RESOURCE: "es_extended" } and resolve player names via GetPlayerName.

Config changes

config.json — new section, disabled by default:

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

config.schema.json — schema entry added, "esxCoreEvents" added to required array.

features/utils/common/config.tsesxCoreEvents: EventConfigSchema added to ConfigSchema.

Wired up in logger.ts

import './third-party/esx-core'
Original prompt

Add ESX Core (es_extended) Logging Integration

Add a new third-party logging integration for es_extended (ESX Legacy core) that automatically sends structured logs to Fivemanage when core ESX player events fire.

Background

The SDK already has a pattern for third-party integrations (see features/logs/server/third-party/ox-inventory.ts). We need to follow the same pattern exactly: create a new file, gate it behind a config flag, and import it in logger.ts.

What to implement

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

Listen to the following es_extended server events and log them using ingest() from ../logger:

Player lifecycle:

  • esx:playerLoaded — args: (playerId: number, xPlayer: { job?: unknown, accounts?: unknown, identifier?: string }) — log message: player ${playerName} loaded, metadata: { playerSource, playerName, job, identifier }
  • esx:playerSpawned — args: (playerId: number) — log message: player ${playerName} spawned, metadata: { playerSource, playerName }

Job changes:

  • esx:setJob — args: (playerId: number, job: { name: string, label: string, grade: number, grade_label: string }, lastJob: { name: string, label: string, grade: number }) — log message: player ${playerName} job changed to ${job.name}, metadata: { playerSource, playerName, job: { name, label, grade, gradeLabel }, previousJob: { name, label, grade } }

Inventory changes (built-in esx_inventory, NOT ox_inventory):

  • esx:addInventoryItem — args: (playerId: number, itemName: string, itemCount: number) — log message: player ${playerName} received item ${itemName} x${itemCount}, metadata: { playerSource, playerName, itemName, itemCount, action: "add" }
  • esx:removeInventoryItem — args: (playerId: number, itemName: string, itemCount: number) — log message: player ${playerName} lost item ${itemName} x${itemCount}, metadata: { playerSource, playerName, itemName, itemCount, action: "remove" }

Account money changes:

  • esx:addAccountMoney — args: (playerId: number, accountName: string, money: number) — log message: player ${playerName} received $${money} in account ${accountName}, metadata: { playerSource, playerName, accountName, amount: money, action: "add" }
  • esx:removeAccountMoney — args: (playerId: number, accountName: string, money: number) — log message: player ${playerName} lost $${money} from account ${accountName}, metadata: { playerSource, playerName, accountName, amount: money, action: "remove" }
  • esx:setAccountMoney — args: (playerId: number, accountName: string, money: number) — log message: player ${playerName} account ${accountName} set to $${money}, metadata: { playerSource, playerName, accountName, amount: money, action: "set" }

All events should:

  • Use onNet(...) to listen
  • Use GetPlayerName(playerId.toString()) to resolve the name
  • Pass { _internal_RESOURCE: "es_extended" } as the last _internalOpts argument to ingest()
  • Be gated by if (config.logs.esxCoreEvents?.enabled)
  • Use config.logs.esxCoreEvents.dataset as the dataset

2. Update config.json

Add the new config section inside "logs":

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

3. Update config.schema.json

Add the schema entry for esxCoreEvents following the exact same structure as the existing entries like oxInventoryEvents:

"esxCoreEvents": {
    "description": "ESX core (es_extended) events configuration.",
    "type": "object",
    "properties": {
        "enabled": {
            "description": "Enable ESX core events to be logged.",
            "type": "boolean",
            "default": false
        },
        "dataset": {
            "description": "Dataset to use for ESX core events.",
            "type": "string",
            "default": "default"
        }
    },
    "default": { "enabled": false, "dataset": "default" }
}

Also add "esxCoreEvents" to the required array.

4. Update features/logs/server/logger.ts

Add the import at the bottom of the existing third-party imports block:

import './third-party/esx-core'

Reference files

  • Pattern to follow: features/logs/server/third-party/ox-inventory.ts
  • Config to update: config.json and config.schema.json
  • Import to add: features/logs/server/logger.ts (add at line ~22 with the other third-party imports)

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Look through the different esx resources in https://github.com/orgs/esx-framework/repositories, including esx_core + legacy addons, and figure out what we can automate in fivemanage/sdk and sends logs directly to Fivemanage from the Fivemanage SDK, by listening to events and other triggers.

We need the logs to have simple log messages and be rich in metadata to make it easy to search for the logs and create dashboards later.

Assistant: Now let m...

This pull request was created from Copilot chat.

Agent-Logs-Url: https://github.com/fivemanage/sdk/sessions/b355eb61-c729-46dc-893f-c51c364ab96a

Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ESX core logging integration for player events Add ESX Core (es_extended) logging integration Apr 7, 2026
Copilot AI requested a review from itschip April 7, 2026 20:09
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