keystone-design-bootstrap 1.0.98 → 1.0.100

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
@@ -88,7 +88,9 @@ import { resourceFromAttributes } from "@opentelemetry/resources";
88
88
  import { BatchLogRecordProcessor, LoggerProvider } from "@opentelemetry/sdk-logs";
89
89
  var BUILD_CONSOLE_DISABLED = process.env.NEXT_PUBLIC_LOGGING_DISABLED === "1";
90
90
  var BUILD_POSTHOG_DISABLED = process.env.NEXT_PUBLIC_POSTHOG_LOGGING_DISABLED === "1";
91
+ var MAX_PENDING_POSTHOG_LOGS = 500;
91
92
  var otelLogger = null;
93
+ var pendingPostHogLogs = [];
92
94
  var browserConsole = globalThis == null ? void 0 : globalThis["console"];
93
95
  var CHANNEL_COLORS = {
94
96
  // Shared diagnostics
@@ -130,6 +132,12 @@ function flattenAttributes(input, prefix = "") {
130
132
  }
131
133
  return output;
132
134
  }
135
+ function enqueuePendingPostHogLog(entry) {
136
+ if (pendingPostHogLogs.length >= MAX_PENDING_POSTHOG_LOGS) {
137
+ pendingPostHogLogs.shift();
138
+ }
139
+ pendingPostHogLogs.push(entry);
140
+ }
133
141
  function isConsoleEnabled() {
134
142
  if (BUILD_CONSOLE_DISABLED) return false;
135
143
  if (typeof window === "undefined") return true;
@@ -162,7 +170,7 @@ function emitConsole(level, channel, event, detail) {
162
170
  (_d = browserConsole == null ? void 0 : browserConsole.log) == null ? void 0 : _d.call(browserConsole, message, channelStyle, eventStyle, detailStyle);
163
171
  }
164
172
  function emitToPostHog(level, channel, event, detail) {
165
- if (!otelLogger) return;
173
+ if (!otelLogger) return false;
166
174
  const severityText = level === "warn" ? "WARNING" : level === "error" ? "ERROR" : "INFO";
167
175
  const attributes = flattenAttributes(__spreadValues({ channel }, detail));
168
176
  otelLogger.emit({
@@ -170,6 +178,7 @@ function emitToPostHog(level, channel, event, detail) {
170
178
  body: event,
171
179
  attributes
172
180
  });
181
+ return true;
173
182
  }
174
183
  function emit(level, channel, event, detail, options) {
175
184
  var _a;
@@ -178,7 +187,10 @@ function emit(level, channel, event, detail, options) {
178
187
  emitConsole(level, channel, event, detail);
179
188
  }
180
189
  if (shouldShip) {
181
- emitToPostHog(level, channel, event, detail);
190
+ const shipped = emitToPostHog(level, channel, event, detail);
191
+ if (!shipped) {
192
+ enqueuePendingPostHogLog({ level, channel, event, detail });
193
+ }
182
194
  }
183
195
  }
184
196
  function log(channel, event, detail = {}, options) {