@cronitorio/cronitor-rum-nextjs 0.5.0 → 0.5.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/dist/index.d.ts +8 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Cronitor from '@cronitorio/cronitor-rum';
|
|
2
|
+
/**
|
|
3
|
+
* React hook for automatically tracking navigation changes on Next.js apps.
|
|
4
|
+
*
|
|
5
|
+
* @param clientKey the client key for the Cronitor site.
|
|
6
|
+
* @param config the Cronitor tracker configuration object.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useCronitor(clientKey: string, config?: Cronitor.CronitorRUMConfig): typeof Cronitor;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = 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);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.useCronitor = useCronitor;
|
|
38
|
+
const Cronitor = __importStar(require("@cronitorio/cronitor-rum"));
|
|
39
|
+
const navigation_1 = require("next/navigation");
|
|
40
|
+
const react_1 = require("react");
|
|
41
|
+
/**
|
|
42
|
+
* React hook for automatically tracking navigation changes on Next.js apps.
|
|
43
|
+
*
|
|
44
|
+
* @param clientKey the client key for the Cronitor site.
|
|
45
|
+
* @param config the Cronitor tracker configuration object.
|
|
46
|
+
*/
|
|
47
|
+
function useCronitor(clientKey, config = {}) {
|
|
48
|
+
const pathname = (0, navigation_1.usePathname)();
|
|
49
|
+
const searchParams = (0, navigation_1.useSearchParams)();
|
|
50
|
+
(0, react_1.useEffect)(() => {
|
|
51
|
+
Cronitor.load(clientKey, config);
|
|
52
|
+
}, []);
|
|
53
|
+
(0, react_1.useEffect)(() => {
|
|
54
|
+
Cronitor.track('Pageview');
|
|
55
|
+
}, [pathname, searchParams]);
|
|
56
|
+
return Cronitor;
|
|
57
|
+
}
|
|
58
|
+
;
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYb,kCAaC;AAvBD,mEAAqD;AACrD,gDAA+D;AAC/D,iCAAkC;AAElC;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,SAAiB,EAAE,SAAqC,EAAE;IACpF,MAAM,QAAQ,GAAG,IAAA,wBAAW,GAAE,CAAC;IAC/B,MAAM,YAAY,GAAG,IAAA,4BAAe,GAAE,CAAC;IAEvC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC,EAAE,EAAE,CAAC,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;AAAA,CAAC"}
|