posthog-node 5.48.0 → 5.48.1
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/capture-v1/sender.d.ts.map +1 -1
- package/dist/capture-v1/sender.js +83 -37
- package/dist/capture-v1/sender.mjs +83 -37
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -1
- package/dist/client.mjs +2 -1
- package/dist/entrypoints/index.node.d.ts +1 -0
- package/dist/entrypoints/index.node.d.ts.map +1 -1
- package/dist/entrypoints/index.node.js +7 -0
- package/dist/entrypoints/index.node.mjs +4 -0
- package/dist/gzip.node.d.ts +2 -0
- package/dist/gzip.node.d.ts.map +1 -0
- package/dist/gzip.node.js +49 -0
- package/dist/gzip.node.mjs +15 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +2 -2
- package/src/capture-v1/sender.ts +130 -55
- package/src/client.ts +1 -0
- package/src/entrypoints/index.node.ts +5 -0
- package/src/gzip.node.ts +16 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sender.d.ts","sourceRoot":"","sources":["../../src/capture-v1/sender.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,sBAAsB,EAO5B,MAAM,eAAe,CAAA;AAYtB,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,qFAAqF;IACrF,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,wFAAwF;IACxF,kBAAkB,EAAE,OAAO,CAAA;IAC3B,gBAAgB,EAAE,MAAM,CAAA;IACxB,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAA;IACnB,iFAAiF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70,41 +70,47 @@ class V1CaptureSender {
|
|
|
70
70
|
} : {},
|
|
71
71
|
batch: pending
|
|
72
72
|
});
|
|
73
|
-
let
|
|
73
|
+
let captureAttempt;
|
|
74
|
+
let retryDelayMs;
|
|
74
75
|
try {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const { status } = response;
|
|
82
|
-
if (status < 200 || status >= 300) {
|
|
83
|
-
if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
|
|
76
|
+
captureAttempt = await this.sendOnce(url, payload, attempt, requestId);
|
|
77
|
+
const { response, signal } = captureAttempt;
|
|
78
|
+
const { status } = response;
|
|
79
|
+
if (status < 200 || status >= 300) if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
|
|
84
80
|
const retryAfterMs = this.parseRetryAfter(response);
|
|
85
|
-
await
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
await captureAttempt.waitFor(captureAttempt.cancelBody()).catch(()=>{});
|
|
82
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
83
|
+
} else {
|
|
84
|
+
const httpError = await this.buildHttpError(response, status, captureAttempt.waitFor);
|
|
85
|
+
return this.surfaceBatchFailure(requestId, drops, pending, httpError);
|
|
88
86
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
else {
|
|
88
|
+
let parsed;
|
|
89
|
+
try {
|
|
90
|
+
parsed = await captureAttempt.waitFor(this.parseResponse(response));
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (signal.aborted) throw error;
|
|
93
|
+
return this.surfaceBatchFailure(requestId, drops, pending, new Error(`Capture V1 returned an unparseable ${status} response body`));
|
|
94
|
+
}
|
|
95
|
+
const retryable = this.classify(pending, parsed, drops);
|
|
96
|
+
if (0 === retryable.length) return this.surfacePartialDrops(requestId, drops);
|
|
97
|
+
if (isLastAttempt) return void this.onError(new external_errors_js_namespaceObject.CaptureV1Error({
|
|
98
|
+
requestId,
|
|
99
|
+
drops,
|
|
100
|
+
retryExhausted: retryable.map((event)=>event.uuid)
|
|
101
|
+
}));
|
|
102
|
+
pending = retryable;
|
|
103
|
+
const retryAfterMs = this.parseRetryAfter(response);
|
|
104
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
105
|
+
}
|
|
106
|
+
} catch (transportError) {
|
|
107
|
+
if (captureAttempt && !captureAttempt.signal.aborted) throw transportError;
|
|
108
|
+
if (isLastAttempt) return this.surfaceBatchFailure(requestId, drops, pending, transportError);
|
|
109
|
+
retryDelayMs = this.backoffDelay(attempt);
|
|
110
|
+
} finally{
|
|
111
|
+
captureAttempt?.cleanup();
|
|
97
112
|
}
|
|
98
|
-
|
|
99
|
-
if (0 === retryable.length) return this.surfacePartialDrops(requestId, drops);
|
|
100
|
-
if (isLastAttempt) return void this.onError(new external_errors_js_namespaceObject.CaptureV1Error({
|
|
101
|
-
requestId,
|
|
102
|
-
drops,
|
|
103
|
-
retryExhausted: retryable.map((event)=>event.uuid)
|
|
104
|
-
}));
|
|
105
|
-
pending = retryable;
|
|
106
|
-
const retryAfterMs = this.parseRetryAfter(response);
|
|
107
|
-
await this.sleep(this.backoffDelay(attempt, retryAfterMs));
|
|
113
|
+
if (void 0 !== retryDelayMs) await this.sleep(retryDelayMs);
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
async sendOnce(url, payload, attempt, requestId) {
|
|
@@ -118,16 +124,54 @@ class V1CaptureSender {
|
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
const controller = new AbortController();
|
|
121
|
-
|
|
127
|
+
let timeoutPhase = 'waiting for response headers';
|
|
128
|
+
let timer;
|
|
129
|
+
const deadline = new Promise((_resolve, reject)=>{
|
|
130
|
+
timer = (0, core_namespaceObject.safeSetTimeout)(()=>{
|
|
131
|
+
const timeoutError = new Error(`Capture V1 request timed out ${timeoutPhase} after ${this.config.requestTimeoutMs}ms`);
|
|
132
|
+
timeoutError.name = 'AbortError';
|
|
133
|
+
reject(timeoutError);
|
|
134
|
+
controller.abort(timeoutError);
|
|
135
|
+
}, this.config.requestTimeoutMs);
|
|
136
|
+
});
|
|
122
137
|
try {
|
|
123
|
-
|
|
138
|
+
const fetchPromise = this.fetchFn(url, {
|
|
124
139
|
method: 'POST',
|
|
125
140
|
headers,
|
|
126
141
|
body,
|
|
127
142
|
signal: controller.signal
|
|
128
143
|
});
|
|
129
|
-
|
|
144
|
+
let responseAccepted = false;
|
|
145
|
+
fetchPromise.then((lateResponse)=>{
|
|
146
|
+
if (controller.signal.aborted && !responseAccepted) this.cancelBody(lateResponse);
|
|
147
|
+
}).catch(()=>{});
|
|
148
|
+
const response = await Promise.race([
|
|
149
|
+
fetchPromise,
|
|
150
|
+
deadline
|
|
151
|
+
]);
|
|
152
|
+
responseAccepted = true;
|
|
153
|
+
timeoutPhase = 'while reading the response body';
|
|
154
|
+
let cleanedUp = false;
|
|
155
|
+
let cancellation;
|
|
156
|
+
const cancelBody = ()=>cancellation ??= this.cancelBody(response);
|
|
157
|
+
return {
|
|
158
|
+
response,
|
|
159
|
+
signal: controller.signal,
|
|
160
|
+
waitFor: (operation)=>Promise.race([
|
|
161
|
+
operation,
|
|
162
|
+
deadline
|
|
163
|
+
]),
|
|
164
|
+
cancelBody,
|
|
165
|
+
cleanup: ()=>{
|
|
166
|
+
if (cleanedUp) return;
|
|
167
|
+
cleanedUp = true;
|
|
168
|
+
clearTimeout(timer);
|
|
169
|
+
if (controller.signal.aborted) cancelBody();
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
} catch (error) {
|
|
130
173
|
clearTimeout(timer);
|
|
174
|
+
throw error;
|
|
131
175
|
}
|
|
132
176
|
}
|
|
133
177
|
buildHeaders(attempt, requestId) {
|
|
@@ -186,10 +230,10 @@ class V1CaptureSender {
|
|
|
186
230
|
results: results ?? {}
|
|
187
231
|
};
|
|
188
232
|
}
|
|
189
|
-
async buildHttpError(response, status) {
|
|
233
|
+
async buildHttpError(response, status, waitFor) {
|
|
190
234
|
let bodyText = '';
|
|
191
235
|
try {
|
|
192
|
-
bodyText = (await response.text()).slice(0, 512);
|
|
236
|
+
bodyText = (await waitFor(response.text())).slice(0, 512);
|
|
193
237
|
} catch {}
|
|
194
238
|
const suffix = bodyText ? `: ${bodyText}` : '';
|
|
195
239
|
return new Error(`Capture V1 request failed with HTTP ${status}${suffix}`);
|
|
@@ -210,7 +254,9 @@ class V1CaptureSender {
|
|
|
210
254
|
}));
|
|
211
255
|
}
|
|
212
256
|
async cancelBody(response) {
|
|
213
|
-
|
|
257
|
+
try {
|
|
258
|
+
await response.body?.cancel();
|
|
259
|
+
} catch {}
|
|
214
260
|
}
|
|
215
261
|
}
|
|
216
262
|
exports.V1CaptureSender = __webpack_exports__.V1CaptureSender;
|
|
@@ -42,41 +42,47 @@ class V1CaptureSender {
|
|
|
42
42
|
} : {},
|
|
43
43
|
batch: pending
|
|
44
44
|
});
|
|
45
|
-
let
|
|
45
|
+
let captureAttempt;
|
|
46
|
+
let retryDelayMs;
|
|
46
47
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const { status } = response;
|
|
54
|
-
if (status < 200 || status >= 300) {
|
|
55
|
-
if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
|
|
48
|
+
captureAttempt = await this.sendOnce(url, payload, attempt, requestId);
|
|
49
|
+
const { response, signal } = captureAttempt;
|
|
50
|
+
const { status } = response;
|
|
51
|
+
if (status < 200 || status >= 300) if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
|
|
56
52
|
const retryAfterMs = this.parseRetryAfter(response);
|
|
57
|
-
await
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
await captureAttempt.waitFor(captureAttempt.cancelBody()).catch(()=>{});
|
|
54
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
55
|
+
} else {
|
|
56
|
+
const httpError = await this.buildHttpError(response, status, captureAttempt.waitFor);
|
|
57
|
+
return this.surfaceBatchFailure(requestId, drops, pending, httpError);
|
|
60
58
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
else {
|
|
60
|
+
let parsed;
|
|
61
|
+
try {
|
|
62
|
+
parsed = await captureAttempt.waitFor(this.parseResponse(response));
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (signal.aborted) throw error;
|
|
65
|
+
return this.surfaceBatchFailure(requestId, drops, pending, new Error(`Capture V1 returned an unparseable ${status} response body`));
|
|
66
|
+
}
|
|
67
|
+
const retryable = this.classify(pending, parsed, drops);
|
|
68
|
+
if (0 === retryable.length) return this.surfacePartialDrops(requestId, drops);
|
|
69
|
+
if (isLastAttempt) return void this.onError(new CaptureV1Error({
|
|
70
|
+
requestId,
|
|
71
|
+
drops,
|
|
72
|
+
retryExhausted: retryable.map((event)=>event.uuid)
|
|
73
|
+
}));
|
|
74
|
+
pending = retryable;
|
|
75
|
+
const retryAfterMs = this.parseRetryAfter(response);
|
|
76
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs);
|
|
77
|
+
}
|
|
78
|
+
} catch (transportError) {
|
|
79
|
+
if (captureAttempt && !captureAttempt.signal.aborted) throw transportError;
|
|
80
|
+
if (isLastAttempt) return this.surfaceBatchFailure(requestId, drops, pending, transportError);
|
|
81
|
+
retryDelayMs = this.backoffDelay(attempt);
|
|
82
|
+
} finally{
|
|
83
|
+
captureAttempt?.cleanup();
|
|
69
84
|
}
|
|
70
|
-
|
|
71
|
-
if (0 === retryable.length) return this.surfacePartialDrops(requestId, drops);
|
|
72
|
-
if (isLastAttempt) return void this.onError(new CaptureV1Error({
|
|
73
|
-
requestId,
|
|
74
|
-
drops,
|
|
75
|
-
retryExhausted: retryable.map((event)=>event.uuid)
|
|
76
|
-
}));
|
|
77
|
-
pending = retryable;
|
|
78
|
-
const retryAfterMs = this.parseRetryAfter(response);
|
|
79
|
-
await this.sleep(this.backoffDelay(attempt, retryAfterMs));
|
|
85
|
+
if (void 0 !== retryDelayMs) await this.sleep(retryDelayMs);
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
88
|
async sendOnce(url, payload, attempt, requestId) {
|
|
@@ -90,16 +96,54 @@ class V1CaptureSender {
|
|
|
90
96
|
}
|
|
91
97
|
}
|
|
92
98
|
const controller = new AbortController();
|
|
93
|
-
|
|
99
|
+
let timeoutPhase = 'waiting for response headers';
|
|
100
|
+
let timer;
|
|
101
|
+
const deadline = new Promise((_resolve, reject)=>{
|
|
102
|
+
timer = safeSetTimeout(()=>{
|
|
103
|
+
const timeoutError = new Error(`Capture V1 request timed out ${timeoutPhase} after ${this.config.requestTimeoutMs}ms`);
|
|
104
|
+
timeoutError.name = 'AbortError';
|
|
105
|
+
reject(timeoutError);
|
|
106
|
+
controller.abort(timeoutError);
|
|
107
|
+
}, this.config.requestTimeoutMs);
|
|
108
|
+
});
|
|
94
109
|
try {
|
|
95
|
-
|
|
110
|
+
const fetchPromise = this.fetchFn(url, {
|
|
96
111
|
method: 'POST',
|
|
97
112
|
headers,
|
|
98
113
|
body,
|
|
99
114
|
signal: controller.signal
|
|
100
115
|
});
|
|
101
|
-
|
|
116
|
+
let responseAccepted = false;
|
|
117
|
+
fetchPromise.then((lateResponse)=>{
|
|
118
|
+
if (controller.signal.aborted && !responseAccepted) this.cancelBody(lateResponse);
|
|
119
|
+
}).catch(()=>{});
|
|
120
|
+
const response = await Promise.race([
|
|
121
|
+
fetchPromise,
|
|
122
|
+
deadline
|
|
123
|
+
]);
|
|
124
|
+
responseAccepted = true;
|
|
125
|
+
timeoutPhase = 'while reading the response body';
|
|
126
|
+
let cleanedUp = false;
|
|
127
|
+
let cancellation;
|
|
128
|
+
const cancelBody = ()=>cancellation ??= this.cancelBody(response);
|
|
129
|
+
return {
|
|
130
|
+
response,
|
|
131
|
+
signal: controller.signal,
|
|
132
|
+
waitFor: (operation)=>Promise.race([
|
|
133
|
+
operation,
|
|
134
|
+
deadline
|
|
135
|
+
]),
|
|
136
|
+
cancelBody,
|
|
137
|
+
cleanup: ()=>{
|
|
138
|
+
if (cleanedUp) return;
|
|
139
|
+
cleanedUp = true;
|
|
140
|
+
clearTimeout(timer);
|
|
141
|
+
if (controller.signal.aborted) cancelBody();
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
} catch (error) {
|
|
102
145
|
clearTimeout(timer);
|
|
146
|
+
throw error;
|
|
103
147
|
}
|
|
104
148
|
}
|
|
105
149
|
buildHeaders(attempt, requestId) {
|
|
@@ -158,10 +202,10 @@ class V1CaptureSender {
|
|
|
158
202
|
results: results ?? {}
|
|
159
203
|
};
|
|
160
204
|
}
|
|
161
|
-
async buildHttpError(response, status) {
|
|
205
|
+
async buildHttpError(response, status, waitFor) {
|
|
162
206
|
let bodyText = '';
|
|
163
207
|
try {
|
|
164
|
-
bodyText = (await response.text()).slice(0, 512);
|
|
208
|
+
bodyText = (await waitFor(response.text())).slice(0, 512);
|
|
165
209
|
} catch {}
|
|
166
210
|
const suffix = bodyText ? `: ${bodyText}` : '';
|
|
167
211
|
return new Error(`Capture V1 request failed with HTTP ${status}${suffix}`);
|
|
@@ -182,7 +226,9 @@ class V1CaptureSender {
|
|
|
182
226
|
}));
|
|
183
227
|
}
|
|
184
228
|
async cancelBody(response) {
|
|
185
|
-
|
|
229
|
+
try {
|
|
230
|
+
await response.body?.cancel();
|
|
231
|
+
} catch {}
|
|
186
232
|
}
|
|
187
233
|
}
|
|
188
234
|
export { V1CaptureSender };
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAGhB,QAAQ,E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,EACnD,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,EAC3B,KAAK,CAAC,EAAE,sBAAsB,GAC7B,IAAI;IAeP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,yBAAyB,CAC7B,KAAK,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACnD,KAAK,CAAC,EAAE,sBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAeH,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAC7D,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,EAAE,sBAAsB,CAAA;QAClC,OAAO,EAAE,qBAAqB,CAAA;KAC/B,CAAC;YAIY,oBAAoB;IAsJlC,OAAO,CAAC,cAAc;CAuBvB"}
|
package/dist/client.js
CHANGED
|
@@ -233,7 +233,8 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
233
233
|
isDebug: this.isDebug
|
|
234
234
|
}, {
|
|
235
235
|
fetch: (url, fetchOptions)=>this.fetch(url, fetchOptions),
|
|
236
|
-
onError: (error)=>this._events.emit('error', error)
|
|
236
|
+
onError: (error)=>this._events.emit('error', error),
|
|
237
|
+
compress: (payload)=>this.compressPayload(payload)
|
|
237
238
|
});
|
|
238
239
|
return this._v1Sender;
|
|
239
240
|
}
|
package/dist/client.mjs
CHANGED
|
@@ -194,7 +194,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
194
194
|
isDebug: this.isDebug
|
|
195
195
|
}, {
|
|
196
196
|
fetch: (url, fetchOptions)=>this.fetch(url, fetchOptions),
|
|
197
|
-
onError: (error)=>this._events.emit('error', error)
|
|
197
|
+
onError: (error)=>this._events.emit('error', error),
|
|
198
|
+
compress: (payload)=>this.compressPayload(payload)
|
|
198
199
|
});
|
|
199
200
|
return this._v1Sender;
|
|
200
201
|
}
|
|
@@ -4,6 +4,7 @@ import { ErrorTracking as CoreErrorTracking } from '@posthog/core';
|
|
|
4
4
|
import { PostHogContext } from '../extensions/context/context';
|
|
5
5
|
export declare class PostHog extends PostHogBackendClient {
|
|
6
6
|
getLibraryId(): string;
|
|
7
|
+
protected compressPayload(payload: string): Promise<Blob | null>;
|
|
7
8
|
protected initializeContext(): PostHogContext;
|
|
8
9
|
protected createErrorPropertiesBuilder(): CoreErrorTracking.ErrorPropertiesBuilder;
|
|
9
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../src/entrypoints/index.node.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAM1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../src/entrypoints/index.node.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAM1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAG9D,qBAAa,OAAQ,SAAQ,oBAAoB;IAC/C,YAAY,IAAI,MAAM;cAIH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAIzE,SAAS,CAAC,iBAAiB,IAAI,cAAc;cAI1B,4BAA4B,IAAI,iBAAiB,CAAC,sBAAsB;CAiB5F"}
|
|
@@ -18,6 +18,9 @@ var __webpack_modules__ = {
|
|
|
18
18
|
"../extensions/error-tracking/modifiers/relative-path.node": function(module) {
|
|
19
19
|
module.exports = require("../extensions/error-tracking/modifiers/relative-path.node.js");
|
|
20
20
|
},
|
|
21
|
+
"../gzip.node": function(module) {
|
|
22
|
+
module.exports = require("../gzip.node.js");
|
|
23
|
+
},
|
|
21
24
|
"@posthog/core": function(module) {
|
|
22
25
|
module.exports = require("@posthog/core");
|
|
23
26
|
}
|
|
@@ -83,10 +86,14 @@ var __webpack_exports__ = {};
|
|
|
83
86
|
var _client__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("../client");
|
|
84
87
|
var _posthog_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("@posthog/core");
|
|
85
88
|
var _extensions_context_context__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("../extensions/context/context");
|
|
89
|
+
var _gzip_node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("../gzip.node");
|
|
86
90
|
class PostHog extends _client__WEBPACK_IMPORTED_MODULE_4__.PostHogBackendClient {
|
|
87
91
|
getLibraryId() {
|
|
88
92
|
return 'posthog-node';
|
|
89
93
|
}
|
|
94
|
+
compressPayload(payload) {
|
|
95
|
+
return (0, _gzip_node__WEBPACK_IMPORTED_MODULE_7__.gzipCompress)(payload, this.isDebug);
|
|
96
|
+
}
|
|
90
97
|
initializeContext() {
|
|
91
98
|
return new _extensions_context_context__WEBPACK_IMPORTED_MODULE_6__.PostHogContext();
|
|
92
99
|
}
|
|
@@ -4,11 +4,15 @@ import { createRelativePathModifier } from "../extensions/error-tracking/modifie
|
|
|
4
4
|
import { PostHogBackendClient } from "../client.mjs";
|
|
5
5
|
import { ErrorTracking } from "@posthog/core";
|
|
6
6
|
import { PostHogContext } from "../extensions/context/context.mjs";
|
|
7
|
+
import { gzipCompress } from "../gzip.node.mjs";
|
|
7
8
|
export * from "../exports.mjs";
|
|
8
9
|
class PostHog extends PostHogBackendClient {
|
|
9
10
|
getLibraryId() {
|
|
10
11
|
return 'posthog-node';
|
|
11
12
|
}
|
|
13
|
+
compressPayload(payload) {
|
|
14
|
+
return gzipCompress(payload, this.isDebug);
|
|
15
|
+
}
|
|
12
16
|
initializeContext() {
|
|
13
17
|
return new PostHogContext();
|
|
14
18
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gzip.node.d.ts","sourceRoot":"","sources":["../src/gzip.node.ts"],"names":[],"mappings":"AAKA,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,UAAO,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAUtF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
gzipCompress: ()=>gzipCompress
|
|
28
|
+
});
|
|
29
|
+
const external_node_zlib_namespaceObject = require("node:zlib");
|
|
30
|
+
const external_node_util_namespaceObject = require("node:util");
|
|
31
|
+
const gzipAsync = (0, external_node_util_namespaceObject.promisify)(external_node_zlib_namespaceObject.gzip);
|
|
32
|
+
async function gzipCompress(input, isDebug = true) {
|
|
33
|
+
try {
|
|
34
|
+
const compressed = await gzipAsync(input);
|
|
35
|
+
return new Blob([
|
|
36
|
+
new Uint8Array(compressed)
|
|
37
|
+
]);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (isDebug) console.error('Failed to gzip compress data', error);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.gzipCompress = __webpack_exports__.gzipCompress;
|
|
44
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
45
|
+
"gzipCompress"
|
|
46
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
47
|
+
Object.defineProperty(exports, '__esModule', {
|
|
48
|
+
value: true
|
|
49
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { gzip } from "node:zlib";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const gzipAsync = promisify(gzip);
|
|
4
|
+
async function gzipCompress(input, isDebug = true) {
|
|
5
|
+
try {
|
|
6
|
+
const compressed = await gzipAsync(input);
|
|
7
|
+
return new Blob([
|
|
8
|
+
new Uint8Array(compressed)
|
|
9
|
+
]);
|
|
10
|
+
} catch (error) {
|
|
11
|
+
if (isDebug) console.error('Failed to gzip compress data', error);
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export { gzipCompress };
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.48.
|
|
1
|
+
export declare const version = "5.48.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
version: ()=>version
|
|
28
28
|
});
|
|
29
|
-
const version = '5.48.
|
|
29
|
+
const version = '5.48.1';
|
|
30
30
|
exports.version = __webpack_exports__.version;
|
|
31
31
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
32
32
|
"version"
|
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '5.48.
|
|
1
|
+
const version = '5.48.1';
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-node",
|
|
3
|
-
"version": "5.48.
|
|
3
|
+
"version": "5.48.1",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"module": "dist/entrypoints/index.node.mjs",
|
|
29
29
|
"types": "dist/entrypoints/index.node.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@posthog/core": "^1.46.
|
|
31
|
+
"@posthog/core": "^1.46.9"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@edge-runtime/jest-environment": "^4.0.0",
|
package/src/capture-v1/sender.ts
CHANGED
|
@@ -50,6 +50,14 @@ export interface V1CaptureSenderHooks {
|
|
|
50
50
|
compress?: (payload: string, isDebug?: boolean) => Promise<Blob | null>
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
interface V1CaptureAttempt {
|
|
54
|
+
response: PostHogFetchResponse
|
|
55
|
+
signal: AbortSignal
|
|
56
|
+
waitFor<T>(operation: Promise<T>): Promise<T>
|
|
57
|
+
cancelBody: () => Promise<void>
|
|
58
|
+
cleanup: () => void
|
|
59
|
+
}
|
|
60
|
+
|
|
53
61
|
/**
|
|
54
62
|
* Sends already-normalized events to the Capture V1 endpoint
|
|
55
63
|
* (`POST /i/v1/analytics/events`), owning the full attempt loop: per-event
|
|
@@ -111,65 +119,73 @@ export class V1CaptureSender {
|
|
|
111
119
|
batch: pending,
|
|
112
120
|
})
|
|
113
121
|
|
|
114
|
-
let
|
|
122
|
+
let captureAttempt: V1CaptureAttempt | undefined
|
|
123
|
+
let retryDelayMs: number | undefined
|
|
115
124
|
try {
|
|
116
|
-
|
|
125
|
+
captureAttempt = await this.sendOnce(url, payload, attempt, requestId)
|
|
126
|
+
const { response, signal } = captureAttempt
|
|
127
|
+
const { status } = response
|
|
128
|
+
if (status < 200 || status >= 300) {
|
|
129
|
+
if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
|
|
130
|
+
const retryAfterMs = this.parseRetryAfter(response)
|
|
131
|
+
await captureAttempt.waitFor(captureAttempt.cancelBody()).catch(() => {})
|
|
132
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs)
|
|
133
|
+
} else {
|
|
134
|
+
const httpError = await this.buildHttpError(response, status, captureAttempt.waitFor)
|
|
135
|
+
return this.surfaceBatchFailure(requestId, drops, pending, httpError)
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
let parsed: V1BatchResponse
|
|
139
|
+
try {
|
|
140
|
+
parsed = await captureAttempt.waitFor(this.parseResponse(response))
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (signal.aborted) {
|
|
143
|
+
throw error
|
|
144
|
+
}
|
|
145
|
+
// A 2xx we cannot parse is terminal — re-sending against a broken success would loop forever.
|
|
146
|
+
return this.surfaceBatchFailure(
|
|
147
|
+
requestId,
|
|
148
|
+
drops,
|
|
149
|
+
pending,
|
|
150
|
+
new Error(`Capture V1 returned an unparseable ${status} response body`)
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const retryable = this.classify(pending, parsed, drops)
|
|
155
|
+
if (retryable.length === 0) {
|
|
156
|
+
return this.surfacePartialDrops(requestId, drops)
|
|
157
|
+
}
|
|
158
|
+
if (isLastAttempt) {
|
|
159
|
+
this.onError(new CaptureV1Error({ requestId, drops, retryExhausted: retryable.map((event) => event.uuid) }))
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
pending = retryable
|
|
163
|
+
// A 200 partial-retry body can also carry Retry-After (e.g. rate-limited
|
|
164
|
+
// retry events); honor it as a minimum the same way as on a retryable status.
|
|
165
|
+
const retryAfterMs = this.parseRetryAfter(response)
|
|
166
|
+
retryDelayMs = this.backoffDelay(attempt, retryAfterMs)
|
|
167
|
+
}
|
|
117
168
|
} catch (transportError) {
|
|
118
|
-
|
|
169
|
+
if (captureAttempt && !captureAttempt.signal.aborted) {
|
|
170
|
+
throw transportError
|
|
171
|
+
}
|
|
172
|
+
// Connection/timeouts, including a timeout while consuming the response body,
|
|
173
|
+
// are retried until the budget runs out.
|
|
119
174
|
if (isLastAttempt) {
|
|
120
175
|
return this.surfaceBatchFailure(requestId, drops, pending, transportError)
|
|
121
176
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const { status } = response
|
|
127
|
-
if (status < 200 || status >= 300) {
|
|
128
|
-
if (!isLastAttempt && RETRYABLE_STATUSES.has(status)) {
|
|
129
|
-
const retryAfterMs = this.parseRetryAfter(response)
|
|
130
|
-
await this.cancelBody(response)
|
|
131
|
-
await this.sleep(this.backoffDelay(attempt, retryAfterMs))
|
|
132
|
-
continue
|
|
133
|
-
}
|
|
134
|
-
const httpError = await this.buildHttpError(response, status)
|
|
135
|
-
return this.surfaceBatchFailure(requestId, drops, pending, httpError)
|
|
177
|
+
retryDelayMs = this.backoffDelay(attempt)
|
|
178
|
+
} finally {
|
|
179
|
+
captureAttempt?.cleanup()
|
|
136
180
|
}
|
|
137
181
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
parsed = await this.parseResponse(response)
|
|
141
|
-
} catch {
|
|
142
|
-
// A 2xx we cannot parse is terminal — re-sending against a broken success would loop forever.
|
|
143
|
-
return this.surfaceBatchFailure(
|
|
144
|
-
requestId,
|
|
145
|
-
drops,
|
|
146
|
-
pending,
|
|
147
|
-
new Error(`Capture V1 returned an unparseable ${status} response body`)
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const retryable = this.classify(pending, parsed, drops)
|
|
152
|
-
if (retryable.length === 0) {
|
|
153
|
-
return this.surfacePartialDrops(requestId, drops)
|
|
154
|
-
}
|
|
155
|
-
if (isLastAttempt) {
|
|
156
|
-
this.onError(new CaptureV1Error({ requestId, drops, retryExhausted: retryable.map((event) => event.uuid) }))
|
|
157
|
-
return
|
|
182
|
+
if (retryDelayMs !== undefined) {
|
|
183
|
+
await this.sleep(retryDelayMs)
|
|
158
184
|
}
|
|
159
|
-
pending = retryable
|
|
160
|
-
// A 200 partial-retry body can also carry Retry-After (e.g. rate-limited
|
|
161
|
-
// retry events); honor it as a minimum the same way as on a retryable status.
|
|
162
|
-
const retryAfterMs = this.parseRetryAfter(response)
|
|
163
|
-
await this.sleep(this.backoffDelay(attempt, retryAfterMs))
|
|
164
185
|
}
|
|
165
186
|
}
|
|
166
187
|
|
|
167
|
-
private async sendOnce(
|
|
168
|
-
url: string,
|
|
169
|
-
payload: string,
|
|
170
|
-
attempt: number,
|
|
171
|
-
requestId: string
|
|
172
|
-
): Promise<PostHogFetchResponse> {
|
|
188
|
+
private async sendOnce(url: string, payload: string, attempt: number, requestId: string): Promise<V1CaptureAttempt> {
|
|
173
189
|
const headers = this.buildHeaders(attempt, requestId)
|
|
174
190
|
let body: string | Blob = payload
|
|
175
191
|
if (this.config.compressionEnabled) {
|
|
@@ -182,11 +198,62 @@ export class V1CaptureSender {
|
|
|
182
198
|
}
|
|
183
199
|
|
|
184
200
|
const controller = new AbortController()
|
|
185
|
-
|
|
201
|
+
let timeoutPhase = 'waiting for response headers'
|
|
202
|
+
let timer: ReturnType<typeof safeSetTimeout>
|
|
203
|
+
// hooks.fetch is user-injectable, so it may ignore an abort signal while
|
|
204
|
+
// resolving headers or reading the body. Race both phases against the same
|
|
205
|
+
// deadline rather than relying only on standards-compliant fetch behavior.
|
|
206
|
+
const deadline = new Promise<never>((_resolve, reject) => {
|
|
207
|
+
timer = safeSetTimeout(() => {
|
|
208
|
+
const timeoutError = new Error(
|
|
209
|
+
`Capture V1 request timed out ${timeoutPhase} after ${this.config.requestTimeoutMs}ms`
|
|
210
|
+
)
|
|
211
|
+
timeoutError.name = 'AbortError'
|
|
212
|
+
// Reject first so this phase-specific error wins even when an abort-aware
|
|
213
|
+
// custom fetch rejects synchronously from the abort event.
|
|
214
|
+
reject(timeoutError)
|
|
215
|
+
controller.abort(timeoutError)
|
|
216
|
+
}, this.config.requestTimeoutMs)
|
|
217
|
+
})
|
|
186
218
|
try {
|
|
187
|
-
|
|
188
|
-
|
|
219
|
+
const fetchPromise = this.fetchFn(url, { method: 'POST', headers, body, signal: controller.signal })
|
|
220
|
+
let responseAccepted = false
|
|
221
|
+
void fetchPromise
|
|
222
|
+
.then((lateResponse) => {
|
|
223
|
+
if (controller.signal.aborted && !responseAccepted) {
|
|
224
|
+
// An injected fetch may ignore abort and resolve after the deadline.
|
|
225
|
+
// Cancel its otherwise unreachable body to release any held resources.
|
|
226
|
+
void this.cancelBody(lateResponse)
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
.catch(() => {})
|
|
230
|
+
const response = await Promise.race([fetchPromise, deadline])
|
|
231
|
+
responseAccepted = true
|
|
232
|
+
timeoutPhase = 'while reading the response body'
|
|
233
|
+
let cleanedUp = false
|
|
234
|
+
let cancellation: Promise<void> | undefined
|
|
235
|
+
const cancelBody = (): Promise<void> => (cancellation ??= this.cancelBody(response))
|
|
236
|
+
return {
|
|
237
|
+
response,
|
|
238
|
+
signal: controller.signal,
|
|
239
|
+
waitFor: <T>(operation: Promise<T>) => Promise.race([operation, deadline]),
|
|
240
|
+
cancelBody,
|
|
241
|
+
cleanup: () => {
|
|
242
|
+
if (cleanedUp) {
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
cleanedUp = true
|
|
246
|
+
clearTimeout(timer)
|
|
247
|
+
if (controller.signal.aborted) {
|
|
248
|
+
// The attempt deadline has already elapsed, so cleanup cannot wait
|
|
249
|
+
// for a custom response body's cancellation promise to settle.
|
|
250
|
+
void cancelBody()
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
}
|
|
254
|
+
} catch (error) {
|
|
189
255
|
clearTimeout(timer)
|
|
256
|
+
throw error
|
|
190
257
|
}
|
|
191
258
|
}
|
|
192
259
|
|
|
@@ -271,12 +338,16 @@ export class V1CaptureSender {
|
|
|
271
338
|
return { results: (results as V1BatchResponse['results']) ?? {} }
|
|
272
339
|
}
|
|
273
340
|
|
|
274
|
-
private async buildHttpError(
|
|
341
|
+
private async buildHttpError(
|
|
342
|
+
response: PostHogFetchResponse,
|
|
343
|
+
status: number,
|
|
344
|
+
waitFor: V1CaptureAttempt['waitFor']
|
|
345
|
+
): Promise<Error> {
|
|
275
346
|
let bodyText = ''
|
|
276
347
|
try {
|
|
277
|
-
bodyText = (await response.text()).slice(0, 512)
|
|
348
|
+
bodyText = (await waitFor(response.text())).slice(0, 512)
|
|
278
349
|
} catch {
|
|
279
|
-
// best-effort; a missing body should not mask the status
|
|
350
|
+
// best-effort; a missing or timed-out body should not mask the status
|
|
280
351
|
}
|
|
281
352
|
const suffix = bodyText ? `: ${bodyText}` : ''
|
|
282
353
|
return new Error(`Capture V1 request failed with HTTP ${status}${suffix}`)
|
|
@@ -293,6 +364,10 @@ export class V1CaptureSender {
|
|
|
293
364
|
}
|
|
294
365
|
|
|
295
366
|
private async cancelBody(response: PostHogFetchResponse): Promise<void> {
|
|
296
|
-
|
|
367
|
+
try {
|
|
368
|
+
await response.body?.cancel()
|
|
369
|
+
} catch {
|
|
370
|
+
// Cancellation is best-effort and must never mask delivery handling.
|
|
371
|
+
}
|
|
297
372
|
}
|
|
298
373
|
}
|
package/src/client.ts
CHANGED
|
@@ -485,6 +485,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
485
485
|
{
|
|
486
486
|
fetch: (url, fetchOptions) => this.fetch(url, fetchOptions),
|
|
487
487
|
onError: (error) => this._events.emit('error', error),
|
|
488
|
+
compress: (payload) => this.compressPayload(payload),
|
|
488
489
|
}
|
|
489
490
|
)
|
|
490
491
|
}
|
|
@@ -7,12 +7,17 @@ import { createRelativePathModifier } from '../extensions/error-tracking/modifie
|
|
|
7
7
|
import { PostHogBackendClient } from '../client'
|
|
8
8
|
import { ErrorTracking as CoreErrorTracking } from '@posthog/core'
|
|
9
9
|
import { PostHogContext } from '../extensions/context/context'
|
|
10
|
+
import { gzipCompress } from '../gzip.node'
|
|
10
11
|
|
|
11
12
|
export class PostHog extends PostHogBackendClient {
|
|
12
13
|
getLibraryId(): string {
|
|
13
14
|
return 'posthog-node'
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
protected override compressPayload(payload: string): Promise<Blob | null> {
|
|
18
|
+
return gzipCompress(payload, this.isDebug)
|
|
19
|
+
}
|
|
20
|
+
|
|
16
21
|
protected initializeContext(): PostHogContext {
|
|
17
22
|
return new PostHogContext()
|
|
18
23
|
}
|
package/src/gzip.node.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { gzip } from 'node:zlib'
|
|
2
|
+
import { promisify } from 'node:util'
|
|
3
|
+
|
|
4
|
+
const gzipAsync = promisify(gzip)
|
|
5
|
+
|
|
6
|
+
export async function gzipCompress(input: string, isDebug = true): Promise<Blob | null> {
|
|
7
|
+
try {
|
|
8
|
+
const compressed = await gzipAsync(input)
|
|
9
|
+
return new Blob([new Uint8Array(compressed)])
|
|
10
|
+
} catch (error) {
|
|
11
|
+
if (isDebug) {
|
|
12
|
+
console.error('Failed to gzip compress data', error)
|
|
13
|
+
}
|
|
14
|
+
return null
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.48.
|
|
1
|
+
export const version = '5.48.1'
|