@djangocfg/monitor 2.1.421 → 2.1.423

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/client.mjs CHANGED
@@ -192,6 +192,18 @@ function detectLocale() {
192
192
  }
193
193
  __name(detectLocale, "detectLocale");
194
194
  function defaultBaseUrl() {
195
+ if (typeof window !== "undefined") {
196
+ try {
197
+ if (typeof process !== "undefined" && process.env) {
198
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
199
+ if (process.env.NEXT_PUBLIC_API_PROXY_URL !== void 0)
200
+ return process.env.NEXT_PUBLIC_API_PROXY_URL;
201
+ return process.env.NEXT_PUBLIC_API_URL || "";
202
+ }
203
+ } catch {
204
+ }
205
+ return "";
206
+ }
195
207
  try {
196
208
  if (typeof process !== "undefined" && process.env) {
197
209
  if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
@@ -203,7 +215,6 @@ function defaultBaseUrl() {
203
215
  }
204
216
  __name(defaultBaseUrl, "defaultBaseUrl");
205
217
  function defaultApiKey() {
206
- if (isBrowser) return null;
207
218
  try {
208
219
  if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
209
220
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -359,7 +370,7 @@ function installAuthOnClient(client2) {
359
370
  const locale = auth.getLocale();
360
371
  if (locale) request.headers.set("Accept-Language", locale);
361
372
  const apiKey = auth.getApiKey();
362
- if (apiKey) request.headers.set("X-API-Key", apiKey);
373
+ if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
363
374
  try {
364
375
  const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
365
376
  if (tz) request.headers.set("X-Timezone", tz);
@@ -972,11 +983,8 @@ var checkForExistence = /* @__PURE__ */ __name((options, name) => {
972
983
  }
973
984
  return false;
974
985
  }, "checkForExistence");
975
- var setAuthParams = /* @__PURE__ */ __name(async ({
976
- security,
977
- ...options
978
- }) => {
979
- for (const auth2 of security) {
986
+ async function setAuthParams(options) {
987
+ for (const auth2 of options.security ?? []) {
980
988
  if (checkForExistence(options, auth2.name)) {
981
989
  continue;
982
990
  }
@@ -1001,7 +1009,8 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
1001
1009
  break;
1002
1010
  }
1003
1011
  }
1004
- }, "setAuthParams");
1012
+ }
1013
+ __name(setAuthParams, "setAuthParams");
1005
1014
  var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
1006
1015
  baseUrl: options.baseUrl,
1007
1016
  path: options.path,
@@ -1131,10 +1140,7 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1131
1140
  serializedBody: void 0
1132
1141
  };
1133
1142
  if (opts.security) {
1134
- await setAuthParams({
1135
- ...opts,
1136
- security: opts.security
1137
- });
1143
+ await setAuthParams(opts);
1138
1144
  }
1139
1145
  if (opts.requestValidator) {
1140
1146
  await opts.requestValidator(opts);
@@ -1449,7 +1455,7 @@ __name(sendBatch, "sendBatch");
1449
1455
  // src/client/utils/env.ts
1450
1456
  var isDevelopment = process.env.NODE_ENV === "development";
1451
1457
  var isProduction = !isDevelopment;
1452
- var MONITOR_VERSION = "2.1.421";
1458
+ var MONITOR_VERSION = "2.1.423";
1453
1459
 
1454
1460
  // src/client/constants.ts
1455
1461
  var MONITOR_INGEST_PATTERN = /cfg\/monitor\/ingest/;