@octelis/monitor 0.1.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/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +71 -0
- package/dist/index.mjs +43 -0
- package/package.json +37 -0
- package/src/OctelisMonitor.tsx +34 -0
- package/src/OctelisNotFound.tsx +17 -0
- package/src/index.ts +2 -0
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
OctelisMonitor: () => OctelisMonitor,
|
|
24
|
+
OctelisNotFound: () => OctelisNotFound
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/OctelisMonitor.tsx
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var APP_URL = "https://app.octelis.com";
|
|
31
|
+
function OctelisMonitor({ siteId }) {
|
|
32
|
+
(0, import_react.useEffect)(() => {
|
|
33
|
+
if (!document.querySelector(`script[data-octelis-site="${siteId}"]`)) {
|
|
34
|
+
const script = document.createElement("script");
|
|
35
|
+
script.src = `${APP_URL}/monitor.js`;
|
|
36
|
+
script.setAttribute("data-site-id", siteId);
|
|
37
|
+
script.setAttribute("data-octelis-site", siteId);
|
|
38
|
+
script.defer = true;
|
|
39
|
+
document.head.appendChild(script);
|
|
40
|
+
}
|
|
41
|
+
const flag = `octelis_registered_${siteId}`;
|
|
42
|
+
if (localStorage.getItem(flag)) return;
|
|
43
|
+
fetch(`${APP_URL}/api/monitor/register`, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: { "Content-Type": "application/json" },
|
|
46
|
+
body: JSON.stringify({ siteId })
|
|
47
|
+
}).then(() => localStorage.setItem(flag, "1")).catch(() => {
|
|
48
|
+
});
|
|
49
|
+
}, [siteId]);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/OctelisNotFound.tsx
|
|
54
|
+
var import_react2 = require("react");
|
|
55
|
+
function OctelisNotFound() {
|
|
56
|
+
(0, import_react2.useEffect)(() => {
|
|
57
|
+
const meta = document.createElement("meta");
|
|
58
|
+
meta.name = "octelis:page-type";
|
|
59
|
+
meta.content = "404";
|
|
60
|
+
document.head.appendChild(meta);
|
|
61
|
+
return () => {
|
|
62
|
+
document.head.removeChild(meta);
|
|
63
|
+
};
|
|
64
|
+
}, []);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
OctelisMonitor,
|
|
70
|
+
OctelisNotFound
|
|
71
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/OctelisMonitor.tsx
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
var APP_URL = "https://app.octelis.com";
|
|
4
|
+
function OctelisMonitor({ siteId }) {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (!document.querySelector(`script[data-octelis-site="${siteId}"]`)) {
|
|
7
|
+
const script = document.createElement("script");
|
|
8
|
+
script.src = `${APP_URL}/monitor.js`;
|
|
9
|
+
script.setAttribute("data-site-id", siteId);
|
|
10
|
+
script.setAttribute("data-octelis-site", siteId);
|
|
11
|
+
script.defer = true;
|
|
12
|
+
document.head.appendChild(script);
|
|
13
|
+
}
|
|
14
|
+
const flag = `octelis_registered_${siteId}`;
|
|
15
|
+
if (localStorage.getItem(flag)) return;
|
|
16
|
+
fetch(`${APP_URL}/api/monitor/register`, {
|
|
17
|
+
method: "POST",
|
|
18
|
+
headers: { "Content-Type": "application/json" },
|
|
19
|
+
body: JSON.stringify({ siteId })
|
|
20
|
+
}).then(() => localStorage.setItem(flag, "1")).catch(() => {
|
|
21
|
+
});
|
|
22
|
+
}, [siteId]);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/OctelisNotFound.tsx
|
|
27
|
+
import { useEffect as useEffect2 } from "react";
|
|
28
|
+
function OctelisNotFound() {
|
|
29
|
+
useEffect2(() => {
|
|
30
|
+
const meta = document.createElement("meta");
|
|
31
|
+
meta.name = "octelis:page-type";
|
|
32
|
+
meta.content = "404";
|
|
33
|
+
document.head.appendChild(meta);
|
|
34
|
+
return () => {
|
|
35
|
+
document.head.removeChild(meta);
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
OctelisMonitor,
|
|
42
|
+
OctelisNotFound
|
|
43
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octelis/monitor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Octelis site monitoring components for React",
|
|
5
|
+
"keywords": ["octelis", "monitoring", "react", "nextjs", "error-tracking"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"src"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --external react",
|
|
23
|
+
"typecheck": "tsc --noEmit"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": "^18 || ^19"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@octelis/config": "workspace:*",
|
|
30
|
+
"@types/react": "^19.0.0",
|
|
31
|
+
"tsup": "^8.0.0",
|
|
32
|
+
"typescript": "^5.7.2"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react'
|
|
4
|
+
|
|
5
|
+
const APP_URL = 'https://app.octelis.com'
|
|
6
|
+
|
|
7
|
+
interface OctelisMonitorProps {
|
|
8
|
+
siteId: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function OctelisMonitor({ siteId }: OctelisMonitorProps) {
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!document.querySelector(`script[data-octelis-site="${siteId}"]`)) {
|
|
14
|
+
const script = document.createElement('script')
|
|
15
|
+
script.src = `${APP_URL}/monitor.js`
|
|
16
|
+
script.setAttribute('data-site-id', siteId)
|
|
17
|
+
script.setAttribute('data-octelis-site', siteId)
|
|
18
|
+
script.defer = true
|
|
19
|
+
document.head.appendChild(script)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const flag = `octelis_registered_${siteId}`
|
|
23
|
+
if (localStorage.getItem(flag)) return
|
|
24
|
+
fetch(`${APP_URL}/api/monitor/register`, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: { 'Content-Type': 'application/json' },
|
|
27
|
+
body: JSON.stringify({ siteId }),
|
|
28
|
+
})
|
|
29
|
+
.then(() => localStorage.setItem(flag, '1'))
|
|
30
|
+
.catch(() => {})
|
|
31
|
+
}, [siteId])
|
|
32
|
+
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react'
|
|
4
|
+
|
|
5
|
+
export function OctelisNotFound() {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const meta = document.createElement('meta')
|
|
8
|
+
meta.name = 'octelis:page-type'
|
|
9
|
+
meta.content = '404'
|
|
10
|
+
document.head.appendChild(meta)
|
|
11
|
+
return () => {
|
|
12
|
+
document.head.removeChild(meta)
|
|
13
|
+
}
|
|
14
|
+
}, [])
|
|
15
|
+
|
|
16
|
+
return null
|
|
17
|
+
}
|
package/src/index.ts
ADDED