hytopia 0.8.6-devtrace-41ce1a9 → 0.8.6-devtrace-dc6c8b1

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/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
 
@@ -6071,6 +6072,130 @@ export declare function startServer(init: ((() => void) | ((world: World) => voi
6071
6072
  /** The input keys that are included in the PlayerInput. @public */
6072
6073
  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"];
6073
6074
 
6075
+ /**
6076
+ * Manages performance telemetry and error tracking through your Sentry.io account.
6077
+ *
6078
+ * @remarks
6079
+ * The Telemetry class provides low-overhead performance monitoring
6080
+ * and error tracking through Sentry (https://sentry.io) integration
6081
+ * and your provided Sentry DSN. It automatically tracks critical game loop
6082
+ * operations like physics simulation, entity updates, network synchronization,
6083
+ * and more. The system only sends telemetry data when errors or slow-tick
6084
+ * performance issues are detected, minimizing bandwidth and storage costs.
6085
+ *
6086
+ * @example
6087
+ * ```typescript
6088
+ * // Initialize Sentry for production telemetry
6089
+ * Telemetry.initializeSentry('MY_SENTRY_PROJECT_DSN');
6090
+ *
6091
+ * // Wrap performance-critical code in spans
6092
+ * Telemetry.startSpan({
6093
+ * operation: TelemetrySpanOperation.CUSTOM_OPERATION,
6094
+ * attributes: { // any arbitrary attributes you want to attach to the span
6095
+ * playerCount: world.playerManager.connectedPlayers.length,
6096
+ * entityCount: world.entityManager.entityCount,
6097
+ * },
6098
+ * }, () => {
6099
+ * // Your performance-critical code here
6100
+ * performExpensiveOperation();
6101
+ * });
6102
+ *
6103
+ * // Get current process statistics
6104
+ * const stats = Telemetry.getProcessStats();
6105
+ * console.log(`Heap usage: ${stats.jsHeapUsagePercent * 100}%`);
6106
+ * ```
6107
+ *
6108
+ * @public
6109
+ */
6110
+ export declare class Telemetry {
6111
+ /**
6112
+ * Gets current Node.js process memory and performance statistics.
6113
+ *
6114
+ * @param asMeasurement - Whether to return data in Sentry measurement format with units.
6115
+ * @returns Process statistics including heap usage, RSS memory, and capacity metrics.
6116
+ */
6117
+ static getProcessStats(asMeasurement?: boolean): Record<string, any>;
6118
+ /**
6119
+ * Initializes Sentry telemetry with the provided DSN.
6120
+ *
6121
+ * @remarks
6122
+ * This method configures Sentry for error tracking and performance monitoring.
6123
+ * It sets up filtering to only send performance spans that exceed the
6124
+ * provided threshold duration, reducing noise and costs. The initialization
6125
+ * includes game-specific tags and process statistics attachment.
6126
+ *
6127
+ * @param sentryDsn - The Sentry Data Source Name (DSN) for your project.
6128
+ * @param tickTimeMsThreshold - The tick duration that must be exceeded to
6129
+ * send a performance span to Sentry for a given tick. Defaults to 50ms.
6130
+ */
6131
+ static initializeSentry(sentryDsn: string, tickTimeMsThreshold?: number): void;
6132
+ /**
6133
+ * Executes a callback function within a performance monitoring span.
6134
+ *
6135
+ * @remarks
6136
+ * This method provides zero-overhead performance monitoring in development
6137
+ * environments. In production with Sentry enabled and `SENTRY_ENABLE_TRACING=true`,
6138
+ * it creates performance spans for monitoring. The span data is only transmitted
6139
+ * to Sentry when performance issues are detected.
6140
+ *
6141
+ * @param options - Configuration for the telemetry span including operation type and attributes.
6142
+ * @param callback - The function to execute within the performance span.
6143
+ * @returns The return value of the callback function.
6144
+ *
6145
+ * @example
6146
+ * ```typescript
6147
+ * const result = Telemetry.startSpan({
6148
+ * operation: TelemetrySpanOperation.ENTITIES_TICK,
6149
+ * attributes: {
6150
+ * entityCount: entities.length,
6151
+ * worldId: world.id,
6152
+ * },
6153
+ * }, () => {
6154
+ * return processEntities(entities);
6155
+ * });
6156
+ * ```
6157
+ */
6158
+ static startSpan<T>(options: TelemetrySpanOptions, callback: (span?: Sentry.Span) => T): T;
6159
+ /**
6160
+ * Gets the Sentry SDK instance for advanced telemetry operations.
6161
+ *
6162
+ * @remarks
6163
+ * This method provides direct access to the Sentry SDK for operations
6164
+ * not covered by the Telemetry wrapper, such as custom error reporting,
6165
+ * user context setting, or advanced span manipulation.
6166
+ *
6167
+ * @returns The Sentry SDK instance.
6168
+ */
6169
+ static sentry(): typeof Sentry;
6170
+ }
6171
+
6172
+ /** Performance telemetry span operation types. @public */
6173
+ export declare enum TelemetrySpanOperation {
6174
+ BUILD_PACKETS = "build_packets",
6175
+ ENTITIES_EMIT_UPDATES = "entities_emit_updates",
6176
+ ENTITIES_TICK = "entities_tick",
6177
+ NETWORK_SYNCHRONIZE = "network_synchronize",
6178
+ NETWORK_SYNCHRONIZE_CLEANUP = "network_synchronize_cleanup",
6179
+ PHYSICS_CLEANUP = "physics_cleanup",
6180
+ PHYSICS_STEP = "physics_step",
6181
+ SEND_ALL_PACKETS = "send_all_packets",
6182
+ SEND_PACKETS = "send_packets",
6183
+ SERIALIZE_FREE_BUFFERS = "serialize_free_buffers",
6184
+ SERIALIZE_PACKETS = "serialize_packets",
6185
+ SERIALIZE_PACKETS_ENCODE = "serialize_packets_encode",
6186
+ SIMULATION_STEP = "simulation_step",
6187
+ TICKER_TICK = "ticker_tick",
6188
+ WORLD_TICK = "world_tick"
6189
+ }
6190
+
6191
+ /** Options for creating a telemetry span. @public */
6192
+ export declare type TelemetrySpanOptions = {
6193
+ /** The operation being measured. */
6194
+ operation: TelemetrySpanOperation | string;
6195
+ /** Additional attributes to attach to the span for context. */
6196
+ attributes?: Record<string, string | number>;
6197
+ };
6198
+
6074
6199
  /** The options for a trimesh collider. @public */
6075
6200
  export declare interface TrimeshColliderOptions extends BaseColliderOptions {
6076
6201
  shape: ColliderShape.TRIMESH;