Skip to content

feat: Add esx_policejob logging integration#28

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

feat: Add esx_policejob logging integration#28
Copilot wants to merge 2 commits intomainfrom
copilot/add-esx-policejob-logging-integration

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 7, 2026

Adds a new third-party log integration for esx_policejob, following the same pattern as the existing ox-inventory integration.

Changes

  • features/logs/server/third-party/esx-policejob.ts — New file; listens via onNet to three esx_policejob server events and ingests structured logs with player/officer metadata:
    • esx_policejob:jailPlayer — logs jail duration, target, and officer
    • esx_policejob:handcuffed — logs target and officer
    • esx_policejob:seizeWeapons — logs target, officer, and weapons array
  • config.json — Adds esxPoliceEvents: { enabled: false, dataset: "default" } under logs
  • config.schema.json — Adds esxPoliceEvents schema entry with enabled/dataset properties; adds to required array
  • features/utils/common/config.ts — Adds esxPoliceEvents: EventConfigSchema to the valibot config schema
  • features/logs/server/logger.ts — Adds import './third-party/esx-policejob'

Example log output

// esx_policejob:jailPlayer
ingest(dataset, "info", `player ${targetName} jailed for ${time} minutes by ${officerName}`, {
    targetSource: targetId, targetName,
    playerSource: officerId, playerName: officerName,
    jailTime: time,
}, { _internal_RESOURCE: "esx_policejob" });

Integration is disabled by default and gated by config.logs.esxPoliceEvents?.enabled.

Original prompt

Add ESX Police Job Logging Integration

Add a new third-party logging integration for esx_policejob (ESX Legacy Addons) that automatically sends structured logs to Fivemanage when police job 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-policejob.ts

Listen to the following esx_policejob server events using onNet():

  • esx_policejob:jailPlayer — args: (targetId: number, time: number, officerId: number) — log message: player ${targetName} jailed for ${time} minutes by ${officerName}, metadata: { targetSource: targetId, targetName, playerSource: officerId, playerName: officerName, jailTime: time }

  • esx_policejob:handcuffed — args: (targetId: number, officerId: number) — log message: player ${targetName} handcuffed by officer ${officerName}, metadata: { targetSource: targetId, targetName, playerSource: officerId, playerName: officerName }

  • esx_policejob:seizeWeapons — args: (targetId: number, officerId: number, weapons: unknown[]) — log message: weapons seized from ${targetName} by officer ${officerName}, metadata: { targetSource: targetId, targetName, playerSource: officerId, playerName: officerName, weapons }

All events should:

  • Use onNet(...) to listen
  • Use GetPlayerName(id.toString()) to resolve names for both officer and target
  • Pass { _internal_RESOURCE: "esx_policejob" } as the last _internalOpts argument
  • Be gated by if (config.logs.esxPoliceEvents?.enabled)
  • Use config.logs.esxPoliceEvents.dataset as the dataset

2. Update config.json

Add inside "logs":

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

3. Update config.schema.json

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

"esxPoliceEvents": {
    "description": "ESX police job events configuration.",
    "type": "object",
    "properties": {
        "enabled": {
            "description": "Enable ESX police job events to be logged.",
            "type": "boolean",
            "default": false
        },
        "dataset": {
            "description": "Dataset to use for ESX police job events.",
            "type": "string",
            "default": "default"
        }
    },
    "default": { "enabled": false, "dataset": "default" }
}

Also add "esxPoliceEvents" 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-policejob'

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

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 me look at some key ESX server files to understand what events are emitted:

Assistant: Now let me look at key ESX server-side files to understand the events fired:

Assistant: Now let me dig into the key ESX server files to understand the available events and callbacks:

Assistant: Looking at the full ESX ecosystem and the existing SDK patterns, here's a comprehensive breakdown of what can be automated as new ESX-specific log integrations in fivemanage/sdk, modelled after the existing features/logs/server/third-party/ox-inventory.ts pattern.


ESX Integration Plan for fivemanage/sdk

How the SDK works (quick summary)

The SDK pattern is consistent and clear:

  • Each integration lives in features/logs/server/third-party/<name>.ts
  • It imports ingest(dataset, level, message, metadata) from ../logger
  • It is gated by a config.logs.<featureName>.enabled flag + dataset in config.json
  • Logs have a short human-readable message and a rich metadata object for searching/dashboards
  • It gets imported in logger.ts alongside the others

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

This single file covers the entire ESX core (es_extended) by listening to the server events and exported callbacks ESX fires. Below is the full proposed implementation with all suggested event hooks.


esx_core — `e...

This pull request was created from Copilot chat.

Agent-Logs-Url: https://github.com/fivemanage/sdk/sessions/fb48ac20-a7d3-47ce-bce3-2e077430b77a

Co-authored-by: itschip <59088889+itschip@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ESX police job logging integration feat: Add esx_policejob logging integration Apr 7, 2026
Copilot AI requested a review from itschip April 7, 2026 21:18
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