bugstash 0.1.0 → 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.js CHANGED
@@ -5040,11 +5040,24 @@ function cleanup() {
5040
5040
 
5041
5041
  // src/index.ts
5042
5042
  var initialized = false;
5043
+ function detectEnvironment() {
5044
+ if (typeof window === "undefined") return "production";
5045
+ const host = window.location.hostname;
5046
+ 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";
5047
+ 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
5048
+ host.includes("netlify.app") || // Netlify preview deployments
5049
+ host.includes("pages.dev") || // Cloudflare Pages previews
5050
+ host.includes("ngrok.io") || // ngrok tunnels
5051
+ host.includes("ngrok-free.app") || // ngrok free tier
5052
+ host.includes("localhost.run") || // localhost.run tunnels
5053
+ host.includes("loca.lt")) return "staging";
5054
+ return "production";
5055
+ }
5043
5056
  var BugStash = {
5044
5057
  init(options) {
5045
5058
  if (initialized) return;
5046
5059
  if (typeof window === "undefined") return;
5047
- const env = options.environment ?? "development";
5060
+ const env = options.environment ?? detectEnvironment();
5048
5061
  if (env === "production") return;
5049
5062
  initialized = true;
5050
5063
  if (options.endpoint) setEndpoint(options.endpoint);