hytopia 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun-server.mjs +170 -168
- package/docs/server.md +33 -0
- package/docs/server.telemetry.getprocessstats.md +55 -0
- package/docs/server.telemetry.initializesentry.md +73 -0
- package/docs/server.telemetry.md +125 -0
- package/docs/server.telemetry.sentry.md +23 -0
- package/docs/server.telemetry.startspan.md +90 -0
- package/docs/server.telemetryspanoperation.md +257 -0
- package/docs/server.telemetryspanoptions.md +18 -0
- package/node-server.mjs +168 -166
- package/package.json +1 -1
- package/server.api.json +656 -0
- package/server.d.ts +126 -0
package/server.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import mediasoup from 'mediasoup';
|
|
|
9
9
|
import protocol from '@hytopia.com/server-protocol';
|
|
10
10
|
import RAPIER from '@dimforge/rapier3d-simd-compat';
|
|
11
11
|
import { SdpMatrix3 } from '@dimforge/rapier3d-simd-compat';
|
|
12
|
+
import * as Sentry from '@sentry/node';
|
|
12
13
|
import type { Socket } from 'net';
|
|
13
14
|
import { WebSocket as WebSocket_2 } from 'ws';
|
|
14
15
|
|
|
@@ -6123,6 +6124,131 @@ export declare function startServer(init: ((() => void) | ((world: World) => voi
|
|
|
6123
6124
|
/** The input keys that are included in the PlayerInput. @public */
|
|
6124
6125
|
export declare const SUPPORTED_INPUT_KEYS: readonly ["w", "a", "s", "d", "sp", "sh", "tb", "ml", "mr", "q", "e", "r", "f", "z", "x", "c", "v", "u", "i", "o", "j", "k", "l", "n", "m", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
|
|
6125
6126
|
|
|
6127
|
+
/**
|
|
6128
|
+
* Manages performance telemetry and error tracking through your Sentry.io account.
|
|
6129
|
+
*
|
|
6130
|
+
* @remarks
|
|
6131
|
+
* The Telemetry class provides low-overhead performance monitoring
|
|
6132
|
+
* and error tracking through Sentry (https://sentry.io) integration
|
|
6133
|
+
* and your provided Sentry DSN. It automatically tracks critical game loop
|
|
6134
|
+
* operations like physics simulation, entity updates, network synchronization,
|
|
6135
|
+
* and more. The system only sends telemetry data when errors or slow-tick
|
|
6136
|
+
* performance issues are detected, minimizing bandwidth and storage costs.
|
|
6137
|
+
*
|
|
6138
|
+
* @example
|
|
6139
|
+
* ```typescript
|
|
6140
|
+
* // Initialize Sentry for production telemetry
|
|
6141
|
+
* Telemetry.initializeSentry('MY_SENTRY_PROJECT_DSN');
|
|
6142
|
+
*
|
|
6143
|
+
* // Wrap performance-critical code in spans
|
|
6144
|
+
* Telemetry.startSpan({
|
|
6145
|
+
* operation: TelemetrySpanOperation.CUSTOM_OPERATION,
|
|
6146
|
+
* attributes: { // any arbitrary attributes you want to attach to the span
|
|
6147
|
+
* playerCount: world.playerManager.connectedPlayers.length,
|
|
6148
|
+
* entityCount: world.entityManager.entityCount,
|
|
6149
|
+
* },
|
|
6150
|
+
* }, () => {
|
|
6151
|
+
* // Your performance-critical code here
|
|
6152
|
+
* performExpensiveOperation();
|
|
6153
|
+
* });
|
|
6154
|
+
*
|
|
6155
|
+
* // Get current process statistics
|
|
6156
|
+
* const stats = Telemetry.getProcessStats();
|
|
6157
|
+
* console.log(`Heap usage: ${stats.jsHeapUsagePercent * 100}%`);
|
|
6158
|
+
* ```
|
|
6159
|
+
*
|
|
6160
|
+
* @public
|
|
6161
|
+
*/
|
|
6162
|
+
export declare class Telemetry {
|
|
6163
|
+
/**
|
|
6164
|
+
* Gets current Node.js process memory and performance statistics.
|
|
6165
|
+
*
|
|
6166
|
+
* @param asMeasurement - Whether to return data in Sentry measurement format with units.
|
|
6167
|
+
* @returns Process statistics including heap usage, RSS memory, and capacity metrics.
|
|
6168
|
+
*/
|
|
6169
|
+
static getProcessStats(asMeasurement?: boolean): Record<string, any>;
|
|
6170
|
+
/**
|
|
6171
|
+
* Initializes Sentry telemetry with the provided DSN.
|
|
6172
|
+
*
|
|
6173
|
+
* @remarks
|
|
6174
|
+
* This method configures Sentry for error tracking and performance monitoring.
|
|
6175
|
+
* It sets up filtering to only send performance spans that exceed the
|
|
6176
|
+
* provided threshold duration, reducing noise and costs. The initialization
|
|
6177
|
+
* includes game-specific tags and process statistics attachment.
|
|
6178
|
+
*
|
|
6179
|
+
* @param sentryDsn - The Sentry Data Source Name (DSN) for your project.
|
|
6180
|
+
* @param tickTimeMsThreshold - The tick duration that must be exceeded to
|
|
6181
|
+
* send a performance span to Sentry for a given tick. Defaults to 50ms.
|
|
6182
|
+
*/
|
|
6183
|
+
static initializeSentry(sentryDsn: string, tickTimeMsThreshold?: number): void;
|
|
6184
|
+
/**
|
|
6185
|
+
* Executes a callback function within a performance monitoring span.
|
|
6186
|
+
*
|
|
6187
|
+
* @remarks
|
|
6188
|
+
* This method provides zero-overhead performance monitoring in development
|
|
6189
|
+
* environments. In production with Sentry enabled and `SENTRY_ENABLE_TRACING=true`,
|
|
6190
|
+
* it creates performance spans for monitoring. The span data is only transmitted
|
|
6191
|
+
* to Sentry when performance issues are detected.
|
|
6192
|
+
*
|
|
6193
|
+
* @param options - Configuration for the telemetry span including operation type and attributes.
|
|
6194
|
+
* @param callback - The function to execute within the performance span.
|
|
6195
|
+
* @returns The return value of the callback function.
|
|
6196
|
+
*
|
|
6197
|
+
* @example
|
|
6198
|
+
* ```typescript
|
|
6199
|
+
* const result = Telemetry.startSpan({
|
|
6200
|
+
* operation: TelemetrySpanOperation.ENTITIES_TICK,
|
|
6201
|
+
* attributes: {
|
|
6202
|
+
* entityCount: entities.length,
|
|
6203
|
+
* worldId: world.id,
|
|
6204
|
+
* },
|
|
6205
|
+
* }, () => {
|
|
6206
|
+
* return processEntities(entities);
|
|
6207
|
+
* });
|
|
6208
|
+
* ```
|
|
6209
|
+
*/
|
|
6210
|
+
static startSpan<T>(options: TelemetrySpanOptions, callback: (span?: Sentry.Span) => T): T;
|
|
6211
|
+
/**
|
|
6212
|
+
* Gets the Sentry SDK instance for advanced telemetry operations.
|
|
6213
|
+
*
|
|
6214
|
+
* @remarks
|
|
6215
|
+
* This method provides direct access to the Sentry SDK for operations
|
|
6216
|
+
* not covered by the Telemetry wrapper, such as custom error reporting,
|
|
6217
|
+
* user context setting, or advanced span manipulation.
|
|
6218
|
+
*
|
|
6219
|
+
* @returns The Sentry SDK instance.
|
|
6220
|
+
*/
|
|
6221
|
+
static sentry(): typeof Sentry;
|
|
6222
|
+
}
|
|
6223
|
+
|
|
6224
|
+
/** Performance telemetry span operation types. @public */
|
|
6225
|
+
export declare enum TelemetrySpanOperation {
|
|
6226
|
+
BUILD_PACKETS = "build_packets",
|
|
6227
|
+
ENTITIES_EMIT_UPDATES = "entities_emit_updates",
|
|
6228
|
+
ENTITIES_TICK = "entities_tick",
|
|
6229
|
+
NETWORK_SYNCHRONIZE = "network_synchronize",
|
|
6230
|
+
NETWORK_SYNCHRONIZE_CLEANUP = "network_synchronize_cleanup",
|
|
6231
|
+
PHYSICS_CLEANUP = "physics_cleanup",
|
|
6232
|
+
PHYSICS_STEP = "physics_step",
|
|
6233
|
+
RELEASE_TICK_ALLOCATION = "release_tick_allocation",
|
|
6234
|
+
SEND_ALL_PACKETS = "send_all_packets",
|
|
6235
|
+
SEND_PACKETS = "send_packets",
|
|
6236
|
+
SERIALIZE_FREE_BUFFERS = "serialize_free_buffers",
|
|
6237
|
+
SERIALIZE_PACKETS = "serialize_packets",
|
|
6238
|
+
SERIALIZE_PACKETS_ENCODE = "serialize_packets_encode",
|
|
6239
|
+
SIMULATION_STEP = "simulation_step",
|
|
6240
|
+
TICKER_TICK = "ticker_tick",
|
|
6241
|
+
WORLD_TICK = "world_tick"
|
|
6242
|
+
}
|
|
6243
|
+
|
|
6244
|
+
/** Options for creating a telemetry span. @public */
|
|
6245
|
+
export declare type TelemetrySpanOptions = {
|
|
6246
|
+
/** The operation being measured. */
|
|
6247
|
+
operation: TelemetrySpanOperation | string;
|
|
6248
|
+
/** Additional attributes to attach to the span for context. */
|
|
6249
|
+
attributes?: Record<string, string | number>;
|
|
6250
|
+
};
|
|
6251
|
+
|
|
6126
6252
|
/**
|
|
6127
6253
|
* High-performance tick-scoped allocator for temporary objects, arrays, and buffers.
|
|
6128
6254
|
* All allocations are automatically bulk-released when reset() is called.
|