@djangocfg/monitor 2.1.420 → 2.1.422

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.cjs CHANGED
@@ -226,6 +226,18 @@ function detectLocale() {
226
226
  }
227
227
  __name(detectLocale, "detectLocale");
228
228
  function defaultBaseUrl() {
229
+ if (typeof window !== "undefined") {
230
+ try {
231
+ if (typeof process !== "undefined" && process.env) {
232
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
233
+ if (process.env.NEXT_PUBLIC_API_PROXY_URL !== void 0)
234
+ return process.env.NEXT_PUBLIC_API_PROXY_URL;
235
+ return process.env.NEXT_PUBLIC_API_URL || "";
236
+ }
237
+ } catch {
238
+ }
239
+ return "";
240
+ }
229
241
  try {
230
242
  if (typeof process !== "undefined" && process.env) {
231
243
  if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
@@ -237,7 +249,6 @@ function defaultBaseUrl() {
237
249
  }
238
250
  __name(defaultBaseUrl, "defaultBaseUrl");
239
251
  function defaultApiKey() {
240
- if (isBrowser) return null;
241
252
  try {
242
253
  if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
243
254
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -393,7 +404,7 @@ function installAuthOnClient(client2) {
393
404
  const locale = auth.getLocale();
394
405
  if (locale) request.headers.set("Accept-Language", locale);
395
406
  const apiKey = auth.getApiKey();
396
- if (apiKey) request.headers.set("X-API-Key", apiKey);
407
+ if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
397
408
  try {
398
409
  const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
399
410
  if (tz) request.headers.set("X-Timezone", tz);
@@ -1006,11 +1017,8 @@ var checkForExistence = /* @__PURE__ */ __name((options, name) => {
1006
1017
  }
1007
1018
  return false;
1008
1019
  }, "checkForExistence");
1009
- var setAuthParams = /* @__PURE__ */ __name(async ({
1010
- security,
1011
- ...options
1012
- }) => {
1013
- for (const auth2 of security) {
1020
+ async function setAuthParams(options) {
1021
+ for (const auth2 of options.security ?? []) {
1014
1022
  if (checkForExistence(options, auth2.name)) {
1015
1023
  continue;
1016
1024
  }
@@ -1035,7 +1043,8 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
1035
1043
  break;
1036
1044
  }
1037
1045
  }
1038
- }, "setAuthParams");
1046
+ }
1047
+ __name(setAuthParams, "setAuthParams");
1039
1048
  var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
1040
1049
  baseUrl: options.baseUrl,
1041
1050
  path: options.path,
@@ -1165,10 +1174,7 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1165
1174
  serializedBody: void 0
1166
1175
  };
1167
1176
  if (opts.security) {
1168
- await setAuthParams({
1169
- ...opts,
1170
- security: opts.security
1171
- });
1177
+ await setAuthParams(opts);
1172
1178
  }
1173
1179
  if (opts.requestValidator) {
1174
1180
  await opts.requestValidator(opts);
@@ -1483,7 +1489,7 @@ __name(sendBatch, "sendBatch");
1483
1489
  // src/client/utils/env.ts
1484
1490
  var isDevelopment = process.env.NODE_ENV === "development";
1485
1491
  var isProduction = !isDevelopment;
1486
- var MONITOR_VERSION = "2.1.420";
1492
+ var MONITOR_VERSION = "2.1.422";
1487
1493
 
1488
1494
  // src/client/constants.ts
1489
1495
  var MONITOR_INGEST_PATTERN = /cfg\/monitor\/ingest/;