@cronitorio/cronitor-rum-nextjs 0.1.0 → 0.2.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
@@ -1,5 +1,7 @@
1
1
  # Cronitor RUM Next.js integration
2
2
 
3
+ > **Important:** As of version 0.2.0 of this package only Next.js 13 or later will be supported. For previous versions of Next.js please install version 0.1.0 of this package.
4
+
3
5
  Official [Cronitor Real User Monitoring](https://cronitor.io/real-user-monitoring) integration for Next.js.
4
6
 
5
7
  ## Quickstart
@@ -51,7 +53,9 @@ import { useCronitor } from '@cronitorio/cronitor-rum-nextjs';
51
53
  function CustomApp({ Component, pageProps }) {
52
54
 
53
55
  useCronitor('YOUR_SITE_ID', {
54
- debug: true
56
+ debug: true,
57
+ environment: "staging",
58
+ includeURLQueryParams: ["tab", "pageNum"]
55
59
  });
56
60
 
57
61
  return <Component {...pageProps} />;
@@ -63,6 +67,14 @@ export default CustomApp;
63
67
 
64
68
  ## Changelog
65
69
 
70
+ ### 0.2.1
71
+
72
+ - Update cronitor-rum-js lib.
73
+
74
+ ### 0.2.0
75
+
76
+ - Support new Next.js 13 'app' directory and client-only components.
77
+
66
78
  ### 0.1.0
67
79
 
68
80
  - Initial open source release.
package/dist/index.d.ts CHANGED
@@ -5,4 +5,4 @@ import * as Cronitor from '@cronitorio/cronitor-rum-js';
5
5
  * @param clientKey the client key for the Cronitor site.
6
6
  * @param config the Cronitor tracker configuration object.
7
7
  */
8
- export declare const useCronitor: (clientKey: string, config?: Cronitor.CronitorRUMConfig) => typeof Cronitor;
8
+ export declare function useCronitor(clientKey: string, config?: Cronitor.CronitorRUMConfig): typeof Cronitor;
package/dist/index.js CHANGED
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
+ 'use client';
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
5
10
  }) : (function(o, m, k, k2) {
6
11
  if (k2 === undefined) k2 = k;
7
12
  o[k2] = m[k];
@@ -21,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
21
26
  Object.defineProperty(exports, "__esModule", { value: true });
22
27
  exports.useCronitor = void 0;
23
28
  const Cronitor = __importStar(require("@cronitorio/cronitor-rum-js"));
24
- const router_1 = require("next/router");
29
+ const navigation_1 = require("next/navigation");
25
30
  const react_1 = require("react");
26
31
  /**
27
32
  * React hook for automatically tracking navigation changes on Next.js apps.
@@ -29,20 +34,17 @@ const react_1 = require("react");
29
34
  * @param clientKey the client key for the Cronitor site.
30
35
  * @param config the Cronitor tracker configuration object.
31
36
  */
32
- const useCronitor = (clientKey, config = {}) => {
33
- const router = (0, router_1.useRouter)();
37
+ function useCronitor(clientKey, config = {}) {
38
+ const pathname = (0, navigation_1.usePathname)();
39
+ const searchParams = (0, navigation_1.useSearchParams)();
34
40
  (0, react_1.useEffect)(() => {
35
41
  Cronitor.load(clientKey, config);
36
- // Trigger initial page view
42
+ }, []);
43
+ (0, react_1.useEffect)(() => {
37
44
  Cronitor.track('Pageview');
38
- // Add on route change handler for client-side navigation
39
- const handleRouteChange = () => Cronitor.track('Pageview');
40
- router.events.on('routeChangeComplete', handleRouteChange);
41
- return () => {
42
- router.events.off('routeChangeComplete', handleRouteChange);
43
- };
44
- }, [clientKey]);
45
+ }, [pathname, searchParams]);
45
46
  return Cronitor;
46
- };
47
+ }
47
48
  exports.useCronitor = useCronitor;
49
+ ;
48
50
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;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AAC,CAAC;IAEP,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IAE7B,OAAO,QAAQ,CAAC;AAClB,CAAC;AAbD,kCAaC;AAAA,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cronitorio/cronitor-rum-nextjs",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Official Cronitor integration for Next.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,20 +29,20 @@
29
29
  "lint": "tslint -p tsconfig.json"
30
30
  },
31
31
  "peerDependencies": {
32
- "next": "^10 || ^11 || ^12 || ^13",
33
- "react": "^16 || ^17 || ^18"
32
+ "next": "^13",
33
+ "react": "^18"
34
34
  },
35
35
  "dependencies": {
36
- "@cronitorio/cronitor-rum-js": "^0.1.0"
36
+ "@cronitorio/cronitor-rum-js": "^0.2.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@types/react": "^17.0.20",
40
- "next": "^11.1.2",
41
- "prettier": "^2.2.1",
42
- "react": "^17.0.2",
39
+ "@types/react": "^18.0.27",
40
+ "next": "^13.1.4",
41
+ "prettier": "^2.8.3",
42
+ "react": "^18.2.0",
43
43
  "tslint": "^6.1.3",
44
44
  "tslint-config-prettier": "^1.18.0",
45
- "typescript": "^4.0.5"
45
+ "typescript": "^4.9.4"
46
46
  },
47
47
  "bugs": {
48
48
  "url": "https://github.com/cronitorio/cronitor-rum-nextjs/issues"