bugstash 0.1.1 → 0.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 CHANGED
@@ -37,7 +37,6 @@ import BugStash from 'bugstash';
37
37
 
38
38
  BugStash.init({
39
39
  projectId: 'your-project-id',
40
- endpoint: 'https://bugstash-backend.azurewebsites.net',
41
40
  environment: 'development', // auto-disabled in 'production'
42
41
  });
43
42
  ```
@@ -54,7 +53,6 @@ BugStash.init({
54
53
  projectId: 'your-project-id',
55
54
 
56
55
  // Optional
57
- endpoint: 'https://bugstash-backend.azurewebsites.net',
58
56
  environment: 'development', // 'development' | 'staging' | 'production'
59
57
  panelPosition: 'bottom-right', // 'bottom-right' | 'bottom-left'
60
58
 
@@ -195,7 +193,6 @@ export function BugStashProvider({ children }: { children: React.ReactNode }) {
195
193
  useEffect(() => {
196
194
  BugStash.init({
197
195
  projectId: process.env.NEXT_PUBLIC_BUGSTASH_PROJECT_ID!,
198
- endpoint: 'https://bugstash-backend.azurewebsites.net',
199
196
  environment: process.env.NODE_ENV as any,
200
197
  });
201
198
  return () => BugStash.destroy();
@@ -228,7 +225,6 @@ import BugStash from 'bugstash';
228
225
 
229
226
  BugStash.init({
230
227
  projectId: import.meta.env.VITE_BUGSTASH_PROJECT_ID,
231
- endpoint: 'https://bugstash-backend.azurewebsites.net',
232
228
  environment: import.meta.env.MODE,
233
229
  });
234
230
  ```
@@ -241,7 +237,6 @@ import BugStash from 'bugstash';
241
237
 
242
238
  BugStash.init({
243
239
  projectId: process.env.REACT_APP_BUGSTASH_PROJECT_ID!,
244
- endpoint: 'https://bugstash-backend.azurewebsites.net',
245
240
  environment: process.env.NODE_ENV,
246
241
  });
247
242
  ```
package/dist/index.cjs CHANGED
@@ -5077,11 +5077,24 @@ function cleanup() {
5077
5077
 
5078
5078
  // src/index.ts
5079
5079
  var initialized = false;
5080
+ function detectEnvironment() {
5081
+ if (typeof window === "undefined") return "production";
5082
+ const host = window.location.hostname;
5083
+ if (host === "localhost" || host === "127.0.0.1" || host === "0.0.0.0" || host.endsWith(".local") || /^192\.168\./.test(host) || /^10\./.test(host) || /^172\.(1[6-9]|2\d|3[01])\./.test(host)) return "development";
5084
+ if (host.includes("staging") || host.includes("stage") || host.includes("preview") || host.includes("preprod") || host.includes("pre-prod") || host.includes("qa.") || host.includes(".qa") || host.includes("test.") || host.includes(".dev.") || host.includes("vercel.app") || // Vercel preview deployments
5085
+ host.includes("netlify.app") || // Netlify preview deployments
5086
+ host.includes("pages.dev") || // Cloudflare Pages previews
5087
+ host.includes("ngrok.io") || // ngrok tunnels
5088
+ host.includes("ngrok-free.app") || // ngrok free tier
5089
+ host.includes("localhost.run") || // localhost.run tunnels
5090
+ host.includes("loca.lt")) return "staging";
5091
+ return "production";
5092
+ }
5080
5093
  var BugStash = {
5081
5094
  init(options) {
5082
5095
  if (initialized) return;
5083
5096
  if (typeof window === "undefined") return;
5084
- const env = options.environment ?? "development";
5097
+ const env = options.environment ?? detectEnvironment();
5085
5098
  if (env === "production") return;
5086
5099
  initialized = true;
5087
5100
  if (options.endpoint) setEndpoint(options.endpoint);