keystone-design-bootstrap 1.0.97 → 1.0.99

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.
@@ -64,6 +64,130 @@ function getThemedComponent(componentName, theme = "classic") {
64
64
 
65
65
  // src/contexts/ThemeContext.tsx
66
66
  import { createContext, useContext } from "react";
67
+
68
+ // src/tracking/logging.ts
69
+ import { logs } from "@opentelemetry/api-logs";
70
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
71
+ import { resourceFromAttributes } from "@opentelemetry/resources";
72
+ import { BatchLogRecordProcessor, LoggerProvider } from "@opentelemetry/sdk-logs";
73
+ var BUILD_CONSOLE_DISABLED = process.env.NEXT_PUBLIC_LOGGING_DISABLED === "1";
74
+ var BUILD_POSTHOG_DISABLED = process.env.NEXT_PUBLIC_POSTHOG_LOGGING_DISABLED === "1";
75
+ var MAX_PENDING_POSTHOG_LOGS = 500;
76
+ var otelLogger = null;
77
+ var pendingPostHogLogs = [];
78
+ var browserConsole = globalThis == null ? void 0 : globalThis["console"];
79
+ var CHANNEL_COLORS = {
80
+ // Shared diagnostics
81
+ "global-client": "#d2a8ff",
82
+ // Section pins (desktop)
83
+ "every-channel-pin": "#9febd7",
84
+ "hero-pin": "#6ecc8b",
85
+ "pricing-pin": "#399587",
86
+ "product-screens-pin": "#4fafa0",
87
+ "social-proof-pin": "#ffbb8a",
88
+ "value-props-pin": "#e0a733",
89
+ "work-pin": "#f57e56",
90
+ // Section pins (mobile)
91
+ "mobile-every-channel-pin": "#7ed9c6",
92
+ "mobile-hero-pin": "#f0eee6",
93
+ "mobile-pricing-pin": "#80d4ff",
94
+ "mobile-product-screens-pin": "#3a9085",
95
+ "mobile-social-proof-pin": "#ffd580",
96
+ "mobile-value-props-pin": "#4fafa0"
97
+ };
98
+ function flattenAttributes(input, prefix = "") {
99
+ const output = {};
100
+ for (const [key, value] of Object.entries(input)) {
101
+ const nextKey = prefix ? `${prefix}.${key}` : key;
102
+ if (value === null || value === void 0) continue;
103
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
104
+ output[nextKey] = value;
105
+ continue;
106
+ }
107
+ if (Array.isArray(value)) {
108
+ output[nextKey] = JSON.stringify(value);
109
+ continue;
110
+ }
111
+ if (typeof value === "object") {
112
+ Object.assign(output, flattenAttributes(value, nextKey));
113
+ continue;
114
+ }
115
+ output[nextKey] = String(value);
116
+ }
117
+ return output;
118
+ }
119
+ function enqueuePendingPostHogLog(entry) {
120
+ if (pendingPostHogLogs.length >= MAX_PENDING_POSTHOG_LOGS) {
121
+ pendingPostHogLogs.shift();
122
+ }
123
+ pendingPostHogLogs.push(entry);
124
+ }
125
+ function isConsoleEnabled() {
126
+ if (BUILD_CONSOLE_DISABLED) return false;
127
+ if (typeof window === "undefined") return true;
128
+ return window.__loggingDisabled !== true;
129
+ }
130
+ function isPostHogShippingEnabled() {
131
+ if (BUILD_POSTHOG_DISABLED) return false;
132
+ if (typeof window === "undefined") return false;
133
+ return window.__posthogLoggingDisabled !== true;
134
+ }
135
+ function formatDetail(detail) {
136
+ return Object.entries(detail).map(([k, v]) => `${k}=${typeof v === "number" ? v.toFixed(4) : String(v)}`).join(" ");
137
+ }
138
+ function emitConsole(level, channel, event, detail) {
139
+ var _a, _b, _c, _d;
140
+ const color2 = (_a = CHANNEL_COLORS[channel]) != null ? _a : "#aaa";
141
+ const detailStr = formatDetail(detail);
142
+ const message = `%c[${channel}] %c${event}%c ${detailStr}`;
143
+ const channelStyle = `color:${color2}; font-weight:bold`;
144
+ const eventStyle = level === "error" ? "color:#e94e4e; font-weight:bold" : level === "warn" ? "color:#f5a623; font-weight:bold" : "color:#fff; font-weight:bold";
145
+ const detailStyle = "color:#999; font-weight:normal";
146
+ if (level === "error") {
147
+ (_b = browserConsole == null ? void 0 : browserConsole.error) == null ? void 0 : _b.call(browserConsole, message, channelStyle, eventStyle, detailStyle);
148
+ return;
149
+ }
150
+ if (level === "warn") {
151
+ (_c = browserConsole == null ? void 0 : browserConsole.warn) == null ? void 0 : _c.call(browserConsole, message, channelStyle, eventStyle, detailStyle);
152
+ return;
153
+ }
154
+ (_d = browserConsole == null ? void 0 : browserConsole.log) == null ? void 0 : _d.call(browserConsole, message, channelStyle, eventStyle, detailStyle);
155
+ }
156
+ function emitToPostHog(level, channel, event, detail) {
157
+ if (!otelLogger) return false;
158
+ const severityText = level === "warn" ? "WARNING" : level === "error" ? "ERROR" : "INFO";
159
+ const attributes = flattenAttributes(__spreadValues({ channel }, detail));
160
+ otelLogger.emit({
161
+ severityText,
162
+ body: event,
163
+ attributes
164
+ });
165
+ return true;
166
+ }
167
+ function emit(level, channel, event, detail, options) {
168
+ var _a;
169
+ const shouldShip = ((_a = options == null ? void 0 : options.shipToPostHog) != null ? _a : level !== "info") && isPostHogShippingEnabled();
170
+ if (level !== "info" || isConsoleEnabled()) {
171
+ emitConsole(level, channel, event, detail);
172
+ }
173
+ if (shouldShip) {
174
+ const shipped = emitToPostHog(level, channel, event, detail);
175
+ if (!shipped) {
176
+ enqueuePendingPostHogLog({ level, channel, event, detail });
177
+ }
178
+ }
179
+ }
180
+ function log(channel, event, detail = {}, options) {
181
+ emit("info", channel, event, detail, options);
182
+ }
183
+ function warn(channel, event, detail = {}, options) {
184
+ emit("warn", channel, event, detail, options);
185
+ }
186
+ function error(channel, event, detail = {}, options) {
187
+ emit("error", channel, event, detail, options);
188
+ }
189
+
190
+ // src/contexts/ThemeContext.tsx
67
191
  var ThemeContext = createContext({ theme: "classic" });
