@posthog/core 1.35.3 → 1.35.4

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.
@@ -7,6 +7,7 @@ export declare class PostHogLogs {
7
7
  private readonly _getContext;
8
8
  private readonly _onReady;
9
9
  private readonly _waitForStoragePersist;
10
+ private readonly _scopeName?;
10
11
  private _maxBufferSize;
11
12
  private _maxQueueSize;
12
13
  private _flushIntervalMs;
@@ -20,7 +21,7 @@ export declare class PostHogLogs {
20
21
  private _intervalWindowStart;
21
22
  private _intervalLogCount;
22
23
  private _droppedWarned;
23
- constructor(_instance: LogsHost, _config: ResolvedPostHogLogsConfig, _logger: Logger, _getContext: () => LogSdkContext, _onReady: (fn: () => void) => void, _waitForStoragePersist?: () => Promise<void>);
24
+ constructor(_instance: LogsHost, _config: ResolvedPostHogLogsConfig, _logger: Logger, _getContext: () => LogSdkContext, _onReady: (fn: () => void) => void, _waitForStoragePersist?: () => Promise<void>, _scopeName?: string | undefined);
24
25
  /**
25
26
  * Clears the flush timer and rate-cap state. The host owns the record queue
26
27
  * and clears it separately (the browser empties its in-memory store).
@@ -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;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,OA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,MAAM,OAAO,CAAC,IAAI,CAA2B,EAIrE,UAAU,CAAC,EAAE,MAAM,YAAA;IAYtC;;;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"}
@@ -31,13 +31,14 @@ const external_types_js_namespaceObject = require("../types.js");
31
31
  const index_js_namespaceObject = require("../utils/index.js");
32
32
  const MAX_FLUSH_BACKOFF_EXPONENT = 6;
33
33
  class PostHogLogs {
34
- constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve()){
34
+ constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve(), _scopeName){
35
35
  this._instance = _instance;
36
36
  this._config = _config;
37
37
  this._logger = _logger;
38
38
  this._getContext = _getContext;
39
39
  this._onReady = _onReady;
40
40
  this._waitForStoragePersist = _waitForStoragePersist;
41
+ this._scopeName = _scopeName;
41
42
  this._flushPromise = null;
42
43
  this._evictedSinceAdvance = 0;
43
44
  this._consecutiveFlushFailures = 0;
@@ -137,7 +138,7 @@ class PostHogLogs {
137
138
  const batchSize = Math.min(queue.length, this._maxBatchRecordsPerPost);
138
139
  const batch = queue.slice(0, batchSize);
139
140
  const records = batch.map((e)=>e.record);
140
- const payload = (0, external_logs_utils_js_namespaceObject.buildOtlpLogsPayload)(records, this._buildResourceAttributes(), this._instance.getLibraryId(), this._instance.getLibraryVersion());
141
+ const payload = (0, external_logs_utils_js_namespaceObject.buildOtlpLogsPayload)(records, this._buildResourceAttributes(), this._scopeName ?? this._instance.getLibraryId(), this._instance.getLibraryVersion());
141
142
  const outcome = await this._instance._sendLogsBatch(payload);
142
143
  if ('too-large' === outcome.kind && batch.length > 1) {
143
144
  this._maxBatchRecordsPerPost = Math.max(1, Math.floor(batch.length / 2));
@@ -3,13 +3,14 @@ import { PostHogPersistedProperty } from "../types.mjs";
3
3
  import { isArray, safeSetTimeout } from "../utils/index.mjs";
4
4
  const MAX_FLUSH_BACKOFF_EXPONENT = 6;
5
5
  class PostHogLogs {
6
- constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve()){
6
+ constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve(), _scopeName){
7
7
  this._instance = _instance;
8
8
  this._config = _config;
9
9
  this._logger = _logger;
10
10
  this._getContext = _getContext;
11
11
  this._onReady = _onReady;
12
12
  this._waitForStoragePersist = _waitForStoragePersist;
13
+ this._scopeName = _scopeName;
13
14
  this._flushPromise = null;
14
15
  this._evictedSinceAdvance = 0;
15
16
  this._consecutiveFlushFailures = 0;
@@ -109,7 +110,7 @@ class PostHogLogs {
109
110
  const batchSize = Math.min(queue.length, this._maxBatchRecordsPerPost);
110
111
  const batch = queue.slice(0, batchSize);
111
112
  const records = batch.map((e)=>e.record);
112
- const payload = buildOtlpLogsPayload(records, this._buildResourceAttributes(), this._instance.getLibraryId(), this._instance.getLibraryVersion());
113
+ const payload = buildOtlpLogsPayload(records, this._buildResourceAttributes(), this._scopeName ?? this._instance.getLibraryId(), this._instance.getLibraryVersion());
113
114
  const outcome = await this._instance._sendLogsBatch(payload);
114
115
  if ('too-large' === outcome.kind && batch.length > 1) {
115
116
  this._maxBatchRecordsPerPost = Math.max(1, Math.floor(batch.length / 2));
@@ -29,14 +29,14 @@ export declare function buildOtlpLogRecord(options: CaptureLogOptions, sdkContex
29
29
  * the `unknown_service` fallback here only fires if a config slips through with
30
30
  * an empty `serviceName`.
31
31
  */
32
- export declare function buildResourceAttributes(config: ResolvedPostHogLogsConfig, scopeName: string, scopeVersion: string): Record<string, LogAttributeValue>;
32
+ export declare function buildResourceAttributes(config: ResolvedPostHogLogsConfig, sdkName: string, sdkVersion: string): Record<string, LogAttributeValue>;
33
33
  /**
34
34
  * Wraps a list of records in the OTLP `resourceLogs` envelope.
35
35
  *
36
- * `scopeName` is the SDK package name (`posthog-js`, `posthog-react-native`,
37
- * etc.). `scopeVersion` is the SDK semver. The server combines them into a
38
- * single `instrumentation_scope` field (`{name}@{version}`) used for
39
- * SDK-version-level attribution in queries and dashboards.
36
+ * `scopeName` is the OTLP instrumentation scope name (`web`/`console` for
37
+ * browser, or the SDK library ID for other platforms). `scopeVersion` is the
38
+ * SDK semver. The server combines them into a single `instrumentation_scope`
39
+ * field (`{name}@{version}`) used for attribution in queries and dashboards.
40
40
  */
41
41
  export declare function buildOtlpLogsPayload(logRecords: OtlpLogRecord[], resourceAttributes: Record<string, LogAttributeValue>, scopeName: string, scopeVersion: string): OtlpLogsPayload;
42
42
  //# sourceMappingURL=logs-utils.d.ts.map
@@ -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,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ED,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,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,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"}
@@ -143,7 +143,7 @@ function buildOtlpLogRecord(options, sdkContext) {
143
143
  if (!(0, index_js_namespaceObject.isUndefined)(options.trace_flags)) record.flags = options.trace_flags;
144
144
  return record;
145
145
  }
146
- function buildResourceAttributes(config, scopeName, scopeVersion) {
146
+ function buildResourceAttributes(config, sdkName, sdkVersion) {
147
147
  return {
148
148
  ...config.resourceAttributes,
149
149
  'service.name': config.serviceName || 'unknown_service',
@@ -153,8 +153,8 @@ function buildResourceAttributes(config, scopeName, scopeVersion) {
153
153
  ...config.serviceVersion && {
154
154
  'service.version': config.serviceVersion
155
155
  },
156
- 'telemetry.sdk.name': scopeName,
157
- 'telemetry.sdk.version': scopeVersion
156
+ 'telemetry.sdk.name': sdkName,
157
+ 'telemetry.sdk.version': sdkVersion
158
158
  };
159
159
  }
160
160
  function buildOtlpLogsPayload(logRecords, resourceAttributes, scopeName, scopeVersion) {
@@ -109,7 +109,7 @@ function buildOtlpLogRecord(options, sdkContext) {
109
109
  if (!isUndefined(options.trace_flags)) record.flags = options.trace_flags;
110
110
  return record;
111
111
  }
112
- function buildResourceAttributes(config, scopeName, scopeVersion) {
112
+ function buildResourceAttributes(config, sdkName, sdkVersion) {
113
113
  return {
114
114
  ...config.resourceAttributes,
115
115
  'service.name': config.serviceName || 'unknown_service',
@@ -119,8 +119,8 @@ function buildResourceAttributes(config, scopeName, scopeVersion) {
119
119
  ...config.serviceVersion && {
120
120
  'service.version': config.serviceVersion
121
121
  },
122
- 'telemetry.sdk.name': scopeName,
123
- 'telemetry.sdk.version': scopeVersion
122
+ 'telemetry.sdk.name': sdkName,
123
+ 'telemetry.sdk.version': sdkVersion
124
124
  };
125
125
  }
126
126
  function buildOtlpLogsPayload(logRecords, resourceAttributes, scopeName, scopeVersion) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/core",
3
- "version": "1.35.3",
3
+ "version": "1.35.4",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -456,6 +456,32 @@ describe('PostHogLogs', () => {
456
456
  expect(readQueue(mockInstance)).toHaveLength(0)
457
457
  })
458
458
 
459
+ it('uses the scopeName constructor param as the OTLP scope name', async () => {
460
+ jest.useFakeTimers()
461
+ const logs = new PostHogLogs(
462
+ mockInstance,
463
+ resolveForTest(),
464
+ logger,
465
+ getContextFor(mockInstance),
466
+ immediateOnReady,
467
+ () => Promise.resolve(),
468
+ 'console'
469
+ )
470
+ logs.captureLog({ body: 'test' })
471
+
472
+ await logs.flush()
473
+
474
+ const payload = mockInstance._sendLogsBatch.mock.calls[0][0]
475
+ const scope = payload.resourceLogs[0].scopeLogs[0].scope
476
+ // scopeName param overrides getLibraryId(); telemetry.sdk.name still uses getLibraryId().
477
+ expect(scope.name).toBe('console')
478
+ const resourceAttrs = Object.fromEntries(
479
+ payload.resourceLogs[0].resource.attributes.map((a: any) => [a.key, a.value])
480
+ )
481
+ expect(resourceAttrs['telemetry.sdk.name']).toEqual({ stringValue: 'posthog-core-tests' })
482
+ jest.useRealTimers()
483
+ })
484
+
459
485
  it('defaults service.name to "unknown_service" when not configured', async () => {
460
486
  const logs = new PostHogLogs(
461
487
  mockInstance,
package/src/logs/index.ts CHANGED
@@ -49,7 +49,11 @@ export class PostHogLogs {
49
49
  // reaches disk can't cause duplicate records on next startup. SDKs with
50
50
  // synchronous storage (or no async persist layer) can pass a no-op. RN
51
51
  // wires this to its dedicated `_logsStorage.waitForPersist()`.
52
- private readonly _waitForStoragePersist: () => Promise<void> = () => Promise.resolve()
52
+ private readonly _waitForStoragePersist: () => Promise<void> = () => Promise.resolve(),
53
+ // OTLP instrumentation scope name. Overrides the `getLibraryId()` fallback
54
+ // so a host can label a specific capture stream (e.g. 'console' for browser
55
+ // console auto-capture). Defaults to `getLibraryId()` when omitted.
56
+ private readonly _scopeName?: string
53
57
  ) {
54
58
  this._maxBufferSize = _config.maxBufferSize
55
59
  // Never below the flush trigger: a smaller eviction cap would stop the
@@ -242,7 +246,7 @@ export class PostHogLogs {
242
246
  const payload = buildOtlpLogsPayload(
243
247
  records,
244
248
  this._buildResourceAttributes(),
245
- this._instance.getLibraryId(),
249
+ this._scopeName ?? this._instance.getLibraryId(),
246
250
  this._instance.getLibraryVersion()
247
251
  )
248
252
 
@@ -184,26 +184,26 @@ export function buildOtlpLogRecord(options: CaptureLogOptions, sdkContext: LogSd
184
184
  */
185
185
  export function buildResourceAttributes(
186
186
  config: ResolvedPostHogLogsConfig,
187
- scopeName: string,
188
- scopeVersion: string
187
+ sdkName: string,
188
+ sdkVersion: string
189
189
  ): Record<string, LogAttributeValue> {
190
190
  return {
191
191
  ...config.resourceAttributes,
192
192
  'service.name': config.serviceName || 'unknown_service',
193
193
  ...(config.environment && { 'deployment.environment': config.environment }),
194
194
  ...(config.serviceVersion && { 'service.version': config.serviceVersion }),
195
- 'telemetry.sdk.name': scopeName,
196
- 'telemetry.sdk.version': scopeVersion,
195
+ 'telemetry.sdk.name': sdkName,
196
+ 'telemetry.sdk.version': sdkVersion,
197
197
  }
198
198
  }
199
199
 
200
200
  /**
201
201
  * Wraps a list of records in the OTLP `resourceLogs` envelope.
202
202
  *
203
- * `scopeName` is the SDK package name (`posthog-js`, `posthog-react-native`,
204
- * etc.). `scopeVersion` is the SDK semver. The server combines them into a
205
- * single `instrumentation_scope` field (`{name}@{version}`) used for
206
- * SDK-version-level attribution in queries and dashboards.
203
+ * `scopeName` is the OTLP instrumentation scope name (`web`/`console` for
204
+ * browser, or the SDK library ID for other platforms). `scopeVersion` is the
205
+ * SDK semver. The server combines them into a single `instrumentation_scope`
206
+ * field (`{name}@{version}`) used for attribution in queries and dashboards.
207
207
  */
208
208
  export function buildOtlpLogsPayload(
209
209
  logRecords: OtlpLogRecord[],