@inkronik/browser-sdk 1.1.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.
package/README.md CHANGED
@@ -21,6 +21,7 @@ import { createInkronikBrowser } from '@inkronik/browser-sdk'
21
21
  const inkronik = createInkronikBrowser({
22
22
  publicKey: 'ik_pub_...',
23
23
  collectorUrl: 'https://collector.inkronik.codemask.dev',
24
+ environment: 'production',
24
25
  tracePropagationOrigins: ['https://api.example.com'],
25
26
  user: {
26
27
  id: currentUser.uuid,
@@ -54,6 +55,29 @@ await inkronik.shutdown()
54
55
  ```
55
56
 
56
57
  The public key is a revocable source identifier, not a secret. It can send only browser RUM, constrained browser spans, and custom events.
58
+ The required `environment` option identifies the deployment sending each batch. The same application-scoped public key may therefore be used by
59
+ multiple exact origins while development, staging, and production telemetry remain separate.
60
+
61
+ ## Next.js
62
+
63
+ Next.js 15.3 and newer can initialize browser telemetry before hydration through `instrumentation-client.ts`. The dedicated entrypoint also uses
64
+ Next.js' router transition hook instead of patching History, so each client-side route change creates one navigation view:
65
+
66
+ ```ts
67
+ // instrumentation-client.ts
68
+ import { createInkronikNext } from '@inkronik/browser-sdk/next'
69
+
70
+ export const { client: inkronik, onRouterTransitionStart } = createInkronikNext({
71
+ publicKey: process.env.NEXT_PUBLIC_INKRONIK_PUBLIC_KEY!,
72
+ collectorUrl: process.env.NEXT_PUBLIC_INKRONIK_COLLECTOR_URL!,
73
+ environment: process.env.NEXT_PUBLIC_INKRONIK_ENVIRONMENT ?? 'development',
74
+ tracePropagationOrigins: ['https://api.example.com'],
75
+ })
76
+ ```
77
+
78
+ Create the integration only after the application's consent policy permits telemetry. Values prefixed with `NEXT_PUBLIC_` are bundled for the
79
+ browser: use only the Browser Source public key here, never the server ingest API key. The root package remains appropriate for older Next.js
80
+ versions and other SPA routers; its History integration ignores `pushState` and `replaceState` calls that do not change the URL.
57
81
 
58
82
  ## Identity and privacy
59
83
 
@@ -74,6 +98,11 @@ The SDK:
74
98
  unavailable;
75
99
  - accepts only primitive custom attribute values and sanitizes them before transport.
76
100
 
101
+ The SDK always applies its baseline URL privacy sanitization before and after the optional `sanitizeUrl` callback. The callback receives an HTTP(S)
102
+ URL with credentials, query strings, fragments, and identifier-like path segments already removed, and can apply additional path redaction. If the
103
+ callback throws or returns an empty, invalid, or non-HTTP(S) URL, the SDK omits the page URL rather than falling back to the original value. This is
104
+ structural data minimization, not general secret detection: applications should still avoid putting sensitive data in URL paths.
105
+
77
106
  ## Distributed tracing
78
107
 
79
108
  The SDK creates a separate trace for every instrumented `fetch`. Browser view events retain their own view trace, while `view_id` and `session_id`
@@ -84,6 +113,7 @@ happens only for exact origins listed in `tracePropagationOrigins`:
84
113
  const inkronik = createInkronikBrowser({
85
114
  publicKey: 'ik_pub_...',
86
115
  collectorUrl: 'https://collector.inkronik.codemask.dev',
116
+ environment: 'production',
87
117
  tracePropagationOrigins: ['https://api.example.com'],
88
118
  })
89
119
  ```
package/dist/client.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import type { CaptureErrorOptions, CaptureEventInput, CreateInkronikBrowserOptions, SetUserInput } from './types.js';
1
+ import type { CaptureBrowserNavigationInput, CaptureErrorOptions, CaptureEventInput, CreateInkronikBrowserOptions, SetUserInput } from './types.js';
2
2
  export declare class InkronikBrowserClient {
3
3
  private readonly publicKey;
4
4
  private readonly collectorUrl;
5
+ private readonly telemetryEnvironment;
5
6
  private readonly sampleRate;
6
7
  private readonly defaultAttributes;
7
8
  private readonly maxBatchSize;
@@ -12,6 +13,7 @@ export declare class InkronikBrowserClient {
12
13
  private readonly getRoute;
13
14
  private readonly sanitizeUrl;
14
15
  private readonly enableFetchTracing;
16
+ private readonly enableNavigationTracking;
15
17
  private readonly tracePropagationOrigins;
16
18
  private readonly environment;
17
19
  private readonly session;
@@ -30,6 +32,7 @@ export declare class InkronikBrowserClient {
30
32
  captureError(error: unknown, options: CaptureErrorOptions): void;
31
33
  setUser(input: SetUserInput): void;
32
34
  clearUser(): void;
35
+ captureNavigation(input: CaptureBrowserNavigationInput): void;
33
36
  flush(): Promise<void>;
34
37
  shutdown(): Promise<void>;
35
38
  private beginView;
@@ -5,7 +5,7 @@ export declare const DEFAULT_MAX_RETRIES = 2;
5
5
  export declare const DEFAULT_RETRY_BASE_MS = 250;
6
6
  export declare const DEFAULT_SAMPLE_RATE = 1;
7
7
  export declare const SDK_NAME = "@inkronik/browser-sdk";
8
- export declare const SDK_VERSION = "1.0.1";
8
+ export declare const SDK_VERSION = "2.1.0";
9
9
  export declare const DEFAULT_SESSION_INACTIVITY_MS: number;
10
10
  export declare const DEFAULT_SESSION_MAX_DURATION_MS: number;
11
11
  export declare const BROWSER_SESSION_STORAGE_KEY = "inkronik.browser.session";