Skip to content

Add ESX world logging integration#30

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

Add ESX world logging integration#30
Copilot wants to merge 2 commits intomainfrom
copilot/add-esx-world-logging-integration

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 7, 2026

Adds a new third-party logging integration that automatically captures and forwards structured logs to Fivemanage from six common ESX civilian/world resources.

Changes

  • features/logs/server/third-party/esx-world.ts — New file listening to 12 onNet events across esx_garage, esx_property, esx_drugs, esx_license, esx_identity, and esx_ambulancejob. Each handler resolves player names via GetPlayerName(), constructs rich metadata, and calls ingest() with _internal_RESOURCE set to the originating resource.
  • config.json — Adds esxWorldEvents: { enabled: false, dataset: "default" } under logs.
  • config.schema.json — Adds schema definition and adds "esxWorldEvents" to the required array.
  • features/utils/common/config.ts — Adds esxWorldEvents: EventConfigSchema to ConfigSchema for startup validation.
  • features/logs/server/logger.ts — Adds import './third-party/esx-world' alongside existing third-party imports.

Example

// esx_ambulancejob:revive — logs both participants with identifiers
onNet("esx_ambulancejob:revive", (targetId: number, medicId: number) => {
    ingest(dataset, "info", `player ${targetName} revived by ${medicName}`, {
        targetSource: targetId,
        targetName,
        playerSource: medicId,
        playerName: medicName,
    }, { _internal_RESOURCE: "esx_ambulancejob" });
});

Integration is opt-in (enabled: false by default) and follows the same pattern as the existing ox-inventory integration.

Original prompt

Add ESX World Logging Integration

Add a new third-party logging integration for ESX world/civilian resources (esx_garage, esx_property, esx_drugs, esx_license, esx_identity, esx_ambulancejob) that automatically sends structured logs to Fivemanage.

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-world.ts

Listen to the following events using onNet():

esx_garage:

  • esx_garage:takeOutVehicle — args: (playerId: number, plate: string, model: string) — message: player ${playerName} took out vehicle ${model} (${plate}) from garage, metadata: { playerSource, playerName, vehiclePlate: plate, vehicleModel: model, action: "takeOut" }, resource: "esx_garage"
  • esx_garage:storeVehicle — args: (playerId: number, plate: string, model: string) — message: player ${playerName} stored vehicle ${model} (${plate}) in garage, metadata: { playerSource, playerName, vehiclePlate: plate, vehicleModel: model, action: "store" }, resource: "esx_garage"

esx_property:

  • esx_property:buy — args: (playerId: number, propertyName: string, price: number) — message: player ${playerName} bought property ${propertyName} for $${price}, metadata: { playerSource, playerName, propertyName, price }, resource: "esx_property"
  • esx_property:enter — args: (playerId: number, propertyName: string) — message: player ${playerName} entered property ${propertyName}, metadata: { playerSource, playerName, propertyName, action: "enter" }, resource: "esx_property"
  • esx_property:exit — args: (playerId: number, propertyName: string) — message: player ${playerName} exited property ${propertyName}, metadata: { playerSource, playerName, propertyName, action: "exit" }, resource: "esx_property"

esx_drugs:

  • esx_drugs:harvestPlants — args: (playerId: number, plantType: string, amount: number) — message: player ${playerName} harvested ${amount}x ${plantType}, metadata: { playerSource, playerName, plantType, amount, action: "harvest" }, resource: "esx_drugs"
  • esx_drugs:processDrugs — args: (playerId: number, drugType: string, amount: number) — message: player ${playerName} processed ${amount}x ${drugType}, metadata: { playerSource, playerName, drugType, amount, action: "process" }, resource: "esx_drugs"

esx_license:

  • esx_license:addLicense — args: (playerId: number, licenseType: string) — message: player ${playerName} granted license ${licenseType}, metadata: { playerSource, playerName, licenseType, action: "add" }, resource: "esx_license"
  • esx_license:removeLicense — args: (playerId: number, licenseType: string) — message: player ${playerName} had license ${licenseType} revoked, metadata: { playerSource, playerName, licenseType, action: "remove" }, resource: "esx_license"

esx_identity:

  • esx_identity:registrationDone — args: (playerId: number, firstName: string, lastName: string, dateOfBirth: string, sex: string, height: number) — message: player ${playerName} completed character registration, metadata: { playerSource, playerName, firstName, lastName, dateOfBirth, sex, height }, resource: "esx_identity"

esx_ambulancejob:

  • esx_ambulancejob:revive — args: (targetId: number, medicId: number) — message: player ${targetName} revived by ${medicName}, metadata: { targetSource: targetId, targetName, playerSource: medicId, playerName: medicName }, resource: "esx_ambulancejob"
  • esx_ambulancejob:onPlayerDead — args: (playerId: number) — message: player ${playerName} declared dead, metadata: { playerSource, playerName }, resource: "esx_ambulancejob"

All events should:

  • Use onNet(...) to listen
  • Use GetPlayerName(id.toString()) to resolve player names where applicable
  • Pass { _internal_RESOURCE: "<resource-name>" } as the last _internalOpts argument to ingest()
  • Be gated by if (config.logs.esxWorldEvents?.enabled)
  • Use config.logs.esxWorldEvents.dataset as the dataset

2. Update config.json

Add inside "logs":

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

3. Update config.schema.json

Add the schema entry for esxWorldEvents following the exact same structure as existing entries:

"esxWorldEvents": {
    "description": "ESX world events configuration (garage, property, drugs, license, identity, ambulance).",
    "type": "object",
    "properties": {
        "enabled": {
            "description": "Enable ESX world events to be logged.",
            "type": "boolean",
            "default": false
        },
        "dataset": {
            "description": "Dataset to use for ESX world events.",
            "type": "string",
            "default": "defa...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

Agent-Logs-Url: https://github.com/fivemanage/sdk/sessions/4ff3773a-13c6-4eb9-8ef9-876b365f996d

Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ESX world logging integration for resource events Add ESX world logging integration Apr 7, 2026
Copilot AI requested a review from itschip April 7, 2026 23:52
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