@steve31415/baselib 2.0.0 → 2.1.0

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.
@@ -6,6 +6,7 @@
6
6
  // <meta name="pw-log-app" content="auth">
7
7
  // <meta name="pw-log-dataset" content="apps">
8
8
  // <meta name="pw-log-token" content="...ingest-only, dataset-scoped...">
9
+ // <meta name="pw-build-id" content="...deployment identity...">
9
10
  //
10
11
  // The token is ingest-only and dataset-scoped by design — visible to any
11
12
  // signed-in user, able to do nothing but add log events.
@@ -19,6 +20,7 @@ export function createBrowserLogger(opts = {}) {
19
20
  const dataset = opts.dataset ?? metaContent('pw-log-dataset') ?? 'apps';
20
21
  const token = opts.token ?? metaContent('pw-log-token');
21
22
  const baseUrl = opts.baseUrl ?? 'https://api.axiom.co';
23
+ const buildId = metaContent('pw-build-id');
22
24
  const shipper = token
23
25
  ? new LogShipper({
24
26
  url: `${baseUrl}/v1/datasets/${dataset}/ingest`,
@@ -55,7 +57,7 @@ export function createBrowserLogger(opts = {}) {
55
57
  flush: () => shipper?.flush() ?? Promise.resolve(),
56
58
  };
57
59
  }
58
- const logger = build(opts.context);
60
+ const logger = build({ ...(buildId ? { build_id: buildId } : {}), ...opts.context });
59
61
  // Ship what's pending whenever the page may be going away.
60
62
  const flushNow = () => void logger.flush();
61
63
  addEventListener('pagehide', flushNow);
package/dist/rum.d.ts CHANGED
@@ -3,5 +3,7 @@ export interface RumOptions {
3
3
  dataset?: string;
4
4
  token?: string;
5
5
  baseUrl?: string;
6
+ /** Defaults to the page's pw-build-id meta tag. */
7
+ buildId?: string;
6
8
  }
7
9
  export declare function initRum(opts?: RumOptions): void;
package/dist/rum.js CHANGED
@@ -15,6 +15,7 @@ export function initRum(opts = {}) {
15
15
  const token = opts.token ?? metaContent('pw-log-token');
16
16
  if (!token)
17
17
  return;
18
+ const buildId = opts.buildId ?? metaContent('pw-build-id');
18
19
  const dataset = opts.dataset ?? 'rum';
19
20
  const baseUrl = (opts.baseUrl ?? 'https://api.axiom.co').replace(/\/$/, '');
20
21
  const shipper = new LogShipper({
@@ -40,6 +41,7 @@ export function initRum(opts = {}) {
40
41
  metric_id: m.id,
41
42
  navigation_type: m.navigationType,
42
43
  path: location.pathname,
44
+ ...(buildId ? { build_id: buildId } : {}),
43
45
  });
44
46
  };
45
47
  onLCP(report);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steve31415/baselib",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Plasticine new-world shared platform library: logging, auth, service-to-service auth, db, http",
5
5
  "type": "module",
6
6
  "license": "MIT",