bugstash 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/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);