Plugin Directory

Changeset 3231917


Ignore:
Timestamp:
01/30/2025 09:55:24 AM (13 months ago)
Author:
anshumanja
Message:

analytics and bug fixes

Location:
accessibe/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • accessibe/trunk/accessibe.php

    r3224617 r3231917  
    44  * Plugin URI: https://accessibe.com/
    55  * Description: accessiBe is the #1 fully automated web accessibility solution. Protect your website from lawsuits and increase your potential audience.
    6   * Version: 2.3.3
     6  * Version: 2.4
    77  * Author: accessiBe
    88  * Author URI: https://accessibe.com/
  • accessibe/trunk/accessibe_inc/js/accessibe.js

    r3223588 r3231917  
    8383    API.sendDataToIframe('redirect-url', redirectUrl);
    8484  },
    85   syncMerchantDetails: async () => {
     85  syncMerchantDetails: async (shouldLogout = false) => {
    8686    if (AcsbStore.jQueryReady && AcsbStore.isIframeReady) {
    8787      const url = new URL(window.location);
    88       API.setMerchant(await API.fetchMerchantDetails());
     88      const merchantData = await API.fetchMerchantDetails();
     89      if(!merchantData.acsbUserId && shouldLogout) {
     90        const iframeRef = document.getElementById('accessibe-universal-iframe');
     91          if (iframeRef) {
     92            iframeRef.contentWindow.postMessage(
     93                { eventName: 'request-logout', data: {} },
     94                '*'
     95            );
     96          }
     97      }
     98      else if (merchantData.acsbUserId) {
     99        delete merchantData['acsbUserId'];
     100      }
     101      API.setMerchant(merchantData);
    89102      API.sendMerchantDetails();
    90103      API.sendRedirectUrl(window.location.href);
     
    115128      case 'iframe-ready':
    116129        AcsbStore.isIframeReady = true;
    117         await API.syncMerchantDetails();
     130        await API.syncMerchantDetails(true);
    118131        break;
    119132      case 'signup':
  • accessibe/trunk/class.accessibeforwp.php

    r3224617 r3231917  
    3030    ];
    3131
     32    public static $DEFAULT_WIDGET_CONFIG_FOR_SCRIPT = [
     33        'leadColor' => '#146ff8',
     34        'language' => 'en',
     35        'position' => 'left',
     36        'triggerColor' => '#146ff8',
     37        'triggerPositionX' => 'right',
     38        'triggerPositionY' => 'bottom',
     39        'triggerSize' => 'medium',
     40        'triggerRadius' => '50%',
     41        'hideTrigger' => 'false',
     42        'triggerOffsetX' => 20,
     43        'triggerOffsetY' => 20,
     44        'triggerIcon' => 'people',
     45        'hideMobile' => 'false',
     46        'mobileTriggerPositionX' => 'right',
     47        'mobileTriggerPositionY' => 'bottom',
     48        'mobileTriggerSize' => 'small',
     49        'mobileTriggerRadius' => '50%',
     50        'mobileTriggerOffsetX' => 10,
     51        'mobileTriggerOffsetY' => 10,
     52        'statementLink' => '',
     53    ];
     54
    3255    public static $icon_mapping_to_widget = [
    3356            "LegacyDisplay" => "display",
     
    6487        /* Render js in footer */
    6588        add_action('wp_footer', array('AccessibeWp', 'accessibe_render_js_in_footer'));
     89
     90        /* Handles the Mixpanel event when the plugin is updated. */
     91        add_action('upgrader_process_complete', array('AccessibeWp', 'accessibe_upgrade_completed'), 10, 2);
     92       
     93        /* Sends the Mixpanel event after the plugin update with both versions. */
     94        add_action('admin_init', array('AccessibeWp', 'accessibe_after_update_tasks'));
    6695
    6796        /* Link to settings page */
     
    174203            $accessibe_options['triggerIcon'] = self::$icon_mapping_to_widget[$icon_value];
    175204        }
     205
     206        $accessibe_options = array_merge(self::$DEFAULT_WIDGET_CONFIG_FOR_SCRIPT, $accessibe_options);
    176207
    177208            echo "<script>(function(){var s=document.createElement('script');e = !document.body ? document.querySelector('head'):document.body;s.src='https://acsbapp.com/apps/app/dist/js/app.js';s.setAttribute('data-source', 'WordPress');s.setAttribute('data-plugin-version', '".self::accessibe_get_plugin_version()."');s.defer=true;s.onload=function(){acsbJS.init({
     
    232263            'fullName' => $current_user->display_name,
    233264            'storeId' => self::sanitizeDomain(wp_parse_url(site_url())['host']),
     265            'mixpanelProps' => array (
     266                'wordpressStoreName' => self::sanitizeDomain(wp_parse_url(site_url())['host']),
     267                'wordpressPluginVersionNumber' => self::accessibe_get_plugin_version() . '',
     268                'wordpressAccountUserID' => $current_user->ID,
     269                'wordpressUserEmail' => $current_user->user_email,
     270                'wordpressUsername' => $current_user->user_login
     271            )
    234272            // 'storeId' => '9cc3-2405-201-5c0f-d070-14fd-b303-b02-1999.ngrok-free.app'
    235273        );
     274
     275        if (isset($current_user_options->acsbUserId)) {
     276            $detail['acsbUserId'] = $current_user_options->acsbUserId;
     277        }
    236278       
    237279        $active_license_id = $current_user_options->activeLicenseId;
     
    365407    public static function accessibe_logout() {
    366408        $current_data = json_decode(get_option(ACCESSIBE_WP_OPTIONS_KEY));
    367         $current_data->activeLicenseId = '';
    368         update_option(ACCESSIBE_WP_OPTIONS_KEY, json_encode($current_data));
     409        if($current_data) {
     410          $current_data->activeLicenseId = '';
     411          update_option(ACCESSIBE_WP_OPTIONS_KEY, json_encode($current_data));
     412        }
    369413        echo json_encode(array('message' => 'ok'));
    370414        wp_die();
     
    514558      // Attempt to retrieve and decode options using ACCESSIBE_OPTIONS_KEY
    515559      $accessibe_options = get_option(ACCESSIBE_WP_OPTIONS_KEY, array());
    516       $isLoggedOutOnce = false;
    517560      if(!empty($accessibe_options)) {
    518561        $accessibe_options = json_decode($accessibe_options, true);
    519         $isLoggedOutOnce = $accessibe_options['isLoggedOutOnce'];
    520562      }
    521563
    522564      // If decoding fails or ACCESSIBE_OPTIONS_KEY does not exist, fallback to ACCESSIBE_OLD_OPTIONS_KEY
    523565      if(empty($accessibe_options) || !isset($accessibe_options['script'])) {
    524           $accessibe_options = get_option(ACCESSIBE_WP_OLD_OPTIONS_KEY, array());
    525           $accessibe_options['isLoggedOutOnce'] = $isLoggedOutOnce;
     566          $older_options = get_option(ACCESSIBE_WP_OLD_OPTIONS_KEY, array());
     567          $accessibe_options = array_merge($accessibe_options, $older_options);
    526568      }
    527569
     
    611653            <iframe id='accessibe-universal-iframe' src='https://universal.accessibe.com'></iframe>
    612654        </div>
    613         <?php
    614         if ($accessibe_options['isLoggedOutOnce'] != true) {
    615            echo "<script>
    616            window.addEventListener('message', (event) => {
    617             if(event.data.eventName == 'iframe-ready') {
    618                 const iframeRef = document.getElementById('accessibe-universal-iframe');
    619                 iframeRef?.contentWindow.postMessage(
    620                 { eventName: 'request-logout', data: {} },
    621                 '*',
    622                 );
    623                 setTimeout(()=> {
    624                   window.location.reload();
    625                 }, 1000);
    626             }});
    627            </script>";
    628            $accessibe_options['isLoggedOutOnce'] = true;
    629 
    630            update_option(ACCESSIBE_WP_OPTIONS_KEY, json_encode($accessibe_options));
    631         }
    632         ?>
    633655        <!-- /.wrap -->
    634656        <?php
     
    681703    } // accessibe_clear_3rd_party_cache
    682704
     705/**
     706 * @param \WP_Upgrader $upgrader_object The upgrader object.
     707 * @param array $hook_extra Extra information about the update.
     708 */
     709  public static function accessibe_upgrade_completed(\WP_Upgrader $upgrader_object, $hook_extra) {
     710
     711    $plugin_basename = ACCESSIBE_WP_BASENAME;
     712
     713    // Check if the hook involves updating plugins.
     714    if (
     715        isset($hook_extra['action'], $hook_extra['type']) &&
     716        $hook_extra['action'] === 'update' &&
     717        $hook_extra['type'] === 'plugin'
     718    ) {
     719        $this_plugin_updated = false;
     720
     721        // Handle bulk plugin updates.
     722        if (isset($hook_extra['plugins']) && is_array($hook_extra['plugins'])) {
     723            foreach ($hook_extra['plugins'] as $updated_plugin) {
     724                if ($updated_plugin === $plugin_basename) {
     725                    $this_plugin_updated = true;
     726                    break;
     727                }
     728            }
     729        }
     730
     731        // Handle single plugin updates or auto-updates.
     732        if (
     733            !$this_plugin_updated && // If not already identified as updated.
     734            isset($hook_extra['plugin']) &&
     735            $hook_extra['plugin'] === $plugin_basename
     736        ) {
     737            $this_plugin_updated = true;
     738        }
     739
     740        if ($this_plugin_updated) {
     741            // Get the previous version of the plugin.
     742            $previous_version = self::accessibe_get_plugin_version() . '';
     743            // Save the previous version in a transient.
     744            set_transient('accessibe_previous_version', $previous_version);
     745        }
     746    }
     747}
     748
     749  public static function accessibe_after_update_tasks() {
     750
     751    // Check if the plugin was recently updated.
     752    $previous_version = get_transient('accessibe_previous_version');
     753    if ($previous_version) {
     754        // Delete the transient after fetching its value.
     755        delete_transient('accessibe_previous_version');
     756
     757        $latest_version = self::accessibe_get_plugin_version() . '';
     758
     759        $current_data = json_decode(get_option(ACCESSIBE_WP_OPTIONS_KEY), true);
     760        $current_user = wp_get_current_user();
     761
     762        if(!isset($current_data['acsbUserId']) && !isset($current_data['mixpanelUUID'])) {
     763            $uuid = self::generateUuidV4();
     764            $current_data['mixpanelUUID'] = $uuid;
     765        }
     766
     767        $current_data['pluginVersion'] = $latest_version;
     768       
     769        $mixpanelHandler = new MixpanelHandler();
     770
     771        if(isset($current_data['acsbUserId'])) {
     772            $mixpanelHandler->trackEvent('pluginUpgraded', ['userId' => $current_data['acsbUserId'], 'pluginVersion' => $latest_version, 'previousPluginVersion' => $previous_version, 'wordpressStoreName' => self::sanitizeDomain(wp_parse_url(site_url())['host']), 'wordpressPluginVersionNumber' => self::accessibe_get_plugin_version() . '', 'wordpressAccountUserID' => $current_user->ID, 'wordpressUserEmail' => $current_user->user_email, 'wordpressUsername' => $current_user->user_login ]);
     773        }
     774        else {
     775            $mixpanelHandler->trackEvent('pluginUpgraded', ['$device_id' => $current_data['mixpanelUUID'], 'pluginVersion' => $latest_version, 'previousPluginVersion' => $previous_version, 'wordpressStoreName' => self::sanitizeDomain(wp_parse_url(site_url())['host']), 'wordpressPluginVersionNumber' => self::accessibe_get_plugin_version() . '', 'wordpressAccountUserID' => $current_user->ID, 'wordpressUserEmail' => $current_user->user_email, 'wordpressUsername' => $current_user->user_login ]);
     776        }
     777        update_option(ACCESSIBE_WP_OPTIONS_KEY, json_encode($current_data));
     778    }
     779}
     780
     781
    683782
    684783    public static function activate() {
    685784        self::accessibe_reset_pointers();
    686785        $current_data = json_decode(get_option(ACCESSIBE_WP_OPTIONS_KEY), true);
    687         if(!isset($current_data['isInstalled']) || $current_data['isInstalled'] === false) {
     786        $data_to_check = self::accessibe_get_options();
     787        if(empty($data_to_check)) {
    688788            $uuid = self::generateUuidV4();
    689789            $current_user = wp_get_current_user();
    690790            $mixpanelHandler = new MixpanelHandler();
    691             $mixpanelHandler->trackEvent('pluginInstalled', ['$device_id' => $uuid, 'primaryDomain' => self::sanitizeDomain(wp_parse_url(site_url())['host']), 'wp_id' => $current_user->ID, 'wp_email' => $current_user->user_email, 'wp_username' => $current_user->user_login, 'wp_display_name' => $current_user->display_name ]);
    692             $current_data['isInstalled'] = true;
     791            $mixpanelHandler->trackEvent('pluginInstalled', ['$device_id' => $uuid, 'wordpressStoreName' => self::sanitizeDomain(wp_parse_url(site_url())['host']), 'wordpressPluginVersionNumber' => self::accessibe_get_plugin_version() . '', 'wordpressAccountUserID' => $current_user->ID, 'wordpressUserEmail' => $current_user->user_email, 'wordpressUsername' => $current_user->user_login ]);
    693792            $current_data['mixpanelUUID'] = $uuid;
     793            $current_data['pluginVersion'] = self::accessibe_get_plugin_version() . '';
    694794            update_option(ACCESSIBE_WP_OPTIONS_KEY, json_encode($current_data));
    695795        }
     
    699799        $current_data = json_decode(get_option(ACCESSIBE_WP_OPTIONS_KEY), true);
    700800        $current_user = wp_get_current_user();
     801
     802        if(!isset($current_data['acsbUserId']) && !isset($current_data['mixpanelUUID'])) {
     803            $uuid = self::generateUuidV4();
     804            $current_data['mixpanelUUID'] = $uuid;
     805        }
     806
    701807        $mixpanelHandler = new MixpanelHandler();
    702         if(isset($current_data['acsbuserId'])) {
    703             $mixpanelHandler->trackEvent('pluginInstalled', ['userId' => $current_data['acsbuserId'], 'primaryDomain' => self::sanitizeDomain(wp_parse_url(site_url())['host']), 'wp_id' => $current_user->ID, 'wp_email' => $current_user->user_email, 'wp_username' => $current_user->user_login, 'wp_display_name' => $current_user->display_name ]);
     808        if(isset($current_data['acsbUserId'])) {
     809            $mixpanelHandler->trackEvent('pluginUninstalled', ['userId' => $current_data['acsbUserId'], 'wordpressStoreName' => self::sanitizeDomain(wp_parse_url(site_url())['host']), 'wordpressPluginVersionNumber' => self::accessibe_get_plugin_version() . '', 'wordpressAccountUserID' => $current_user->ID, 'wordpressUserEmail' => $current_user->user_email, 'wordpressUsername' => $current_user->user_login ]);
    704810        }
    705811        else {
    706             $mixpanelHandler->trackEvent('pluginInstalled', ['$device_id' => $current_data['mixpanelUUID'], 'primaryDomain' => self::sanitizeDomain(wp_parse_url(site_url())['host']), 'wp_id' => $current_user->ID, 'wp_email' => $current_user->user_email, 'wp_username' => $current_user->user_login, 'wp_display_name' => $current_user->display_name ]);
    707         }
    708         $mixpanelHandler->trackEvent('pluginUninstalled', ['primaryDomain' => self::sanitizeDomain(wp_parse_url(site_url())['host'])]);
     812            $mixpanelHandler->trackEvent('pluginUninstalled', ['$device_id' => $current_data['mixpanelUUID'], 'wordpressStoreName' => self::sanitizeDomain(wp_parse_url(site_url())['host']), 'wordpressPluginVersionNumber' => self::accessibe_get_plugin_version() . '', 'wordpressAccountUserID' => $current_user->ID, 'wordpressUserEmail' => $current_user->user_email, 'wordpressUsername' => $current_user->user_login ]);
     813        }
    709814        delete_option(ACCESSIBE_WP_OPTIONS_KEY);
    710815        delete_option(ACCESSIBE_WP_POINTERS_KEY);
  • accessibe/trunk/readme.txt

    r3224617 r3231917  
    44Requires at least: 4.7
    55Tested up to: 6.7
    6 Stable tag: 2.3.3
     6Stable tag: 2.4
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    5757Plans start at $490 a year (or $59/mo), and vary depending on your website’s monthly traffic.
    5858
     59== Installation ==
     601. Download the plugin file.
     612. In your WordPress dashboard go to **Plugins** > **Add New** > **Upload Plugin** and select the file you downloaded in the previous step.
     623. Select **Install Now**. Once it’s installed, the **Install Now** button will change to Activate.
     634. Select **Activate**.
     645. Sign up to accessiBe in the plugin. If you already have an account, select **Log in**.
     656. Select the domain to **start your 7-day free trial**.
     66
     67See [here](https://accessibe.com/support/installation/how-to-install-accessibe-on-a-wordpress-website) for details.
     68
    5969== Changelog ==
     70= v2.4 =
     71* 2025-01-30
     72* Analytics and bug fixes
     73
    6074= v2.3.3 =
    6175* 2025-01-18
Note: See TracChangeset for help on using the changeset viewer.