@inkronik/browser-sdk 2.0.0 → 2.1.1
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 +23 -0
- package/dist/client.d.ts +3 -1
- package/dist/constants.d.ts +3 -2
- package/dist/index-rsfpk3kf.js +881 -0
- package/dist/index-rsfpk3kf.js.map +18 -0
- package/dist/index.js +11 -845
- package/dist/index.js.map +3 -12
- package/dist/next/index.d.ts +3 -0
- package/dist/next/index.js +18 -0
- package/dist/next/index.js.map +10 -0
- package/dist/next/types.d.ts +8 -0
- package/dist/types.d.ts +18 -0
- package/dist/utils.d.ts +4 -1
- package/package.json +27 -14
- /package/dist/{instrumentation.d.ts → browser-instrumentation.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -58,6 +58,27 @@ The public key is a revocable source identifier, not a secret. It can send only
|
|
|
58
58
|
The required `environment` option identifies the deployment sending each batch. The same application-scoped public key may therefore be used by
|
|
59
59
|
multiple exact origins while development, staging, and production telemetry remain separate.
|
|
60
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.
|
|
81
|
+
|
|
61
82
|
## Identity and privacy
|
|
62
83
|
|
|
63
84
|
Use one stable, opaque user ID across the browser and backend, ideally the authentication `sub` or UUID. Matching identifiers let RUM, product
|
|
@@ -118,6 +139,8 @@ await inkronik.flush()
|
|
|
118
139
|
|
|
119
140
|
## Development
|
|
120
141
|
|
|
142
|
+
The SDK declaration build uses TypeScript 7 (`tsc`, provided by the `@typescript/native` alias). ESLint and Next.js use the TypeScript 6 compatibility API through the `typescript` alias, following [Microsoft's side-by-side setup](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0). Keep both compiler aliases pinned when updating the toolchain.
|
|
143
|
+
|
|
121
144
|
```bash
|
|
122
145
|
bun install --frozen-lockfile
|
|
123
146
|
bun test
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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;
|
|
@@ -13,6 +13,7 @@ export declare class InkronikBrowserClient {
|
|
|
13
13
|
private readonly getRoute;
|
|
14
14
|
private readonly sanitizeUrl;
|
|
15
15
|
private readonly enableFetchTracing;
|
|
16
|
+
private readonly enableNavigationTracking;
|
|
16
17
|
private readonly tracePropagationOrigins;
|
|
17
18
|
private readonly environment;
|
|
18
19
|
private readonly session;
|
|
@@ -31,6 +32,7 @@ export declare class InkronikBrowserClient {
|
|
|
31
32
|
captureError(error: unknown, options: CaptureErrorOptions): void;
|
|
32
33
|
setUser(input: SetUserInput): void;
|
|
33
34
|
clearUser(): void;
|
|
35
|
+
captureNavigation(input: CaptureBrowserNavigationInput): void;
|
|
34
36
|
flush(): Promise<void>;
|
|
35
37
|
shutdown(): Promise<void>;
|
|
36
38
|
private beginView;
|
package/dist/constants.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ export declare const DEFAULT_MAX_QUEUE_SIZE = 200;
|
|
|
3
3
|
export declare const DEFAULT_FLUSH_INTERVAL_MS = 5000;
|
|
4
4
|
export declare const DEFAULT_MAX_RETRIES = 2;
|
|
5
5
|
export declare const DEFAULT_RETRY_BASE_MS = 250;
|
|
6
|
+
export declare const BROWSER_TELEMETRY_MAX_AGE_MS: number;
|
|
6
7
|
export declare const DEFAULT_SAMPLE_RATE = 1;
|
|
7
8
|
export declare const SDK_NAME = "@inkronik/browser-sdk";
|
|
8
|
-
export declare const SDK_VERSION = "2.
|
|
9
|
+
export declare const SDK_VERSION = "2.1.1";
|
|
9
10
|
export declare const DEFAULT_SESSION_INACTIVITY_MS: number;
|
|
10
11
|
export declare const DEFAULT_SESSION_MAX_DURATION_MS: number;
|
|
11
12
|
export declare const BROWSER_SESSION_STORAGE_KEY = "inkronik.browser.session";
|
|
@@ -16,7 +17,7 @@ export declare const MAX_ATTRIBUTE_VALUE_LENGTH = 512;
|
|
|
16
17
|
export declare const MAX_EVENT_MESSAGE_LENGTH = 1024;
|
|
17
18
|
export declare const MAX_ERROR_VALUE_LENGTH = 4096;
|
|
18
19
|
export declare const INKRONIK_ORIGINAL_BROWSER_FETCH: unique symbol;
|
|
19
|
-
export declare const SENSITIVE_KEY_FRAGMENTS: readonly [
|
|
20
|
+
export declare const SENSITIVE_KEY_FRAGMENTS: readonly ['password', 'passwd', 'secret', 'token', 'authorization', 'cookie', 'api_key', 'apikey', 'credential', 'session', 'card', 'cvv', 'cvc', 'email', 'phone', 'ssn', 'input', 'value'];
|
|
20
21
|
export declare const EMAIL_PATTERN: RegExp;
|
|
21
22
|
export declare const PHONE_PATTERN: RegExp;
|
|
22
23
|
export declare const CARD_PATTERN: RegExp;
|