Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Clarify behaviour of using both matomoAsyncInit and _paq.push()

オープン
#779 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
documentation

調査の方向性

まず、matomoAsyncInit、Matomo.getAsyncTracker()、_paq.push()、addTracker() の間で文書化されている相互作用を追跡します。最初の tracker とキューに入れられたコマンドが処理される順序を確認し、その後、確認された tracker の動作と、getAsyncTracker() の呼び出しを繰り返す必要があるタイミングを説明するよう、関連する開発者向けドキュメントを更新します。

索引モデルが issue の本文から書いたものです。

説明

I have not found any clear documentation what happens if you use _paq push in combination with matomoAsyncInit. This could lead to some unexpected behaviour that could not be explained with a simple documentation link.

Given the following tracker integration:

var _paq = window._paq = window._paq || [];

(function() {
  var siteIdFirst = 1;
  var siteIdSecond = 2;
  var urlFirst = 'https://first.matomo.instance/matomo.php';
  var urlSecond = 'https://second.matomo.instance/matomo.php';

  window.matomoAsyncInit = function() {
    var tracker = Matomo.getAsyncTracker(urlSecond, siteIdSecond);

    tracker.MyPlugin.disable();
  };

  _paq.push(['setTrackerUrl', urlFirst]);
  _paq.push(['setSiteId', siteIdFirst]);
  _paq.push(['trackPageView']);

  // regular script tag integration
})();

From the code one could expect that MyPlugin.disable() would be called on the tracker for the second url/site. But, this is not the case.

The call to getAsyncTracker() in matomoAsyncInit will create the first tracker. All queued _paq commands are executed for this instance, overwriting the parameters given to the getAsyncTracker() call and resulting in only a single tracker instance being set up.

Adding _paq.push(['addTracker', urlSecond, siteIdSecond]) before the script tag creation will create that second tracker, but it will not be used inside matomoAsyncInit. The first tracker is being returned there.

It should be clearer that matomoAsyncInit is getting executed before the first tracker instance is created. And the first call to getAsyncTracker() (and the other methods affected) is running all queued _paq commands, requiring to call getAsyncTracker twice if you want to e.g. deactivate a plugin only on the second tracker.

Refs matomo-org/matomo#21976.

主要言語
PHP
スター
58
フォーク
88
平均マージ
32分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

matomo-org/developer-documentation のほかの issue

matomo-org/developer-documentation の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。