@bigz-app/booking-widget 0.3.2 → 0.3.4

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.esm.js CHANGED
@@ -237,7 +237,7 @@ const resolveSemanticColor = (colorValue, fallbackValue) => {
237
237
  const themes = {
238
238
  // --- Light Themes ---
239
239
  "light-fresh": {
240
- highlight: "#00a8a1", // accent-strong
240
+ highlight: "#00b1aa", // accent-strong
241
241
  background: "#f8fdfe", // neutral-strong (background)
242
242
  surface: "#ffffff", // card (pure white)
243
243
  text: "#0e7490", // Turquoise 800
@@ -6781,7 +6781,6 @@ function DialogPortal({ children, isOpen, zIndex = 999999, }) {
6781
6781
  }
6782
6782
  catch (error) {
6783
6783
  // Ignore removal errors - element may have already been removed
6784
- console.debug("Portal cleanup: Element already removed");
6785
6784
  }
6786
6785
  }
6787
6786
  document.body.style.overflow = "";
@@ -10275,312 +10274,116 @@ function BookingForm({ config, eventDetails, stripePromise, onSuccess, onError,
10275
10274
  /**
10276
10275
  * Google Ads Conversion Tracking Utility
10277
10276
  *
10278
- * This utility handles Google Ads conversion tracking for the booking widget.
10279
- * It includes consent checking, gtag initialization, and conversion tracking.
10277
+ * Simplified utility that waits 1500ms, checks/initializes gtag, and sends conversion.
10280
10278
  */
10281
10279
  /**
10282
- * Check if Google Consent Mode has granted the necessary permissions for ads tracking
10283
- * This checks multiple sources of consent state in order of preference
10280
+ * Check if gtag is available in current or parent window
10284
10281
  */
10285
- function checkGoogleConsent() {
10286
- console.log("[Google Ads Tracking] 🔍 Checking Google consent...");
10282
+ function isGtagAvailable() {
10287
10283
  if (typeof window === "undefined") {
10288
- console.log("[Google Ads Tracking] ❌ Window object not available (SSR context)");
10289
10284
  return false;
10290
10285
  }
10291
- console.log("[Google Ads Tracking] ✅ Window object available");
10292
- // Method 1: Check dataLayer for consent_update events (most reliable)
10293
- if (window.dataLayer && Array.isArray(window.dataLayer)) {
10294
- console.log("[Google Ads Tracking] 🔍 Checking dataLayer for consent events...");
10295
- const dataLayer = window.dataLayer;
10296
- // Debug: Show the entire dataLayer contents
10297
- console.log("[Google Ads Tracking] 🗂️ Complete dataLayer contents:", JSON.stringify(dataLayer, null, 2));
10298
- console.log("[Google Ads Tracking] 📊 dataLayer length:", dataLayer.length);
10299
- // Look for the most recent consent update in dataLayer
10300
- let latestConsentState = null;
10301
- const foundEvents = [];
10302
- // Search backwards through dataLayer for most recent consent state
10303
- for (let i = dataLayer.length - 1; i >= 0; i--) {
10304
- const event = dataLayer[i];
10305
- console.log(`[Google Ads Tracking] 🔍 Checking dataLayer[${i}]:`, event);
10306
- if (event && typeof event === "object") {
10307
- // Check for various consent event patterns
10308
- if (event.event === "consent_update" || event.event === "default_consent") {
10309
- console.log("[Google Ads Tracking] 📋 Found consent event:", event);
10310
- foundEvents.push(event);
10311
- if (event.consent_mode) {
10312
- latestConsentState = event.consent_mode;
10313
- break;
10314
- }
10315
- }
10316
- // Also check for direct consent_mode properties
10317
- if (event.consent_mode) {
10318
- console.log("[Google Ads Tracking] 📋 Found consent_mode property:", event);
10319
- foundEvents.push(event);
10320
- latestConsentState = event.consent_mode;
10321
- break;
10322
- }
10286
+ // Check current window
10287
+ if (typeof window.gtag === "function") {
10288
+ return true;
10289
+ }
10290
+ // Check parent window (for iframe/widget scenarios)
10291
+ if (window !== window.parent) {
10292
+ try {
10293
+ if (typeof window.parent?.gtag === "function") {
10294
+ return true;
10323
10295
  }
10324
10296
  }
10325
- console.log("[Google Ads Tracking] 📋 All found consent events:", foundEvents);
10326
- if (latestConsentState) {
10327
- const adStorageGranted = latestConsentState.ad_storage === "granted";
10328
- console.log("[Google Ads Tracking] 🔐 ad_storage from dataLayer:", latestConsentState.ad_storage);
10329
- console.log("[Google Ads Tracking] 🎯 Consent result from dataLayer:", adStorageGranted);
10330
- return adStorageGranted;
10297
+ catch (e) {
10298
+ // Cannot access parent window (cross-origin)
10331
10299
  }
10332
- console.log("[Google Ads Tracking] ❌ No consent events found in dataLayer");
10333
- }
10334
- console.log("[Google Ads Tracking] ❌ dataLayer not found or not an array");
10335
- // Method 2: Check for cookie-based consent (fallback for host implementation)
10336
- console.log("[Google Ads Tracking] 🔍 Checking cookie-based consent...");
10337
- try {
10338
- // Debug: Show all cookies
10339
- console.log("[Google Ads Tracking] 🍪 All cookies:", document.cookie);
10340
- const allCookies = document.cookie.split(";").map((cookie) => cookie.trim());
10341
- console.log("[Google Ads Tracking] 🍪 Parsed cookies:", allCookies);
10342
- // Check for the host page's conversion tracking consent cookie
10343
- const conversionTrackingCookie = document.cookie
10344
- .split(";")
10345
- .find((cookie) => cookie.trim().startsWith("conversionTrackingConsent="));
10346
- if (conversionTrackingCookie) {
10347
- const cookieValue = conversionTrackingCookie.split("=")[1];
10348
- const isGranted = cookieValue === "true";
10349
- console.log("[Google Ads Tracking] 🍪 Found conversionTrackingConsent cookie:", cookieValue);
10350
- console.log("[Google Ads Tracking] 🎯 Consent result from cookie:", isGranted);
10351
- return isGranted;
10352
- }
10353
- console.log("[Google Ads Tracking] ❌ conversionTrackingConsent cookie not found");
10354
- // Also check for other potential cookie names
10355
- const alternativeCookieNames = ["analyticsConsent", "ads_consent", "ad_storage"];
10356
- for (const cookieName of alternativeCookieNames) {
10357
- const alternativeCookie = allCookies.find((cookie) => cookie.startsWith(`${cookieName}=`));
10358
- if (alternativeCookie) {
10359
- console.log(`[Google Ads Tracking] 🍪 Found alternative cookie ${cookieName}:`, alternativeCookie);
10360
- }
10361
- }
10362
- }
10363
- catch (error) {
10364
- console.warn("[Google Ads Tracking] ⚠️ Error checking cookies:", error);
10365
- }
10366
- // Method 3: Check if gtag exists but no consent state found
10367
- if (typeof window.gtag === "function") {
10368
- console.log("[Google Ads Tracking] ⚠️ gtag function exists but no consent state found");
10369
- console.log("[Google Ads Tracking] 💡 This might indicate consent hasn't been set yet");
10370
- }
10371
- else {
10372
- console.log("[Google Ads Tracking] ❌ gtag function not found");
10373
10300
  }
10374
- // If no consent mechanism is found, assume consent is not granted
10375
- console.log("[Google Ads Tracking] 🚫 No valid consent state found, returning false");
10376
10301
  return false;
10377
10302
  }
10378
10303
  /**
10379
- * Check if gtag is already initialized on the host page
10304
+ * Initialize gtag if not already available
10380
10305
  */
10381
- function isGtagInitialized() {
10382
- console.log("[Google Ads Tracking] 🔍 Checking if gtag is initialized...");
10306
+ function initializeGtag(tagId) {
10383
10307
  if (typeof window === "undefined") {
10384
- console.log("[Google Ads Tracking] ❌ Window object not available (SSR context)");
10385
- return false;
10308
+ return;
10386
10309
  }
10387
- console.log("[Google Ads Tracking] Window object available");
10388
- // Check if gtag function exists
10389
- if (typeof window.gtag === "function") {
10390
- console.log("[Google Ads Tracking] ✅ gtag function exists");
10391
- return true;
10310
+ // Skip if gtag already exists
10311
+ if (isGtagAvailable()) {
10312
+ return;
10392
10313
  }
10393
- console.log("[Google Ads Tracking] gtag function not found, checking for scripts...");
10394
- // Check if Google Analytics or Google Ads scripts are already loaded
10395
- const scripts = document.querySelectorAll('script[src*="googletagmanager.com"]');
10396
- console.log("[Google Ads Tracking] 📜 Found", scripts.length, "Google Tag Manager scripts");
10397
- const isInitialized = scripts.length > 0;
10398
- console.log("[Google Ads Tracking] 🎯 gtag initialization status:", isInitialized);
10399
- return isInitialized;
10400
- }
10401
- /**
10402
- * Initialize Google Tag (gtag) if not already present
10403
- */
10404
- function initializeGtag(tagId) {
10405
- console.log("[Google Ads Tracking] 🚀 Starting gtag initialization with tagId:", tagId);
10406
- return new Promise((resolve, reject) => {
10407
- if (typeof window === "undefined") {
10408
- console.log("[Google Ads Tracking] ❌ Window object not available (SSR context)");
10409
- reject(new Error("Window object not available"));
10410
- return;
10411
- }
10412
- console.log("[Google Ads Tracking] ✅ Window object available");
10413
- // If gtag is already initialized, just resolve
10414
- if (isGtagInitialized()) {
10415
- console.log("[Google Ads Tracking] ⚡ gtag already initialized, skipping setup");
10416
- resolve();
10417
- return;
10418
- }
10419
- console.log("[Google Ads Tracking] 📦 gtag not found, creating new script element...");
10420
- try {
10421
- // Create the gtag script
10422
- const script = document.createElement("script");
10423
- script.async = true;
10424
- script.src = `https://www.googletagmanager.com/gtag/js?id=${tagId}`;
10425
- console.log("[Google Ads Tracking] 🌐 Script src set to:", script.src);
10426
- script.onload = () => {
10427
- console.log("[Google Ads Tracking] 📥 Script loaded successfully, initializing gtag...");
10428
- // Initialize gtag
10429
- window.dataLayer = window.dataLayer || [];
10430
- console.log("[Google Ads Tracking] 📊 dataLayer initialized");
10431
- window.gtag = (...args) => {
10432
- window.dataLayer.push(args);
10433
- };
10434
- console.log("[Google Ads Tracking] 🔧 gtag function created");
10435
- // Configure gtag
10436
- console.log("[Google Ads Tracking] ⚙️ Configuring gtag with privacy settings...");
10437
- window.gtag("js", new Date());
10438
- window.gtag("config", tagId, {
10439
- // Respect consent settings
10440
- anonymize_ip: true,
10441
- allow_google_signals: false,
10442
- allow_ad_personalization_signals: false,
10443
- });
10444
- console.log("[Google Ads Tracking] ✅ gtag initialized successfully with tagId:", tagId);
10445
- resolve();
10446
- };
10447
- script.onerror = (error) => {
10448
- console.error("[Google Ads Tracking] ❌ Failed to load Google Tag script:", error);
10449
- reject(new Error("Failed to load Google Tag script"));
10450
- };
10451
- console.log("[Google Ads Tracking] 📑 Adding script to document head...");
10452
- // Add script to head
10453
- document.head.appendChild(script);
10454
- console.log("[Google Ads Tracking] ✅ Script element appended to head");
10455
- }
10456
- catch (error) {
10457
- console.error("[Google Ads Tracking] ❌ Error during gtag initialization:", error);
10458
- reject(error);
10459
- }
10314
+ // Initialize dataLayer and gtag function
10315
+ window.dataLayer = window.dataLayer || [];
10316
+ window.gtag = (...args) => {
10317
+ window.dataLayer.push(args);
10318
+ };
10319
+ // Set current timestamp
10320
+ window.gtag("js", new Date());
10321
+ // Load gtag script
10322
+ const script = document.createElement("script");
10323
+ script.async = true;
10324
+ script.src = `https://www.googletagmanager.com/gtag/js?id=${tagId}`;
10325
+ document.head.appendChild(script);
10326
+ // Configure the tag
10327
+ window.gtag("config", tagId, {
10328
+ anonymize_ip: true,
10329
+ allow_google_signals: false,
10330
+ allow_ad_personalization_signals: false,
10460
10331
  });
10461
10332
  }
10462
10333
  /**
10463
- * Track a Google Ads conversion
10334
+ * Send conversion event using available gtag
10464
10335
  */
10465
- function trackConversion(config) {
10466
- console.log("[Google Ads Tracking] 🎯 Starting conversion tracking with config:", config);
10336
+ function sendConversion(config) {
10467
10337
  if (typeof window === "undefined") {
10468
- console.warn("[Google Ads Tracking] ❌ Window object not available");
10469
10338
  return;
10470
10339
  }
10471
- console.log("[Google Ads Tracking] ✅ Window object available");
10472
- if (!config.tagId || !config.conversionId) {
10473
- console.warn("[Google Ads Tracking] Missing tagId or conversionId", {
10474
- tagId: config.tagId,
10475
- conversionId: config.conversionId,
10476
- });
10477
- return;
10340
+ let gtag = window.gtag;
10341
+ // Try parent window gtag if current window doesn't have it
10342
+ if (typeof gtag !== "function" && window !== window.parent) {
10343
+ try {
10344
+ gtag = window.parent?.gtag;
10345
+ }
10346
+ catch {
10347
+ // Cannot access parent window (cross-origin)
10348
+ }
10478
10349
  }
10479
- console.log("[Google Ads Tracking] ✅ Required config fields present:", {
10480
- tagId: config.tagId,
10481
- conversionId: config.conversionId,
10482
- });
10483
- if (typeof window.gtag !== "function") {
10484
- console.warn("[Google Ads Tracking] ❌ gtag function not available");
10350
+ if (typeof gtag !== "function") {
10485
10351
  return;
10486
10352
  }
10487
- console.log("[Google Ads Tracking] ✅ gtag function is available");
10488
- try {
10489
- console.log("[Google Ads Tracking] 🔧 Building conversion data...");
10490
- const conversionData = {
10491
- send_to: `${config.tagId}/${config.conversionId}`,
10492
- };
10493
- console.log("[Google Ads Tracking] 📋 Base conversion data:", conversionData);
10494
- // Add optional parameters
10495
- if (config.conversionValue !== undefined) {
10496
- conversionData.value = config.conversionValue;
10497
- console.log("[Google Ads Tracking] 💰 Added conversion value:", config.conversionValue);
10498
- }
10499
- if (config.conversionCurrency) {
10500
- conversionData.currency = config.conversionCurrency;
10501
- console.log("[Google Ads Tracking] 💱 Added currency:", config.conversionCurrency);
10502
- }
10503
- if (config.transactionId) {
10504
- conversionData.transaction_id = config.transactionId;
10505
- console.log("[Google Ads Tracking] 🔖 Added transaction ID:", config.transactionId);
10506
- }
10507
- console.log("[Google Ads Tracking] 📦 Final conversion data:", conversionData);
10508
- // Track the conversion
10509
- console.log("[Google Ads Tracking] 🚀 Sending conversion event to gtag...");
10510
- window.gtag("event", "conversion", conversionData);
10511
- console.log("[Google Ads Tracking] ✅ Conversion tracked successfully:", conversionData);
10353
+ // Build conversion data
10354
+ const conversionData = {
10355
+ send_to: `${config.tagId}/${config.conversionId}`,
10356
+ };
10357
+ // Add optional parameters
10358
+ if (config.conversionValue !== undefined) {
10359
+ conversionData.value = config.conversionValue;
10512
10360
  }
10513
- catch (error) {
10514
- console.error("[Google Ads Tracking] ❌ Error tracking conversion:", error);
10361
+ if (config.conversionCurrency) {
10362
+ conversionData.currency = config.conversionCurrency;
10515
10363
  }
10364
+ if (config.transactionId) {
10365
+ conversionData.transaction_id = config.transactionId;
10366
+ }
10367
+ // Send conversion event
10368
+ gtag("event", "conversion", conversionData);
10516
10369
  }
10517
10370
  /**
10518
10371
  * Main function to handle Google Ads conversion tracking
10519
- * This function checks consent, initializes gtag if needed, and tracks the conversion
10372
+ * Waits 1500ms, checks/initializes gtag, then sends conversion
10520
10373
  */
10521
- async function handleGoogleAdsConversion(config) {
10522
- console.log("[Google Ads Tracking] 🎬 Starting handleGoogleAdsConversion with config:", config);
10523
- // Validate config
10374
+ function handleGoogleAdsConversion(config) {
10375
+ // Validate required config
10524
10376
  if (!config.tagId || !config.conversionId) {
10525
- console.log("[Google Ads Tracking] ❌ No tagId or conversionId provided, skipping conversion tracking", { tagId: config.tagId, conversionId: config.conversionId });
10526
- return;
10527
- }
10528
- console.log("[Google Ads Tracking] ✅ Config validation passed");
10529
- // Check consent first
10530
- console.log("[Google Ads Tracking] 🔐 Checking consent...");
10531
- if (!checkGoogleConsent()) {
10532
- console.log("[Google Ads Tracking] 🚫 Google consent not granted, skipping conversion tracking");
10533
10377
  return;
10534
10378
  }
10535
- console.log("[Google Ads Tracking] Consent check passed");
10536
- try {
10537
- // Initialize gtag if not already present
10538
- console.log("[Google Ads Tracking] 🔍 Checking if gtag needs initialization...");
10539
- if (!isGtagInitialized()) {
10540
- console.log("[Google Ads Tracking] 🚀 Initializing gtag...");
10541
- await initializeGtag(config.tagId);
10542
- console.log("[Google Ads Tracking] ✅ gtag initialization completed");
10379
+ // Wait 1500ms before proceeding
10380
+ setTimeout(() => {
10381
+ // Check if gtag is available, initialize if not
10382
+ if (!isGtagAvailable()) {
10383
+ initializeGtag(config.tagId);
10543
10384
  }
10544
- else {
10545
- console.log("[Google Ads Tracking] ⚡ gtag already initialized, proceeding...");
10546
- }
10547
- // Small delay to ensure gtag is ready
10548
- console.log("[Google Ads Tracking] ⏱️ Adding 100ms delay to ensure gtag is ready...");
10549
- setTimeout(() => {
10550
- console.log("[Google Ads Tracking] 🎯 Delay completed, tracking conversion...");
10551
- trackConversion(config);
10552
- }, 100);
10553
- }
10554
- catch (error) {
10555
- console.error("[Google Ads Tracking] ❌ Error handling conversion:", error);
10556
- }
10557
- }
10558
- /**
10559
- * Utility function to get conversion value from booking data
10560
- */
10561
- function getConversionValueFromBooking(bookingData) {
10562
- console.log("[Google Ads Tracking] 💰 Extracting conversion value from booking data:", bookingData);
10563
- // Try to get the total amount from various possible structures
10564
- const possiblePaths = [
10565
- { path: "order.total", value: bookingData?.order?.total },
10566
- { path: "booking.total", value: bookingData?.booking?.total },
10567
- { path: "total", value: bookingData?.total },
10568
- { path: "amount", value: bookingData?.amount },
10569
- { path: "payment.amount", value: bookingData?.payment?.amount },
10570
- { path: "stripePaymentIntent.amount", value: bookingData?.stripePaymentIntent?.amount },
10571
- ];
10572
- console.log("[Google Ads Tracking] 🔍 Checking possible value paths:", possiblePaths);
10573
- for (const { path, value } of possiblePaths) {
10574
- console.log(`[Google Ads Tracking] 📋 Checking path '${path}':`, value);
10575
- if (typeof value === "number" && value > 0) {
10576
- // Convert from cents to euros
10577
- const convertedValue = value / 100;
10578
- console.log(`[Google Ads Tracking] ✅ Found valid value at '${path}': ${value} cents = ${convertedValue} euros`);
10579
- return convertedValue;
10580
- }
10581
- }
10582
- console.log("[Google Ads Tracking] ❌ No valid conversion value found in booking data");
10583
- return undefined;
10385
+ sendConversion(config);
10386
+ }, 1500);
10584
10387
  }
10585
10388
 
10586
10389
  const BookingSuccessModal = ({ isOpen, onClose, config, onError, paymentIntentId, }) => {
@@ -10631,11 +10434,10 @@ const BookingSuccessModal = ({ isOpen, onClose, config, onError, paymentIntentId
10631
10434
  const finalPaymentStatus = data.stripePaymentIntent?.status || data.order.status;
10632
10435
  if (finalPaymentStatus === "succeeded" &&
10633
10436
  config.googleAds?.tagId &&
10634
- config.googleAds?.conversionId) {
10437
+ config.googleAds?.conversionId &&
10438
+ config.googleAds?.consent !== false) {
10635
10439
  // Prepare conversion tracking data
10636
- const conversionValue = config.googleAds.includeValue !== false
10637
- ? getConversionValueFromBooking(data)
10638
- : undefined;
10440
+ const conversionValue = data.order.total;
10639
10441
  const transactionId = data.order.id;
10640
10442
  // Track the conversion
10641
10443
  handleGoogleAdsConversion({
@@ -10644,8 +10446,6 @@ const BookingSuccessModal = ({ isOpen, onClose, config, onError, paymentIntentId
10644
10446
  conversionValue,
10645
10447
  conversionCurrency: config.googleAds.conversionCurrency || "EUR",
10646
10448
  transactionId,
10647
- }).catch((error) => {
10648
- console.warn("[BookingSuccessModal] Google Ads conversion tracking failed:", error);
10649
10449
  });
10650
10450
  }
10651
10451
  }
@@ -10727,7 +10527,7 @@ const BookingSuccessModal = ({ isOpen, onClose, config, onError, paymentIntentId
10727
10527
  fontWeight: "600",
10728
10528
  color: "var(--bw-highlight-color)",
10729
10529
  margin: "0px 10px",
10730
- }, children: "Buchung erfolgreich erstellt!" })] }), jsx("button", { onClick: handlePrint, style: {
10530
+ }, children: "Reservierung erfolgreich!" })] }), jsx("button", { onClick: handlePrint, style: {
10731
10531
  backgroundColor: "transparent",
10732
10532
  border: `1px solid var(--bw-border-color)`,
10733
10533
  color: "var(--bw-text-color)",