keystone-design-bootstrap 1.0.96 → 1.0.98

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,118 @@ 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 otelLogger = null;
76
+ var browserConsole = globalThis == null ? void 0 : globalThis["console"];
77
+ var CHANNEL_COLORS = {
78
+ // Shared diagnostics
79
+ "global-client": "#d2a8ff",
80
+ // Section pins (desktop)
81
+ "every-channel-pin": "#9febd7",
82
+ "hero-pin": "#6ecc8b",
83
+ "pricing-pin": "#399587",
84
+ "product-screens-pin": "#4fafa0",
85
+ "social-proof-pin": "#ffbb8a",
86
+ "value-props-pin": "#e0a733",
87
+ "work-pin": "#f57e56",
88
+ // Section pins (mobile)
89
+ "mobile-every-channel-pin": "#7ed9c6",
90
+ "mobile-hero-pin": "#f0eee6",
91
+ "mobile-pricing-pin": "#80d4ff",
92
+ "mobile-product-screens-pin": "#3a9085",
93
+ "mobile-social-proof-pin": "#ffd580",
94
+ "mobile-value-props-pin": "#4fafa0"
95
+ };
96
+ function flattenAttributes(input, prefix = "") {
97
+ const output = {};
98
+ for (const [key, value] of Object.entries(input)) {
99
+ const nextKey = prefix ? `${prefix}.${key}` : key;
100
+ if (value === null || value === void 0) continue;
101
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
102
+ output[nextKey] = value;
103
+ continue;
104
+ }
105
+ if (Array.isArray(value)) {
106
+ output[nextKey] = JSON.stringify(value);
107
+ continue;
108
+ }
109
+ if (typeof value === "object") {
110
+ Object.assign(output, flattenAttributes(value, nextKey));
111
+ continue;
112
+ }
113
+ output[nextKey] = String(value);
114
+ }
115
+ return output;
116
+ }
117
+ function isConsoleEnabled() {
118
+ if (BUILD_CONSOLE_DISABLED) return false;
119
+ if (typeof window === "undefined") return true;
120
+ return window.__loggingDisabled !== true;
121
+ }
122
+ function isPostHogShippingEnabled() {
123
+ if (BUILD_POSTHOG_DISABLED) return false;
124
+ if (typeof window === "undefined") return false;
125
+ return window.__posthogLoggingDisabled !== true;
126
+ }
127
+ function formatDetail(detail) {
128
+ return Object.entries(detail).map(([k, v]) => `${k}=${typeof v === "number" ? v.toFixed(4) : String(v)}`).join(" ");
129
+ }
130
+ function emitConsole(level, channel, event, detail) {
131
+ var _a, _b, _c, _d;
132
+ const color2 = (_a = CHANNEL_COLORS[channel]) != null ? _a : "#aaa";
133
+ const detailStr = formatDetail(detail);
134
+ const message = `%c[${channel}] %c${event}%c ${detailStr}`;
135
+ const channelStyle = `color:${color2}; font-weight:bold`;
136
+ const eventStyle = level === "error" ? "color:#e94e4e; font-weight:bold" : level === "warn" ? "color:#f5a623; font-weight:bold" : "color:#fff; font-weight:bold";
137
+ const detailStyle = "color:#999; font-weight:normal";
138
+ if (level === "error") {
139
+ (_b = browserConsole == null ? void 0 : browserConsole.error) == null ? void 0 : _b.call(browserConsole, message, channelStyle, eventStyle, detailStyle);
140
+ return;
141
+ }
142
+ if (level === "warn") {
143
+ (_c = browserConsole == null ? void 0 : browserConsole.warn) == null ? void 0 : _c.call(browserConsole, message, channelStyle, eventStyle, detailStyle);
144
+ return;
145
+ }
146
+ (_d = browserConsole == null ? void 0 : browserConsole.log) == null ? void 0 : _d.call(browserConsole, message, channelStyle, eventStyle, detailStyle);
147
+ }
148
+ function emitToPostHog(level, channel, event, detail) {
149
+ if (!otelLogger) return;
150
+ const severityText = level === "warn" ? "WARNING" : level === "error" ? "ERROR" : "INFO";
151
+ const attributes = flattenAttributes(__spreadValues({ channel }, detail));
152
+ otelLogger.emit({
153
+ severityText,
154
+ body: event,
155
+ attributes
156
+ });
157
+ }
158
+ function emit(level, channel, event, detail, options) {
159
+ var _a;
160
+ const shouldShip = ((_a = options == null ? void 0 : options.shipToPostHog) != null ? _a : level !== "info") && isPostHogShippingEnabled();
161
+ if (level !== "info" || isConsoleEnabled()) {
162
+ emitConsole(level, channel, event, detail);
163
+ }
164
+ if (shouldShip) {
165
+ emitToPostHog(level, channel, event, detail);
166
+ }
167
+ }
168
+ function log(channel, event, detail = {}, options) {
169
+ emit("info", channel, event, detail, options);
170
+ }
171
+ function warn(channel, event, detail = {}, options) {
172
+ emit("warn", channel, event, detail, options);
173
+ }
174
+ function error(channel, event, detail = {}, options) {
175
+ emit("error", channel, event, detail, options);
176
+ }
177
+
178
+ // src/contexts/ThemeContext.tsx
67
179
  var ThemeContext = createContext({ theme: "classic" });
