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/docs/server.md CHANGED
@@ -445,6 +445,17 @@ A simple entity controller with basic movement functions.
445
445
  Represents the physics simulation for a world.
446
446
 
447
447
 
448
+ </td></tr>
449
+ <tr><td>
450
+
451
+ [Telemetry](./server.telemetry.md)
452
+
453
+
454
+ </td><td>
455
+
456
+ Manages performance telemetry and error tracking through your Sentry.io account.
457
+
458
+
448
459
  </td></tr>
449
460
  <tr><td>
450
461
 
@@ -794,6 +805,17 @@ Event types a SceneUI instance can emit. See [SceneUIEventPayloads](./server.sce
794
805
  Event types a Simulation instance can emit. See [SimulationEventPayloads](./server.simulationeventpayloads.md) for the payloads.
795
806
 
796
807
 
808
+ </td></tr>
809
+ <tr><td>
810
+
811
+ [TelemetrySpanOperation](./server.telemetryspanoperation.md)
812
+
813
+
814
+ </td><td>
815
+
816
+ Performance telemetry span operation types.
817
+
818
+
797
819
  </td></tr>
798
820
  <tr><td>
799
821
 
@@ -1899,6 +1921,17 @@ Additional mass properties for a RigidBody.
1899
1921
  The options for a rigid body.
1900
1922
 
1901
1923
 
1924
+ </td></tr>
1925
+ <tr><td>
1926
+
1927
+ [TelemetrySpanOptions](./server.telemetryspanoptions.md)
1928
+
1929
+
1930
+ </td><td>
1931
+
1932
+ Options for creating a telemetry span.
1933
+
1934
+
1902
1935
  </td></tr>
1903
1936
  <tr><td>
1904
1937
 
@@ -0,0 +1,55 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [Telemetry](./server.telemetry.md) &gt; [getProcessStats](./server.telemetry.getprocessstats.md)
4
+
5
+ ## Telemetry.getProcessStats() method
6
+
7
+ Gets current Node.js process memory and performance statistics.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ static getProcessStats(asMeasurement?: boolean): Record<string, any>;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ asMeasurement
36
+
37
+
38
+ </td><td>
39
+
40
+ boolean
41
+
42
+
43
+ </td><td>
44
+
45
+ _(Optional)_ Whether to return data in Sentry measurement format with units.
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+ **Returns:**
51
+
52
+ Record&lt;string, any&gt;
53
+
54
+ Process statistics including heap usage, RSS memory, and capacity metrics.
55
+
@@ -0,0 +1,73 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [Telemetry](./server.telemetry.md) &gt; [initializeSentry](./server.telemetry.initializesentry.md)
4
+
5
+ ## Telemetry.initializeSentry() method
6
+
7
+ Initializes Sentry telemetry with the provided DSN.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ static initializeSentry(sentryDsn: string, tickTimeMsThreshold?: number): void;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ sentryDsn
36
+
37
+
38
+ </td><td>
39
+
40
+ string
41
+
42
+
43
+ </td><td>
44
+
45
+ The Sentry Data Source Name (DSN) for your project.
46
+
47
+
48
+ </td></tr>
49
+ <tr><td>
50
+
51
+ tickTimeMsThreshold
52
+
53
+
54
+ </td><td>
55
+
56
+ number
57
+
58
+
59
+ </td><td>
60
+
61
+ _(Optional)_ The tick duration that must be exceeded to send a performance span to Sentry for a given tick. Defaults to 50ms.
62
+
63
+
64
+ </td></tr>
65
+ </tbody></table>
66
+ **Returns:**
67
+
68
+ void
69
+
70
+ ## Remarks
71
+
72
+ This method configures Sentry for error tracking and performance monitoring. It sets up filtering to only send performance spans that exceed the provided threshold duration, reducing noise and costs. The initialization includes game-specific tags and process statistics attachment.
73
+
@@ -0,0 +1,125 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [Telemetry](./server.telemetry.md)
4
+
5
+ ## Telemetry class
6
+
7
+ Manages performance telemetry and error tracking through your Sentry.io account.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export default class Telemetry
13
+ ```
14
+
15
+ ## Remarks
16
+
17
+ The Telemetry class provides low-overhead performance monitoring and error tracking through Sentry (https://sentry.io) integration and your provided Sentry DSN. It automatically tracks critical game loop operations like physics simulation, entity updates, network synchronization, and more. The system only sends telemetry data when errors or slow-tick performance issues are detected, minimizing bandwidth and storage costs.
18
+
19
+ ## Example
20
+
21
+
22
+ ```typescript
23
+ // Initialize Sentry for production telemetry
24
+ Telemetry.initializeSentry('MY_SENTRY_PROJECT_DSN');
25
+
26
+ // Wrap performance-critical code in spans
27
+ Telemetry.startSpan({
28
+ operation: TelemetrySpanOperation.CUSTOM_OPERATION,
29
+ attributes: { // any arbitrary attributes you want to attach to the span
30
+ playerCount: world.playerManager.connectedPlayers.length,
31
+ entityCount: world.entityManager.entityCount,
32
+ },
33
+ }, () => {
34
+ // Your performance-critical code here
35
+ performExpensiveOperation();
36
+ });
37
+
38
+ // Get current process statistics
39
+ const stats = Telemetry.getProcessStats();
40
+ console.log(`Heap usage: ${stats.jsHeapUsagePercent * 100}%`);
41
+ ```
42
+
43
+ ## Methods
44
+
45
+ <table><thead><tr><th>
46
+
47
+ Method
48
+
49
+
50
+ </th><th>
51
+
52
+ Modifiers
53
+
54
+
55
+ </th><th>
56
+
57
+ Description
58
+
59
+
60
+ </th></tr></thead>
61
+ <tbody><tr><td>
62
+
63
+ [getProcessStats(asMeasurement)](./server.telemetry.getprocessstats.md)
64
+
65
+
66
+ </td><td>
67
+
68
+ `static`
69
+
70
+
71
+ </td><td>
72
+
73
+ Gets current Node.js process memory and performance statistics.
74
+
75
+
76
+ </td></tr>
77
+ <tr><td>
78
+
79
+ [initializeSentry(sentryDsn, tickTimeMsThreshold)](./server.telemetry.initializesentry.md)
80
+
81
+
82
+ </td><td>
83
+
84
+ `static`
85
+
86
+
87
+ </td><td>
88
+
89
+ Initializes Sentry telemetry with the provided DSN.
90
+
91
+
92
+ </td></tr>
93
+ <tr><td>
94
+
95
+ [sentry()](./server.telemetry.sentry.md)
96
+
97
+
98
+ </td><td>
99
+
100
+ `static`
101
+
102
+
103
+ </td><td>
104
+
105
+ Gets the Sentry SDK instance for advanced telemetry operations.
106
+
107
+
108
+ </td></tr>
109
+ <tr><td>
110
+
111
+ [startSpan(options, callback)](./server.telemetry.startspan.md)
112
+
113
+
114
+ </td><td>
115
+
116
+ `static`
117
+
118
+
119
+ </td><td>
120
+
121
+ Executes a callback function within a performance monitoring span.
122
+
123
+
124
+ </td></tr>
125
+ </tbody></table>
@@ -0,0 +1,23 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [Telemetry](./server.telemetry.md) &gt; [sentry](./server.telemetry.sentry.md)
4
+
5
+ ## Telemetry.sentry() method
6
+
7
+ Gets the Sentry SDK instance for advanced telemetry operations.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ static sentry(): typeof Sentry;
13
+ ```
14
+ **Returns:**
15
+
16
+ typeof Sentry
17
+
18
+ The Sentry SDK instance.
19
+
20
+ ## Remarks
21
+
22
+ This method provides direct access to the Sentry SDK for operations not covered by the Telemetry wrapper, such as custom error reporting, user context setting, or advanced span manipulation.
23
+
@@ -0,0 +1,90 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [Telemetry](./server.telemetry.md) &gt; [startSpan](./server.telemetry.startspan.md)
4
+
5
+ ## Telemetry.startSpan() method
6
+
7
+ Executes a callback function within a performance monitoring span.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ static startSpan<T>(options: TelemetrySpanOptions, callback: (span?: Sentry.Span) => T): T;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ options
36
+
37
+
38
+ </td><td>
39
+
40
+ [TelemetrySpanOptions](./server.telemetryspanoptions.md)
41
+
42
+
43
+ </td><td>
44
+
45
+ Configuration for the telemetry span including operation type and attributes.
46
+
47
+
48
+ </td></tr>
49
+ <tr><td>
50
+
51
+ callback
52
+
53
+
54
+ </td><td>
55
+
56
+ (span?: Sentry.Span) =&gt; T
57
+
58
+
59
+ </td><td>
60
+
61
+ The function to execute within the performance span.
62
+
63
+
64
+ </td></tr>
65
+ </tbody></table>
66
+ **Returns:**
67
+
68
+ T
69
+
70
+ The return value of the callback function.
71
+
72
+ ## Remarks
73
+
74
+ This method provides zero-overhead performance monitoring in development environments. In production with Sentry enabled and `SENTRY_ENABLE_TRACING=true`<!-- -->, it creates performance spans for monitoring. The span data is only transmitted to Sentry when performance issues are detected.
75
+
76
+ ## Example
77
+
78
+
79
+ ```typescript
80
+ const result = Telemetry.startSpan({
81
+ operation: TelemetrySpanOperation.ENTITIES_TICK,
82
+ attributes: {
83
+ entityCount: entities.length,
84
+ worldId: world.id,
85
+ },
86
+ }, () => {
87
+ return processEntities(entities);
88
+ });
89
+ ```
90
+
@@ -0,0 +1,257 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [TelemetrySpanOperation](./server.telemetryspanoperation.md)
4
+
5
+ ## TelemetrySpanOperation enum
6
+
7
+ Performance telemetry span operation types.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare enum TelemetrySpanOperation
13
+ ```
14
+
15
+ ## Enumeration Members
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Member
20
+
21
+
22
+ </th><th>
23
+
24
+ Value
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ BUILD\_PACKETS
36
+
37
+
38
+ </td><td>
39
+
40
+ `"build_packets"`
41
+
42
+
43
+ </td><td>
44
+
45
+
46
+ </td></tr>
47
+ <tr><td>
48
+
49
+ ENTITIES\_EMIT\_UPDATES
50
+
51
+
52
+ </td><td>
53
+
54
+ `"entities_emit_updates"`
55
+
56
+
57
+ </td><td>
58
+
59
+
60
+ </td></tr>
61
+ <tr><td>
62
+
63
+ ENTITIES\_TICK
64
+
65
+
66
+ </td><td>
67
+
68
+ `"entities_tick"`
69
+
70
+
71
+ </td><td>
72
+
73
+
74
+ </td></tr>
75
+ <tr><td>
76
+
77
+ NETWORK\_SYNCHRONIZE
78
+
79
+
80
+ </td><td>
81
+
82
+ `"network_synchronize"`
83
+
84
+
85
+ </td><td>
86
+
87
+
88
+ </td></tr>
89
+ <tr><td>
90
+
91
+ NETWORK\_SYNCHRONIZE\_CLEANUP
92
+
93
+
94
+ </td><td>
95
+
96
+ `"network_synchronize_cleanup"`
97
+
98
+
99
+ </td><td>
100
+
101
+
102
+ </td></tr>
103
+ <tr><td>
104
+
105
+ PHYSICS\_CLEANUP
106
+
107
+
108
+ </td><td>
109
+
110
+ `"physics_cleanup"`
111
+
112
+
113
+ </td><td>
114
+
115
+
116
+ </td></tr>
117
+ <tr><td>
118
+
119
+ PHYSICS\_STEP
120
+
121
+
122
+ </td><td>
123
+
124
+ `"physics_step"`
125
+
126
+
127
+ </td><td>
128
+
129
+
130
+ </td></tr>
131
+ <tr><td>
132
+
133
+ RELEASE\_TICK\_ALLOCATION
134
+
135
+
136
+ </td><td>
137
+
138
+ `"release_tick_allocation"`
139
+
140
+
141
+ </td><td>
142
+
143
+
144
+ </td></tr>
145
+ <tr><td>
146
+
147
+ SEND\_ALL\_PACKETS
148
+
149
+
150
+ </td><td>
151
+
152
+ `"send_all_packets"`
153
+
154
+
155
+ </td><td>
156
+
157
+
158
+ </td></tr>
159
+ <tr><td>
160
+
161
+ SEND\_PACKETS
162
+
163
+
164
+ </td><td>
165
+
166
+ `"send_packets"`
167
+
168
+
169
+ </td><td>
170
+
171
+
172
+ </td></tr>
173
+ <tr><td>
174
+
175
+ SERIALIZE\_FREE\_BUFFERS
176
+
177
+
178
+ </td><td>
179
+
180
+ `"serialize_free_buffers"`
181
+
182
+
183
+ </td><td>
184
+
185
+
186
+ </td></tr>
187
+ <tr><td>
188
+
189
+ SERIALIZE\_PACKETS
190
+
191
+
192
+ </td><td>
193
+
194
+ `"serialize_packets"`
195
+
196
+
197
+ </td><td>
198
+
199
+
200
+ </td></tr>
201
+ <tr><td>
202
+
203
+ SERIALIZE\_PACKETS\_ENCODE
204
+
205
+
206
+ </td><td>
207
+
208
+ `"serialize_packets_encode"`
209
+
210
+
211
+ </td><td>
212
+
213
+
214
+ </td></tr>
215
+ <tr><td>
216
+
217
+ SIMULATION\_STEP
218
+
219
+
220
+ </td><td>
221
+
222
+ `"simulation_step"`
223
+
224
+
225
+ </td><td>
226
+
227
+
228
+ </td></tr>
229
+ <tr><td>
230
+
231
+ TICKER\_TICK
232
+
233
+
234
+ </td><td>
235
+
236
+ `"ticker_tick"`
237
+
238
+
239
+ </td><td>
240
+
241
+
242
+ </td></tr>
243
+ <tr><td>
244
+
245
+ WORLD\_TICK
246
+
247
+
248
+ </td><td>
249
+
250
+ `"world_tick"`
251
+
252
+
253
+ </td><td>
254
+
255
+
256
+ </td></tr>
257
+ </tbody></table>
@@ -0,0 +1,18 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [TelemetrySpanOptions](./server.telemetryspanoptions.md)
4
+
5
+ ## TelemetrySpanOptions type
6
+
7
+ Options for creating a telemetry span.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type TelemetrySpanOptions = {
13
+ operation: TelemetrySpanOperation | string;
14
+ attributes?: Record<string, string | number>;
15
+ };
16
+ ```
17
+ **References:** [TelemetrySpanOperation](./server.telemetryspanoperation.md)
18
+