Plugin Directory

Changeset 3433065


Ignore:
Timestamp:
01/05/2026 08:48:03 PM (7 weeks ago)
Author:
routedev
Message:

reduce bloat bugfix

Location:
routeapp/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • routeapp/trunk/public/class-routeapp-public.php

    r3402749 r3433065  
    3636    const ALLOWED_QUOTE_TYPE = 'paid_by_customer';
    3737
    38     const AMPLITUDE_API_KEY = [
    39         'production' => '6d4f9158886e0c6d78e3bd97663ba920',
    40         'stage' => '99a869d62986f6415610c6741057bc92',
    41         'dev' => '527af176070cf4b775c6a718f0737f0a'
    42     ];
    43 
    4438    /**
    4539     * The ID of this plugin.
     
    5044     */
    5145    private $plugin_name;
    52 
    53     private $route_insurance_data = null;
    5446
    5547    /**
     
    398390        $cartItems = $this->get_cart_shippable_items($cart);
    399391        $route_insurance_quote = $this->routeapp_get_quote_from_api($cartRef, $cartTotal, $currency, $cartItems);
    400         $this->route_insurance_data = $route_insurance_quote;
    401392
    402393        $route_insurance_amount = false;
     
    491482        wp_enqueue_script($this->plugin_name . '-widget', 'https://protection-widget.route.com/route-protection-widget.js', array(), $this->version, false);
    492483
    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);
    524485
    525486        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  
    2323            is_cart_page: window.location.pathname === "/cart/",
    2424            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,
    2626        };
    2727
     
    6363                success: function () {
    6464                    RouteConfig.is_cart_page ? triggerCartUpdate() : triggerCheckoutUpdate();
    65 
    66                     // Track protection change using RouteAmplitudeAnalytics
    67                     if (window.RouteAmplitudeAnalytics) {
    68                         RouteAmplitudeAnalytics.trackProtectChange(checkbox);
    69                     }
    7065                }
    7166            });
     
    113108                        $(ROUTE_WIDGET_ID).show();
    114109                        renderWidget(result['routeapp-subtotal']);
    115                         // Track widget render using RouteAmplitudeAnalytics
    116                         if (window.RouteAmplitudeAnalytics) {
    117                             RouteAmplitudeAnalytics.trackWidgetRender();
    118                         }
    119110                    } else {
    120111                        $(ROUTE_WIDGET_ID).hide();
     
    128119        $(document.body).on( UPDATED_CHECKOUT_EVENT, checkWidgetShow);
    129120
    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 
    150121        if (!$(RouteConfig.invalid_shipping_method).length) {
    151122            renderWidget($(RouteConfig.subtotal).val());
  • routeapp/trunk/readme.txt

    r3402749 r3433065  
    66Requires at least: 4.0
    77Tested up to: 6.7.1
    8 Stable tag: 2.2.30
     8Stable tag: 2.2.29
    99Requires PHP: 5.6
    1010License: GPLv2 or later
     
    106106
    107107== Changelog ==
    108 
    109 = 2.2.30 =
    110 * Add Amplitude tracking for Route widget interactions
    111108
    112109= 2.2.29 =
  • routeapp/trunk/routeapp.php

    r3402749 r3433065  
    1010 * Plugin URI:        https://route.com/for-merchants/
    1111 * 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.30
     12 * Version:           2.2.29
    1313 * Author:            Route
    1414 * Author URI:        https://route.com/
     
    2626 * Currently plugin version.
    2727 */
    28 define( 'ROUTEAPP_VERSION', '2.2.30' );
     28define( 'ROUTEAPP_VERSION', '2.2.29' );
    2929
    3030/**
Note: See TracChangeset for help on using the changeset viewer.