Changeset 3433065
- Timestamp:
- 01/05/2026 08:48:03 PM (7 weeks 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
r3402749 r3433065 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 44 38 /** 45 39 * The ID of this plugin. … … 50 44 */ 51 45 private $plugin_name; 52 53 private $route_insurance_data = null;54 46 55 47 /** … … 398 390 $cartItems = $this->get_cart_shippable_items($cart); 399 391 $route_insurance_quote = $this->routeapp_get_quote_from_api($cartRef, $cartTotal, $currency, $cartItems); 400 $this->route_insurance_data = $route_insurance_quote;401 392 402 393 $route_insurance_amount = false; … … 491 482 wp_enqueue_script($this->plugin_name . '-widget', 'https://protection-widget.route.com/route-protection-widget.js', array(), $this->version, false); 492 483 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 )); 484 wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/routeapp-public-pbc.js', array('jquery'), $this->version, false); 524 485 525 486 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
r3402749 r3433065 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 RouteAmplitudeAnalytics67 if (window.RouteAmplitudeAnalytics) {68 RouteAmplitudeAnalytics.trackProtectChange(checkbox);69 }70 65 } 71 66 }); … … 113 108 $(ROUTE_WIDGET_ID).show(); 114 109 renderWidget(result['routeapp-subtotal']); 115 // Track widget render using RouteAmplitudeAnalytics116 if (window.RouteAmplitudeAnalytics) {117 RouteAmplitudeAnalytics.trackWidgetRender();118 }119 110 } else { 120 111 $(ROUTE_WIDGET_ID).hide(); … … 128 119 $(document.body).on( UPDATED_CHECKOUT_EVENT, checkWidgetShow); 129 120 130 // Initialize Amplitude analytics using RouteAmplitudeAnalytics131 if (window.RouteAmplitudeAnalytics) {132 RouteAmplitudeAnalytics.initialize();133 }134 135 // Set up event listeners for info modal tracking136 // Listen for clicks on Route widget info buttons137 $(document).on('click', '#RouteWidget .pw-info-icon', function() {138 if (window.RouteAmplitudeAnalytics) {139 RouteAmplitudeAnalytics.trackInfoChange('opened');140 }141 });142 143 // Listen for modal close events144 $(document).on('click', '#RouteWidget .route-modal__close', function() {145 if (window.RouteAmplitudeAnalytics) {146 RouteAmplitudeAnalytics.trackInfoChange('closed');147 }148 });149 150 121 if (!$(RouteConfig.invalid_shipping_method).length) { 151 122 renderWidget($(RouteConfig.subtotal).val()); -
routeapp/trunk/readme.txt
r3402749 r3433065 6 6 Requires at least: 4.0 7 7 Tested up to: 6.7.1 8 Stable tag: 2.2. 308 Stable tag: 2.2.29 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 interactions111 108 112 109 = 2.2.29 = -
routeapp/trunk/routeapp.php
r3402749 r3433065 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. 3012 * Version: 2.2.29 13 13 * Author: Route 14 14 * Author URI: https://route.com/ … … 26 26 * Currently plugin version. 27 27 */ 28 define( 'ROUTEAPP_VERSION', '2.2. 30' );28 define( 'ROUTEAPP_VERSION', '2.2.29' ); 29 29 30 30 /**
Note: See TracChangeset
for help on using the changeset viewer.