68
192
  function useTheme() {
69
193
  return useContext(ThemeContext);
@@ -2407,7 +2531,9 @@ function GoogleMap({ address, locationName, className = "" }) {
2407
2531
  return;
2408
2532
  }
2409
2533
  if (!window.google.maps.Geocoder) {
2410
- console.warn("Google Maps Geocoder not yet available, retrying...");
2534
+ warn("google-map", "GEOCODER_NOT_READY_RETRYING", {
2535
+ address
2536
+ });
2411
2537
  setTimeout(() => {
2412
2538
  var _a, _b;
2413
2539
  if (mapRef.current && ((_b = (_a = window.google) == null ? void 0 : _a.maps) == null ? void 0 : _b.Geocoder) && initMapRef.current) {
@@ -2465,8 +2591,12 @@ function GoogleMap({ address, locationName, className = "" }) {
2465
2591
  }
2466
2592
  isInitializingRef.current = false;
2467
2593
  });
2468
- } catch (error) {
2469
- console.error("Error initializing map:", error);
2594
+ } catch (error2) {
2595
+ error("google-map", "MAP_INITIALIZATION_FAILED", {
2596
+ address,
2597
+ message: error2 instanceof Error ? error2.message : String(error2),
2598
+ stack: error2 instanceof Error ? error2.stack || "" : ""
2599
+ });
2470
2600
  setMapError("Error loading map. Please try again later.");
2471
2601
  isInitializingRef.current = false;
2472
2602
  }
@@ -6264,7 +6394,7 @@ async function setPixelUserData(userData) {
6264
6394
  function firePixelEvent(event, params, eventId) {
6265
6395
  const fbq = getFbq();
6266
6396
  if (!fbq) {
6267
- console.debug("[MetaPixel] skipped \u2014 fbq not loaded", { event });
6397
+ warn("meta-pixel", "PIXEL_EVENT_SKIPPED_FBQ_NOT_LOADED", { event });
6268
6398
  return;
6269
6399
  }
6270
6400
  applyStoredUserData(fbq);
@@ -6273,7 +6403,9 @@ function firePixelEvent(event, params, eventId) {
6273
6403
  if (params == null ? void 0 : params.contentCategory) normalized.content_category = params.contentCategory;
6274
6404
  const customData = Object.keys(normalized).length > 0 ? normalized : void 0;
6275
6405
  const eventData = eventId ? { eventID: eventId } : void 0;
6276
- console.debug("[MetaPixel]", event, normalized, eventId ? { eventID: eventId } : "");
6406
+ log("meta-pixel", "PIXEL_EVENT_FIRED", __spreadValues(__spreadValues({
6407
+ event
6408
+ }, normalized), eventId ? { eventId } : {}), { shipToPostHog: true });
6277
6409
  fbq("track", event, customData, eventData);
6278
6410
  }
6279
6411
 
@@ -7907,7 +8039,10 @@ var BlogPostSection = ({
7907
8039
  setCopied(true);
7908
8040
  setTimeout(() => setCopied(false), 2e3);
7909
8041
  } catch (err) {
7910
- console.error("Failed to copy:", err);
8042
+ error("blog-post", "COPY_LINK_FAILED", {
8043
+ message: err instanceof Error ? err.message : String(err),
8044
+ stack: err instanceof Error ? err.stack || "" : ""
8045
+ });
7911
8046
  }
7912
8047
  };
7913
8048
  const handleShareLink = () => {
@@ -7916,7 +8051,10 @@ var BlogPostSection = ({
7916
8051
  title: blogPost == null ? void 0 : blogPost.title,
7917
8052
  url: window.location.href
7918
8053
  }).catch((err) => {
7919
- console.error("Error sharing:", err);
8054
+ error("blog-post", "SHARE_LINK_FAILED", {
8055
+ message: err instanceof Error ? err.message : String(err),
8056
+ stack: err instanceof Error ? err.stack || "" : ""
8057
+ });
7920
8058
  });
7921
8059
  } else {
7922
8060
  handleCopyLink();
@@ -7979,7 +8117,10 @@ var BlogPostSection = ({
7979
8117
  onSubmit: (e) => {
7980
8118
  e.preventDefault();
7981
8119
  const formData = new FormData(e.currentTarget);
7982
- console.log("Form data:", formData);
8120
+ const email = formData.get("email");
8121
+ log("blog-post", "NEWSLETTER_FORM_SUBMIT", {
8122
+ email: typeof email === "string" ? email : ""
8123
+ }, { shipToPostHog: true });
7983
8124
  },
7984
8125
  className: "flex flex-col gap-4"
7985
8126
  },
@@ -8390,7 +8531,7 @@ var HomeHeroComponent = ({
8390
8531
  if (onEmailSubmit) {
8391
8532
  onEmailSubmit(email);
8392
8533
  } else {
8393
- console.log("Email signup:", email);
8534
+ log("home-hero", "EMAIL_SIGNUP_SUBMIT", { email }, { shipToPostHog: true });
8394
8535
  }
8395
8536
  },
8396
8537
  className: "mt-8 flex w-full flex-col items-stretch gap-4 md:mt-12 md:max-w-120 md:flex-row md:items-start"