trackjs-nextjs 1.0.0-canary.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 +26 -0
- package/dist/TrackJSAgent.js +16 -0
- package/dist/index.browser.js +9 -0
- package/dist/index.js +51 -0
- package/dist/types/TrackJSAgent.d.ts +5 -0
- package/dist/types/index.browser.d.ts +5 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/utils.d.ts +1 -0
- package/dist/utils.js +7 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://trackjs.com/" target="_blank" align="center">
|
|
3
|
+
<img src="https://trackjs.com/assets/external/github_readme.svg" width="280">
|
|
4
|
+
</a>
|
|
5
|
+
<br />
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
# Official NextJS Integration for TrackJS
|
|
9
|
+
|
|
10
|
+
This package integrates the TrackJS agent into Next.js projects.
|
|
11
|
+
|
|
12
|
+
# Compatibility
|
|
13
|
+
This package supports **Next.js** versions **14** and **15**. Please refer to our documentation to integrate with older versions of Next.js.
|
|
14
|
+
|
|
15
|
+
# Reference
|
|
16
|
+
- [TrackJS Next.js Documentation](https://docs.trackjs.com/browser-agent/integrations/nextjs15/)
|
|
17
|
+
- [TrackJS Next.js Documentation For Next.js versions < 14](http://docs.trackjs.com/browser-agent/integrations/legacy/)
|
|
18
|
+
|
|
19
|
+
# Usage
|
|
20
|
+
To get started, install this package.
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npm i trackjs-nextjs
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Next, configure the package with your token from the TrackJS dashboard. Read the TrackJS [Next.JS integration documentation](https://docs.trackjs.com/browser-agent/integrations/nextjs15/) for details.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TrackJSAgent = TrackJSAgent;
|
|
5
|
+
const trackjs_1 = require("trackjs");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
function TrackJSAgent(props) {
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
if (!trackjs_1.TrackJS.isInstalled()) {
|
|
10
|
+
trackjs_1.TrackJS.install(props.config);
|
|
11
|
+
trackjs_1.TrackJS.addMetadata("next-execution", "client");
|
|
12
|
+
window.TrackJS = trackjs_1.TrackJS;
|
|
13
|
+
}
|
|
14
|
+
}, []);
|
|
15
|
+
return '<!-- TrackJS browser agent installed -->';
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TrackJSAgent = exports.TrackJSServer = exports.TrackJS = void 0;
|
|
4
|
+
const trackjs_1 = require("trackjs");
|
|
5
|
+
Object.defineProperty(exports, "TrackJS", { enumerable: true, get: function () { return trackjs_1.TrackJS; } });
|
|
6
|
+
const TrackJSAgent_1 = require("./TrackJSAgent");
|
|
7
|
+
Object.defineProperty(exports, "TrackJSAgent", { enumerable: true, get: function () { return TrackJSAgent_1.TrackJSAgent; } });
|
|
8
|
+
const TrackJSServer = null;
|
|
9
|
+
exports.TrackJSServer = TrackJSServer;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TrackJSAgent = exports.TrackJSServer = exports.TrackJS = void 0;
|
|
4
|
+
const trackjs_node_1 = require("trackjs-node");
|
|
5
|
+
Object.defineProperty(exports, "TrackJSServer", { enumerable: true, get: function () { return trackjs_node_1.TrackJS; } });
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const TrackJSAgent_1 = require("./TrackJSAgent");
|
|
8
|
+
Object.defineProperty(exports, "TrackJSAgent", { enumerable: true, get: function () { return TrackJSAgent_1.TrackJSAgent; } });
|
|
9
|
+
function wrapTrackJSInstall() {
|
|
10
|
+
const originalInstall = trackjs_node_1.TrackJS.install;
|
|
11
|
+
trackjs_node_1.TrackJS.install = (options) => {
|
|
12
|
+
if ((0, utils_1.isClient)()) {
|
|
13
|
+
throw new Error("You cannot run install the TrackJS Node package in the client");
|
|
14
|
+
}
|
|
15
|
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
16
|
+
console.warn("TrackJS agent was not installed. Running on the edge is not currently supported.");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
20
|
+
var shouldModifyConsoleError = !trackjs_node_1.TrackJS.isInstalled();
|
|
21
|
+
var originalConsoleError = console.error;
|
|
22
|
+
originalInstall(options);
|
|
23
|
+
trackjs_node_1.TrackJS.addMetadata("next-execution", "server");
|
|
24
|
+
if (shouldModifyConsoleError) {
|
|
25
|
+
var tjsConsoleError = console.error;
|
|
26
|
+
console.error = function () {
|
|
27
|
+
if (arguments.length < 2) {
|
|
28
|
+
tjsConsoleError(...arguments);
|
|
29
|
+
}
|
|
30
|
+
var errorInstance = null;
|
|
31
|
+
if (Object.prototype.toString.call(arguments[0]) == "[object Error]") {
|
|
32
|
+
errorInstance = arguments[0];
|
|
33
|
+
}
|
|
34
|
+
else if (Object.prototype.toString.call(arguments[1]) == "[object Error]") {
|
|
35
|
+
errorInstance = arguments[1];
|
|
36
|
+
}
|
|
37
|
+
if (errorInstance) {
|
|
38
|
+
trackjs_node_1.TrackJS.track(errorInstance);
|
|
39
|
+
originalConsoleError(...arguments);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
tjsConsoleError(...arguments);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
wrapTrackJSInstall();
|
|
50
|
+
const TrackJS = null;
|
|
51
|
+
exports.TrackJS = TrackJS;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isClient(): boolean;
|
package/dist/utils.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "trackjs-nextjs",
|
|
3
|
+
"version": "1.0.0-canary.0",
|
|
4
|
+
"description": "TrackJS error tracking integration for Next.js",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "run-s clean-dist build-internal",
|
|
8
|
+
"build-internal": "tsc -p tsconfig.json",
|
|
9
|
+
"watch": "run-s clean-dist watch-tsc",
|
|
10
|
+
"watch-internal": "tsc -p tsconfig.json --watch",
|
|
11
|
+
"clean-dist": "node -e \"require('fs').rmSync('./dist', { recursive: true, force: true });\"",
|
|
12
|
+
"npm:canary": "run-s build npm:canary-internal",
|
|
13
|
+
"npm:canary-internal": "npm publish --tag canary",
|
|
14
|
+
"npm:prod": "run-s build npm:prod-internal",
|
|
15
|
+
"npm:prod-internal": "npm publish --tag latest --dry-run"
|
|
16
|
+
},
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "TrackJS LLC",
|
|
19
|
+
"email": "hello@trackjs.com",
|
|
20
|
+
"url": "https://trackjs.com/"
|
|
21
|
+
},
|
|
22
|
+
"license": "",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"email": "hello@trackjs.com"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://trackjs.com/",
|
|
27
|
+
"types": "./dist/types/",
|
|
28
|
+
"exports": {
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
"./README.md": "./README.md",
|
|
31
|
+
".": {
|
|
32
|
+
"browser": "./dist/index.browser.js",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist/**/*"
|
|
38
|
+
],
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"next": "^13.2.0 || ^14.0 || ^15.0",
|
|
41
|
+
"react": "^17.0 || ^18.0 || ^19.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "22.10.1",
|
|
46
|
+
"@types/react": "18.3.12",
|
|
47
|
+
"trackjs": "^3.10.4",
|
|
48
|
+
"trackjs-node": "^1.1.0",
|
|
49
|
+
"npm-run-all": "4.1.5",
|
|
50
|
+
"next": "14.2.20",
|
|
51
|
+
"typescript": "5.7.2"
|
|
52
|
+
}
|
|
53
|
+
}
|