Skip to content

Commit e8a47c3

Browse files
committed
fix: inline TelemetryClient queue initialization to avoid method binding issues
1 parent 3e1e411 commit e8a47c3

File tree

1 file changed

+29
-37
lines changed

1 file changed

+29
-37
lines changed

packages/cloud/src/TelemetryClient.ts

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,39 @@ export class TelemetryClient extends BaseTelemetryClient {
3434

3535
// Initialize queue and retry manager if context is provided
3636
if (context) {
37-
this.initializeQueueSystem()
38-
}
39-
}
40-
41-
private initializeQueueSystem(): void {
42-
if (!this.context) {
43-
return
44-
}
45-
46-
// Initialize queue
47-
this.queue = new TelemetryQueue(this.context, {
48-
maxQueueSize: 1000,
49-
maxRetries: 5,
50-
queueSizeWarningThreshold: 100,
51-
})
37+
// Initialize queue
38+
this.queue = new TelemetryQueue(context, {
39+
maxQueueSize: 1000,
40+
maxRetries: 5,
41+
queueSizeWarningThreshold: 100,
42+
})
5243

53-
// Initialize retry manager
54-
this.retryManager = new TelemetryRetryManager(
55-
this.queue,
56-
async (event) => {
57-
// Send event without queueing on retry
58-
await this.sendEventDirect(event)
59-
},
60-
{
61-
retryIntervalMs: 30000, // 30 seconds
62-
batchSize: 10,
63-
onConnectionStatusChange: (isConnected) => {
64-
if (this.connectionStatusCallback) {
65-
this.connectionStatusCallback(isConnected)
66-
}
44+
// Initialize retry manager
45+
this.retryManager = new TelemetryRetryManager(
46+
this.queue,
47+
async (event) => {
48+
// Send event without queueing on retry
49+
await this.sendEventDirect(event)
6750
},
68-
onQueueSizeChange: (size, isAboveThreshold) => {
69-
if (this.queueSizeCallback) {
70-
this.queueSizeCallback(size, isAboveThreshold)
71-
}
51+
{
52+
retryIntervalMs: 30000, // 30 seconds
53+
batchSize: 10,
54+
onConnectionStatusChange: (isConnected) => {
55+
if (this.connectionStatusCallback) {
56+
this.connectionStatusCallback(isConnected)
57+
}
58+
},
59+
onQueueSizeChange: (size, isAboveThreshold) => {
60+
if (this.queueSizeCallback) {
61+
this.queueSizeCallback(size, isAboveThreshold)
62+
}
63+
},
7264
},
73-
},
74-
)
65+
)
7566

76-
// Start the retry manager
77-
this.retryManager.start()
67+
// Start the retry manager
68+
this.retryManager.start()
69+
}
7870
}
7971

8072
/**

0 commit comments

Comments
 (0)