@codmir/sdk 0.1.1 → 0.1.2

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 CHANGED
@@ -1,20 +1,76 @@
1
1
  # @codmir/sdk
2
2
 
3
- Official TypeScript/JavaScript SDK for the Codmir API.
3
+ Official TypeScript/JavaScript SDK for the Codmir platform.
4
4
 
5
- > **Note:** For CLI usage, install the `codmir` package instead: `npm install -g codmir`
5
+ [![npm version](https://img.shields.io/npm/v/@codmir/sdk.svg)](https://www.npmjs.com/package/@codmir/sdk)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@codmir/sdk.svg)](https://www.npmjs.com/package/@codmir/sdk)
7
+
8
+ ## Features
9
+
10
+ - 🔍 **Error Tracking** - Capture and track errors with full context
11
+ - 🎬 **Session Replay** - Record and replay user sessions
12
+ - 📊 **Performance Monitoring** - Track Core Web Vitals
13
+ - 🤖 **AI Agent API** - Run automated tasks and workflows
14
+ - 📝 **Ticket Management** - Create and manage project tickets
6
15
 
7
16
  ## Installation
8
17
 
9
18
  ```bash
10
19
  npm install @codmir/sdk
11
- # or
12
- pnpm add @codmir/sdk
13
- # or
14
- yarn add @codmir/sdk
15
20
  ```
16
21
 
17
- ## Quick Start
22
+ ## Platform-Specific Imports
23
+
24
+ | Platform | Import |
25
+ |----------|--------|
26
+ | Next.js | `@codmir/sdk/nextjs` |
27
+ | React Native | `@codmir/sdk/react-native` |
28
+ | Browser (vanilla) | `@codmir/sdk/browser` |
29
+ | Node.js/Server | `@codmir/sdk/overseer` |
30
+ | API Client | `@codmir/sdk` or `@codmir/sdk/client` |
31
+
32
+ ## Quick Start - Error Tracking
33
+
34
+ ### Next.js
35
+
36
+ ```typescript
37
+ // instrumentation-client.ts
38
+ import * as Codmir from '@codmir/sdk/nextjs';
39
+
40
+ Codmir.init({
41
+ dsn: process.env.NEXT_PUBLIC_OVERSEER_DSN,
42
+ environment: process.env.NODE_ENV,
43
+ release: process.env.NEXT_PUBLIC_APP_VERSION,
44
+ });
45
+ ```
46
+
47
+ ### React Native
48
+
49
+ ```typescript
50
+ // App.tsx
51
+ import * as Codmir from '@codmir/sdk/react-native';
52
+
53
+ Codmir.init({
54
+ dsn: 'https://your-project.codmir.com/api/overseer',
55
+ });
56
+
57
+ // Track screen views
58
+ Codmir.trackScreenView('HomeScreen');
59
+ ```
60
+
61
+ ### Browser (Vanilla JS)
62
+
63
+ ```typescript
64
+ import { init, captureException } from '@codmir/sdk/browser';
65
+
66
+ init({
67
+ dsn: 'https://your-project.codmir.com/api/overseer',
68
+ trackClicks: true,
69
+ trackRequests: true,
70
+ });
71
+ ```
72
+
73
+ ## Quick Start - API Client
18
74
 
19
75
  ```typescript
20
76
  import { CodmirClient } from '@codmir/sdk';
@@ -43,6 +43,8 @@ var OverseerClient = class {
43
43
  eventQueue = [];
44
44
  flushTimer = null;
45
45
  isInitialized = false;
46
+ conversationId = null;
47
+ sessionId = null;
46
48
  constructor(config = {}) {
47
49
  this.config = {
48
50
  dsn: config.dsn || "",
@@ -94,11 +96,19 @@ var OverseerClient = class {
94
96
  },
95
97
  user: this.user || void 0,
96
98
  tags: { ...this.tags },
97
- extra: context,
99
+ extra: {
100
+ ...context,
101
+ conversationId: this.conversationId,
102
+ sessionId: this.sessionId
103
+ },
98
104
  breadcrumbs: [...this.breadcrumbs],
99
105
  environment: this.config.environment,
100
106
  release: this.config.release,
101
- sdk: { name: "@codmir/sdk", version: "1.0.0" }
107
+ sdk: { name: "@codmir/sdk", version: "1.0.0" },
108
+ contexts: {
109
+ conversation: this.conversationId ? { id: this.conversationId } : void 0,
110
+ session: this.sessionId ? { id: this.sessionId } : void 0
111
+ }
102
112
  };
103
113
  this.sendEvent(event);
104
114
  return eventId;
@@ -134,6 +144,18 @@ var OverseerClient = class {
134
144
  }
135
145
  setExtra(key, value) {
136
146
  }
147
+ setConversationId(conversationId) {
148
+ this.conversationId = conversationId;
149
+ }
150
+ getConversationId() {
151
+ return this.conversationId;
152
+ }
153
+ setSessionId(sessionId) {
154
+ this.sessionId = sessionId;
155
+ }
156
+ getSessionId() {
157
+ return this.sessionId;
158
+ }
137
159
  addBreadcrumb(breadcrumb) {
138
160
  this.breadcrumbs.push({
139
161
  ...breadcrumb,
@@ -8,7 +8,7 @@ import {
8
8
  init,
9
9
  setTags,
10
10
  setUser
11
- } from "../chunk-T7OAAOG2.js";
11
+ } from "../chunk-4W5YK72Y.js";
12
12
  import "../chunk-MLKGABMK.js";
13
13
 
14
14
  // src/browser/index.ts
@@ -12,7 +12,11 @@ __export(overseer_exports, {
12
12
  close: () => close,
13
13
  flush: () => flush,
14
14
  getClient: () => getClient,
15
+ getConversationId: () => getConversationId,
16
+ getSessionId: () => getSessionId,
15
17
  init: () => init,
18
+ setConversationId: () => setConversationId,
19
+ setSessionId: () => setSessionId,
16
20
  setTag: () => setTag,
17
21
  setTags: () => setTags,
18
22
  setUser: () => setUser
@@ -26,6 +30,8 @@ var OverseerClient = class {
26
30
  eventQueue = [];
27
31
  flushTimer = null;
28
32
  isInitialized = false;
33
+ conversationId = null;
34
+ sessionId = null;
29
35
  constructor(config = {}) {
30
36
  this.config = {
31
37
  dsn: config.dsn || "",
@@ -77,11 +83,19 @@ var OverseerClient = class {
77
83
  },
78
84
  user: this.user || void 0,
79
85
  tags: { ...this.tags },
80
- extra: context,
86
+ extra: {
87
+ ...context,
88
+ conversationId: this.conversationId,
89
+ sessionId: this.sessionId
90
+ },
81
91
  breadcrumbs: [...this.breadcrumbs],
82
92
  environment: this.config.environment,
83
93
  release: this.config.release,
84
- sdk: { name: "@codmir/sdk", version: "1.0.0" }
94
+ sdk: { name: "@codmir/sdk", version: "1.0.0" },
95
+ contexts: {
96
+ conversation: this.conversationId ? { id: this.conversationId } : void 0,
97
+ session: this.sessionId ? { id: this.sessionId } : void 0
98
+ }
85
99
  };
86
100
  this.sendEvent(event);
87
101
  return eventId;
@@ -117,6 +131,18 @@ var OverseerClient = class {
117
131
  }
118
132
  setExtra(key, value) {
119
133
  }
134
+ setConversationId(conversationId) {
135
+ this.conversationId = conversationId;
136
+ }
137
+ getConversationId() {
138
+ return this.conversationId;
139
+ }
140
+ setSessionId(sessionId) {
141
+ this.sessionId = sessionId;
142
+ }
143
+ getSessionId() {
144
+ return this.sessionId;
145
+ }
120
146
  addBreadcrumb(breadcrumb) {
121
147
  this.breadcrumbs.push({
122
148
  ...breadcrumb,
@@ -218,6 +244,18 @@ function flush(timeout) {
218
244
  function close() {
219
245
  client?.close();
220
246
  }
247
+ function setConversationId(conversationId) {
248
+ client?.setConversationId(conversationId);
249
+ }
250
+ function getConversationId() {
251
+ return client?.getConversationId() || null;
252
+ }
253
+ function setSessionId(sessionId) {
254
+ client?.setSessionId(sessionId);
255
+ }
256
+ function getSessionId() {
257
+ return client?.getSessionId() || null;
258
+ }
221
259
 
222
260
  export {
223
261
  OverseerClient,
@@ -231,5 +269,9 @@ export {
231
269
  addBreadcrumb,
232
270
  flush,
233
271
  close,
272
+ setConversationId,
273
+ getConversationId,
274
+ setSessionId,
275
+ getSessionId,
234
276
  overseer_exports
235
277
  };