@posthog/core 1.50.1 → 1.50.2
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.
|
@@ -170,6 +170,10 @@ function encodeArrayValues(values, logger, state, depth) {
|
|
|
170
170
|
function encodeKeyValueList(attrs, logger, state, depth) {
|
|
171
171
|
const result = [];
|
|
172
172
|
for(const key in attrs)if (propertyIsEnumerable.call(attrs, key)) {
|
|
173
|
+
if (!key) {
|
|
174
|
+
logger?.debug('Dropping an attribute with an empty key');
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
173
177
|
if (result.length >= external_json_utils_js_namespaceObject.MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) {
|
|
174
178
|
logger?.debug('Attributes truncated: the value exceeds the OTLP encoder budget');
|
|
175
179
|
break;
|
|
@@ -141,6 +141,10 @@ function encodeArrayValues(values, logger, state, depth) {
|
|
|
141
141
|
function encodeKeyValueList(attrs, logger, state, depth) {
|
|
142
142
|
const result = [];
|
|
143
143
|
for(const key in attrs)if (propertyIsEnumerable.call(attrs, key)) {
|
|
144
|
+
if (!key) {
|
|
145
|
+
logger?.debug('Dropping an attribute with an empty key');
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
144
148
|
if (result.length >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) {
|
|
145
149
|
logger?.debug('Attributes truncated: the value exceeds the OTLP encoder budget');
|
|
146
150
|
break;
|
package/package.json
CHANGED
|
@@ -357,5 +357,20 @@ describe('otlp-any-value', () => {
|
|
|
357
357
|
})
|
|
358
358
|
).toEqual([{ key: 'kept', value: { stringValue: 'yes' } }])
|
|
359
359
|
})
|
|
360
|
+
|
|
361
|
+
it('skips an empty key, which OTLP does not allow', () => {
|
|
362
|
+
expect(toOtlpKeyValueList({ '': 'nameless', kept: 'yes' })).toEqual([
|
|
363
|
+
{ key: 'kept', value: { stringValue: 'yes' } },
|
|
364
|
+
])
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
it('skips an empty key nested inside a value', () => {
|
|
368
|
+
expect(toOtlpKeyValueList({ outer: { '': 'nameless', kept: 'yes' } })).toEqual([
|
|
369
|
+
{
|
|
370
|
+
key: 'outer',
|
|
371
|
+
value: { kvlistValue: { values: [{ key: 'kept', value: { stringValue: 'yes' } }] } },
|
|
372
|
+
},
|
|
373
|
+
])
|
|
374
|
+
})
|
|
360
375
|
})
|
|
361
376
|
})
|
|
@@ -204,6 +204,12 @@ function encodeKeyValueList(
|
|
|
204
204
|
if (!propertyIsEnumerable.call(attrs, key)) {
|
|
205
205
|
continue
|
|
206
206
|
}
|
|
207
|
+
if (!key) {
|
|
208
|
+
// OTLP requires a non-empty key. The server stores one verbatim, where it
|
|
209
|
+
// shows up as a nameless attribute nothing can filter on.
|
|
210
|
+
logger?.debug('Dropping an attribute with an empty key')
|
|
211
|
+
continue
|
|
212
|
+
}
|
|
207
213
|
if (result.length >= MAX_JSON_SAFE_VALUE_ITEMS || state.remainingNodes <= 0) {
|
|
208
214
|
// Reported rather than written into the attributes: a synthetic key would
|
|
209
215
|
// land in the user's own namespace and could collide with a real one.
|