@datadog/browser-rum-nextjs 7.12.0 → 7.14.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/cjs/domain/error/addNextjsError.js +2 -1
- package/cjs/domain/error/addNextjsError.js.map +1 -1
- package/cjs/domain/nextJSRouter/datadogAppRouter.js +3 -3
- package/cjs/domain/nextJSRouter/datadogAppRouter.js.map +1 -1
- package/cjs/domain/nextJSRouter/datadogPagesRouter.js +2 -2
- package/cjs/domain/nextJSRouter/datadogPagesRouter.js.map +1 -1
- package/esm/domain/error/addNextjsError.mjs +2 -1
- package/esm/domain/error/addNextjsError.mjs.map +1 -1
- package/esm/domain/nextJSRouter/datadogAppRouter.mjs +1 -1
- package/esm/domain/nextJSRouter/datadogPagesRouter.mjs +1 -1
- package/package.json +9 -9
- package/src/domain/error/addNextjsError.ts +2 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_nextjsPlugin = require("../nextjsPlugin.js");
|
|
2
2
|
let _datadog_browser_core = require("@datadog/browser-core");
|
|
3
3
|
let _datadog_js_core_time = require("@datadog/js-core/time");
|
|
4
|
+
let _datadog_js_core_monitor = require("@datadog/js-core/monitor");
|
|
4
5
|
//#region src/domain/error/addNextjsError.ts
|
|
5
6
|
/**
|
|
6
7
|
* Add a Next.js error to the RUM session.
|
|
@@ -25,7 +26,7 @@ function addNextjsError(error, errorInfo) {
|
|
|
25
26
|
const handlingStack = (0, _datadog_browser_core.createHandlingStack)("nextjs error");
|
|
26
27
|
const startClocks = (0, _datadog_js_core_time.clocksNow)();
|
|
27
28
|
require_nextjsPlugin.onRumStart((addError) => {
|
|
28
|
-
(0,
|
|
29
|
+
(0, _datadog_js_core_monitor.callMonitored)(() => {
|
|
29
30
|
addError({
|
|
30
31
|
error,
|
|
31
32
|
handlingStack,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNextjsError.js","names":["createHandlingStack","clocksNow"],"sources":["../../../src/domain/error/addNextjsError.ts"],"sourcesContent":["import { clocksNow } from '@datadog/js-core/time'\nimport { callMonitored
|
|
1
|
+
{"version":3,"file":"addNextjsError.js","names":["createHandlingStack","clocksNow"],"sources":["../../../src/domain/error/addNextjsError.ts"],"sourcesContent":["import { clocksNow } from '@datadog/js-core/time'\nimport { callMonitored } from '@datadog/js-core/monitor'\nimport { createHandlingStack } from '@datadog/browser-core'\nimport type { Context } from '@datadog/browser-core'\nimport type { ErrorInfo } from 'react'\nimport { onRumStart } from '../nextjsPlugin'\n\n/**\n * Add a Next.js error to the RUM session.\n *\n * @category Error\n * @example\n * ```ts\n * // app/error.tsx (or app/global-error.tsx)\n * 'use client'\n * import { useEffect } from 'react'\n * import { addNextjsError } from '@datadog/browser-rum-nextjs'\n *\n * export default function Error({ error }: { error: Error & { digest?: string } }) {\n * useEffect(() => {\n * addNextjsError(error)\n * }, [error])\n * return <div>Something went wrong</div>\n * }\n * ```\n */\nexport function addNextjsError(error: Error & { digest?: string }, errorInfo?: ErrorInfo) {\n const handlingStack = createHandlingStack('nextjs error')\n const startClocks = clocksNow()\n onRumStart((addError) => {\n callMonitored(() => {\n addError({\n error,\n handlingStack,\n componentStack: errorInfo?.componentStack ?? undefined,\n startClocks,\n context: {\n ...(error as Error & { dd_context?: Context }).dd_context,\n ...(error.digest && { nextjs: { digest: error.digest } }),\n framework: 'nextjs',\n },\n })\n })\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,eAAe,OAAoC,WAAuB;CACxF,MAAM,iBAAA,GAAgBA,sBAAAA,oBAAAA,CAAoB,cAAc;CACxD,MAAM,eAAA,GAAcC,sBAAAA,UAAAA,CAAU;CAC9B,qBAAA,YAAY,aAAa;EACvB,CAAA,GAAA,yBAAA,cAAA,OAAoB;GAClB,SAAS;IACP;IACA;IACA,gBAAgB,WAAW,kBAAkB,KAAA;IAC7C;IACA,SAAS;KACP,GAAI,MAA2C;KAC/C,GAAI,MAAM,UAAU,EAAE,QAAQ,EAAE,QAAQ,MAAM,OAAO,EAAE;KACvD,WAAW;IACb;GACF,CAAC;EACH,CAAC;CACH,CAAC;AACH"}
|
|
@@ -3,11 +3,11 @@ const require_nextjsPlugin = require("../nextjsPlugin.js");
|
|
|
3
3
|
const require_computeViewNameFromParams = require("./computeViewNameFromParams.js");
|
|
4
4
|
let _datadog_browser_core = require("@datadog/browser-core");
|
|
5
5
|
let react = require("react");
|
|
6
|
-
let
|
|
6
|
+
let next_navigation = require("next/navigation");
|
|
7
7
|
//#region src/domain/nextJSRouter/datadogAppRouter.tsx
|
|
8
8
|
function DatadogAppRouter() {
|
|
9
|
-
const pathname = (0, _datadog_browser_core.mockable)(
|
|
10
|
-
const params = (0, _datadog_browser_core.mockable)(
|
|
9
|
+
const pathname = (0, _datadog_browser_core.mockable)(next_navigation.usePathname)();
|
|
10
|
+
const params = (0, _datadog_browser_core.mockable)(next_navigation.useParams)();
|
|
11
11
|
const previousPathname = (0, _datadog_browser_core.mockable)(react.useRef)(null);
|
|
12
12
|
if (previousPathname.current !== pathname) {
|
|
13
13
|
previousPathname.current = pathname;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datadogAppRouter.js","names":["mockable","usePathname","useParams","useRef","computeViewNameFromParams"],"sources":["../../../src/domain/nextJSRouter/datadogAppRouter.tsx"],"sourcesContent":["'use client'\n\nimport { useRef } from 'react'\nimport { usePathname, useParams } from 'next/navigation'\nimport { mockable } from '@datadog/browser-core'\nimport { startNextjsView } from '../nextjsPlugin'\nimport { computeViewNameFromParams } from './computeViewNameFromParams'\n\nexport function DatadogAppRouter() {\n const pathname = mockable(usePathname)()\n const params = mockable(useParams)()\n const previousPathname = mockable(useRef)<string | null>(null)\n\n if (previousPathname.current !== pathname) {\n previousPathname.current = pathname\n startNextjsView(computeViewNameFromParams(pathname, params))\n }\n\n return null\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,mBAAmB;CACjC,MAAM,YAAA,GAAWA,sBAAAA,SAAAA,CAASC,
|
|
1
|
+
{"version":3,"file":"datadogAppRouter.js","names":["mockable","usePathname","useParams","useRef","computeViewNameFromParams"],"sources":["../../../src/domain/nextJSRouter/datadogAppRouter.tsx"],"sourcesContent":["'use client'\n\nimport { useRef } from 'react'\nimport { usePathname, useParams } from 'next/navigation'\nimport { mockable } from '@datadog/browser-core'\nimport { startNextjsView } from '../nextjsPlugin'\nimport { computeViewNameFromParams } from './computeViewNameFromParams'\n\nexport function DatadogAppRouter() {\n const pathname = mockable(usePathname)()\n const params = mockable(useParams)()\n const previousPathname = mockable(useRef)<string | null>(null)\n\n if (previousPathname.current !== pathname) {\n previousPathname.current = pathname\n startNextjsView(computeViewNameFromParams(pathname, params))\n }\n\n return null\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,mBAAmB;CACjC,MAAM,YAAA,GAAWA,sBAAAA,SAAAA,CAASC,gBAAAA,WAAW,CAAC,CAAC;CACvC,MAAM,UAAA,GAASD,sBAAAA,SAAAA,CAASE,gBAAAA,SAAS,CAAC,CAAC;CACnC,MAAM,oBAAA,GAAmBF,sBAAAA,SAAAA,CAASG,MAAAA,MAAM,CAAC,CAAgB,IAAI;CAE7D,IAAI,iBAAiB,YAAY,UAAU;EACzC,iBAAiB,UAAU;EAC3B,qBAAA,gBAAgBC,kCAAAA,0BAA0B,UAAU,MAAM,CAAC;CAC7D;CAEA,OAAO;AACT"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_nextjsPlugin = require("../nextjsPlugin.js");
|
|
2
2
|
let _datadog_browser_core = require("@datadog/browser-core");
|
|
3
3
|
let react = require("react");
|
|
4
|
-
let
|
|
4
|
+
let next_router = require("next/router");
|
|
5
5
|
//#region src/domain/nextJSRouter/datadogPagesRouter.tsx
|
|
6
6
|
function DatadogPagesRouter() {
|
|
7
|
-
const router = (0, _datadog_browser_core.mockable)(
|
|
7
|
+
const router = (0, _datadog_browser_core.mockable)(next_router.useRouter)();
|
|
8
8
|
const previousPath = (0, _datadog_browser_core.mockable)(react.useRef)(null);
|
|
9
9
|
if (!router.isReady) return null;
|
|
10
10
|
const path = router.asPath.split(/[?#]/)[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datadogPagesRouter.js","names":["mockable","useRouter","useRef"],"sources":["../../../src/domain/nextJSRouter/datadogPagesRouter.tsx"],"sourcesContent":["import { useRef } from 'react'\nimport { useRouter } from 'next/router'\nimport { mockable } from '@datadog/browser-core'\nimport { startNextjsView } from '../nextjsPlugin'\n\nexport function DatadogPagesRouter() {\n const router = mockable(useRouter)()\n const previousPath = mockable(useRef)<string | null>(null)\n\n if (!router.isReady) {\n return null\n }\n\n // Extract the path portion of asPath (without query params or hash) to detect navigations.\n const path = router.asPath.split(/[?#]/)[0]\n\n if (previousPath.current !== path) {\n // router.pathname is the route pattern (e.g., \"/user/[id]\") — used as the view name\n // router.asPath is the actual URL (e.g., \"/user/42\") — used to detect navigations between\n // different concrete URLs of the same dynamic route (e.g., /user/42 → /user/43)\n previousPath.current = path\n startNextjsView(router.pathname)\n }\n\n return null\n}\n"],"mappings":";;;;;AAKA,SAAgB,qBAAqB;CACnC,MAAM,UAAA,GAASA,sBAAAA,SAAAA,CAASC,
|
|
1
|
+
{"version":3,"file":"datadogPagesRouter.js","names":["mockable","useRouter","useRef"],"sources":["../../../src/domain/nextJSRouter/datadogPagesRouter.tsx"],"sourcesContent":["import { useRef } from 'react'\nimport { useRouter } from 'next/router'\nimport { mockable } from '@datadog/browser-core'\nimport { startNextjsView } from '../nextjsPlugin'\n\nexport function DatadogPagesRouter() {\n const router = mockable(useRouter)()\n const previousPath = mockable(useRef)<string | null>(null)\n\n if (!router.isReady) {\n return null\n }\n\n // Extract the path portion of asPath (without query params or hash) to detect navigations.\n const path = router.asPath.split(/[?#]/)[0]\n\n if (previousPath.current !== path) {\n // router.pathname is the route pattern (e.g., \"/user/[id]\") — used as the view name\n // router.asPath is the actual URL (e.g., \"/user/42\") — used to detect navigations between\n // different concrete URLs of the same dynamic route (e.g., /user/42 → /user/43)\n previousPath.current = path\n startNextjsView(router.pathname)\n }\n\n return null\n}\n"],"mappings":";;;;;AAKA,SAAgB,qBAAqB;CACnC,MAAM,UAAA,GAASA,sBAAAA,SAAAA,CAASC,YAAAA,SAAS,CAAC,CAAC;CACnC,MAAM,gBAAA,GAAeD,sBAAAA,SAAAA,CAASE,MAAAA,MAAM,CAAC,CAAgB,IAAI;CAEzD,IAAI,CAAC,OAAO,SACV,OAAO;CAIT,MAAM,OAAO,OAAO,OAAO,MAAM,MAAM,CAAC,CAAC;CAEzC,IAAI,aAAa,YAAY,MAAM;EAIjC,aAAa,UAAU;EACvB,qBAAA,gBAAgB,OAAO,QAAQ;CACjC;CAEA,OAAO;AACT"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { onRumStart } from "../nextjsPlugin.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { createHandlingStack } from "@datadog/browser-core";
|
|
3
3
|
import { clocksNow } from "@datadog/js-core/time";
|
|
4
|
+
import { callMonitored } from "@datadog/js-core/monitor";
|
|
4
5
|
//#region src/domain/error/addNextjsError.ts
|
|
5
6
|
/**
|
|
6
7
|
* Add a Next.js error to the RUM session.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNextjsError.mjs","names":[],"sources":["../../../src/domain/error/addNextjsError.ts"],"sourcesContent":["import { clocksNow } from '@datadog/js-core/time'\nimport { callMonitored
|
|
1
|
+
{"version":3,"file":"addNextjsError.mjs","names":[],"sources":["../../../src/domain/error/addNextjsError.ts"],"sourcesContent":["import { clocksNow } from '@datadog/js-core/time'\nimport { callMonitored } from '@datadog/js-core/monitor'\nimport { createHandlingStack } from '@datadog/browser-core'\nimport type { Context } from '@datadog/browser-core'\nimport type { ErrorInfo } from 'react'\nimport { onRumStart } from '../nextjsPlugin'\n\n/**\n * Add a Next.js error to the RUM session.\n *\n * @category Error\n * @example\n * ```ts\n * // app/error.tsx (or app/global-error.tsx)\n * 'use client'\n * import { useEffect } from 'react'\n * import { addNextjsError } from '@datadog/browser-rum-nextjs'\n *\n * export default function Error({ error }: { error: Error & { digest?: string } }) {\n * useEffect(() => {\n * addNextjsError(error)\n * }, [error])\n * return <div>Something went wrong</div>\n * }\n * ```\n */\nexport function addNextjsError(error: Error & { digest?: string }, errorInfo?: ErrorInfo) {\n const handlingStack = createHandlingStack('nextjs error')\n const startClocks = clocksNow()\n onRumStart((addError) => {\n callMonitored(() => {\n addError({\n error,\n handlingStack,\n componentStack: errorInfo?.componentStack ?? undefined,\n startClocks,\n context: {\n ...(error as Error & { dd_context?: Context }).dd_context,\n ...(error.digest && { nextjs: { digest: error.digest } }),\n framework: 'nextjs',\n },\n })\n })\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,eAAe,OAAoC,WAAuB;CACxF,MAAM,gBAAgB,oBAAoB,cAAc;CACxD,MAAM,cAAc,UAAU;CAC9B,YAAY,aAAa;EACvB,oBAAoB;GAClB,SAAS;IACP;IACA;IACA,gBAAgB,WAAW,kBAAkB,KAAA;IAC7C;IACA,SAAS;KACP,GAAI,MAA2C;KAC/C,GAAI,MAAM,UAAU,EAAE,QAAQ,EAAE,QAAQ,MAAM,OAAO,EAAE;KACvD,WAAW;IACb;GACF,CAAC;EACH,CAAC;CACH,CAAC;AACH"}
|
|
@@ -3,7 +3,7 @@ import { startNextjsView } from "../nextjsPlugin.mjs";
|
|
|
3
3
|
import { computeViewNameFromParams } from "./computeViewNameFromParams.mjs";
|
|
4
4
|
import { mockable } from "@datadog/browser-core";
|
|
5
5
|
import { useRef } from "react";
|
|
6
|
-
import { useParams, usePathname } from "next/navigation
|
|
6
|
+
import { useParams, usePathname } from "next/navigation";
|
|
7
7
|
//#region src/domain/nextJSRouter/datadogAppRouter.tsx
|
|
8
8
|
function DatadogAppRouter() {
|
|
9
9
|
const pathname = mockable(usePathname)();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { startNextjsView } from "../nextjsPlugin.mjs";
|
|
2
2
|
import { mockable } from "@datadog/browser-core";
|
|
3
3
|
import { useRef } from "react";
|
|
4
|
-
import { useRouter } from "next/router
|
|
4
|
+
import { useRouter } from "next/router";
|
|
5
5
|
//#region src/domain/nextJSRouter/datadogPagesRouter.tsx
|
|
6
6
|
function DatadogPagesRouter() {
|
|
7
7
|
const router = mockable(useRouter)();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/browser-rum-nextjs",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.14.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "cjs/entries/main.js",
|
|
6
6
|
"module": "esm/entries/main.mjs",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"prepack": "yarn build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@datadog/browser-core": "7.
|
|
21
|
-
"@datadog/browser-rum-core": "7.
|
|
22
|
-
"@datadog/browser-rum-react": "7.
|
|
23
|
-
"@datadog/js-core": "0.0.
|
|
20
|
+
"@datadog/browser-core": "7.14.0",
|
|
21
|
+
"@datadog/browser-rum-core": "7.14.0",
|
|
22
|
+
"@datadog/browser-rum-react": "7.14.0",
|
|
23
|
+
"@datadog/js-core": "0.0.15"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"next": ">=13.0.0",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"extends": "../../package.json"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/react": "19.
|
|
47
|
-
"next": "16.3.
|
|
48
|
-
"react": "19.
|
|
49
|
-
"react-dom": "19.
|
|
46
|
+
"@types/react": "19.3.0",
|
|
47
|
+
"next": "16.3.5",
|
|
48
|
+
"react": "19.3.0",
|
|
49
|
+
"react-dom": "19.3.0"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clocksNow } from '@datadog/js-core/time'
|
|
2
|
-
import { callMonitored
|
|
2
|
+
import { callMonitored } from '@datadog/js-core/monitor'
|
|
3
|
+
import { createHandlingStack } from '@datadog/browser-core'
|
|
3
4
|
import type { Context } from '@datadog/browser-core'
|
|
4
5
|
import type { ErrorInfo } from 'react'
|
|
5
6
|
import { onRumStart } from '../nextjsPlugin'
|