@p-r-d-i-f-y/monitor 0.1.0 → 0.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 CHANGED
@@ -10,6 +10,21 @@ npm install @p-r-d-i-f-y/monitor
10
10
 
11
11
  Copy your project DSN from **Engineering → Monitoring** in PRDify.
12
12
 
13
+ ## Universal setup
14
+
15
+ Use `initMonitor` when you want the SDK to auto-detect browser vs Node.js.
16
+
17
+ ```ts
18
+ import { initMonitor } from '@p-r-d-i-f-y/monitor';
19
+
20
+ initMonitor({
21
+ dsn: process.env.NEXT_PUBLIC_PRDIFY_MONITOR_DSN ?? process.env.PRDIFY_MONITOR_DSN!,
22
+ apiUrl: process.env.NEXT_PUBLIC_API_BASE_URL ?? process.env.PRDIFY_MONITOR_API_URL,
23
+ environment: process.env.NODE_ENV,
24
+ release: '1.0.0',
25
+ });
26
+ ```
27
+
13
28
  ## Browser
14
29
 
15
30
  ```ts
package/dist/index.d.ts CHANGED
@@ -1,3 +1,36 @@
1
+ import { type MonitorClientOptions } from './core';
2
+ export declare function initMonitor(options: MonitorClientOptions): {
3
+ addBreadcrumb: (crumb: import("./core").MonitorBreadcrumb) => void;
4
+ captureEvent: (payload: import("./core").MonitorEventPayload) => Promise<{
5
+ ok: false;
6
+ status?: undefined;
7
+ } | {
8
+ ok: boolean;
9
+ status: number;
10
+ }>;
11
+ captureException: (error: unknown, extra?: Partial<import("./core").MonitorEventPayload>) => Promise<{
12
+ ok: false;
13
+ status?: undefined;
14
+ } | {
15
+ ok: boolean;
16
+ status: number;
17
+ }>;
18
+ recordSpan: (span: import("./core").SpanPayload) => Promise<{
19
+ ok: false;
20
+ status?: undefined;
21
+ } | {
22
+ ok: boolean;
23
+ status: number;
24
+ }>;
25
+ startTimedSpan: (operation: string, route?: string, parentSpanId?: string) => {
26
+ spanId: string;
27
+ traceId: string;
28
+ end: (status?: string, metadata?: Record<string, unknown>) => Promise<void>;
29
+ };
30
+ getTraceId: () => string;
31
+ getPublicKey: () => string | null;
32
+ getIngestUrl: () => string;
33
+ } | null;
1
34
  export * from './core';
2
35
  export * from './browser';
3
36
  export * from './node';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAGxE,wBAAgB,WAAW,CAAC,OAAO,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAUxD;AAED,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,15 @@
1
+ import { initBrowserMonitor } from './browser';
2
+ import { createMonitorClient } from './core';
3
+ import { initNodeMonitor } from './node';
4
+ export function initMonitor(options) {
5
+ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
6
+ return initBrowserMonitor(options);
7
+ }
8
+ if (typeof process !== 'undefined' && typeof process.on === 'function') {
9
+ return initNodeMonitor(options);
10
+ }
11
+ return createMonitorClient(options);
12
+ }
1
13
  export * from './core';
2
14
  export * from './browser';
3
15
  export * from './node';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p-r-d-i-f-y/monitor",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "PRDify error monitoring, tracing, and session replay SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",