diff --git a/.github/workflows/matomo-tests.yml b/.github/workflows/matomo-tests.yml index 362ae8f..75ed05c 100644 --- a/.github/workflows/matomo-tests.yml +++ b/.github/workflows/matomo-tests.yml @@ -1,7 +1,7 @@ # Action for running tests # This file has been automatically created. # To recreate it you can run this command -# ./console generate:test-action --plugin="CustomVariables" --php-versions="matomo5_min_php,matomo5_max_php" --schedule-cron="0 3 * * 6" +# ./console generate:test-action --plugin="CustomVariables" --php-versions="matomo6_min_php,matomo6_max_php" --schedule-cron="0 3 * * 6" name: Plugin CustomVariables Tests @@ -37,8 +37,11 @@ jobs: strategy: fail-fast: false matrix: - php: [ 'matomo5_min_php', 'matomo5_max_php' ] + php: [ 'matomo6_min_php', 'matomo6_max_php' ] target: ['minimum_required_matomo', 'maximum_supported_matomo'] + database: + - { engine: 'Mysql', version: '8.0' } + - { engine: 'Mariadb', version: '10.6' } steps: - uses: actions/checkout@v3 with: @@ -52,9 +55,11 @@ jobs: plugin-name: 'CustomVariables' php-version: ${{ matrix.php }} test-type: 'PluginTests' + mysql-engine: ${{ matrix.database.engine }} + mysql-version: ${{ matrix.database.version }} matomo-test-branch: ${{ matrix.target }} artifacts-pass: ${{ secrets.ARTIFACTS_PASS }} - upload-artifacts: ${{ matrix.php == 'matomo5_min_php' && matrix.target == 'maximum_supported_matomo' }} + upload-artifacts: ${{ matrix.php == 'matomo6_min_php' && matrix.target == 'maximum_supported_matomo' && matrix.database.engine == 'Mysql' }} UI: runs-on: ubuntu-24.04 steps: @@ -68,7 +73,9 @@ jobs: plugin-name: 'CustomVariables' matomo-test-branch: 'maximum_supported_matomo' test-type: 'UI' - php-version: 'matomo5_min_php' - node-version: '16' + php-version: 'matomo6_min_php' + node-version: '24' + mysql-engine: 'Mysql' + mysql-version: '8.0' artifacts-pass: ${{ secrets.ARTIFACTS_PASS }} upload-artifacts: true diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 9d675e4..c2feadc 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -26,7 +26,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: '8.1' tools: cs2pr - name: Install dependencies run: diff --git a/.gitignore b/.gitignore index 71f2693..a3f1cec 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ tests/System/processed/*text /vue/dist/*.common.js /vue/dist/*.map /vue/dist/*.development.* +# only the minified bundle is served; the unminified one is no longer built +/vue/dist/*.umd.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 75252cb..767e39f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +6.0.0 - 2026-08-09 +- Compatibility with Matomo 6 + 5.0.6 - 2026-04-27 - Updated API documentation diff --git a/plugin.json b/plugin.json index 4d16ad6..73f1331 100644 --- a/plugin.json +++ b/plugin.json @@ -1,12 +1,12 @@ { "name": "CustomVariables", "description": "Categorise your visitors and actions with custom name-value pairs. Segment by these values and get more insights to draw the right conclusions.", - "version": "5.0.6", + "version": "6.0.0", "keywords": ["custom variables"], "license": "GPL v3+", "homepage": "https://matomo.org", "require": { - "matomo": ">=5.0.0-b4,<6.0.0-b1" + "matomo": ">=6.0.0-b1,<7.0.0-b1" }, "support": { "email": "hello@matomo.org", diff --git a/tests/Fixtures/TwoVisitsWithCustomVariables.php b/tests/Fixtures/TwoVisitsWithCustomVariables.php index 47e8517..50738bb 100644 --- a/tests/Fixtures/TwoVisitsWithCustomVariables.php +++ b/tests/Fixtures/TwoVisitsWithCustomVariables.php @@ -151,7 +151,10 @@ private function trackVisits() $visitorB->setCustomVariable($id = 2, $name = 'Othercustom value which should be truncated abcdefghijklmnopqrstuvwxyz', $value = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'); $visitorB->setCustomVariable($id = -2, $name = 'not tracked', $value = 'not tracked'); $visitorB->setCustomVariable($id = 6, $name = 'not tracked', $value = 'not tracked'); - $visitorB->setCustomVariable($id = 6, $name = array('not tracked'), $value = 'not tracked'); + // A custom variable with a non-string (array) name can no longer go through the + // type-safe setCustomVariable(); inject it straight into the cvar payload so we + // still verify a malformed custom variable is not tracked. + $visitorB->visitorCustomVar[6] = array(array('not tracked'), 'not tracked'); $visitorB->setUrl('http://example.org/homepage'); self::checkResponse($visitorB->doTrackGoal($idGoal, 1000)); diff --git a/tests/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php b/tests/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php index 47eb8fb..335c9bc 100644 --- a/tests/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php +++ b/tests/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\CustomVariables\tests\System; +use Piwik\Columns\Dimension; use Piwik\Plugins\API\tests\System\AutoSuggestAPITest; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Plugins\CustomVariables\tests\Fixtures\TwoVisitsWithCustomVariables; @@ -63,9 +64,15 @@ public function getSegmentToTest() $this->assertGreaterThan($minimumExpectedSegmentsCount, count($segments)); $segmentExpression = array(); + $temporalSegmentValues = self::getTemporalSegmentValues(); + $seenVisitorId = false; foreach ($segments as $segment) { - $value = 'campaign'; + // Date/time segments can't be compared against an arbitrary string: MySQL 8.0 rejects + // e.g. "visitEndServerDate != 'campaign'" as an invalid DATE value (5.7 tolerated it). + // Give them a valid, type-appropriate value (a date for DATE() segments, a number for + // the HOUR()/MINUTE()/YEAR()/... integer extractions) so they stay covered. + $value = $temporalSegmentValues[$segment] ?? 'campaign'; if ($segment == 'visitorId') { $seenVisitorId = true; $value = '34c31e04394bdc63'; @@ -107,6 +114,42 @@ public static function getOutputPrefix() return 'twoVisitsWithCustomVariables_segmentMatchNONE'; } + /** + * Returns a valid comparison value for every non-internal segment backed by a date/time typed + * dimension, keyed by segment name. + * + * These segments map to SQL that expects either a date (e.g. DATE(...)) or an integer (the + * HOUR()/MINUTE()/YEAR()/... extractions), so an arbitrary string like "campaign" produces an + * invalid DATE value error on MySQL 8.0. The returned values are valid for the respective + * comparison. + */ + private static function getTemporalSegmentValues(): array + { + $temporalTypes = [ + Dimension::TYPE_DATE, + Dimension::TYPE_DATETIME, + Dimension::TYPE_TIME, + Dimension::TYPE_TIMESTAMP, + ]; + + $values = []; + foreach (Dimension::getAllDimensions() as $dimension) { + if (!in_array($dimension->getType(), $temporalTypes, true)) { + continue; + } + + foreach ($dimension->getSegments() as $segment) { + $isIntegerExtraction = (bool) preg_match( + '/^\s*(HOUR|MINUTE|SECOND|DAYOFWEEK|DAYOFMONTH|DAYOFYEAR|WEEKOFYEAR|WEEK|MONTH|QUARTER|YEAR)\s*\(/i', + $segment->getSqlSegment() + ); + $values[$segment->getSegment()] = $isIntegerExtraction ? '99' : '2099-12-31'; + } + } + + return $values; + } + public static function getPathToTestDirectory() { return dirname(__FILE__); diff --git a/tests/UI/expected-ui-screenshots/CustomVariables_link_in_menu.png b/tests/UI/expected-ui-screenshots/CustomVariables_link_in_menu.png index 4ede3a3..acec0ab 100644 Binary files a/tests/UI/expected-ui-screenshots/CustomVariables_link_in_menu.png and b/tests/UI/expected-ui-screenshots/CustomVariables_link_in_menu.png differ diff --git a/tests/UI/expected-ui-screenshots/CustomVariables_manage.png b/tests/UI/expected-ui-screenshots/CustomVariables_manage.png index 08bb356..5917560 100644 Binary files a/tests/UI/expected-ui-screenshots/CustomVariables_manage.png and b/tests/UI/expected-ui-screenshots/CustomVariables_manage.png differ diff --git a/vue/dist/CustomVariables.umd.js b/vue/dist/CustomVariables.umd.js deleted file mode 100644 index 0cba004..0000000 --- a/vue/dist/CustomVariables.umd.js +++ /dev/null @@ -1,446 +0,0 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("CoreHome"), require("vue")); - else if(typeof define === 'function' && define.amd) - define(["CoreHome", ], factory); - else if(typeof exports === 'object') - exports["CustomVariables"] = factory(require("CoreHome"), require("vue")); - else - root["CustomVariables"] = factory(root["CoreHome"], root["Vue"]); -})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__19dc__, __WEBPACK_EXTERNAL_MODULE__8bbf__) { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = "plugins/CustomVariables/vue/dist/"; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "fae3"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "19dc": -/***/ (function(module, exports) { - -module.exports = __WEBPACK_EXTERNAL_MODULE__19dc__; - -/***/ }), - -/***/ "8bbf": -/***/ (function(module, exports) { - -module.exports = __WEBPACK_EXTERNAL_MODULE__8bbf__; - -/***/ }), - -/***/ "fae3": -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -// ESM COMPAT FLAG -__webpack_require__.r(__webpack_exports__); - -// EXPORTS -__webpack_require__.d(__webpack_exports__, "ManageCustomVarsStore", function() { return /* reexport */ ManageCustomVars_store; }); -__webpack_require__.d(__webpack_exports__, "ManageCustomVars", function() { return /* reexport */ ManageCustomVars; }); - -// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js -// This file is imported into lib/wc client bundles. - -if (typeof window !== 'undefined') { - var currentScript = window.document.currentScript - if (false) { var getCurrentScript; } - - var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/) - if (src) { - __webpack_require__.p = src[1] // eslint-disable-line - } -} - -// Indicate to webpack that this file can be concatenated -/* harmony default export */ var setPublicPath = (null); - -// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"} -var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf"); - -// EXTERNAL MODULE: external "CoreHome" -var external_CoreHome_ = __webpack_require__("19dc"); - -// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.store.ts -function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } - -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - -function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - -/*! - * Matomo - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - - - -var ManageCustomVars_store_ManageCustomVarsStore = /*#__PURE__*/function () { - function ManageCustomVarsStore() { - var _this = this; - - _classCallCheck(this, ManageCustomVarsStore); - - _defineProperty(this, "privateState", Object(external_commonjs_vue_commonjs2_vue_root_Vue_["reactive"])({ - customVariables: [], - isLoading: false, - hasCustomVariablesInGeneral: false, - hasAtLeastOneUsage: false, - numSlotsAvailable: 5 - })); - - _defineProperty(this, "state", Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { - return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["readonly"])(_this.privateState); - })); - } - - _createClass(ManageCustomVarsStore, [{ - key: "init", - value: function init() { - return this.fetchUsages(); - } - }, { - key: "fetchCustomVariables", - value: function fetchCustomVariables() { - var _this2 = this; - - return external_CoreHome_["AjaxHelper"].fetch({ - method: 'CustomVariables.getCustomVariables', - period: 'year', - date: 'today', - filter_limit: 1 - }).then(function (customVariables) { - _this2.privateState.hasCustomVariablesInGeneral = (customVariables === null || customVariables === void 0 ? void 0 : customVariables.length) > 0; - }); - } - }, { - key: "fetchUsages", - value: function fetchUsages() { - var _this3 = this; - - this.privateState.isLoading = true; - return Promise.all([this.fetchCustomVariables(), external_CoreHome_["AjaxHelper"].fetch({ - method: 'CustomVariables.getUsagesOfSlots', - filter_limit: '-1' - })]).then(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2), - customVariableUsages = _ref2[1]; - - _this3.privateState.customVariables = customVariableUsages; - customVariableUsages.forEach(function (customVar) { - if (customVar.index > _this3.state.value.numSlotsAvailable) { - _this3.privateState.numSlotsAvailable = customVar.index; - } - - if (customVar.usages && customVar.usages.length > 0) { - _this3.privateState.hasAtLeastOneUsage = true; - } - }); - }).finally(function () { - _this3.privateState.isLoading = false; - }); - } - }]); - - return ManageCustomVarsStore; -}(); - -/* harmony default export */ var ManageCustomVars_store = (new ManageCustomVars_store_ManageCustomVarsStore()); -// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=template&id=ddf373e4 - -var _hoisted_1 = { - class: "manageCustomVars" -}; -var _hoisted_2 = ["innerHTML"]; -var _hoisted_3 = { - class: "index" -}; -var _hoisted_4 = ["title"]; -var _hoisted_5 = { - key: 0 -}; - -var _hoisted_6 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); - -var _hoisted_7 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); - -var _hoisted_8 = ["innerHTML"]; - -var _hoisted_9 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); - -var _hoisted_10 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); - -var _hoisted_11 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); - -var _hoisted_12 = ["textContent"]; -function render(_ctx, _cache, $props, $setup, $data, $options) { - var _component_EnrichedHeadline = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("EnrichedHeadline"); - - var _component_ContentBlock = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ContentBlock"); - - var _directive_content_intro = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("content-intro"); - - var _directive_content_table = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("content-table"); - - var _directive_select_on_focus = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("select-on-focus"); - - return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h2", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_EnrichedHeadline, { - "help-url": "https://matomo.org/docs/custom-variables/" - }, { - default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { - return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_CustomVariables')), 1)]; - }), - _: 1 - })]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { - innerHTML: _ctx.$sanitize(_ctx.translate('CustomVariables_ManageDescription', _ctx.siteName)) - }, null, 8, _hoisted_2)])], 512), [[_directive_content_intro]]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", { - class: "alert alert-info" - }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_SlotsReportIsGeneratedOverTime')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.isLoading && _ctx.hasCustomVariablesInGeneral && !_ctx.hasAtLeastOneUsage]]), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.scopes, function (scope) { - return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", { - key: scope.name - }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ContentBlock, { - "content-title": _ctx.translate('CustomVariables_ScopeX', scope.name) - }, { - default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { - return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("table", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("thead", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("tr", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_Index')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_Usages')), 1)])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("tbody", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("tr", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", { - colspan: "3" - }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Loading')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.isLoading]])]), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.customVariablesByScope[scope.value], function (customVariables, index) { - return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("tr", { - key: index - }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", _hoisted_3, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(customVariables.index), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { - class: "unused" - }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_Unused')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], customVariables.usages.length === 0]]), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.sortUsages(customVariables), function (cvar, cvarIndex) { - return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])((Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", { - key: cvarIndex - }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { - title: _ctx.translate('CustomVariables_UsageDetails', cvar.nb_visits ? cvar.nb_visits : 0, cvar.nb_actions ? cvar.nb_actions : 0) - }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(cvar.name), 9, _hoisted_4), cvarIndex < customVariables.usages.length - 1 ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", _hoisted_5, ", ")) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)], 512)), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], customVariables.usages.length]]); - }), 128))])]); - }), 128))])], 512), [[_directive_content_table]])]; - }), - _: 2 - }, 1032, ["content-title"])]); - }), 128)), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ContentBlock, { - id: "CustomVariablesCreateNewSlot", - "content-title": _ctx.translate('CustomVariables_CreateNewSlot') - }, { - default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { - return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_CreatingCustomVariableTakesTime')) + " ", 1), _hoisted_6, _hoisted_7, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { - innerHTML: _ctx.$sanitize(_ctx.currentAvailableCustomVariablesText) - }, null, 8, _hoisted_8), _hoisted_9, _hoisted_10, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_ToCreateCustomVarExecute')) + " ", 1), _hoisted_11]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("pre", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("code", { - textContent: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.setMaxCustomVariablesCmd) - }, null, 8, _hoisted_12)], 512), [[_directive_select_on_focus, {}]])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.isLoading]])]; - }), - _: 1 - }, 8, ["content-title"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.isLoading]])]); -} -// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=template&id=ddf373e4 - -// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=script&lang=ts -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || ManageCustomVarsvue_type_script_lang_ts_unsupportedIterableToArray(arr) || _nonIterableSpread(); } - -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - -function ManageCustomVarsvue_type_script_lang_ts_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return ManageCustomVarsvue_type_script_lang_ts_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return ManageCustomVarsvue_type_script_lang_ts_arrayLikeToArray(o, minLen); } - -function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } - -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return ManageCustomVarsvue_type_script_lang_ts_arrayLikeToArray(arr); } - -function ManageCustomVarsvue_type_script_lang_ts_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - - - - -/* harmony default export */ var ManageCustomVarsvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ - components: { - EnrichedHeadline: external_CoreHome_["EnrichedHeadline"], - ContentBlock: external_CoreHome_["ContentBlock"] - }, - directives: { - ContentIntro: external_CoreHome_["ContentIntro"], - ContentTable: external_CoreHome_["ContentTable"], - SelectOnFocus: external_CoreHome_["SelectOnFocus"] - }, - data: function data() { - return { - siteName: external_CoreHome_["Matomo"].siteName, - scopes: [{ - value: 'visit', - name: Object(external_CoreHome_["translate"])('General_TrackingScopeVisit') - }, { - value: 'page', - name: Object(external_CoreHome_["translate"])('General_TrackingScopePage') - }] - }; - }, - created: function created() { - ManageCustomVars_store.init(); - }, - methods: { - sortUsages: function sortUsages(customVar) { - var result = _toConsumableArray(customVar.usages); - - result.sort(function (lhs, rhs) { - var rhsActions = "".concat(rhs.nb_actions); - var lhsActions = "".concat(lhs.nb_actions); - return parseInt(rhsActions, 10) - parseInt(lhsActions, 10); - }); - return result; - } - }, - computed: { - isLoading: function isLoading() { - return ManageCustomVars_store.state.value.isLoading; - }, - hasCustomVariablesInGeneral: function hasCustomVariablesInGeneral() { - return ManageCustomVars_store.state.value.hasCustomVariablesInGeneral; - }, - hasAtLeastOneUsage: function hasAtLeastOneUsage() { - return ManageCustomVars_store.state.value.hasAtLeastOneUsage; - }, - numSlotsAvailable: function numSlotsAvailable() { - return ManageCustomVars_store.state.value.numSlotsAvailable; - }, - customVariablesByScope: function customVariablesByScope() { - var result = {}; - ManageCustomVars_store.state.value.customVariables.forEach(function (customVar) { - result[customVar.scope] = result[customVar.scope] || []; - result[customVar.scope].push(customVar); - }); - return result; - }, - currentAvailableCustomVariablesText: function currentAvailableCustomVariablesText() { - return Object(external_CoreHome_["translate"])('CustomVariables_CurrentAvailableCustomVariables', "".concat(this.numSlotsAvailable, "")); - }, - setMaxCustomVariablesCmd: function setMaxCustomVariablesCmd() { - return "./console customvariables:set-max-custom-variables ".concat(this.numSlotsAvailable + 1); - } - } -})); -// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=script&lang=ts - -// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue - - - -ManageCustomVarsvue_type_script_lang_ts.render = render - -/* harmony default export */ var ManageCustomVars = (ManageCustomVarsvue_type_script_lang_ts); -// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/index.ts -/*! - * Matomo - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - - -// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib-no-default.js - - - - -/***/ }) - -/******/ }); -}); -//# sourceMappingURL=CustomVariables.umd.js.map \ No newline at end of file diff --git a/vue/dist/CustomVariables.umd.min.js b/vue/dist/CustomVariables.umd.min.js index 5834a0c..da21a1c 100644 --- a/vue/dist/CustomVariables.umd.min.js +++ b/vue/dist/CustomVariables.umd.min.js @@ -1,14 +1,8 @@ -(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("CoreHome"),require("vue")):"function"===typeof define&&define.amd?define(["CoreHome"],t):"object"===typeof exports?exports["CustomVariables"]=t(require("CoreHome"),require("vue")):e["CustomVariables"]=t(e["CoreHome"],e["Vue"])})("undefined"!==typeof self?self:this,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="plugins/CustomVariables/vue/dist/",n(n.s="fae3")}({"19dc":function(t,n){t.exports=e},"8bbf":function(e,n){e.exports=t},fae3:function(e,t,n){"use strict";if(n.r(t),n.d(t,"ManageCustomVarsStore",(function(){return j})),n.d(t,"ManageCustomVars",(function(){return H})),"undefined"!==typeof window){var r=window.document.currentScript,a=r&&r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);a&&(n.p=a[1])}var o=n("8bbf"),l=n("19dc");function i(e,t){return m(e)||b(e,t)||s(e,t)||c()}function c(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){if(e){if("string"===typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n((e,t,a)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);const s=new /*! - * Matomo - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */var O=function(){function e(){var t=this;d(this,e),v(this,"privateState",Object(o["reactive"])({customVariables:[],isLoading:!1,hasCustomVariablesInGeneral:!1,hasAtLeastOneUsage:!1,numSlotsAvailable:5})),v(this,"state",Object(o["computed"])((function(){return Object(o["readonly"])(t.privateState)})))}return p(e,[{key:"init",value:function(){return this.fetchUsages()}},{key:"fetchCustomVariables",value:function(){var e=this;return l["AjaxHelper"].fetch({method:"CustomVariables.getCustomVariables",period:"year",date:"today",filter_limit:1}).then((function(t){e.privateState.hasCustomVariablesInGeneral=(null===t||void 0===t?void 0:t.length)>0}))}},{key:"fetchUsages",value:function(){var e=this;return this.privateState.isLoading=!0,Promise.all([this.fetchCustomVariables(),l["AjaxHelper"].fetch({method:"CustomVariables.getUsagesOfSlots",filter_limit:"-1"})]).then((function(t){var n=i(t,2),r=n[1];e.privateState.customVariables=r,r.forEach((function(t){t.index>e.state.value.numSlotsAvailable&&(e.privateState.numSlotsAvailable=t.index),t.usages&&t.usages.length>0&&(e.privateState.hasAtLeastOneUsage=!0)}))})).finally((function(){e.privateState.isLoading=!1}))}}]),e}(),j=new O,h={class:"manageCustomVars"},g=["innerHTML"],y={class:"index"},V=["title"],C={key:0},S=Object(o["createElementVNode"])("br",null,null,-1),E=Object(o["createElementVNode"])("br",null,null,-1),N=["innerHTML"],w=Object(o["createElementVNode"])("br",null,null,-1),x=Object(o["createElementVNode"])("br",null,null,-1),_=Object(o["createElementVNode"])("br",null,null,-1),k=["textContent"];function A(e,t,n,r,a,l){var i=Object(o["resolveComponent"])("EnrichedHeadline"),c=Object(o["resolveComponent"])("ContentBlock"),s=Object(o["resolveDirective"])("content-intro"),u=Object(o["resolveDirective"])("content-table"),b=Object(o["resolveDirective"])("select-on-focus");return Object(o["openBlock"])(),Object(o["createElementBlock"])("div",h,[Object(o["withDirectives"])(Object(o["createElementVNode"])("div",null,[Object(o["createElementVNode"])("h2",null,[Object(o["createVNode"])(i,{"help-url":"https://matomo.org/docs/custom-variables/"},{default:Object(o["withCtx"])((function(){return[Object(o["createTextVNode"])(Object(o["toDisplayString"])(e.translate("CustomVariables_CustomVariables")),1)]})),_:1})]),Object(o["createElementVNode"])("p",null,[Object(o["createElementVNode"])("span",{innerHTML:e.$sanitize(e.translate("CustomVariables_ManageDescription",e.siteName))},null,8,g)])],512),[[s]]),Object(o["withDirectives"])(Object(o["createElementVNode"])("div",{class:"alert alert-info"},Object(o["toDisplayString"])(e.translate("CustomVariables_SlotsReportIsGeneratedOverTime")),513),[[o["vShow"],!e.isLoading&&e.hasCustomVariablesInGeneral&&!e.hasAtLeastOneUsage]]),(Object(o["openBlock"])(!0),Object(o["createElementBlock"])(o["Fragment"],null,Object(o["renderList"])(e.scopes,(function(t){return Object(o["openBlock"])(),Object(o["createElementBlock"])("div",{key:t.name},[Object(o["createVNode"])(c,{"content-title":e.translate("CustomVariables_ScopeX",t.name)},{default:Object(o["withCtx"])((function(){return[Object(o["withDirectives"])(Object(o["createElementVNode"])("table",null,[Object(o["createElementVNode"])("thead",null,[Object(o["createElementVNode"])("tr",null,[Object(o["createElementVNode"])("th",null,Object(o["toDisplayString"])(e.translate("CustomVariables_Index")),1),Object(o["createElementVNode"])("th",null,Object(o["toDisplayString"])(e.translate("CustomVariables_Usages")),1)])]),Object(o["createElementVNode"])("tbody",null,[Object(o["createElementVNode"])("tr",null,[Object(o["withDirectives"])(Object(o["createElementVNode"])("td",{colspan:"3"},Object(o["toDisplayString"])(e.translate("General_Loading")),513),[[o["vShow"],e.isLoading]])]),(Object(o["openBlock"])(!0),Object(o["createElementBlock"])(o["Fragment"],null,Object(o["renderList"])(e.customVariablesByScope[t.value],(function(t,n){return Object(o["openBlock"])(),Object(o["createElementBlock"])("tr",{key:n},[Object(o["createElementVNode"])("td",y,Object(o["toDisplayString"])(t.index),1),Object(o["createElementVNode"])("td",null,[Object(o["withDirectives"])(Object(o["createElementVNode"])("span",{class:"unused"},Object(o["toDisplayString"])(e.translate("CustomVariables_Unused")),513),[[o["vShow"],0===t.usages.length]]),(Object(o["openBlock"])(!0),Object(o["createElementBlock"])(o["Fragment"],null,Object(o["renderList"])(e.sortUsages(t),(function(n,r){return Object(o["withDirectives"])((Object(o["openBlock"])(),Object(o["createElementBlock"])("span",{key:r},[Object(o["createElementVNode"])("span",{title:e.translate("CustomVariables_UsageDetails",n.nb_visits?n.nb_visits:0,n.nb_actions?n.nb_actions:0)},Object(o["toDisplayString"])(n.name),9,V),re.length)&&(t=e.length);for(var n=0,r=new Array(t);n".concat(this.numSlotsAvailable,""))},setMaxCustomVariablesCmd:function(){return"./console customvariables:set-max-custom-variables ".concat(this.numSlotsAvailable+1)}}});U.render=A;var H=U; -/*! - * Matomo - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */}})})); -//# sourceMappingURL=CustomVariables.umd.min.js.map \ No newline at end of file + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ +class{constructor(){l(this,"privateState",t.reactive({customVariables:[],isLoading:!1,hasCustomVariablesInGeneral:!1,hasAtLeastOneUsage:!1,numSlotsAvailable:5})),l(this,"state",t.computed(()=>t.readonly(this.privateState)))}init(){return this.fetchUsages()}fetchCustomVariables(){return a.AjaxHelper.fetch({method:"CustomVariables.getCustomVariables",period:"year",date:"today",filter_limit:1}).then(e=>{this.privateState.hasCustomVariablesInGeneral=(null==e?void 0:e.length)>0})}fetchUsages(){return this.privateState.isLoading=!0,Promise.all([this.fetchCustomVariables(),a.AjaxHelper.fetch({method:"CustomVariables.getUsagesOfSlots",filter_limit:"-1"})]).then(([,e])=>{this.privateState.customVariables=e,e.forEach(e=>{e.index>this.state.value.numSlotsAvailable&&(this.privateState.numSlotsAvailable=e.index),e.usages&&e.usages.length>0&&(this.privateState.hasAtLeastOneUsage=!0)})}).finally(()=>{this.privateState.isLoading=!1})}},o=t.defineComponent({components:{EnrichedHeadline:a.EnrichedHeadline,ContentBlock:a.ContentBlock},directives:{ContentIntro:a.ContentIntro,ContentTable:a.ContentTable,SelectOnFocus:a.SelectOnFocus},data:()=>({siteName:a.Matomo.siteName,scopes:[{value:"visit",name:a.translate("General_TrackingScopeVisit")},{value:"page",name:a.translate("General_TrackingScopePage")}]}),created(){s.init()},methods:{sortUsages(e){const t=[...e.usages];return t.sort((e,t)=>{const a=`${t.nb_actions}`,n=`${e.nb_actions}`;return parseInt(a,10)-parseInt(n,10)}),t}},computed:{isLoading:()=>s.state.value.isLoading,hasCustomVariablesInGeneral:()=>s.state.value.hasCustomVariablesInGeneral,hasAtLeastOneUsage:()=>s.state.value.hasAtLeastOneUsage,numSlotsAvailable:()=>s.state.value.numSlotsAvailable,customVariablesByScope(){const e={};return s.state.value.customVariables.forEach(t=>{e[t.scope]=e[t.scope]||[],e[t.scope].push(t)}),e},currentAvailableCustomVariablesText(){return a.translate("CustomVariables_CurrentAvailableCustomVariables",`${this.numSlotsAvailable}`)},setMaxCustomVariablesCmd(){return`./console customvariables:set-max-custom-variables ${this.numSlotsAvailable+1}`}}}),r={class:"manageCustomVars"},i=["innerHTML"],c={class:"index"},u=["title"],m={key:0},d=["innerHTML"],p=["textContent"];const b=((e,t)=>{const a=e.__vccOpts||e;for(const[n,l]of t)a[n]=l;return a})(o,[["render",function(e,a,n,l,s,o){const b=t.resolveComponent("EnrichedHeadline"),h=t.resolveComponent("ContentBlock"),V=t.resolveDirective("content-intro"),v=t.resolveDirective("content-table"),g=t.resolveDirective("select-on-focus");return t.openBlock(),t.createElementBlock("div",r,[t.withDirectives((t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("h2",null,[t.createVNode(b,{"help-url":"https://matomo.org/docs/custom-variables/"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.translate("CustomVariables_CustomVariables")),1)]),_:1})]),t.createElementVNode("p",null,[t.createElementVNode("span",{innerHTML:e.$sanitize(e.translate("CustomVariables_ManageDescription",e.siteName))},null,8,i)])])),[[V]]),t.withDirectives(t.createElementVNode("div",{class:"alert alert-info"},t.toDisplayString(e.translate("CustomVariables_SlotsReportIsGeneratedOverTime")),513),[[t.vShow,!e.isLoading&&e.hasCustomVariablesInGeneral&&!e.hasAtLeastOneUsage]]),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.scopes,a=>(t.openBlock(),t.createElementBlock("div",{key:a.name},[t.createVNode(h,{"content-title":e.translate("CustomVariables_ScopeX",a.name)},{default:t.withCtx(()=>[t.withDirectives((t.openBlock(),t.createElementBlock("table",null,[t.createElementVNode("thead",null,[t.createElementVNode("tr",null,[t.createElementVNode("th",null,t.toDisplayString(e.translate("CustomVariables_Index")),1),t.createElementVNode("th",null,t.toDisplayString(e.translate("CustomVariables_Usages")),1)])]),t.createElementVNode("tbody",null,[t.createElementVNode("tr",null,[t.withDirectives(t.createElementVNode("td",{colspan:"3"},t.toDisplayString(e.translate("General_Loading")),513),[[t.vShow,e.isLoading]])]),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.customVariablesByScope[a.value],(a,n)=>(t.openBlock(),t.createElementBlock("tr",{key:n},[t.createElementVNode("td",c,t.toDisplayString(a.index),1),t.createElementVNode("td",null,[t.withDirectives(t.createElementVNode("span",{class:"unused"},t.toDisplayString(e.translate("CustomVariables_Unused")),513),[[t.vShow,0===a.usages.length]]),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.sortUsages(a),(n,l)=>t.withDirectives((t.openBlock(),t.createElementBlock("span",{key:l},[t.createElementVNode("span",{title:e.translate("CustomVariables_UsageDetails",String(n.nb_visits||0),String(n.nb_actions||0))},t.toDisplayString(n.name),9,u),l[t.withDirectives(t.createElementVNode("div",null,[t.createElementVNode("p",null,[t.createTextVNode(t.toDisplayString(e.translate("CustomVariables_CreatingCustomVariableTakesTime"))+" ",1),a[0]||(a[0]=t.createElementVNode("br",null,null,-1)),a[1]||(a[1]=t.createElementVNode("br",null,null,-1)),t.createElementVNode("span",{innerHTML:e.$sanitize(e.currentAvailableCustomVariablesText)},null,8,d),a[2]||(a[2]=t.createElementVNode("br",null,null,-1)),a[3]||(a[3]=t.createElementVNode("br",null,null,-1)),t.createTextVNode(" "+t.toDisplayString(e.translate("CustomVariables_ToCreateCustomVarExecute"))+" ",1),a[4]||(a[4]=t.createElementVNode("br",null,null,-1))]),t.withDirectives((t.openBlock(),t.createElementBlock("pre",null,[t.createElementVNode("code",{textContent:t.toDisplayString(e.setMaxCustomVariablesCmd)},null,8,p)])),[[g,{}]])],512),[[t.vShow,!e.isLoading]])]),_:1},8,["content-title"]),[[t.vShow,!e.isLoading]])])}]]);e.ManageCustomVars=b,e.ManageCustomVarsStore=s,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}); diff --git a/vue/dist/umd.metadata.json b/vue/dist/umd.metadata.json index 9ecfcc0..f7dddfd 100644 --- a/vue/dist/umd.metadata.json +++ b/vue/dist/umd.metadata.json @@ -2,4 +2,4 @@ "dependsOn": [ "CoreHome" ] -} \ No newline at end of file +} diff --git a/vue/src/ManageCustomVars/ManageCustomVars.vue b/vue/src/ManageCustomVars/ManageCustomVars.vue index 3361f5c..9d62aa5 100644 --- a/vue/src/ManageCustomVars/ManageCustomVars.vue +++ b/vue/src/ManageCustomVars/ManageCustomVars.vue @@ -53,13 +53,13 @@ >{{ translate('CustomVariables_Unused') }} {{ cvar.name }} , diff --git a/vue/src/types.ts b/vue/src/types.ts index c5f9abb..b0dcc25 100644 --- a/vue/src/types.ts +++ b/vue/src/types.ts @@ -5,7 +5,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -interface CustomVariableUsageRow { +export interface CustomVariableUsageRow { name: string; nb_actions: number|string; nb_visits: number|string; @@ -17,4 +17,4 @@ interface CustomVariableUsage { usages: CustomVariableUsageRow[]; } -export { CustomVariableUsage }; +export type { CustomVariableUsage };