@datadog/browser-rum-nextjs 7.4.0 → 7.5.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.
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  const require_nextjsPlugin = require("../nextjsPlugin.js");
3
3
  const require_computeViewNameFromParams = require("./computeViewNameFromParams.js");
4
- let _datadog_browser_core = require("@datadog/browser-core");
5
4
  let react = require("react");
6
5
  let next_navigation_js = require("next/navigation.js");
6
+ let _datadog_browser_core = require("@datadog/browser-core");
7
7
  //#region src/domain/nextJSRouter/datadogAppRouter.tsx
8
8
  function DatadogAppRouter() {
9
9
  const pathname = (0, _datadog_browser_core.mockable)(next_navigation_js.usePathname)();
@@ -1,6 +1,6 @@
1
1
  const require_nextjsPlugin = require("../nextjsPlugin.js");
2
- let _datadog_browser_core = require("@datadog/browser-core");
3
2
  let react = require("react");
3
+ let _datadog_browser_core = require("@datadog/browser-core");
4
4
  let next_router_js = require("next/router.js");
5
5
  //#region src/domain/nextJSRouter/datadogPagesRouter.tsx
6
6
  function DatadogPagesRouter() {
@@ -1,4 +1,4 @@
1
- let _datadog_browser_core = require("@datadog/browser-core");
1
+ let _datadog_js_core_util = require("@datadog/js-core/util");
2
2
  //#region src/domain/nextjsPlugin.ts
3
3
  let globalPublicApi;
4
4
  let globalAddError;
@@ -21,7 +21,7 @@ function nextjsPlugin() {
21
21
  }
22
22
  function startNextjsView(viewName) {
23
23
  if (globalPublicApi) {
24
- const url = lastNavigationUrl ? (0, _datadog_browser_core.buildUrl)(lastNavigationUrl, window.location.origin).href : void 0;
24
+ const url = lastNavigationUrl ? (0, _datadog_js_core_util.buildUrl)(lastNavigationUrl, window.location.origin).href : void 0;
25
25
  lastNavigationUrl = void 0;
26
26
  globalPublicApi.startView({
27
27
  name: viewName,
@@ -1 +1 @@
1
- {"version":3,"file":"nextjsPlugin.js","names":[],"sources":["../../src/domain/nextjsPlugin.ts"],"sourcesContent":["import { buildUrl } from '@datadog/browser-core'\nimport type { RumPlugin, RumPublicApi, StartRumResult } from '@datadog/browser-rum-core'\n\nexport type NextjsPlugin = Pick<Required<RumPlugin>, 'name' | 'onInit' | 'onRumStart'>\n\ntype InitSubscriber = (rumPublicApi: RumPublicApi) => void\ntype StartSubscriber = (addError: StartRumResult['addError']) => void\n\nlet globalPublicApi: RumPublicApi | undefined\nlet globalAddError: StartRumResult['addError'] | undefined\nlet lastNavigationUrl: string | undefined\n\nconst onRumInitSubscribers: InitSubscriber[] = []\nconst onRumStartSubscribers: StartSubscriber[] = []\n\nexport function nextjsPlugin(): NextjsPlugin {\n return {\n name: 'nextjs',\n onInit({ publicApi, initConfiguration }) {\n globalPublicApi = publicApi\n initConfiguration.trackViewsManually = true\n\n for (const subscriber of onRumInitSubscribers) {\n subscriber(publicApi)\n }\n },\n onRumStart({ addError }) {\n globalAddError = addError\n if (addError) {\n for (const subscriber of onRumStartSubscribers) {\n subscriber(addError)\n }\n }\n },\n } satisfies RumPlugin\n}\n\nexport function startNextjsView(viewName: string) {\n if (globalPublicApi) {\n // Use the URL captured by onRouterTransitionStart if available, since React renders before pushState updates window.location\n const url = lastNavigationUrl ? buildUrl(lastNavigationUrl, window.location.origin).href : undefined\n lastNavigationUrl = undefined\n globalPublicApi.startView({ name: viewName, url })\n }\n}\n\n// Must be re-exported from the user's instrumentation-client.ts so we can capture the URL before React renders\nexport function onRouterTransitionStart(url: string) {\n lastNavigationUrl = url\n}\n\nexport function onRumInit(callback: InitSubscriber) {\n if (globalPublicApi) {\n callback(globalPublicApi)\n } else {\n onRumInitSubscribers.push(callback)\n }\n}\n\nexport function onRumStart(callback: StartSubscriber) {\n if (globalAddError) {\n callback(globalAddError)\n } else {\n onRumStartSubscribers.push(callback)\n }\n}\n\nexport function resetNextjsPlugin() {\n globalPublicApi = undefined\n globalAddError = undefined\n onRumInitSubscribers.length = 0\n onRumStartSubscribers.length = 0\n lastNavigationUrl = undefined\n}\n"],"mappings":";;AAQA,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,MAAM,uBAAyC,CAAC;AAChD,MAAM,wBAA2C,CAAC;AAElD,SAAgB,eAA6B;CAC3C,OAAO;EACL,MAAM;EACN,OAAO,EAAE,WAAW,qBAAqB;GACvC,kBAAkB;GAClB,kBAAkB,qBAAqB;GAEvC,KAAK,MAAM,cAAc,sBACvB,WAAW,SAAS;EAExB;EACA,WAAW,EAAE,YAAY;GACvB,iBAAiB;GACjB,IAAI,UACF,KAAK,MAAM,cAAc,uBACvB,WAAW,QAAQ;EAGzB;CACF;AACF;AAEA,SAAgB,gBAAgB,UAAkB;CAChD,IAAI,iBAAiB;EAEnB,MAAM,MAAM,qBAAA,GAAA,sBAAA,SAAA,CAA6B,mBAAmB,OAAO,SAAS,MAAM,CAAC,CAAC,OAAO,KAAA;EAC3F,oBAAoB,KAAA;EACpB,gBAAgB,UAAU;GAAE,MAAM;GAAU;EAAI,CAAC;CACnD;AACF;AAGA,SAAgB,wBAAwB,KAAa;CACnD,oBAAoB;AACtB;AAUA,SAAgB,WAAW,UAA2B;CACpD,IAAI,gBACF,SAAS,cAAc;MAEvB,sBAAsB,KAAK,QAAQ;AAEvC"}
1
+ {"version":3,"file":"nextjsPlugin.js","names":[],"sources":["../../src/domain/nextjsPlugin.ts"],"sourcesContent":["import { buildUrl } from '@datadog/js-core/util'\nimport type { RumPlugin, RumPublicApi, StartRumResult } from '@datadog/browser-rum-core'\n\nexport type NextjsPlugin = Pick<Required<RumPlugin>, 'name' | 'onInit' | 'onRumStart'>\n\ntype InitSubscriber = (rumPublicApi: RumPublicApi) => void\ntype StartSubscriber = (addError: StartRumResult['addError']) => void\n\nlet globalPublicApi: RumPublicApi | undefined\nlet globalAddError: StartRumResult['addError'] | undefined\nlet lastNavigationUrl: string | undefined\n\nconst onRumInitSubscribers: InitSubscriber[] = []\nconst onRumStartSubscribers: StartSubscriber[] = []\n\nexport function nextjsPlugin(): NextjsPlugin {\n return {\n name: 'nextjs',\n onInit({ publicApi, initConfiguration }) {\n globalPublicApi = publicApi\n initConfiguration.trackViewsManually = true\n\n for (const subscriber of onRumInitSubscribers) {\n subscriber(publicApi)\n }\n },\n onRumStart({ addError }) {\n globalAddError = addError\n if (addError) {\n for (const subscriber of onRumStartSubscribers) {\n subscriber(addError)\n }\n }\n },\n } satisfies RumPlugin\n}\n\nexport function startNextjsView(viewName: string) {\n if (globalPublicApi) {\n // Use the URL captured by onRouterTransitionStart if available, since React renders before pushState updates window.location\n const url = lastNavigationUrl ? buildUrl(lastNavigationUrl, window.location.origin).href : undefined\n lastNavigationUrl = undefined\n globalPublicApi.startView({ name: viewName, url })\n }\n}\n\n// Must be re-exported from the user's instrumentation-client.ts so we can capture the URL before React renders\nexport function onRouterTransitionStart(url: string) {\n lastNavigationUrl = url\n}\n\nexport function onRumInit(callback: InitSubscriber) {\n if (globalPublicApi) {\n callback(globalPublicApi)\n } else {\n onRumInitSubscribers.push(callback)\n }\n}\n\nexport function onRumStart(callback: StartSubscriber) {\n if (globalAddError) {\n callback(globalAddError)\n } else {\n onRumStartSubscribers.push(callback)\n }\n}\n\nexport function resetNextjsPlugin() {\n globalPublicApi = undefined\n globalAddError = undefined\n onRumInitSubscribers.length = 0\n onRumStartSubscribers.length = 0\n lastNavigationUrl = undefined\n}\n"],"mappings":";;AAQA,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,MAAM,uBAAyC,CAAC;AAChD,MAAM,wBAA2C,CAAC;AAElD,SAAgB,eAA6B;CAC3C,OAAO;EACL,MAAM;EACN,OAAO,EAAE,WAAW,qBAAqB;GACvC,kBAAkB;GAClB,kBAAkB,qBAAqB;GAEvC,KAAK,MAAM,cAAc,sBACvB,WAAW,SAAS;EAExB;EACA,WAAW,EAAE,YAAY;GACvB,iBAAiB;GACjB,IAAI,UACF,KAAK,MAAM,cAAc,uBACvB,WAAW,QAAQ;EAGzB;CACF;AACF;AAEA,SAAgB,gBAAgB,UAAkB;CAChD,IAAI,iBAAiB;EAEnB,MAAM,MAAM,qBAAA,GAAA,sBAAA,SAAA,CAA6B,mBAAmB,OAAO,SAAS,MAAM,CAAC,CAAC,OAAO,KAAA;EAC3F,oBAAoB,KAAA;EACpB,gBAAgB,UAAU;GAAE,MAAM;GAAU;EAAI,CAAC;CACnD;AACF;AAGA,SAAgB,wBAAwB,KAAa;CACnD,oBAAoB;AACtB;AAUA,SAAgB,WAAW,UAA2B;CACpD,IAAI,gBACF,SAAS,cAAc;MAEvB,sBAAsB,KAAK,QAAQ;AAEvC"}
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { startNextjsView } from "../nextjsPlugin.mjs";
3
3
  import { computeViewNameFromParams } from "./computeViewNameFromParams.mjs";
4
- import { mockable } from "@datadog/browser-core";
5
4
  import { useRef } from "react";
6
5
  import { useParams, usePathname } from "next/navigation.js";
6
+ import { mockable } from "@datadog/browser-core";
7
7
  //#region src/domain/nextJSRouter/datadogAppRouter.tsx
8
8
  function DatadogAppRouter() {
9
9
  const pathname = mockable(usePathname)();
@@ -1,6 +1,6 @@
1
1
  import { startNextjsView } from "../nextjsPlugin.mjs";
2
- import { mockable } from "@datadog/browser-core";
3
2
  import { useRef } from "react";
3
+ import { mockable } from "@datadog/browser-core";
4
4
  import { useRouter } from "next/router.js";
5
5
  //#region src/domain/nextJSRouter/datadogPagesRouter.tsx
6
6
  function DatadogPagesRouter() {
@@ -1,4 +1,4 @@
1
- import { buildUrl } from "@datadog/browser-core";
1
+ import { buildUrl } from "@datadog/js-core/util";
2
2
  //#region src/domain/nextjsPlugin.ts
3
3
  let globalPublicApi;
4
4
  let globalAddError;
@@ -1 +1 @@
1
- {"version":3,"file":"nextjsPlugin.mjs","names":[],"sources":["../../src/domain/nextjsPlugin.ts"],"sourcesContent":["import { buildUrl } from '@datadog/browser-core'\nimport type { RumPlugin, RumPublicApi, StartRumResult } from '@datadog/browser-rum-core'\n\nexport type NextjsPlugin = Pick<Required<RumPlugin>, 'name' | 'onInit' | 'onRumStart'>\n\ntype InitSubscriber = (rumPublicApi: RumPublicApi) => void\ntype StartSubscriber = (addError: StartRumResult['addError']) => void\n\nlet globalPublicApi: RumPublicApi | undefined\nlet globalAddError: StartRumResult['addError'] | undefined\nlet lastNavigationUrl: string | undefined\n\nconst onRumInitSubscribers: InitSubscriber[] = []\nconst onRumStartSubscribers: StartSubscriber[] = []\n\nexport function nextjsPlugin(): NextjsPlugin {\n return {\n name: 'nextjs',\n onInit({ publicApi, initConfiguration }) {\n globalPublicApi = publicApi\n initConfiguration.trackViewsManually = true\n\n for (const subscriber of onRumInitSubscribers) {\n subscriber(publicApi)\n }\n },\n onRumStart({ addError }) {\n globalAddError = addError\n if (addError) {\n for (const subscriber of onRumStartSubscribers) {\n subscriber(addError)\n }\n }\n },\n } satisfies RumPlugin\n}\n\nexport function startNextjsView(viewName: string) {\n if (globalPublicApi) {\n // Use the URL captured by onRouterTransitionStart if available, since React renders before pushState updates window.location\n const url = lastNavigationUrl ? buildUrl(lastNavigationUrl, window.location.origin).href : undefined\n lastNavigationUrl = undefined\n globalPublicApi.startView({ name: viewName, url })\n }\n}\n\n// Must be re-exported from the user's instrumentation-client.ts so we can capture the URL before React renders\nexport function onRouterTransitionStart(url: string) {\n lastNavigationUrl = url\n}\n\nexport function onRumInit(callback: InitSubscriber) {\n if (globalPublicApi) {\n callback(globalPublicApi)\n } else {\n onRumInitSubscribers.push(callback)\n }\n}\n\nexport function onRumStart(callback: StartSubscriber) {\n if (globalAddError) {\n callback(globalAddError)\n } else {\n onRumStartSubscribers.push(callback)\n }\n}\n\nexport function resetNextjsPlugin() {\n globalPublicApi = undefined\n globalAddError = undefined\n onRumInitSubscribers.length = 0\n onRumStartSubscribers.length = 0\n lastNavigationUrl = undefined\n}\n"],"mappings":";;AAQA,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,MAAM,uBAAyC,CAAC;AAChD,MAAM,wBAA2C,CAAC;AAElD,SAAgB,eAA6B;CAC3C,OAAO;EACL,MAAM;EACN,OAAO,EAAE,WAAW,qBAAqB;GACvC,kBAAkB;GAClB,kBAAkB,qBAAqB;GAEvC,KAAK,MAAM,cAAc,sBACvB,WAAW,SAAS;EAExB;EACA,WAAW,EAAE,YAAY;GACvB,iBAAiB;GACjB,IAAI,UACF,KAAK,MAAM,cAAc,uBACvB,WAAW,QAAQ;EAGzB;CACF;AACF;AAEA,SAAgB,gBAAgB,UAAkB;CAChD,IAAI,iBAAiB;EAEnB,MAAM,MAAM,oBAAoB,SAAS,mBAAmB,OAAO,SAAS,MAAM,CAAC,CAAC,OAAO,KAAA;EAC3F,oBAAoB,KAAA;EACpB,gBAAgB,UAAU;GAAE,MAAM;GAAU;EAAI,CAAC;CACnD;AACF;AAGA,SAAgB,wBAAwB,KAAa;CACnD,oBAAoB;AACtB;AAUA,SAAgB,WAAW,UAA2B;CACpD,IAAI,gBACF,SAAS,cAAc;MAEvB,sBAAsB,KAAK,QAAQ;AAEvC"}
1
+ {"version":3,"file":"nextjsPlugin.mjs","names":[],"sources":["../../src/domain/nextjsPlugin.ts"],"sourcesContent":["import { buildUrl } from '@datadog/js-core/util'\nimport type { RumPlugin, RumPublicApi, StartRumResult } from '@datadog/browser-rum-core'\n\nexport type NextjsPlugin = Pick<Required<RumPlugin>, 'name' | 'onInit' | 'onRumStart'>\n\ntype InitSubscriber = (rumPublicApi: RumPublicApi) => void\ntype StartSubscriber = (addError: StartRumResult['addError']) => void\n\nlet globalPublicApi: RumPublicApi | undefined\nlet globalAddError: StartRumResult['addError'] | undefined\nlet lastNavigationUrl: string | undefined\n\nconst onRumInitSubscribers: InitSubscriber[] = []\nconst onRumStartSubscribers: StartSubscriber[] = []\n\nexport function nextjsPlugin(): NextjsPlugin {\n return {\n name: 'nextjs',\n onInit({ publicApi, initConfiguration }) {\n globalPublicApi = publicApi\n initConfiguration.trackViewsManually = true\n\n for (const subscriber of onRumInitSubscribers) {\n subscriber(publicApi)\n }\n },\n onRumStart({ addError }) {\n globalAddError = addError\n if (addError) {\n for (const subscriber of onRumStartSubscribers) {\n subscriber(addError)\n }\n }\n },\n } satisfies RumPlugin\n}\n\nexport function startNextjsView(viewName: string) {\n if (globalPublicApi) {\n // Use the URL captured by onRouterTransitionStart if available, since React renders before pushState updates window.location\n const url = lastNavigationUrl ? buildUrl(lastNavigationUrl, window.location.origin).href : undefined\n lastNavigationUrl = undefined\n globalPublicApi.startView({ name: viewName, url })\n }\n}\n\n// Must be re-exported from the user's instrumentation-client.ts so we can capture the URL before React renders\nexport function onRouterTransitionStart(url: string) {\n lastNavigationUrl = url\n}\n\nexport function onRumInit(callback: InitSubscriber) {\n if (globalPublicApi) {\n callback(globalPublicApi)\n } else {\n onRumInitSubscribers.push(callback)\n }\n}\n\nexport function onRumStart(callback: StartSubscriber) {\n if (globalAddError) {\n callback(globalAddError)\n } else {\n onRumStartSubscribers.push(callback)\n }\n}\n\nexport function resetNextjsPlugin() {\n globalPublicApi = undefined\n globalAddError = undefined\n onRumInitSubscribers.length = 0\n onRumStartSubscribers.length = 0\n lastNavigationUrl = undefined\n}\n"],"mappings":";;AAQA,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,MAAM,uBAAyC,CAAC;AAChD,MAAM,wBAA2C,CAAC;AAElD,SAAgB,eAA6B;CAC3C,OAAO;EACL,MAAM;EACN,OAAO,EAAE,WAAW,qBAAqB;GACvC,kBAAkB;GAClB,kBAAkB,qBAAqB;GAEvC,KAAK,MAAM,cAAc,sBACvB,WAAW,SAAS;EAExB;EACA,WAAW,EAAE,YAAY;GACvB,iBAAiB;GACjB,IAAI,UACF,KAAK,MAAM,cAAc,uBACvB,WAAW,QAAQ;EAGzB;CACF;AACF;AAEA,SAAgB,gBAAgB,UAAkB;CAChD,IAAI,iBAAiB;EAEnB,MAAM,MAAM,oBAAoB,SAAS,mBAAmB,OAAO,SAAS,MAAM,CAAC,CAAC,OAAO,KAAA;EAC3F,oBAAoB,KAAA;EACpB,gBAAgB,UAAU;GAAE,MAAM;GAAU;EAAI,CAAC;CACnD;AACF;AAGA,SAAgB,wBAAwB,KAAa;CACnD,oBAAoB;AACtB;AAUA,SAAgB,WAAW,UAA2B;CACpD,IAAI,gBACF,SAAS,cAAc;MAEvB,sBAAsB,KAAK,QAAQ;AAEvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/browser-rum-nextjs",
3
- "version": "7.4.0",
3
+ "version": "7.5.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.4.0",
21
- "@datadog/browser-rum-core": "7.4.0",
22
- "@datadog/browser-rum-react": "7.4.0",
23
- "@datadog/js-core": "0.0.4"
20
+ "@datadog/browser-core": "7.5.0",
21
+ "@datadog/browser-rum-core": "7.5.0",
22
+ "@datadog/browser-rum-react": "7.5.0",
23
+ "@datadog/js-core": "0.0.5"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "next": ">=13.0.0",
@@ -1,4 +1,4 @@
1
- import { buildUrl } from '@datadog/browser-core'
1
+ import { buildUrl } from '@datadog/js-core/util'
2
2
  import type { RumPlugin, RumPublicApi, StartRumResult } from '@datadog/browser-rum-core'
3
3
 
4
4
  export type NextjsPlugin = Pick<Required<RumPlugin>, 'name' | 'onInit' | 'onRumStart'>