Changeset 3402749
- Timestamp:
- 11/25/2025 06:08:10 PM (3 months ago)
- Location:
- routeapp/trunk
- Files:
-
- 4 edited
-
public/class-routeapp-public.php (modified) (4 diffs)
-
public/js/routeapp-public-pbc.js (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
routeapp.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
routeapp/trunk/public/class-routeapp-public.php
r3391431 r3402749 36 36 const ALLOWED_QUOTE_TYPE = 'paid_by_customer'; 37 37 38 const AMPLITUDE_API_KEY = [ 39 'production' => '6d4f9158886e0c6d78e3bd97663ba920', 40 'stage' => '99a869d62986f6415610c6741057bc92', 41 'dev' => '527af176070cf4b775c6a718f0737f0a' 42 ]; 43 38 44 /** 39 45 * The ID of this plugin. … … 44 50 */ 45 51 private $plugin_name; 52 53 private $route_insurance_data = null; 46 54 47 55 /** … … 390 398 $cartItems = $this->get_cart_shippable_items($cart); 391 399 $route_insurance_quote = $this->routeapp_get_quote_from_api($cartRef, $cartTotal, $currency, $cartItems); 400 $this->route_insurance_data = $route_insurance_quote; 392 401 393 402 $route_insurance_amount = false; … … 482 491 wp_enqueue_script($this->plugin_name . '-widget', 'https://protection-widget.route.com/route-protection-widget.js', array(), $this->version, false); 483 492 484 wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/routeapp-public-pbc.js', array('jquery'), $this->version, false); 493 $amplitude_key = self::AMPLITUDE_API_KEY[$custom_env]; 494 495 // Load Amplitude SDK (standard version, not snippet) 496 wp_enqueue_script('amplitude-js', "https://cdn.amplitude.com/script/$amplitude_key.js", array(), null, false); 497 498 // Enqueue Amplitude Analytics module (depends on jQuery and Amplitude SDK) 499 wp_enqueue_script($this->plugin_name . '-amplitude-analytics', plugin_dir_url(__FILE__) . 'js/amplitude-analytics.js', array('jquery', 'amplitude-js'), $this->version, false); 500 501 // Main script depends on amplitude-analytics when available 502 wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/routeapp-public-pbc.js', array('jquery', $this->plugin_name . '-amplitude-analytics'), $this->version, false); 503 504 /** 505 * Calculate total Route fee 506 * Uses the premium amount from route insurance data if available, 507 * otherwise defaults to 0.98 as a fallback fee amount 508 */ 509 $totalRouteFee = (is_object($this->route_insurance_data) && isset($this->route_insurance_data->premium->amount)) 510 ? (float) $this->route_insurance_data->premium->amount 511 : 0.98; 512 513 // Pass cart data to JavaScript - send to amplitude-analytics.js 514 wp_localize_script($this->plugin_name . '-amplitude-analytics', 'cartData', array( 515 'cartId' => WC()->cart->get_cart_hash(), 516 'amplitudeKey' => $amplitude_key, 517 'widgetId' => uniqid('widget-', true), 518 'subtotal' => round($this->get_cart_subtotal_with_only_shippable_items(WC()->cart), 2), 519 'totalRouteFee' => $totalRouteFee, 520 'environment' => $custom_env, 521 'currency' => get_woocommerce_currency(), 522 'merchantId' => $this->routeapp_api_client->get_merchant_id(), 523 )); 485 524 486 525 wp_enqueue_style($this->plugin_name . '-widget', plugin_dir_url(__FILE__) . 'css/routeapp-widget.css', array(), $this->version, false); -
routeapp/trunk/public/js/routeapp-public-pbc.js
r2979691 r3402749 23 23 is_cart_page: window.location.pathname === "/cart/", 24 24 invalid_shipping_method: '.routeapp-invalid-shipping-method', 25 checkbox: $(PROTECTION_COOKIE).length ? parseCheckboxValue() : Route.Coverage.ActiveByDefault ,25 checkbox: $(PROTECTION_COOKIE).length ? parseCheckboxValue() : Route.Coverage.ActiveByDefault 26 26 }; 27 27 … … 63 63 success: function () { 64 64 RouteConfig.is_cart_page ? triggerCartUpdate() : triggerCheckoutUpdate(); 65 66 // Track protection change using RouteAmplitudeAnalytics 67 if (window.RouteAmplitudeAnalytics) { 68 RouteAmplitudeAnalytics.trackProtectChange(checkbox); 69 } 65 70 } 66 71 }); … … 108 113 $(ROUTE_WIDGET_ID).show(); 109 114 renderWidget(result['routeapp-subtotal']); 115 // Track widget render using RouteAmplitudeAnalytics 116 if (window.RouteAmplitudeAnalytics) { 117 RouteAmplitudeAnalytics.trackWidgetRender(); 118 } 110 119 } else { 111 120 $(ROUTE_WIDGET_ID).hide(); … … 119 128 $(document.body).on( UPDATED_CHECKOUT_EVENT, checkWidgetShow); 120 129 130 // Initialize Amplitude analytics using RouteAmplitudeAnalytics 131 if (window.RouteAmplitudeAnalytics) { 132 RouteAmplitudeAnalytics.initialize(); 133 } 134 135 // Set up event listeners for info modal tracking 136 // Listen for clicks on Route widget info buttons 137 $(document).on('click', '#RouteWidget .pw-info-icon', function() { 138 if (window.RouteAmplitudeAnalytics) { 139 RouteAmplitudeAnalytics.trackInfoChange('opened'); 140 } 141 }); 142 143 // Listen for modal close events 144 $(document).on('click', '#RouteWidget .route-modal__close', function() { 145 if (window.RouteAmplitudeAnalytics) { 146 RouteAmplitudeAnalytics.trackInfoChange('closed'); 147 } 148 }); 149 121 150 if (!$(RouteConfig.invalid_shipping_method).length) { 122 151 renderWidget($(RouteConfig.subtotal).val()); -
routeapp/trunk/readme.txt
r3391431 r3402749 6 6 Requires at least: 4.0 7 7 Tested up to: 6.7.1 8 Stable tag: 2.2. 298 Stable tag: 2.2.30 9 9 Requires PHP: 5.6 10 10 License: GPLv2 or later … … 106 106 107 107 == Changelog == 108 109 = 2.2.30 = 110 * Add Amplitude tracking for Route widget interactions 108 111 109 112 = 2.2.29 = -
routeapp/trunk/routeapp.php
r3391431 r3402749 10 10 * Plugin URI: https://route.com/for-merchants/ 11 11 * Description: Route allows shoppers to insure their orders with one-click during checkout, adding a layer of 3rd party trust while improving the customer shopping experience. 12 * Version: 2.2. 2912 * Version: 2.2.30 13 13 * Author: Route 14 14 * Author URI: https://route.com/ … … 26 26 * Currently plugin version. 27 27 */ 28 define( 'ROUTEAPP_VERSION', '2.2. 29' );28 define( 'ROUTEAPP_VERSION', '2.2.30' ); 29 29 30 30 /**
Note: See TracChangeset
for help on using the changeset viewer.