Plugin Directory

Changeset 3457833


Ignore:
Timestamp:
02/10/2026 09:54:24 AM (4 weeks ago)
Author:
metriondev
Message:

Deploy version 1.6.3 from GitHub Actions

Location:
metrion
Files:
62 added
4 edited

Legend:

Unmodified
Added
Removed
  • metrion/trunk/includes/js_bundler.php

    r3453715 r3457833  
    113113    }
    114114
     115    // MyYounit integration
     116    if (get_option('metrion_enable_myyounit_integration', false)) {
     117        $source_files[] = $plugin_dir . 'js/myyounit/integration.js';
     118    }
     119
    115120    // WooCommerce tracking
    116121    if (get_option('metrion_enable_woocommerce_tracking', false)) {
     
    120125            $source_files[] = $plugin_dir . 'js/woo/other_events.js';
    121126        }
    122     }
    123 
    124     // MyYounit integration
    125     if (get_option('metrion_enable_myyounit_integration', false)) {
    126         $source_files[] = $plugin_dir . 'js/myyounit/integration.js';
    127127    }
    128128
     
    172172            // translators: %s is the file path that could not be read.
    173173            return new WP_Error('read_failed', sprintf(__('Failed to read source file: %s', 'metrion'), esc_html($file)));
     174        }
     175
     176        if (strpos($file, "myyounit") !== false) {
     177            $installation_id = get_option('metrion_installation_id', '');
     178            $content = str_replace('__INSTALLATION_ID_H__', esc_js($installation_id), $content);
    174179        }
    175180
     
    217222        $source_files[] = $plugin_dir . 'js/cmp/' . $cmp_selection . '/logic.js';
    218223    }
     224   
     225    // MyYounit integration
     226    if (get_option('metrion_enable_myyounit_integration', false)) {
     227        $source_files[] = $plugin_dir . 'js/myyounit/integration.js';
     228    }
    219229
    220230    // WooCommerce tracking
     
    225235            $source_files[] = $plugin_dir . 'js/woo/other_events.js';
    226236        }
    227     }
    228 
    229     // MyYounit integration
    230     if (get_option('metrion_enable_myyounit_integration', false)) {
    231         $source_files[] = $plugin_dir . 'js/myyounit/integration.js';
    232237    }
    233238
     
    295300            // translators: %s is the file path that could not be read.
    296301            return new WP_Error('read_failed', sprintf(__('Failed to read source file: %s', 'metrion'), esc_html($file)));
     302        }
     303
     304        if (strpos($file, "myyounit") !== false) {
     305            $installation_id = get_option('metrion_installation_id', '');
     306            $content = str_replace('__INSTALLATION_ID_H__', esc_js($installation_id), $content);
    297307        }
    298308
  • metrion/trunk/js/myyounit/integration.js

    r3453715 r3457833  
    22
    33window.metrion.append_cookies_for_myyounit = function () {
    4     let aTags = document.querySelectorAll("a");
    5     let me_uid = window.metrion.user_manager.get_user_cookie_values()[0];
    6     let me_sid = window.metrion.session_manager.get_session_cookie_values()[0];
    7     let me_installation_id = window.metrion_api.installation_id;
    8     for (let a of aTags) {
    9         if (!a.href || !a.href.includes("myyounit.nl")) continue;
    10         var newUrl = new URL(a.href);
    11         if (!a.href.includes("metrion_uid")) {   
    12             newUrl.searchParams.append("metrion_uid", me_uid);
     4  let aTags = document.querySelectorAll("a");
     5 
     6  let me_uid = window.metrion?.user_manager?.get_user_cookie_values()?.[0];
     7  let me_sid = window.metrion?.session_manager?.get_session_cookie_values()?.[0];
     8  let me_installation_id = "__INSTALLATION_ID_H__";
     9  if (!me_installation_id || me_installation_id === "") {
     10    me_installation_id = window.metrion_api?.installation_id;
     11  }
     12
     13  for (let a of aTags) {
     14    if (!a.href || !a.href.includes("myyounit.nl")) continue;
     15   
     16    try {
     17      var newUrl = new URL(a.href);
     18     
     19      if (me_uid && !newUrl.searchParams.has("metrion_uid")) {
     20        newUrl.searchParams.append("metrion_uid", me_uid);
     21      }
     22      if (me_sid && !newUrl.searchParams.has("metrion_sid")) {
     23        newUrl.searchParams.append("metrion_sid", me_sid);
     24      }
     25      if (me_installation_id && !newUrl.searchParams.has("metrion_installation_id")) {
     26        newUrl.searchParams.append("metrion_installation_id", me_installation_id);
     27      }
     28     
     29      a.href = newUrl.toString();
     30    } catch (e) { }
     31  }
     32};
     33
     34window.metrion._myyHandleLinkClick = function (e) {
     35  const link = e.target.closest('a[href*="myyounit.nl"]');
     36  if (!link) return;
     37
     38  window.metrion.append_cookies_for_myyounit();
     39
     40  if (e.button === 1 || e.ctrlKey || e.metaKey || e.shiftKey) {
     41    return;
     42  }
     43
     44  if (e.button === 0) {
     45    e.preventDefault();
     46    window.location.href = link.href;
     47  }
     48};
     49
     50window.metrion._myyHandleKeydown = function (e) {
     51  if (e.key !== "Enter") return;
     52 
     53  const link = e.target.closest('a[href*="myyounit.nl"]');
     54  if (!link) return;
     55
     56  window.metrion.append_cookies_for_myyounit();
     57  e.preventDefault();
     58  window.location.href = link.href;
     59};
     60
     61window.metrion._myySetupObserver = function () {
     62  if (window.metrion._observer) return;
     63
     64  window.metrion._observer = new MutationObserver((mutations) => {
     65    let shouldUpdate = false;
     66   
     67    for (const mutation of mutations) {
     68      for (const node of mutation.addedNodes) {
     69        if (node.nodeType !== Node.ELEMENT_NODE) continue;
     70       
     71        if (node.matches?.('a[href*="myyounit.nl"]') ||
     72            node.querySelector?.('a[href*="myyounit.nl"]')) {
     73          shouldUpdate = true;
     74          break;
    1375        }
    14         if (!a.href.includes("metrion_sid")) {   
    15             newUrl.searchParams.append("metrion_sid", me_sid);
     76      }
     77      if (shouldUpdate) break;
     78    }
     79   
     80    if (shouldUpdate) {
     81      window.metrion.append_cookies_for_myyounit();
     82    }
     83  });
     84
     85  window.metrion._observer.observe(document.body, {
     86    childList: true,
     87    subtree: true
     88  });
     89};
     90
     91window.metrion._myyEnsureInitialized = function () {
     92  const maxAttempts = 10;
     93  const interval = 300;
     94  let attempts = 0;
     95
     96  const tryInit = () => {
     97    attempts++;
     98   
     99    if (window.metrion_api?.installation_id) {
     100      window.metrion.append_cookies_for_myyounit();
     101      return;
     102    }
     103   
     104    if (attempts < maxAttempts) {
     105      setTimeout(tryInit, interval);
     106    } else {
     107        if (window.metrion) {
     108            window.metrion.send_event("metrion_api_failed", {
     109                message: "Something went wrong reading metrion_api",
     110            });
    16111        }
    17         if (!a.href.includes("metrion_installation_id")) {   
    18             newUrl.searchParams.append("metrion_installation_id", me_installation_id);
    19         }
    20         a.href = newUrl.toString();
    21112    }
     113  };
     114
     115  tryInit();
     116};
     117
     118window.metrion._myyInit = function () {
     119  document.removeEventListener("click", window.metrion._myyHandleLinkClick);
     120  document.removeEventListener("auxclick", window.metrion._myyHandleLinkClick);
     121  document.removeEventListener("keydown", window.metrion._myyHandleKeydown);
     122
     123  document.addEventListener("click", window.metrion._myyHandleLinkClick);
     124  document.addEventListener("auxclick", window.metrion._myyHandleLinkClick);
     125  document.addEventListener("keydown", window.metrion._myyHandleKeydown);
     126
     127  window.metrion._myySetupObserver();
     128
     129  window.metrion._myyEnsureInitialized();
     130};
     131
     132if (document.readyState === "loading") {
     133  document.addEventListener("DOMContentLoaded", window.metrion._myyInit);
     134} else {
     135  window.metrion._myyInit();
    22136}
    23 
    24 window.metrion.append_cookies_for_myyounit();
    25 
    26 addEventListener("click", () => {
    27     window.metrion.append_cookies_for_myyounit();
    28 });
  • metrion/trunk/main.php

    r3453910 r3457833  
    33* Plugin Name:          Metrion
    44* Description:          Skip manual implementation, sync data directly tailored to destinations like Google Ads and Meta Ads.
    5 * Version:              1.6.2
     5* Version:              1.6.3
    66* Author:               Metrion
    77* Author URI:           https://getmetrion.com
     
    1212if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    1313
    14 define('GLOBAL_METRION_PLUGIN_VERSION', '1.6.2');
     14define('GLOBAL_METRION_PLUGIN_VERSION', '1.6.3');
    1515
    1616require_once plugin_dir_path(__FILE__) . 'includes/js_bundler.php';
  • metrion/trunk/readme.txt

    r3453910 r3457833  
    44Requires at least: 3.8
    55Tested up to: 6.8
    6 Stable tag: 1.6.2
     6Stable tag: 1.6.3
    77Requires PHP: 7.1
    88License: GPLv3 or later
     
    9393== Changelog ==
    9494
     95= 1.6.3 =
     96- Improved integration with MyYounit
     97
    9598= 1.6.2 =
    9699- Collection preparations for Klaviyo
Note: See TracChangeset for help on using the changeset viewer.