@posthog/core 1.34.0 → 1.35.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/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -18
- package/dist/index.mjs +3 -3
- package/dist/logs/index.d.ts +14 -15
- package/dist/logs/index.d.ts.map +1 -1
- package/dist/logs/index.js +46 -18
- package/dist/logs/index.mjs +47 -19
- package/dist/logs/logs-utils.d.ts +16 -1
- package/dist/logs/logs-utils.d.ts.map +1 -1
- package/dist/logs/logs-utils.js +17 -0
- package/dist/logs/logs-utils.mjs +15 -1
- package/dist/logs/types.d.ts +23 -38
- package/dist/logs/types.d.ts.map +1 -1
- package/dist/posthog-core.d.ts +3 -0
- package/dist/posthog-core.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/logs/index.spec.ts +259 -0
- package/src/logs/index.ts +108 -49
- package/src/logs/logs-utils.ts +30 -1
- package/src/logs/types.ts +32 -37
- package/src/posthog-core.ts +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { getFeatureFlagValue } from './featureFlagUtils';
|
|
1
|
+
export { getFeatureFlagValue, getEnabledFromValue, getVariantFromValue, parsePayload } from './featureFlagUtils';
|
|
2
2
|
export { gzipCompress, isGzipData, isGzipRequest, isGzipSupported, isNativeAsyncGzipError, isNativeAsyncGzipReadError, } from './gzip';
|
|
3
3
|
export * from './utils';
|
|
4
4
|
export * as ErrorTracking from './error-tracking';
|
|
5
|
-
export { buildOtlpLogRecord, buildOtlpLogsPayload, getOtlpSeverityNumber, getOtlpSeverityText, toOtlpAnyValue, toOtlpKeyValueList, } from './logs/logs-utils';
|
|
5
|
+
export { buildOtlpLogRecord, buildOtlpLogsPayload, buildResourceAttributes, getOtlpSeverityNumber, getOtlpSeverityText, toOtlpAnyValue, toOtlpKeyValueList, } from './logs/logs-utils';
|
|
6
6
|
export { PostHogLogs } from './logs';
|
|
7
7
|
export type { BeforeSendLogFn, BufferedLogEntry, CaptureLogger, LogSdkContext, PostHogLogsConfig, ResolvedPostHogLogsConfig, } from './logs/types';
|
|
8
8
|
export type { CaptureLogOptions, LogAttributeValue, LogAttributes, LogSeverityLevel } from './logs/types';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAChH,OAAO,EACL,YAAY,EACZ,UAAU,EACV,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,QAAQ,CAAA;AACf,cAAc,SAAS,CAAA;AACvB,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAA;AACjD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,GACnB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,cAAc,CAAA;AAIrB,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACzG,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -88,18 +88,22 @@ var __webpack_exports__ = {};
|
|
|
88
88
|
PostHogLogs: ()=>_logs__WEBPACK_IMPORTED_MODULE_5__.PostHogLogs,
|
|
89
89
|
buildOtlpLogRecord: ()=>_logs_logs_utils__WEBPACK_IMPORTED_MODULE_4__.buildOtlpLogRecord,
|
|
90
90
|
buildOtlpLogsPayload: ()=>_logs_logs_utils__WEBPACK_IMPORTED_MODULE_4__.buildOtlpLogsPayload,
|
|
91
|
+
buildResourceAttributes: ()=>_logs_logs_utils__WEBPACK_IMPORTED_MODULE_4__.buildResourceAttributes,
|
|
92
|
+
getEnabledFromValue: ()=>_featureFlagUtils__WEBPACK_IMPORTED_MODULE_0__.getEnabledFromValue,
|
|
91
93
|
getFeatureFlagValue: ()=>_featureFlagUtils__WEBPACK_IMPORTED_MODULE_0__.getFeatureFlagValue,
|
|
92
94
|
getLengthFromRules: ()=>_surveys_validation__WEBPACK_IMPORTED_MODULE_12__.getLengthFromRules,
|
|
93
95
|
getOtlpSeverityNumber: ()=>_logs_logs_utils__WEBPACK_IMPORTED_MODULE_4__.getOtlpSeverityNumber,
|
|
94
96
|
getOtlpSeverityText: ()=>_logs_logs_utils__WEBPACK_IMPORTED_MODULE_4__.getOtlpSeverityText,
|
|
95
97
|
getRequirementsHint: ()=>_surveys_validation__WEBPACK_IMPORTED_MODULE_12__.getRequirementsHint,
|
|
96
98
|
getValidationError: ()=>_surveys_validation__WEBPACK_IMPORTED_MODULE_12__.getValidationError,
|
|
99
|
+
getVariantFromValue: ()=>_featureFlagUtils__WEBPACK_IMPORTED_MODULE_0__.getVariantFromValue,
|
|
97
100
|
gzipCompress: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.gzipCompress,
|
|
98
101
|
isGzipData: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.isGzipData,
|
|
99
102
|
isGzipRequest: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.isGzipRequest,
|
|
100
103
|
isGzipSupported: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.isGzipSupported,
|
|
101
104
|
isNativeAsyncGzipError: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.isNativeAsyncGzipError,
|
|
102
105
|
isNativeAsyncGzipReadError: ()=>_gzip__WEBPACK_IMPORTED_MODULE_1__.isNativeAsyncGzipReadError,
|
|
106
|
+
parsePayload: ()=>_featureFlagUtils__WEBPACK_IMPORTED_MODULE_0__.parsePayload,
|
|
103
107
|
toOtlpAnyValue: ()=>_logs_logs_utils__WEBPACK_IMPORTED_MODULE_4__.toOtlpAnyValue,
|
|
104
108
|
toOtlpKeyValueList: ()=>_logs_logs_utils__WEBPACK_IMPORTED_MODULE_4__.toOtlpKeyValueList,
|
|
105
109
|
uuidv7: ()=>_vendor_uuidv7__WEBPACK_IMPORTED_MODULE_6__.uuidv7
|
|
@@ -110,21 +114,25 @@ var __webpack_exports__ = {};
|
|
|
110
114
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
111
115
|
for(var __WEBPACK_IMPORT_KEY__ in _utils__WEBPACK_IMPORTED_MODULE_2__)if ([
|
|
112
116
|
"toOtlpKeyValueList",
|
|
117
|
+
"getLengthFromRules",
|
|
113
118
|
"PostHogLogs",
|
|
114
119
|
"isNativeAsyncGzipError",
|
|
115
120
|
"getOtlpSeverityText",
|
|
121
|
+
"getEnabledFromValue",
|
|
116
122
|
"isNativeAsyncGzipReadError",
|
|
117
|
-
"getFeatureFlagValue",
|
|
118
123
|
"isGzipRequest",
|
|
124
|
+
"getFeatureFlagValue",
|
|
125
|
+
"getVariantFromValue",
|
|
119
126
|
"gzipCompress",
|
|
120
|
-
"uuidv7",
|
|
121
127
|
"ErrorTracking",
|
|
128
|
+
"uuidv7",
|
|
122
129
|
"getValidationError",
|
|
123
130
|
"default",
|
|
124
131
|
"getRequirementsHint",
|
|
125
132
|
"isGzipData",
|
|
133
|
+
"parsePayload",
|
|
134
|
+
"buildResourceAttributes",
|
|
126
135
|
"getOtlpSeverityNumber",
|
|
127
|
-
"getLengthFromRules",
|
|
128
136
|
"isGzipSupported",
|
|
129
137
|
"buildOtlpLogsPayload",
|
|
130
138
|
"buildOtlpLogRecord",
|
|
@@ -141,21 +149,25 @@ var __webpack_exports__ = {};
|
|
|
141
149
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
142
150
|
for(var __WEBPACK_IMPORT_KEY__ in _cookie__WEBPACK_IMPORTED_MODULE_7__)if ([
|
|
143
151
|
"toOtlpKeyValueList",
|
|
152
|
+
"getLengthFromRules",
|
|
144
153
|
"PostHogLogs",
|
|
145
154
|
"isNativeAsyncGzipError",
|
|
146
155
|
"getOtlpSeverityText",
|
|
156
|
+
"getEnabledFromValue",
|
|
147
157
|
"isNativeAsyncGzipReadError",
|
|
148
|
-
"getFeatureFlagValue",
|
|
149
158
|
"isGzipRequest",
|
|
159
|
+
"getFeatureFlagValue",
|
|
160
|
+
"getVariantFromValue",
|
|
150
161
|
"gzipCompress",
|
|
151
|
-
"uuidv7",
|
|
152
162
|
"ErrorTracking",
|
|
163
|
+
"uuidv7",
|
|
153
164
|
"getValidationError",
|
|
154
165
|
"default",
|
|
155
166
|
"getRequirementsHint",
|
|
156
167
|
"isGzipData",
|
|
168
|
+
"parsePayload",
|
|
169
|
+
"buildResourceAttributes",
|
|
157
170
|
"getOtlpSeverityNumber",
|
|
158
|
-
"getLengthFromRules",
|
|
159
171
|
"isGzipSupported",
|
|
160
172
|
"buildOtlpLogsPayload",
|
|
161
173
|
"buildOtlpLogRecord",
|
|
@@ -168,21 +180,25 @@ var __webpack_exports__ = {};
|
|
|
168
180
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
169
181
|
for(var __WEBPACK_IMPORT_KEY__ in _posthog_core__WEBPACK_IMPORTED_MODULE_8__)if ([
|
|
170
182
|
"toOtlpKeyValueList",
|
|
183
|
+
"getLengthFromRules",
|
|
171
184
|
"PostHogLogs",
|
|
172
185
|
"isNativeAsyncGzipError",
|
|
173
186
|
"getOtlpSeverityText",
|
|
187
|
+
"getEnabledFromValue",
|
|
174
188
|
"isNativeAsyncGzipReadError",
|
|
175
|
-
"getFeatureFlagValue",
|
|
176
189
|
"isGzipRequest",
|
|
190
|
+
"getFeatureFlagValue",
|
|
191
|
+
"getVariantFromValue",
|
|
177
192
|
"gzipCompress",
|
|
178
|
-
"uuidv7",
|
|
179
193
|
"ErrorTracking",
|
|
194
|
+
"uuidv7",
|
|
180
195
|
"getValidationError",
|
|
181
196
|
"default",
|
|
182
197
|
"getRequirementsHint",
|
|
183
198
|
"isGzipData",
|
|
199
|
+
"parsePayload",
|
|
200
|
+
"buildResourceAttributes",
|
|
184
201
|
"getOtlpSeverityNumber",
|
|
185
|
-
"getLengthFromRules",
|
|
186
202
|
"isGzipSupported",
|
|
187
203
|
"buildOtlpLogsPayload",
|
|
188
204
|
"buildOtlpLogRecord",
|
|
@@ -195,21 +211,25 @@ var __webpack_exports__ = {};
|
|
|
195
211
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
196
212
|
for(var __WEBPACK_IMPORT_KEY__ in _posthog_core_stateless__WEBPACK_IMPORTED_MODULE_9__)if ([
|
|
197
213
|
"toOtlpKeyValueList",
|
|
214
|
+
"getLengthFromRules",
|
|
198
215
|
"PostHogLogs",
|
|
199
216
|
"isNativeAsyncGzipError",
|
|
200
217
|
"getOtlpSeverityText",
|
|
218
|
+
"getEnabledFromValue",
|
|
201
219
|
"isNativeAsyncGzipReadError",
|
|
202
|
-
"getFeatureFlagValue",
|
|
203
220
|
"isGzipRequest",
|
|
221
|
+
"getFeatureFlagValue",
|
|
222
|
+
"getVariantFromValue",
|
|
204
223
|
"gzipCompress",
|
|
205
|
-
"uuidv7",
|
|
206
224
|
"ErrorTracking",
|
|
225
|
+
"uuidv7",
|
|
207
226
|
"getValidationError",
|
|
208
227
|
"default",
|
|
209
228
|
"getRequirementsHint",
|
|
210
229
|
"isGzipData",
|
|
230
|
+
"parsePayload",
|
|
231
|
+
"buildResourceAttributes",
|
|
211
232
|
"getOtlpSeverityNumber",
|
|
212
|
-
"getLengthFromRules",
|
|
213
233
|
"isGzipSupported",
|
|
214
234
|
"buildOtlpLogsPayload",
|
|
215
235
|
"buildOtlpLogRecord",
|
|
@@ -222,21 +242,25 @@ var __webpack_exports__ = {};
|
|
|
222
242
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
223
243
|
for(var __WEBPACK_IMPORT_KEY__ in _tracing_headers__WEBPACK_IMPORTED_MODULE_10__)if ([
|
|
224
244
|
"toOtlpKeyValueList",
|
|
245
|
+
"getLengthFromRules",
|
|
225
246
|
"PostHogLogs",
|
|
226
247
|
"isNativeAsyncGzipError",
|
|
227
248
|
"getOtlpSeverityText",
|
|
249
|
+
"getEnabledFromValue",
|
|
228
250
|
"isNativeAsyncGzipReadError",
|
|
229
|
-
"getFeatureFlagValue",
|
|
230
251
|
"isGzipRequest",
|
|
252
|
+
"getFeatureFlagValue",
|
|
253
|
+
"getVariantFromValue",
|
|
231
254
|
"gzipCompress",
|
|
232
|
-
"uuidv7",
|
|
233
255
|
"ErrorTracking",
|
|
256
|
+
"uuidv7",
|
|
234
257
|
"getValidationError",
|
|
235
258
|
"default",
|
|
236
259
|
"getRequirementsHint",
|
|
237
260
|
"isGzipData",
|
|
261
|
+
"parsePayload",
|
|
262
|
+
"buildResourceAttributes",
|
|
238
263
|
"getOtlpSeverityNumber",
|
|
239
|
-
"getLengthFromRules",
|
|
240
264
|
"isGzipSupported",
|
|
241
265
|
"buildOtlpLogsPayload",
|
|
242
266
|
"buildOtlpLogRecord",
|
|
@@ -249,21 +273,25 @@ var __webpack_exports__ = {};
|
|
|
249
273
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
250
274
|
for(var __WEBPACK_IMPORT_KEY__ in _types__WEBPACK_IMPORTED_MODULE_11__)if ([
|
|
251
275
|
"toOtlpKeyValueList",
|
|
276
|
+
"getLengthFromRules",
|
|
252
277
|
"PostHogLogs",
|
|
253
278
|
"isNativeAsyncGzipError",
|
|
254
279
|
"getOtlpSeverityText",
|
|
280
|
+
"getEnabledFromValue",
|
|
255
281
|
"isNativeAsyncGzipReadError",
|
|
256
|
-
"getFeatureFlagValue",
|
|
257
282
|
"isGzipRequest",
|
|
283
|
+
"getFeatureFlagValue",
|
|
284
|
+
"getVariantFromValue",
|
|
258
285
|
"gzipCompress",
|
|
259
|
-
"uuidv7",
|
|
260
286
|
"ErrorTracking",
|
|
287
|
+
"uuidv7",
|
|
261
288
|
"getValidationError",
|
|
262
289
|
"default",
|
|
263
290
|
"getRequirementsHint",
|
|
264
291
|
"isGzipData",
|
|
292
|
+
"parsePayload",
|
|
293
|
+
"buildResourceAttributes",
|
|
265
294
|
"getOtlpSeverityNumber",
|
|
266
|
-
"getLengthFromRules",
|
|
267
295
|
"isGzipSupported",
|
|
268
296
|
"buildOtlpLogsPayload",
|
|
269
297
|
"buildOtlpLogRecord",
|
|
@@ -278,18 +306,22 @@ exports.ErrorTracking = __webpack_exports__.ErrorTracking;
|
|
|
278
306
|
exports.PostHogLogs = __webpack_exports__.PostHogLogs;
|
|
279
307
|
exports.buildOtlpLogRecord = __webpack_exports__.buildOtlpLogRecord;
|
|
280
308
|
exports.buildOtlpLogsPayload = __webpack_exports__.buildOtlpLogsPayload;
|
|
309
|
+
exports.buildResourceAttributes = __webpack_exports__.buildResourceAttributes;
|
|
310
|
+
exports.getEnabledFromValue = __webpack_exports__.getEnabledFromValue;
|
|
281
311
|
exports.getFeatureFlagValue = __webpack_exports__.getFeatureFlagValue;
|
|
282
312
|
exports.getLengthFromRules = __webpack_exports__.getLengthFromRules;
|
|
283
313
|
exports.getOtlpSeverityNumber = __webpack_exports__.getOtlpSeverityNumber;
|
|
284
314
|
exports.getOtlpSeverityText = __webpack_exports__.getOtlpSeverityText;
|
|
285
315
|
exports.getRequirementsHint = __webpack_exports__.getRequirementsHint;
|
|
286
316
|
exports.getValidationError = __webpack_exports__.getValidationError;
|
|
317
|
+
exports.getVariantFromValue = __webpack_exports__.getVariantFromValue;
|
|
287
318
|
exports.gzipCompress = __webpack_exports__.gzipCompress;
|
|
288
319
|
exports.isGzipData = __webpack_exports__.isGzipData;
|
|
289
320
|
exports.isGzipRequest = __webpack_exports__.isGzipRequest;
|
|
290
321
|
exports.isGzipSupported = __webpack_exports__.isGzipSupported;
|
|
291
322
|
exports.isNativeAsyncGzipError = __webpack_exports__.isNativeAsyncGzipError;
|
|
292
323
|
exports.isNativeAsyncGzipReadError = __webpack_exports__.isNativeAsyncGzipReadError;
|
|
324
|
+
exports.parsePayload = __webpack_exports__.parsePayload;
|
|
293
325
|
exports.toOtlpAnyValue = __webpack_exports__.toOtlpAnyValue;
|
|
294
326
|
exports.toOtlpKeyValueList = __webpack_exports__.toOtlpKeyValueList;
|
|
295
327
|
exports.uuidv7 = __webpack_exports__.uuidv7;
|
|
@@ -298,18 +330,22 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
298
330
|
"PostHogLogs",
|
|
299
331
|
"buildOtlpLogRecord",
|
|
300
332
|
"buildOtlpLogsPayload",
|
|
333
|
+
"buildResourceAttributes",
|
|
334
|
+
"getEnabledFromValue",
|
|
301
335
|
"getFeatureFlagValue",
|
|
302
336
|
"getLengthFromRules",
|
|
303
337
|
"getOtlpSeverityNumber",
|
|
304
338
|
"getOtlpSeverityText",
|
|
305
339
|
"getRequirementsHint",
|
|
306
340
|
"getValidationError",
|
|
341
|
+
"getVariantFromValue",
|
|
307
342
|
"gzipCompress",
|
|
308
343
|
"isGzipData",
|
|
309
344
|
"isGzipRequest",
|
|
310
345
|
"isGzipSupported",
|
|
311
346
|
"isNativeAsyncGzipError",
|
|
312
347
|
"isNativeAsyncGzipReadError",
|
|
348
|
+
"parsePayload",
|
|
313
349
|
"toOtlpAnyValue",
|
|
314
350
|
"toOtlpKeyValueList",
|
|
315
351
|
"uuidv7"
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getFeatureFlagValue } from "./featureFlagUtils.mjs";
|
|
1
|
+
import { getEnabledFromValue, getFeatureFlagValue, getVariantFromValue, parsePayload } from "./featureFlagUtils.mjs";
|
|
2
2
|
import { gzipCompress, isGzipData, isGzipRequest, isGzipSupported, isNativeAsyncGzipError, isNativeAsyncGzipReadError } from "./gzip.mjs";
|
|
3
|
-
import { buildOtlpLogRecord, buildOtlpLogsPayload, getOtlpSeverityNumber, getOtlpSeverityText, toOtlpAnyValue, toOtlpKeyValueList } from "./logs/logs-utils.mjs";
|
|
3
|
+
import { buildOtlpLogRecord, buildOtlpLogsPayload, buildResourceAttributes, getOtlpSeverityNumber, getOtlpSeverityText, toOtlpAnyValue, toOtlpKeyValueList } from "./logs/logs-utils.mjs";
|
|
4
4
|
import { PostHogLogs } from "./logs/index.mjs";
|
|
5
5
|
import { uuidv7 } from "./vendor/uuidv7.mjs";
|
|
6
6
|
import { getLengthFromRules, getRequirementsHint, getValidationError } from "./surveys/validation.mjs";
|
|
@@ -11,4 +11,4 @@ export * from "./posthog-core-stateless.mjs";
|
|
|
11
11
|
export * from "./tracing-headers.mjs";
|
|
12
12
|
export * from "./types.mjs";
|
|
13
13
|
import * as __WEBPACK_EXTERNAL_MODULE__error_tracking_index_mjs_b3406d6f__ from "./error-tracking/index.mjs";
|
|
14
|
-
export { __WEBPACK_EXTERNAL_MODULE__error_tracking_index_mjs_b3406d6f__ as ErrorTracking, PostHogLogs, buildOtlpLogRecord, buildOtlpLogsPayload, getFeatureFlagValue, getLengthFromRules, getOtlpSeverityNumber, getOtlpSeverityText, getRequirementsHint, getValidationError, gzipCompress, isGzipData, isGzipRequest, isGzipSupported, isNativeAsyncGzipError, isNativeAsyncGzipReadError, toOtlpAnyValue, toOtlpKeyValueList, uuidv7 };
|
|
14
|
+
export { __WEBPACK_EXTERNAL_MODULE__error_tracking_index_mjs_b3406d6f__ as ErrorTracking, PostHogLogs, buildOtlpLogRecord, buildOtlpLogsPayload, buildResourceAttributes, getEnabledFromValue, getFeatureFlagValue, getLengthFromRules, getOtlpSeverityNumber, getOtlpSeverityText, getRequirementsHint, getValidationError, getVariantFromValue, gzipCompress, isGzipData, isGzipRequest, isGzipSupported, isNativeAsyncGzipError, isNativeAsyncGzipReadError, parsePayload, toOtlpAnyValue, toOtlpKeyValueList, uuidv7 };
|
package/dist/logs/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Logger } from '../types';
|
|
2
|
-
import type {
|
|
3
|
-
import type { CaptureLogOptions, LogSdkContext, ResolvedPostHogLogsConfig } from './types';
|
|
2
|
+
import type { CaptureLogOptions, LogSdkContext, LogsHost, ResolvedPostHogLogsConfig } from './types';
|
|
4
3
|
export declare class PostHogLogs {
|
|
5
4
|
private readonly _instance;
|
|
6
5
|
private readonly _config;
|
|
@@ -9,16 +8,25 @@ export declare class PostHogLogs {
|
|
|
9
8
|
private readonly _onReady;
|
|
10
9
|
private readonly _waitForStoragePersist;
|
|
11
10
|
private _maxBufferSize;
|
|
11
|
+
private _maxQueueSize;
|
|
12
12
|
private _flushIntervalMs;
|
|
13
13
|
private _maxBatchRecordsPerPost;
|
|
14
14
|
private _flushTimer?;
|
|
15
15
|
private _flushPromise;
|
|
16
|
+
private _evictedSinceAdvance;
|
|
17
|
+
private _consecutiveFlushFailures;
|
|
16
18
|
private _rateCapWindowMs;
|
|
17
19
|
private _maxLogsPerInterval?;
|
|
18
20
|
private _intervalWindowStart;
|
|
19
21
|
private _intervalLogCount;
|
|
20
22
|
private _droppedWarned;
|
|
21
|
-
constructor(_instance:
|
|
23
|
+
constructor(_instance: LogsHost, _config: ResolvedPostHogLogsConfig, _logger: Logger, _getContext: () => LogSdkContext, _onReady: (fn: () => void) => void, _waitForStoragePersist?: () => Promise<void>);
|
|
24
|
+
/**
|
|
25
|
+
* Clears the flush timer and rate-cap state. The host owns the record queue
|
|
26
|
+
* and clears it separately (the browser empties its in-memory store).
|
|
27
|
+
*/
|
|
28
|
+
reset(): void;
|
|
29
|
+
onReconnect(): void;
|
|
22
30
|
captureLog(options: CaptureLogOptions): void;
|
|
23
31
|
/**
|
|
24
32
|
* Runs the configured `beforeSend` hook(s) on a capture record:
|
|
@@ -61,20 +69,11 @@ export declare class PostHogLogs {
|
|
|
61
69
|
flush(): Promise<void>;
|
|
62
70
|
private _flushInner;
|
|
63
71
|
private _persistQueueAdvance;
|
|
64
|
-
/**
|
|
65
|
-
* OTLP resource attributes for every batch.
|
|
66
|
-
*
|
|
67
|
-
* Layout: user `resourceAttributes` spread first, then SDK-controlled
|
|
68
|
-
* keys layered on top so users cannot accidentally clobber them. Most logs
|
|
69
|
-
* backends index on `service.name` and `telemetry.sdk.*` for routing,
|
|
70
|
-
* SDK-version dashboards, and bug-correlation; letting a stray user key
|
|
71
|
-
* overwrite them silently breaks ingestion attribution. The dedicated
|
|
72
|
-
* `serviceName` / `environment` / `serviceVersion` config fields are the
|
|
73
|
-
* supported way to override `service.name` / `deployment.environment` /
|
|
74
|
-
* `service.version`.
|
|
75
|
-
*/
|
|
76
72
|
private _buildResourceAttributes;
|
|
77
73
|
private _enqueue;
|
|
74
|
+
private _armFlushTimer;
|
|
75
|
+
private _nextFlushDelay;
|
|
76
|
+
private _hasQueuedRecords;
|
|
78
77
|
/**
|
|
79
78
|
* Stops the timer-based flush and sends anything still in the queue.
|
|
80
79
|
* Intended for process-teardown paths (RN `_shutdown` override). Swallows
|
package/dist/logs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logs/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAA4B,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logs/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAA4B,MAAM,UAAU,CAAA;AAE3D,OAAO,KAAK,EAAoB,iBAAiB,EAAE,aAAa,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAKtH,qBAAa,WAAW;IAgCpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAMzB,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IAzCzC,OAAO,CAAC,cAAc,CAAQ;IAG9B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,gBAAgB,CAAQ;IAIhC,OAAO,CAAC,uBAAuB,CAAQ;IACvC,OAAO,CAAC,WAAW,CAAC,CAAmC;IAGvD,OAAO,CAAC,aAAa,CAA6B;IAGlD,OAAO,CAAC,oBAAoB,CAAI;IAGhC,OAAO,CAAC,yBAAyB,CAAI;IAMrC,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,mBAAmB,CAAC,CAAQ;IACpC,OAAO,CAAC,oBAAoB,CAAI;IAChC,OAAO,CAAC,iBAAiB,CAAI;IAC7B,OAAO,CAAC,cAAc,CAAQ;gBAGX,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,aAAa,EAChC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,EAMlC,sBAAsB,GAAE,MAAM,OAAO,CAAC,IAAI,CAA2B;IAYxF;;;OAGG;IACH,KAAK,IAAI,IAAI;IAcb,WAAW,IAAI,IAAI;IAKnB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAqC5C;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAuBtB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,eAAe;IAwBvB;;;;;;;;;OASG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAad,WAAW;YAuEX,oBAAoB;IAYlC,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,QAAQ;IA+BhB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,iBAAiB;IAKzB;;;;;;;;;OASG;IACG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcjD;;;;;;;;;;;OAWG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBxD,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,gBAAgB;CAMzB"}
|
package/dist/logs/index.js
CHANGED
|
@@ -29,6 +29,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
const external_logs_utils_js_namespaceObject = require("./logs-utils.js");
|
|
30
30
|
const external_types_js_namespaceObject = require("../types.js");
|
|
31
31
|
const index_js_namespaceObject = require("../utils/index.js");
|
|
32
|
+
const MAX_FLUSH_BACKOFF_EXPONENT = 6;
|
|
32
33
|
class PostHogLogs {
|
|
33
34
|
constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve()){
|
|
34
35
|
this._instance = _instance;
|
|
@@ -38,22 +39,39 @@ class PostHogLogs {
|
|
|
38
39
|
this._onReady = _onReady;
|
|
39
40
|
this._waitForStoragePersist = _waitForStoragePersist;
|
|
40
41
|
this._flushPromise = null;
|
|
42
|
+
this._evictedSinceAdvance = 0;
|
|
43
|
+
this._consecutiveFlushFailures = 0;
|
|
41
44
|
this._intervalWindowStart = 0;
|
|
42
45
|
this._intervalLogCount = 0;
|
|
43
46
|
this._droppedWarned = false;
|
|
44
47
|
this._maxBufferSize = _config.maxBufferSize;
|
|
48
|
+
this._maxQueueSize = Math.max(_config.maxQueueSize ?? _config.maxBufferSize, _config.maxBufferSize);
|
|
45
49
|
this._flushIntervalMs = _config.flushIntervalMs;
|
|
46
50
|
this._maxBatchRecordsPerPost = _config.maxBatchRecordsPerPost;
|
|
47
51
|
this._rateCapWindowMs = _config.rateCapWindowMs;
|
|
48
52
|
this._maxLogsPerInterval = _config.maxLogsPerInterval;
|
|
49
53
|
}
|
|
54
|
+
reset() {
|
|
55
|
+
this._clearFlushTimer();
|
|
56
|
+
this._flushPromise = null;
|
|
57
|
+
this._intervalWindowStart = 0;
|
|
58
|
+
this._intervalLogCount = 0;
|
|
59
|
+
this._droppedWarned = false;
|
|
60
|
+
this._evictedSinceAdvance = 0;
|
|
61
|
+
this._consecutiveFlushFailures = 0;
|
|
62
|
+
this._maxBatchRecordsPerPost = this._config.maxBatchRecordsPerPost;
|
|
63
|
+
}
|
|
64
|
+
onReconnect() {
|
|
65
|
+
this._consecutiveFlushFailures = 0;
|
|
66
|
+
this._flushInBackground();
|
|
67
|
+
}
|
|
50
68
|
captureLog(options) {
|
|
51
69
|
if (this._instance.isDisabled) return;
|
|
52
70
|
if (this._instance.optedOut) return;
|
|
53
71
|
if (!options?.body) return;
|
|
54
72
|
const filtered = this._runBeforeSend(options);
|
|
55
73
|
if (null === filtered) return;
|
|
56
|
-
if (!filtered.body) return;
|
|
74
|
+
if (!filtered.body) return void this._logger.info("Log was rejected in beforeSend function");
|
|
57
75
|
if (!this._checkRateLimit()) return;
|
|
58
76
|
const record = (0, external_logs_utils_js_namespaceObject.buildOtlpLogRecord)(filtered, this._getContext());
|
|
59
77
|
const entry = {
|
|
@@ -115,6 +133,7 @@ class PostHogLogs {
|
|
|
115
133
|
const originalQueueLength = queue.length;
|
|
116
134
|
let sentCount = 0;
|
|
117
135
|
while(queue.length > 0 && sentCount < originalQueueLength){
|
|
136
|
+
this._evictedSinceAdvance = 0;
|
|
118
137
|
const batchSize = Math.min(queue.length, this._maxBatchRecordsPerPost);
|
|
119
138
|
const batch = queue.slice(0, batchSize);
|
|
120
139
|
const records = batch.map((e)=>e.record);
|
|
@@ -135,38 +154,42 @@ class PostHogLogs {
|
|
|
135
154
|
}
|
|
136
155
|
}
|
|
137
156
|
async _persistQueueAdvance(consumed) {
|
|
157
|
+
const evicted = this._evictedSinceAdvance;
|
|
158
|
+
const drop = Math.max(0, consumed - evicted);
|
|
138
159
|
const refreshed = this._instance.getPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue) ?? [];
|
|
139
|
-
this._instance.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue, refreshed.slice(
|
|
160
|
+
this._instance.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue, refreshed.slice(drop));
|
|
140
161
|
await this._waitForStoragePersist();
|
|
141
162
|
}
|
|
142
163
|
_buildResourceAttributes() {
|
|
143
|
-
return
|
|
144
|
-
...this._config.resourceAttributes,
|
|
145
|
-
'service.name': this._config.serviceName || 'unknown_service',
|
|
146
|
-
...this._config.environment && {
|
|
147
|
-
'deployment.environment': this._config.environment
|
|
148
|
-
},
|
|
149
|
-
...this._config.serviceVersion && {
|
|
150
|
-
'service.version': this._config.serviceVersion
|
|
151
|
-
},
|
|
152
|
-
'telemetry.sdk.name': this._instance.getLibraryId(),
|
|
153
|
-
'telemetry.sdk.version': this._instance.getLibraryVersion()
|
|
154
|
-
};
|
|
164
|
+
return (0, external_logs_utils_js_namespaceObject.buildResourceAttributes)(this._config, this._instance.getLibraryId(), this._instance.getLibraryVersion());
|
|
155
165
|
}
|
|
156
166
|
_enqueue(entry) {
|
|
157
167
|
if (this._instance.optedOut) return;
|
|
158
168
|
const queue = this._instance.getPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue) ?? [];
|
|
159
|
-
if (queue.length >= this.
|
|
169
|
+
if (queue.length >= this._maxQueueSize) {
|
|
160
170
|
queue.shift();
|
|
171
|
+
this._evictedSinceAdvance++;
|
|
161
172
|
this._logger.info('Logs queue is full, dropping oldest record.');
|
|
162
173
|
}
|
|
163
174
|
queue.push(entry);
|
|
164
175
|
this._instance.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue, queue);
|
|
165
176
|
if (queue.length >= this._maxBufferSize) return void this._flushInBackground();
|
|
166
|
-
|
|
177
|
+
this._armFlushTimer();
|
|
178
|
+
}
|
|
179
|
+
_armFlushTimer(delayMs = this._flushIntervalMs) {
|
|
180
|
+
if (this._flushTimer) return;
|
|
181
|
+
this._flushTimer = (0, index_js_namespaceObject.safeSetTimeout)(()=>{
|
|
167
182
|
this._flushTimer = void 0;
|
|
168
183
|
this._flushInBackground();
|
|
169
|
-
},
|
|
184
|
+
}, delayMs);
|
|
185
|
+
}
|
|
186
|
+
_nextFlushDelay() {
|
|
187
|
+
const exponent = Math.min(Math.max(0, this._consecutiveFlushFailures - 1), MAX_FLUSH_BACKOFF_EXPONENT);
|
|
188
|
+
return this._flushIntervalMs * 2 ** exponent;
|
|
189
|
+
}
|
|
190
|
+
_hasQueuedRecords() {
|
|
191
|
+
const queue = this._instance.getPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue);
|
|
192
|
+
return !!queue && queue.length > 0;
|
|
170
193
|
}
|
|
171
194
|
async shutdown(timeoutMs) {
|
|
172
195
|
this._clearFlushTimer();
|
|
@@ -194,8 +217,13 @@ class PostHogLogs {
|
|
|
194
217
|
}
|
|
195
218
|
}
|
|
196
219
|
_flushInBackground() {
|
|
197
|
-
this.flush().
|
|
220
|
+
this.flush().then(()=>{
|
|
221
|
+
this._consecutiveFlushFailures = 0;
|
|
222
|
+
}, (err)=>{
|
|
223
|
+
this._consecutiveFlushFailures++;
|
|
198
224
|
this._logger.error('PostHog logs flush failed:', err);
|
|
225
|
+
}).finally(()=>{
|
|
226
|
+
if (!this._instance.isDisabled && this._hasQueuedRecords()) this._armFlushTimer(this._nextFlushDelay());
|
|
199
227
|
});
|
|
200
228
|
}
|
|
201
229
|
_clearFlushTimer() {
|
package/dist/logs/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { buildOtlpLogRecord, buildOtlpLogsPayload } from "./logs-utils.mjs";
|
|
1
|
+
import { buildOtlpLogRecord, buildOtlpLogsPayload, buildResourceAttributes } from "./logs-utils.mjs";
|
|
2
2
|
import { PostHogPersistedProperty } from "../types.mjs";
|
|
3
3
|
import { isArray, safeSetTimeout } from "../utils/index.mjs";
|
|
4
|
+
const MAX_FLUSH_BACKOFF_EXPONENT = 6;
|
|
4
5
|
class PostHogLogs {
|
|
5
6
|
constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve()){
|
|
6
7
|
this._instance = _instance;
|
|
@@ -10,22 +11,39 @@ class PostHogLogs {
|
|
|
10
11
|
this._onReady = _onReady;
|
|
11
12
|
this._waitForStoragePersist = _waitForStoragePersist;
|
|
12
13
|
this._flushPromise = null;
|
|
14
|
+
this._evictedSinceAdvance = 0;
|
|
15
|
+
this._consecutiveFlushFailures = 0;
|
|
13
16
|
this._intervalWindowStart = 0;
|
|
14
17
|
this._intervalLogCount = 0;
|
|
15
18
|
this._droppedWarned = false;
|
|
16
19
|
this._maxBufferSize = _config.maxBufferSize;
|
|
20
|
+
this._maxQueueSize = Math.max(_config.maxQueueSize ?? _config.maxBufferSize, _config.maxBufferSize);
|
|
17
21
|
this._flushIntervalMs = _config.flushIntervalMs;
|
|
18
22
|
this._maxBatchRecordsPerPost = _config.maxBatchRecordsPerPost;
|
|
19
23
|
this._rateCapWindowMs = _config.rateCapWindowMs;
|
|
20
24
|
this._maxLogsPerInterval = _config.maxLogsPerInterval;
|
|
21
25
|
}
|
|
26
|
+
reset() {
|
|
27
|
+
this._clearFlushTimer();
|
|
28
|
+
this._flushPromise = null;
|
|
29
|
+
this._intervalWindowStart = 0;
|
|
30
|
+
this._intervalLogCount = 0;
|
|
31
|
+
this._droppedWarned = false;
|
|
32
|
+
this._evictedSinceAdvance = 0;
|
|
33
|
+
this._consecutiveFlushFailures = 0;
|
|
34
|
+
this._maxBatchRecordsPerPost = this._config.maxBatchRecordsPerPost;
|
|
35
|
+
}
|
|
36
|
+
onReconnect() {
|
|
37
|
+
this._consecutiveFlushFailures = 0;
|
|
38
|
+
this._flushInBackground();
|
|
39
|
+
}
|
|
22
40
|
captureLog(options) {
|
|
23
41
|
if (this._instance.isDisabled) return;
|
|
24
42
|
if (this._instance.optedOut) return;
|
|
25
43
|
if (!options?.body) return;
|
|
26
44
|
const filtered = this._runBeforeSend(options);
|
|
27
45
|
if (null === filtered) return;
|
|
28
|
-
if (!filtered.body) return;
|
|
46
|
+
if (!filtered.body) return void this._logger.info("Log was rejected in beforeSend function");
|
|
29
47
|
if (!this._checkRateLimit()) return;
|
|
30
48
|
const record = buildOtlpLogRecord(filtered, this._getContext());
|
|
31
49
|
const entry = {
|
|
@@ -87,6 +105,7 @@ class PostHogLogs {
|
|
|
87
105
|
const originalQueueLength = queue.length;
|
|
88
106
|
let sentCount = 0;
|
|
89
107
|
while(queue.length > 0 && sentCount < originalQueueLength){
|
|
108
|
+
this._evictedSinceAdvance = 0;
|
|
90
109
|
const batchSize = Math.min(queue.length, this._maxBatchRecordsPerPost);
|
|
91
110
|
const batch = queue.slice(0, batchSize);
|
|
92
111
|
const records = batch.map((e)=>e.record);
|
|
@@ -107,38 +126,42 @@ class PostHogLogs {
|
|
|
107
126
|
}
|
|
108
127
|
}
|
|
109
128
|
async _persistQueueAdvance(consumed) {
|
|
129
|
+
const evicted = this._evictedSinceAdvance;
|
|
130
|
+
const drop = Math.max(0, consumed - evicted);
|
|
110
131
|
const refreshed = this._instance.getPersistedProperty(PostHogPersistedProperty.LogsQueue) ?? [];
|
|
111
|
-
this._instance.setPersistedProperty(PostHogPersistedProperty.LogsQueue, refreshed.slice(
|
|
132
|
+
this._instance.setPersistedProperty(PostHogPersistedProperty.LogsQueue, refreshed.slice(drop));
|
|
112
133
|
await this._waitForStoragePersist();
|
|
113
134
|
}
|
|
114
135
|
_buildResourceAttributes() {
|
|
115
|
-
return
|
|
116
|
-
...this._config.resourceAttributes,
|
|
117
|
-
'service.name': this._config.serviceName || 'unknown_service',
|
|
118
|
-
...this._config.environment && {
|
|
119
|
-
'deployment.environment': this._config.environment
|
|
120
|
-
},
|
|
121
|
-
...this._config.serviceVersion && {
|
|
122
|
-
'service.version': this._config.serviceVersion
|
|
123
|
-
},
|
|
124
|
-
'telemetry.sdk.name': this._instance.getLibraryId(),
|
|
125
|
-
'telemetry.sdk.version': this._instance.getLibraryVersion()
|
|
126
|
-
};
|
|
136
|
+
return buildResourceAttributes(this._config, this._instance.getLibraryId(), this._instance.getLibraryVersion());
|
|
127
137
|
}
|
|
128
138
|
_enqueue(entry) {
|
|
129
139
|
if (this._instance.optedOut) return;
|
|
130
140
|
const queue = this._instance.getPersistedProperty(PostHogPersistedProperty.LogsQueue) ?? [];
|
|
131
|
-
if (queue.length >= this.
|
|
141
|
+
if (queue.length >= this._maxQueueSize) {
|
|
132
142
|
queue.shift();
|
|
143
|
+
this._evictedSinceAdvance++;
|
|
133
144
|
this._logger.info('Logs queue is full, dropping oldest record.');
|
|
134
145
|
}
|
|
135
146
|
queue.push(entry);
|
|
136
147
|
this._instance.setPersistedProperty(PostHogPersistedProperty.LogsQueue, queue);
|
|
137
148
|
if (queue.length >= this._maxBufferSize) return void this._flushInBackground();
|
|
138
|
-
|
|
149
|
+
this._armFlushTimer();
|
|
150
|
+
}
|
|
151
|
+
_armFlushTimer(delayMs = this._flushIntervalMs) {
|
|
152
|
+
if (this._flushTimer) return;
|
|
153
|
+
this._flushTimer = safeSetTimeout(()=>{
|
|
139
154
|
this._flushTimer = void 0;
|
|
140
155
|
this._flushInBackground();
|
|
141
|
-
},
|
|
156
|
+
}, delayMs);
|
|
157
|
+
}
|
|
158
|
+
_nextFlushDelay() {
|
|
159
|
+
const exponent = Math.min(Math.max(0, this._consecutiveFlushFailures - 1), MAX_FLUSH_BACKOFF_EXPONENT);
|
|
160
|
+
return this._flushIntervalMs * 2 ** exponent;
|
|
161
|
+
}
|
|
162
|
+
_hasQueuedRecords() {
|
|
163
|
+
const queue = this._instance.getPersistedProperty(PostHogPersistedProperty.LogsQueue);
|
|
164
|
+
return !!queue && queue.length > 0;
|
|
142
165
|
}
|
|
143
166
|
async shutdown(timeoutMs) {
|
|
144
167
|
this._clearFlushTimer();
|
|
@@ -166,8 +189,13 @@ class PostHogLogs {
|
|
|
166
189
|
}
|
|
167
190
|
}
|
|
168
191
|
_flushInBackground() {
|
|
169
|
-
this.flush().
|
|
192
|
+
this.flush().then(()=>{
|
|
193
|
+
this._consecutiveFlushFailures = 0;
|
|
194
|
+
}, (err)=>{
|
|
195
|
+
this._consecutiveFlushFailures++;
|
|
170
196
|
this._logger.error('PostHog logs flush failed:', err);
|
|
197
|
+
}).finally(()=>{
|
|
198
|
+
if (!this._instance.isDisabled && this._hasQueuedRecords()) this._armFlushTimer(this._nextFlushDelay());
|
|
171
199
|
});
|
|
172
200
|
}
|
|
173
201
|
_clearFlushTimer() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CaptureLogOptions, LogAttributeValue, LogSeverityLevel, OtlpAnyValue, OtlpKeyValue, OtlpLogRecord, OtlpLogsPayload, OtlpSeverityText } from '@posthog/types';
|
|
2
|
-
import type { LogSdkContext } from './types';
|
|
2
|
+
import type { LogSdkContext, ResolvedPostHogLogsConfig } from './types';
|
|
3
3
|
export declare function getOtlpSeverityText(level: LogSeverityLevel): OtlpSeverityText;
|
|
4
4
|
export declare function getOtlpSeverityNumber(level: LogSeverityLevel): number;
|
|
5
5
|
export declare function toOtlpAnyValue(value: LogAttributeValue): OtlpAnyValue;
|
|
@@ -15,6 +15,21 @@ export declare function toOtlpKeyValueList(attrs: Record<string, LogAttributeVal
|
|
|
15
15
|
* User-provided `options.attributes` always wins on conflicts.
|
|
16
16
|
*/
|
|
17
17
|
export declare function buildOtlpLogRecord(options: CaptureLogOptions, sdkContext: LogSdkContext): OtlpLogRecord;
|
|
18
|
+
/**
|
|
19
|
+
* OTLP resource attributes for every batch, shared by the core flush path and
|
|
20
|
+
* SDK-specific paths that bypass it (e.g. the browser's synchronous sendBeacon
|
|
21
|
+
* drain). Having one builder keeps those paths from drifting.
|
|
22
|
+
*
|
|
23
|
+
* Layout: user `resourceAttributes` spread first, then SDK-controlled keys
|
|
24
|
+
* (`service.name`, `deployment.environment`, `service.version`,
|
|
25
|
+
* `telemetry.sdk.*`) layered on top so a stray user key can't clobber the
|
|
26
|
+
* ingestion-attribution keys. The dedicated `serviceName` / `environment` /
|
|
27
|
+
* `serviceVersion` config fields are the supported way to override the first
|
|
28
|
+
* three; each SDK resolves its own `service.name` default before this point, so
|
|
29
|
+
* the `unknown_service` fallback here only fires if a config slips through with
|
|
30
|
+
* an empty `serviceName`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildResourceAttributes(config: ResolvedPostHogLogsConfig, scopeName: string, scopeVersion: string): Record<string, LogAttributeValue>;
|
|
18
33
|
/**
|
|
19
34
|
* Wraps a list of records in the OTLP `resourceLogs` envelope.
|
|
20
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs-utils.d.ts","sourceRoot":"","sources":["../../src/logs/logs-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,eAAe,EAEf,gBAAgB,EACjB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"logs-utils.d.ts","sourceRoot":"","sources":["../../src/logs/logs-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,eAAe,EAEf,gBAAgB,EACjB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAkBvE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAE7E;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAErE;AAMD,wBAAgB,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAiCrE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,YAAY,EAAE,CAU3F;AAiBD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,GAAG,aAAa,CAmDvG;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,yBAAyB,EACjC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CASnC;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,aAAa,EAAE,EAC3B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACrD,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,eAAe,CAcjB"}
|