68
180
  function useTheme() {
69
181
  return useContext(ThemeContext);
@@ -2407,7 +2519,9 @@ function GoogleMap({ address, locationName, className = "" }) {
2407
2519
  return;
2408
2520
  }
2409
2521
  if (!window.google.maps.Geocoder) {
2410
- console.warn("Google Maps Geocoder not yet available, retrying...");
2522
+ warn("google-map", "GEOCODER_NOT_READY_RETRYING", {
2523
+ address
2524
+ });
2411
2525
  setTimeout(() => {
2412
2526
  var _a, _b;
2413
2527
  if (mapRef.current && ((_b = (_a = window.google) == null ? void 0 : _a.maps) == null ? void 0 : _b.Geocoder) && initMapRef.current) {
@@ -2465,8 +2579,12 @@ function GoogleMap({ address, locationName, className = "" }) {
2465
2579
  }
2466
2580
  isInitializingRef.current = false;
2467
2581
  });
2468
- } catch (error) {
2469
- console.error("Error initializing map:", error);
2582
+ } catch (error2) {
2583
+ error("google-map", "MAP_INITIALIZATION_FAILED", {
2584
+ address,
2585
+ message: error2 instanceof Error ? error2.message : String(error2),
2586
+ stack: error2 instanceof Error ? error2.stack || "" : ""
2587
+ });
2470
2588
  setMapError("Error loading map. Please try again later.");
2471
2589
  isInitializingRef.current = false;
2472
2590
  }
@@ -6264,7 +6382,7 @@ async function setPixelUserData(userData) {
6264
6382
  function firePixelEvent(event, params, eventId) {
6265
6383
  const fbq = getFbq();
6266
6384
  if (!fbq) {
6267
- console.debug("[MetaPixel] skipped \u2014 fbq not loaded", { event });
6385
+ warn("meta-pixel", "PIXEL_EVENT_SKIPPED_FBQ_NOT_LOADED", { event });
6268
6386
  return;
6269
6387
  }
6270
6388
  applyStoredUserData(fbq);
@@ -6273,7 +6391,9 @@ function firePixelEvent(event, params, eventId) {
6273
6391
  if (params == null ? void 0 : params.contentCategory) normalized.content_category = params.contentCategory;
6274
6392
  const customData = Object.keys(normalized).length > 0 ? normalized : void 0;
6275
6393
  const eventData = eventId ? { eventID: eventId } : void 0;
6276
- console.debug("[MetaPixel]", event, normalized, eventId ? { eventID: eventId } : "");
6394
+ log("meta-pixel", "PIXEL_EVENT_FIRED", __spreadValues(__spreadValues({
6395
+ event
6396
+ }, normalized), eventId ? { eventId } : {}), { shipToPostHog: true });
6277
6397
  fbq("track", event, customData, eventData);
6278
6398
  }
6279
6399
 
@@ -7907,7 +8027,10 @@ var BlogPostSection = ({
7907
8027
  setCopied(true);
7908
8028
  setTimeout(() => setCopied(false), 2e3);
7909
8029
  } catch (err) {
7910
- console.error("Failed to copy:", err);
8030
+ error("blog-post", "COPY_LINK_FAILED", {
8031
+ message: err instanceof Error ? err.message : String(err),
8032
+ stack: err instanceof Error ? err.stack || "" : ""
8033
+ });
7911
8034
  }
7912
8035
  };
7913
8036
  const handleShareLink = () => {
@@ -7916,7 +8039,10 @@ var BlogPostSection = ({
7916
8039
  title: blogPost == null ? void 0 : blogPost.title,
7917
8040
  url: window.location.href
7918
8041
  }).catch((err) => {
7919
- console.error("Error sharing:", err);
8042
+ error("blog-post", "SHARE_LINK_FAILED", {
8043
+ message: err instanceof Error ? err.message : String(err),
8044
+ stack: err instanceof Error ? err.stack || "" : ""
8045
+ });
7920
8046
  });
7921
8047
  } else {
7922
8048
  handleCopyLink();
@@ -7979,7 +8105,10 @@ var BlogPostSection = ({
7979
8105
  onSubmit: (e) => {
7980
8106
  e.preventDefault();
7981
8107
  const formData = new FormData(e.currentTarget);
7982
- console.log("Form data:", formData);
8108
+ const email = formData.get("email");
8109
+ log("blog-post", "NEWSLETTER_FORM_SUBMIT", {
8110
+ email: typeof email === "string" ? email : ""
8111
+ }, { shipToPostHog: true });
7983
8112
  },
7984
8113
  className: "flex flex-col gap-4"
7985
8114
  },
@@ -8390,7 +8519,7 @@ var HomeHeroComponent = ({
8390
8519
  if (onEmailSubmit) {
8391
8520
  onEmailSubmit(email);
8392
8521
  } else {
8393
- console.log("Email signup:", email);
8522
+ log("home-hero", "EMAIL_SIGNUP_SUBMIT", { email }, { shipToPostHog: true });
8394
8523
  }
8395
8524
  },
8396
8525
  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"