@glimt.dev/otel-browser 0.1.1 → 0.2.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.
@@ -62,6 +62,14 @@ export type BrowserConfig = {
62
62
  attributes?: Record<string, unknown>;
63
63
  instrumentations?: Array<'auto' | 'fetch' | 'xhr' | 'document' | 'user'>;
64
64
  exporter?: 'http/protobuf' | 'http/json';
65
+ /**
66
+ * OTLP endpoint for exporting traces.
67
+ *
68
+ * Prefer providing a base endpoint (no signal path), e.g. `https://collector.example.com`.
69
+ * The SDK will derive `.../v1/traces` and `.../v1/logs` from it.
70
+ *
71
+ * For backwards compatibility, you may also pass a full traces URL ending in `/v1/traces`.
72
+ */
65
73
  exporterUrl?: string;
66
74
  exporterHeaders?: Record<string, string>;
67
75
  credentials?: RequestCredentials;
@@ -81,12 +89,10 @@ export type BrowserConfig = {
81
89
  exporterHeaders?: Record<string, string>;
82
90
  credentials?: RequestCredentials;
83
91
  };
84
- errors?: {
85
- captureUnhandled?: boolean;
86
- };
87
- console?: {
88
- enabled?: boolean;
89
- };
92
+ /** Capture unhandled errors (window.onerror, unhandledrejection). Defaults to true. */
93
+ captureUnhandledErrors?: boolean;
94
+ /** Capture console.* calls as OTLP logs. Defaults to false. */
95
+ captureConsoleLogs?: boolean;
90
96
  /**
91
97
  * Organisation ID for authenticated telemetry.
92
98
  * When set together with publishableKey, telemetry will be sent with Basic authentication.
@@ -103,6 +109,20 @@ export type BrowserConfig = {
103
109
  * @see UserContext
104
110
  */
105
111
  user?: UserContext;
112
+ /**
113
+ * Release/Deployment metadata for source mapping.
114
+ * Required for associating telemetry with source code.
115
+ */
116
+ release?: {
117
+ /** Git commit SHA (full or short) */
118
+ commit?: string;
119
+ /** Git branch name */
120
+ branch?: string;
121
+ /** Application version */
122
+ version?: string;
123
+ /** Environment (e.g. 'production', 'staging') */
124
+ environment?: string;
125
+ };
106
126
  };
107
127
  export type BrowserSDK = {
108
128
  /** Force flush all pending spans and logs */
@@ -149,7 +169,7 @@ export type BrowserSDK = {
149
169
  * ```ts
150
170
  * const sdk = registerOTelBrowser({
151
171
  * serviceName: 'my-app',
152
- * exporterUrl: 'https://otel-collector.example.com/v1/traces',
172
+ * exporterUrl: 'https://otel-collector.example.com',
153
173
  * user: { userId: 'user_123' }
154
174
  * })
155
175
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glimt.dev/otel-browser",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,8 +26,6 @@
26
26
  "README.md"
27
27
  ],
28
28
  "dependencies": {
29
- "@opentelemetry/api": "^1.9.0",
30
- "@opentelemetry/api-logs": "^0.208.0",
31
29
  "@opentelemetry/context-zone": "^2.2.0",
32
30
  "@opentelemetry/core": "^2.2.0",
33
31
  "@opentelemetry/instrumentation": "^0.208.0",
@@ -44,20 +42,28 @@
44
42
  "protobufjs": "^7.5.4"
45
43
  },
46
44
  "devDependencies": {
47
- "@types/node": "24.10.1",
45
+ "@types/node": "25.0.1",
48
46
  "esbuild": "^0.27.1",
49
- "jsdom": "^27.2.0",
47
+ "jsdom": "^27.3.0",
50
48
  "typescript": "^5.9.3",
51
49
  "vitest": "4.0.15",
52
50
  "typescript-config": "1.0.0"
53
51
  },
52
+ "peerDependencies": {
53
+ "@opentelemetry/api": ">=1.9.0 <3.0.0",
54
+ "@opentelemetry/api-logs": ">=0.200.0 <0.300.0"
55
+ },
54
56
  "engines": {
55
57
  "node": ">=18.19.0"
56
58
  },
57
59
  "scripts": {
58
60
  "build": "pnpm clean && tsc --noEmit false --declaration --emitDeclarationOnly --stripInternal --declarationDir dist/types src/index.ts && tsc -p tsconfig.json && node ./build.mjs",
59
61
  "clean": "rm -rf dist",
62
+ "lint": "true",
63
+ "lint:fix": "true",
60
64
  "type-check": "tsc --noEmit",
65
+ "test:unit": "pnpm unit-test",
66
+ "test:unit:watch": "pnpm unit-test-watch",
61
67
  "unit-test": "vitest --run",
62
68
  "unit-test-watch": "vitest",
63
69
  "size": "node -e \"const fs=require('fs');const zlib=require('zlib');const b=fs.readFileSync('dist/cdn/index.js');const gz=zlib.gzipSync(b,{level:9});const kb=(gz.length/1024).toFixed(1);const max=200;console.log('cdn gz',kb+'kb');if(gz.length>max*1024){console.error('Size limit exceeded:'+kb+'kb > '+max+'kb');process.exit(1)}\""