@monoscopetech/browser 0.4.3 → 0.4.4
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/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Monoscopetech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Monoscope Browser SDK
|
|
2
|
+
|
|
3
|
+
The **Monoscope Browser SDK** is a lightweight JavaScript library for adding **session replay**, **performance tracing**, and **frontend logging** to your web applications.
|
|
4
|
+
|
|
5
|
+
When used together with the [Monoscope Server SDKs](https://apitoolkit.io/docs/sdks/), you gain **end-to-end observability** — seamlessly connecting user interactions in the browser to backend services, APIs, and databases.
|
|
6
|
+
|
|
7
|
+
This means you can:
|
|
8
|
+
|
|
9
|
+
- **Replay user sessions** to see exactly what happened.
|
|
10
|
+
- **Trace requests** from the frontend, through your backend, and into your database.
|
|
11
|
+
- **Capture logs and errors** with full context for faster debugging.
|
|
12
|
+
|
|
13
|
+
With the sdk, you can seamlessly monitor how users interact with your app, measure performance, and gain insights into issues — all in one place.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Install via **npm/bun**:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @monoscopetech/browser
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or include it directly in your HTML using a `<script>` tag:
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<script src="https://unpkg.com/@monoscopetech/browser@latest/dist/monoscope.min.js"></script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
Initialize Monoscope with your **project ID** and configuration:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
import Monoscope from "@monoscopetech/browser";
|
|
39
|
+
|
|
40
|
+
const monoscope = new Monoscope({
|
|
41
|
+
projectId: "YOUR_PROJECT_ID",
|
|
42
|
+
serviceName: "my-web-app",
|
|
43
|
+
// ...other configuration options
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
The `Monoscope` constructor accepts the following options:
|
|
52
|
+
|
|
53
|
+
| Name | Type | Description |
|
|
54
|
+
| ------------------------------ | --------------------- | ---------------------------------------------------------------------------- |
|
|
55
|
+
| `projectId` | `string` | **Required** – Your Monoscope project ID. |
|
|
56
|
+
| `serviceName` | `string` | **Required** – Name of your service or application. |
|
|
57
|
+
| `exporterEndpoint` | `string` | Endpoint for exporting traces/logs. Defaults to Monoscope's ingest endpoint. |
|
|
58
|
+
| `propagateTraceHeaderCorsUrls` | `RegExp[]` | Array of regex patterns for URLs where trace headers should be propagated. |
|
|
59
|
+
| `resourceAttributes` | `Record<string, any>` | Additional resource-level attributes. |
|
|
60
|
+
| `instrumentations` | `any[]` | OpenTelemetry instrumentations to enable. |
|
|
61
|
+
| `replayEventsBaseUrl` | `string` | Base URL for session replay events. Defaults to Monoscope's ingest endpoint. |
|
|
62
|
+
| `user` | `MonoscopeUser` | Default user information for the session. |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### User Object
|
|
67
|
+
|
|
68
|
+
The `MonoscopeUser` object can contain:
|
|
69
|
+
|
|
70
|
+
| Name | Type | Description |
|
|
71
|
+
| ---------- | ---------- | ------------------------- |
|
|
72
|
+
| `email` | `string` | User's email address. |
|
|
73
|
+
| `fullName` | `string` | User's full name. |
|
|
74
|
+
| `name` | `string` | User's preferred name. |
|
|
75
|
+
| `id` | `string` | User's unique identifier. |
|
|
76
|
+
| `roles` | `string[]` | User's roles. |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## API
|
|
81
|
+
|
|
82
|
+
### `setUser(user: MonoscopeUser)`
|
|
83
|
+
|
|
84
|
+
Associates the given user with the current session.
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
monoscope.setUser({
|
|
88
|
+
id: "user-123",
|
|
89
|
+
email: "user@example.com",
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### `getSessionId(): string`
|
|
96
|
+
|
|
97
|
+
Retrieves the current session ID — useful for tagging custom spans or events.
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
const sessionId = monoscope.getSessionId();
|
|
101
|
+
console.log(sessionId);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
This SDK is licensed under the [MIT License](LICENSE).
|
package/dist/types.d.ts
CHANGED