@xrayradar/nextjs 0.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 ADDED
@@ -0,0 +1,61 @@
1
+ # @xrayradar/nextjs
2
+
3
+ XrayRadar SDK for Next.js: use **@xrayradar/node** on the server and **@xrayradar/react** (or **@xrayradar/browser**) on the client.
4
+
5
+ ## Server (Node)
6
+
7
+ 1. Create `instrumentation.ts` at your project root (same level as `app/` or `pages/`):
8
+
9
+ ```ts
10
+ import { init } from "@xrayradar/node";
11
+
12
+ export async function register() {
13
+ if (process.env.NEXT_RUNTIME === "nodejs") {
14
+ init({
15
+ dsn: process.env.XRAYRADAR_DSN!,
16
+ authToken: process.env.XRAYRADAR_AUTH_TOKEN,
17
+ environment: process.env.XRAYRADAR_ENVIRONMENT,
18
+ release: process.env.XRAYRADAR_RELEASE,
19
+ });
20
+ }
21
+ }
22
+ ```
23
+
24
+ 2. Set env: `XRAYRADAR_DSN`, `XRAYRADAR_AUTH_TOKEN` (and optional `XRAYRADAR_ENVIRONMENT`, `XRAYRADAR_RELEASE`).
25
+
26
+ ## Client (Browser)
27
+
28
+ In your root layout or `_app.tsx`:
29
+
30
+ ```tsx
31
+ import { init } from "@xrayradar/react";
32
+ import { ErrorBoundary } from "@xrayradar/react";
33
+
34
+ // Call once when the app loads (client-side)
35
+ if (typeof window !== "undefined") {
36
+ init({
37
+ dsn: process.env.NEXT_PUBLIC_XRAYRADAR_DSN!,
38
+ authToken: process.env.NEXT_PUBLIC_XRAYRADAR_AUTH_TOKEN,
39
+ });
40
+ }
41
+
42
+ export default function App({ Component, pageProps }) {
43
+ return (
44
+ <ErrorBoundary>
45
+ <Component {...pageProps} />
46
+ </ErrorBoundary>
47
+ );
48
+ }
49
+ ```
50
+
51
+ Use `NEXT_PUBLIC_*` for any client-visible DSN/token so Next.js inlines them.
52
+
53
+ ## Optional config wrapper
54
+
55
+ ```js
56
+ // next.config.js
57
+ const { withXrayRadarConfig } = require("@xrayradar/nextjs");
58
+ module.exports = withXrayRadarConfig(yourExistingConfig);
59
+ ```
60
+
61
+ This is a no-op placeholder for future Next.js-specific config (e.g. source maps, rewrites).
@@ -0,0 +1,31 @@
1
+ export { ErrorBoundary, XrayRadarProvider, addBreadcrumb, captureException, captureMessage, getClient as getBrowserClient, init as initBrowser, setContext, setExtra, setTag, setUser, useXrayRadar } from '@xrayradar/react';
2
+ export { getClient as getNodeClient, init as initNode } from '@xrayradar/node';
3
+
4
+ /**
5
+ * Optional wrapper for next.config.js to integrate XrayRadar.
6
+ * Usage: const nextConfig = withXrayRadarConfig(yourExistingConfig);
7
+ */
8
+ declare function withXrayRadarConfig<T extends Record<string, unknown>>(nextConfig: T): T;
9
+
10
+ /**
11
+ * Next.js 13+ instrumentation: runs once when the Node server starts.
12
+ * Use this to init @xrayradar/node for server-side error capture.
13
+ *
14
+ * In your project, create instrumentation.ts (or .js) at the project root (same level as app/)
15
+ * and call registerServerInstrumentation() from there, or init @xrayradar/node directly:
16
+ *
17
+ * import { init } from "@xrayradar/node";
18
+ * export async function register() {
19
+ * if (process.env.NEXT_RUNTIME === "nodejs") {
20
+ * init({ dsn: process.env.XRAYRADAR_DSN, authToken: process.env.XRAYRADAR_AUTH_TOKEN });
21
+ * }
22
+ * }
23
+ */
24
+ declare function registerServerInstrumentation(options?: {
25
+ dsn?: string;
26
+ authToken?: string;
27
+ environment?: string;
28
+ release?: string;
29
+ }): Promise<void>;
30
+
31
+ export { registerServerInstrumentation, withXrayRadarConfig };
@@ -0,0 +1,31 @@
1
+ export { ErrorBoundary, XrayRadarProvider, addBreadcrumb, captureException, captureMessage, getClient as getBrowserClient, init as initBrowser, setContext, setExtra, setTag, setUser, useXrayRadar } from '@xrayradar/react';
2
+ export { getClient as getNodeClient, init as initNode } from '@xrayradar/node';
3
+
4
+ /**
5
+ * Optional wrapper for next.config.js to integrate XrayRadar.
6
+ * Usage: const nextConfig = withXrayRadarConfig(yourExistingConfig);
7
+ */
8
+ declare function withXrayRadarConfig<T extends Record<string, unknown>>(nextConfig: T): T;
9
+
10
+ /**
11
+ * Next.js 13+ instrumentation: runs once when the Node server starts.
12
+ * Use this to init @xrayradar/node for server-side error capture.
13
+ *
14
+ * In your project, create instrumentation.ts (or .js) at the project root (same level as app/)
15
+ * and call registerServerInstrumentation() from there, or init @xrayradar/node directly:
16
+ *
17
+ * import { init } from "@xrayradar/node";
18
+ * export async function register() {
19
+ * if (process.env.NEXT_RUNTIME === "nodejs") {
20
+ * init({ dsn: process.env.XRAYRADAR_DSN, authToken: process.env.XRAYRADAR_AUTH_TOKEN });
21
+ * }
22
+ * }
23
+ */
24
+ declare function registerServerInstrumentation(options?: {
25
+ dsn?: string;
26
+ authToken?: string;
27
+ environment?: string;
28
+ release?: string;
29
+ }): Promise<void>;
30
+
31
+ export { registerServerInstrumentation, withXrayRadarConfig };
package/dist/index.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ ErrorBoundary: () => import_react.ErrorBoundary,
34
+ XrayRadarProvider: () => import_react.XrayRadarProvider,
35
+ addBreadcrumb: () => import_react.addBreadcrumb,
36
+ captureException: () => import_react.captureException,
37
+ captureMessage: () => import_react.captureMessage,
38
+ getBrowserClient: () => import_react.getClient,
39
+ getNodeClient: () => import_node.getClient,
40
+ initBrowser: () => import_react.init,
41
+ initNode: () => import_node.init,
42
+ registerServerInstrumentation: () => registerServerInstrumentation,
43
+ setContext: () => import_react.setContext,
44
+ setExtra: () => import_react.setExtra,
45
+ setTag: () => import_react.setTag,
46
+ setUser: () => import_react.setUser,
47
+ useXrayRadar: () => import_react.useXrayRadar,
48
+ withXrayRadarConfig: () => withXrayRadarConfig
49
+ });
50
+ module.exports = __toCommonJS(index_exports);
51
+
52
+ // src/config.ts
53
+ function withXrayRadarConfig(nextConfig) {
54
+ return nextConfig;
55
+ }
56
+
57
+ // src/instrumentation.ts
58
+ async function registerServerInstrumentation(options) {
59
+ if (typeof process === "undefined" || process.env.NEXT_RUNTIME !== "nodejs") {
60
+ return;
61
+ }
62
+ const { init: init3 } = await import("@xrayradar/node");
63
+ init3({
64
+ dsn: options?.dsn ?? process.env.XRAYRADAR_DSN,
65
+ authToken: options?.authToken ?? process.env.XRAYRADAR_AUTH_TOKEN,
66
+ environment: options?.environment ?? process.env.XRAYRADAR_ENVIRONMENT,
67
+ release: options?.release ?? process.env.XRAYRADAR_RELEASE
68
+ });
69
+ }
70
+
71
+ // src/index.ts
72
+ var import_react = require("@xrayradar/react");
73
+ var import_node = require("@xrayradar/node");
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ ErrorBoundary,
77
+ XrayRadarProvider,
78
+ addBreadcrumb,
79
+ captureException,
80
+ captureMessage,
81
+ getBrowserClient,
82
+ getNodeClient,
83
+ initBrowser,
84
+ initNode,
85
+ registerServerInstrumentation,
86
+ setContext,
87
+ setExtra,
88
+ setTag,
89
+ setUser,
90
+ useXrayRadar,
91
+ withXrayRadarConfig
92
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,53 @@
1
+ // src/config.ts
2
+ function withXrayRadarConfig(nextConfig) {
3
+ return nextConfig;
4
+ }
5
+
6
+ // src/instrumentation.ts
7
+ async function registerServerInstrumentation(options) {
8
+ if (typeof process === "undefined" || process.env.NEXT_RUNTIME !== "nodejs") {
9
+ return;
10
+ }
11
+ const { init: init3 } = await import("@xrayradar/node");
12
+ init3({
13
+ dsn: options?.dsn ?? process.env.XRAYRADAR_DSN,
14
+ authToken: options?.authToken ?? process.env.XRAYRADAR_AUTH_TOKEN,
15
+ environment: options?.environment ?? process.env.XRAYRADAR_ENVIRONMENT,
16
+ release: options?.release ?? process.env.XRAYRADAR_RELEASE
17
+ });
18
+ }
19
+
20
+ // src/index.ts
21
+ import {
22
+ init,
23
+ getClient,
24
+ captureException,
25
+ captureMessage,
26
+ addBreadcrumb,
27
+ setUser,
28
+ setTag,
29
+ setExtra,
30
+ setContext,
31
+ ErrorBoundary,
32
+ XrayRadarProvider,
33
+ useXrayRadar
34
+ } from "@xrayradar/react";
35
+ import { init as init2, getClient as getClient2 } from "@xrayradar/node";
36
+ export {
37
+ ErrorBoundary,
38
+ XrayRadarProvider,
39
+ addBreadcrumb,
40
+ captureException,
41
+ captureMessage,
42
+ getClient as getBrowserClient,
43
+ getClient2 as getNodeClient,
44
+ init as initBrowser,
45
+ init2 as initNode,
46
+ registerServerInstrumentation,
47
+ setContext,
48
+ setExtra,
49
+ setTag,
50
+ setUser,
51
+ useXrayRadar,
52
+ withXrayRadarConfig
53
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@xrayradar/nextjs",
3
+ "version": "0.1.0",
4
+ "description": "XrayRadar SDK for Next.js – server + client setup",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md"],
16
+ "scripts": {
17
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
18
+ "test": "vitest run --passWithNoTests",
19
+ "lint": "eslint src",
20
+ "clean": "rm -rf dist"
21
+ },
22
+ "dependencies": {
23
+ "@xrayradar/node": "*",
24
+ "@xrayradar/react": "*"
25
+ },
26
+ "devDependencies": {
27
+ "tsup": "^8.0.0",
28
+ "typescript": "^5.3.3",
29
+ "vitest": "^4.0.0"
30
+ },
31
+ "peerDependencies": {
32
+ "next": ">=13.0.0"
33
+ }
34
+ }