@mynitorai/sdk 0.2.6 → 0.2.7

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.
Files changed (2) hide show
  1. package/dist/cli.js +17 -13
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -11,6 +11,7 @@ async function run() {
11
11
  process.exit(1);
12
12
  }
13
13
  const command = process.argv[2];
14
+ const BASE_URL = process.env.MYNITOR_API_URL || 'https://app.mynitor.ai';
14
15
  if (command === 'doctor') {
15
16
  const pkg = require('../package.json');
16
17
  console.log(`🩺 MyNitor Doctor (v${pkg.version})`);
@@ -25,7 +26,8 @@ async function run() {
25
26
  }
26
27
  try {
27
28
  console.log('📡 Testing Connection...');
28
- const res = await fetch('https://app.mynitor.ai/api/v1/onboarding/status', {
29
+ const endpoint = `${BASE_URL}/api/v1/onboarding/status`;
30
+ const res = await fetch(endpoint, {
29
31
  headers: { 'Authorization': `Bearer ${apiKey}` }
30
32
  });
31
33
  if (res.ok) {
@@ -38,14 +40,22 @@ async function run() {
38
40
  }
39
41
  }
40
42
  catch (e) {
41
- console.error('❌ Connection: Failed to reach app.mynitor.ai');
43
+ console.error('❌ Connection: Failed to reach MyNitor Cloud');
44
+ console.error(` Error details: ${e.message || e}`);
45
+ if (e.code === 'ENOTFOUND')
46
+ console.log(' 💡 Suggestion: Check your internet connection or DNS settings.');
47
+ if (e.code === 'ECONNREFUSED')
48
+ console.log(' 💡 Suggestion: The server refused the connection. Is the API URL correct?');
49
+ if (e.message?.includes('certificate'))
50
+ console.log(' 💡 Suggestion: This looks like an SSL/Certificate issue.');
42
51
  }
43
52
  return;
44
53
  }
45
54
  if (command === 'mock') {
46
55
  console.log('🎭 MyNitor: Sending mock OpenAI event to Cloud API...');
47
56
  try {
48
- const response = await fetch('https://app.mynitor.ai/api/v1/events', {
57
+ const endpoint = `${BASE_URL}/api/v1/events`;
58
+ const response = await fetch(endpoint, {
49
59
  method: 'POST',
50
60
  headers: {
51
61
  'Content-Type': 'application/json',
@@ -75,7 +85,7 @@ async function run() {
75
85
  }
76
86
  }
77
87
  catch (error) {
78
- console.error('❌ Network Error:', error);
88
+ console.error('❌ Network Error:', error.message || error);
79
89
  }
80
90
  return;
81
91
  }
@@ -86,13 +96,7 @@ async function run() {
86
96
  apiKey,
87
97
  environment: 'onboarding-test'
88
98
  });
89
- // Trigger a manual event to verify connection
90
- // We use a custom internal method or just a standard track if available
91
- // In the current SDK, we can use the private sendEvent if it were public,
92
- // or just trigger instrument() and a small log.
93
- // For now, let's just use a fetch directly to verify connectivity
94
- // and trigger the onboarding checkmark.
95
- const endpoint = 'https://app.mynitor.ai/api/v1/events';
99
+ const endpoint = `${BASE_URL}/api/v1/events`;
96
100
  const response = await fetch(endpoint, {
97
101
  method: 'POST',
98
102
  headers: {
@@ -124,12 +128,12 @@ async function run() {
124
128
  }
125
129
  catch (error) {
126
130
  console.error('❌ Network Error: Could not reach MyNitor Cloud.');
127
- console.error(error);
131
+ console.error(error.message || error);
128
132
  process.exit(1);
129
133
  }
130
134
  }
131
135
  else {
132
- console.log('Usage: npx @mynitorai/sdk ping');
136
+ console.log('Usage: npx @mynitorai/sdk [ping|doctor|mock]');
133
137
  }
134
138
  }
135
139
  run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mynitorai/sdk",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Production safety and observability for AI systems.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -33,4 +33,4 @@
33
33
  "openai": "^4.0.0",
34
34
  "@types/node": "^20.0.0"
35
35
  }
36
- }
36
+ }