@mynitorai/sdk 0.2.6 → 0.2.8

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 +21 -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,10 +26,15 @@ 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) {
34
+ const contentType = res.headers.get('content-type');
35
+ if (contentType && contentType.includes('text/html')) {
36
+ throw new Error('Received HTML response instead of JSON. You might be behind a login portal or proxy redirect.');
37
+ }
32
38
  const data = await res.json();
33
39
  console.log(`✅ Connection: MyNitor Cloud is reachable`);
34
40
  console.log(`✅ Organization: ${data.orgId || 'Verified'}`);
@@ -38,14 +44,22 @@ async function run() {
38
44
  }
39
45
  }
40
46
  catch (e) {
41
- console.error('❌ Connection: Failed to reach app.mynitor.ai');
47
+ console.error('❌ Connection: Failed to reach MyNitor Cloud');
48
+ console.error(` Error details: ${e.message || e}`);
49
+ if (e.code === 'ENOTFOUND')
50
+ console.log(' 💡 Suggestion: Check your internet connection or DNS settings.');
51
+ if (e.code === 'ECONNREFUSED')
52
+ console.log(' 💡 Suggestion: The server refused the connection. Is the API URL correct?');
53
+ if (e.message?.includes('certificate'))
54
+ console.log(' 💡 Suggestion: This looks like an SSL/Certificate issue.');
42
55
  }
43
56
  return;
44
57
  }
45
58
  if (command === 'mock') {
46
59
  console.log('🎭 MyNitor: Sending mock OpenAI event to Cloud API...');
47
60
  try {
48
- const response = await fetch('https://app.mynitor.ai/api/v1/events', {
61
+ const endpoint = `${BASE_URL}/api/v1/events`;
62
+ const response = await fetch(endpoint, {
49
63
  method: 'POST',
50
64
  headers: {
51
65
  'Content-Type': 'application/json',
@@ -75,7 +89,7 @@ async function run() {
75
89
  }
76
90
  }
77
91
  catch (error) {
78
- console.error('❌ Network Error:', error);
92
+ console.error('❌ Network Error:', error.message || error);
79
93
  }
80
94
  return;
81
95
  }
@@ -86,13 +100,7 @@ async function run() {
86
100
  apiKey,
87
101
  environment: 'onboarding-test'
88
102
  });
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';
103
+ const endpoint = `${BASE_URL}/api/v1/events`;
96
104
  const response = await fetch(endpoint, {
97
105
  method: 'POST',
98
106
  headers: {
@@ -124,12 +132,12 @@ async function run() {
124
132
  }
125
133
  catch (error) {
126
134
  console.error('❌ Network Error: Could not reach MyNitor Cloud.');
127
- console.error(error);
135
+ console.error(error.message || error);
128
136
  process.exit(1);
129
137
  }
130
138
  }
131
139
  else {
132
- console.log('Usage: npx @mynitorai/sdk ping');
140
+ console.log('Usage: npx @mynitorai/sdk [ping|doctor|mock]');
133
141
  }
134
142
  }
135
143
  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.8",
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
+ }