@orbitai/orbitrace 1.1.2 → 1.1.3
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 +202 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,202 @@
|
|
|
1
|
-
|
|
1
|
+
# @orbitai/orbitrace
|
|
2
|
+
|
|
3
|
+
Error tracking and monitoring for Node.js and browser applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @orbitai/orbitrace
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Backend Setup
|
|
12
|
+
|
|
13
|
+
### 1. Initialize Orbitrace
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
// orbitrace.js
|
|
17
|
+
const Orbitrace = require("@orbitai/orbitrace");
|
|
18
|
+
|
|
19
|
+
function getOrbitraceInstance({ service }) {
|
|
20
|
+
console.log("Initializing Orbitrace for service:", service);
|
|
21
|
+
|
|
22
|
+
Orbitrace.getInstance({
|
|
23
|
+
apiKey: process.env.ORBITRACE_API_KEY,
|
|
24
|
+
orgId: process.env.ORBITRACE_ORG_ID,
|
|
25
|
+
projectId: process.env.ORBITRACE_PROJECT_ID,
|
|
26
|
+
endpoint: process.env.ORBITRACE_ENDPOINT,
|
|
27
|
+
environment: process.env.APP_ENV,
|
|
28
|
+
service,
|
|
29
|
+
version: process.env.APP_VERSION,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return Orbitrace;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
getOrbitraceInstance,
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Usage
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
const { getOrbitraceInstance } = require("/path/to/orbitrace");
|
|
44
|
+
const orbitrace = getOrbitraceInstance({ service: "api" });
|
|
45
|
+
|
|
46
|
+
// Capture exceptions
|
|
47
|
+
try {
|
|
48
|
+
// Your code here
|
|
49
|
+
} catch (error) {
|
|
50
|
+
await orbitrace.captureException(error, {
|
|
51
|
+
endpoint: "/users",
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Capture messages
|
|
56
|
+
await orbitrace.captureMessage("User registered", {
|
|
57
|
+
userId: "123",
|
|
58
|
+
email: "user@example.com",
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Frontend Setup (Vue 3 + Pinia)
|
|
63
|
+
|
|
64
|
+
### 1. Initialize Orbitrace
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
// orbitrace.js
|
|
68
|
+
import { provide, inject } from "vue";
|
|
69
|
+
import Orbitrace from "@orbitai/orbitrace";
|
|
70
|
+
|
|
71
|
+
export const ORBITRACE_KEY = Symbol("orbitrace");
|
|
72
|
+
|
|
73
|
+
export function getOrbitraceInstance({ service }) {
|
|
74
|
+
Orbitrace.getInstance({
|
|
75
|
+
apiKey: import.meta.env.VITE_ORBITRACE_API_KEY,
|
|
76
|
+
orgId: import.meta.env.VITE_ORBITRACE_ORG_ID,
|
|
77
|
+
projectId: import.meta.env.VITE_ORBITRACE_PROJECT_ID,
|
|
78
|
+
endpoint: import.meta.env.VITE_ORBITRACE_ENDPOINT,
|
|
79
|
+
environment: import.meta.env.VITE_APP_ENV,
|
|
80
|
+
service,
|
|
81
|
+
version: import.meta.env.VITE_APP_VERSION,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return orbitrace;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function useOrbitrace() {
|
|
88
|
+
const orbitrace = inject(ORBITRACE_KEY);
|
|
89
|
+
if (!orbitrace) {
|
|
90
|
+
throw new Error("Orbitrace not properly initialized");
|
|
91
|
+
}
|
|
92
|
+
return orbitrace;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 2. Setup in Main App
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
// main.js
|
|
100
|
+
import { createApp } from "vue";
|
|
101
|
+
import { createPinia } from "pinia";
|
|
102
|
+
import App from "./App.vue";
|
|
103
|
+
import { getOrbitraceInstance, ORBITRACE_KEY } from "/path/to/orbitrace";
|
|
104
|
+
|
|
105
|
+
const app = createApp(App);
|
|
106
|
+
const pinia = createPinia();
|
|
107
|
+
|
|
108
|
+
// Initialize Orbitrace
|
|
109
|
+
const orbitrace = getOrbitraceInstance({ service: "webapp" });
|
|
110
|
+
|
|
111
|
+
// Make Orbitrace available everywhere
|
|
112
|
+
app.provide(ORBITRACE_KEY, orbitrace);
|
|
113
|
+
|
|
114
|
+
// Add Orbitrace to Pinia
|
|
115
|
+
pinia.use(({ store }) => {
|
|
116
|
+
store.orbitrace = orbitrace;
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
app.use(pinia);
|
|
120
|
+
app.mount("#app");
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 3. Usage in Vue Components
|
|
124
|
+
|
|
125
|
+
```vue
|
|
126
|
+
<script setup>
|
|
127
|
+
import { useOrbitrace } from "/path/to/orbitrace";
|
|
128
|
+
|
|
129
|
+
const orbitrace = useOrbitrace();
|
|
130
|
+
|
|
131
|
+
async function handleUserAction() {
|
|
132
|
+
try {
|
|
133
|
+
// Your code here
|
|
134
|
+
} catch (error) {
|
|
135
|
+
await orbitrace.captureException(error, {
|
|
136
|
+
component: "UserProfile",
|
|
137
|
+
action: "updateProfile",
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Log custom events
|
|
143
|
+
async function trackEvent() {
|
|
144
|
+
await orbitrace.captureMessage("User completed onboarding", {
|
|
145
|
+
userId: "user123",
|
|
146
|
+
completedSteps: ["profile", "preferences"],
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
</script>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 4. Usage in Pinia Stores
|
|
153
|
+
|
|
154
|
+
```javascript
|
|
155
|
+
// stores/userStore.js
|
|
156
|
+
import { defineStore } from "pinia";
|
|
157
|
+
|
|
158
|
+
export const useUserStore = defineStore("user", {
|
|
159
|
+
state: () => ({
|
|
160
|
+
user: null,
|
|
161
|
+
}),
|
|
162
|
+
actions: {
|
|
163
|
+
async fetchUser() {
|
|
164
|
+
try {
|
|
165
|
+
// Fetch user logic
|
|
166
|
+
} catch (error) {
|
|
167
|
+
await this.orbitrace.captureException(error, {
|
|
168
|
+
store: "userStore",
|
|
169
|
+
action: "fetchUser",
|
|
170
|
+
});
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Environment Variables
|
|
179
|
+
|
|
180
|
+
For Vite:
|
|
181
|
+
|
|
182
|
+
```env
|
|
183
|
+
VITE_ORBITRACE_API_KEY=your-api-key
|
|
184
|
+
VITE_ORBITRACE_ORG_ID=your-org-id
|
|
185
|
+
VITE_ORBITRACE_PROJECT_ID=your-project-id
|
|
186
|
+
VITE_ORBITRACE_ENDPOINT=your-endpoint
|
|
187
|
+
VITE_APP_ENV=your-environment
|
|
188
|
+
VITE_APP_VERSION=your-version
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
For Node.js:
|
|
192
|
+
|
|
193
|
+
```env
|
|
194
|
+
ORBITRACE_API_KEY=your-api-key
|
|
195
|
+
ORBITRACE_ORG_ID=your-org-id
|
|
196
|
+
ORBITRACE_PROJECT_ID=your-project-id
|
|
197
|
+
ORBITRACE_ENDPOINT=your-endpoint
|
|
198
|
+
APP_ENV=your-environment
|
|
199
|
+
APP_VERSION=your-version
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
|