@posthog/agent 2.1.125 → 2.1.131
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/dist/agent.js +1 -35
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +1 -35
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +1 -35
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +1 -1
- package/src/session-log-writer.ts +1 -36
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@ export class SessionLogWriter {
|
|
|
37
37
|
private lastFlushAttemptTime: Map<string, number> = new Map();
|
|
38
38
|
private retryCounts: Map<string, number> = new Map();
|
|
39
39
|
private sessions: Map<string, SessionState> = new Map();
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
private logger: Logger;
|
|
42
42
|
private localCachePath?: string;
|
|
43
43
|
|
|
@@ -51,20 +51,6 @@ export class SessionLogWriter {
|
|
|
51
51
|
|
|
52
52
|
async flushAll(): Promise<void> {
|
|
53
53
|
const sessionIds = [...this.sessions.keys()];
|
|
54
|
-
const pendingCounts = sessionIds.map((id) => {
|
|
55
|
-
const session = this.sessions.get(id);
|
|
56
|
-
return {
|
|
57
|
-
taskId: session?.context.taskId,
|
|
58
|
-
runId: session?.context.runId,
|
|
59
|
-
pending: this.pendingEntries.get(id)?.length ?? 0,
|
|
60
|
-
messages: this.messageCounts.get(id) ?? 0,
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
this.logger.info("flushAll called", {
|
|
64
|
-
sessions: sessionIds.length,
|
|
65
|
-
pending: pendingCounts,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
54
|
const flushPromises: Promise<void>[] = [];
|
|
69
55
|
for (const sessionId of sessionIds) {
|
|
70
56
|
flushPromises.push(this.flush(sessionId));
|
|
@@ -115,16 +101,6 @@ export class SessionLogWriter {
|
|
|
115
101
|
return;
|
|
116
102
|
}
|
|
117
103
|
|
|
118
|
-
const count = (this.messageCounts.get(sessionId) ?? 0) + 1;
|
|
119
|
-
this.messageCounts.set(sessionId, count);
|
|
120
|
-
if (count % 10 === 1) {
|
|
121
|
-
this.logger.info("Messages received", {
|
|
122
|
-
count,
|
|
123
|
-
taskId: session.context.taskId,
|
|
124
|
-
runId: session.context.runId,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
104
|
try {
|
|
129
105
|
const message = JSON.parse(line);
|
|
130
106
|
const timestamp = new Date().toISOString();
|
|
@@ -186,12 +162,6 @@ export class SessionLogWriter {
|
|
|
186
162
|
|
|
187
163
|
const pending = this.pendingEntries.get(sessionId);
|
|
188
164
|
if (!this.posthogAPI || !pending?.length) {
|
|
189
|
-
this.logger.info("flush: nothing to persist", {
|
|
190
|
-
taskId: session.context.taskId,
|
|
191
|
-
runId: session.context.runId,
|
|
192
|
-
hasPosthogAPI: !!this.posthogAPI,
|
|
193
|
-
pendingCount: pending?.length ?? 0,
|
|
194
|
-
});
|
|
195
165
|
return;
|
|
196
166
|
}
|
|
197
167
|
|
|
@@ -211,11 +181,6 @@ export class SessionLogWriter {
|
|
|
211
181
|
pending,
|
|
212
182
|
);
|
|
213
183
|
this.retryCounts.set(sessionId, 0);
|
|
214
|
-
this.logger.info("Flushed session logs", {
|
|
215
|
-
taskId: session.context.taskId,
|
|
216
|
-
runId: session.context.runId,
|
|
217
|
-
entryCount: pending.length,
|
|
218
|
-
});
|
|
219
184
|
} catch (error) {
|
|
220
185
|
const retryCount = (this.retryCounts.get(sessionId) ?? 0) + 1;
|
|
221
186
|
this.retryCounts.set(sessionId, retryCount);
|