From 64497dc5c6bc11be8cdd57ed5b6a11cf249bbb5e Mon Sep 17 00:00:00 2001 From: sgiehl Date: Mon, 9 Dec 2019 18:01:07 +0100 Subject: [PATCH 1/2] Rebrand from Piwik to Matomo --- LICENSE | 2 +- PiwikTracker.php => MatomoTracker.php | 130 +++++++++++++------------- README.md | 4 +- composer.json | 20 ++-- 4 files changed, 77 insertions(+), 79 deletions(-) rename PiwikTracker.php => MatomoTracker.php (93%) diff --git a/LICENSE b/LICENSE index f7cc808..6efca76 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014, Piwik Open Source Analytics +Copyright (c) 2014, Matomo Open Source Analytics All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/PiwikTracker.php b/MatomoTracker.php similarity index 93% rename from PiwikTracker.php rename to MatomoTracker.php index a4ab871..f6903b8 100644 --- a/PiwikTracker.php +++ b/MatomoTracker.php @@ -1,30 +1,30 @@ CustomVariableName, 1 => CustomVariableValue ) or false - * @see Piwik.js getCustomVariable() + * @see matomo.js getCustomVariable() */ public function getCustomVariable($id, $scope = 'visit') { @@ -334,7 +334,7 @@ public function clearCustomVariables() /** * Sets a custom tracking parameter. This is useful if you need to send any tracking parameters for a 3rd party - * plugin that is not shipped with Piwik itself. Please note that custom parameters are cleared after each + * plugin that is not shipped with Matomo itself. Please note that custom parameters are cleared after each * tracking request. * * @param string $trackingApiParameter The name of the tracking API parameter, eg 'dimension1' @@ -406,7 +406,7 @@ public function setUserAgent($userAgent) } /** - * Sets the country of the visitor. If not used, Piwik will try to find the country + * Sets the country of the visitor. If not used, Matomo will try to find the country * using either the visitor's IP address or language. * * Allowed only for Admin/Super User, must be used along with setTokenAuth(). @@ -420,7 +420,7 @@ public function setCountry($country) } /** - * Sets the region of the visitor. If not used, Piwik may try to find the region + * Sets the region of the visitor. If not used, Matomo may try to find the region * using the visitor's IP address (if configured to do so). * * Allowed only for Admin/Super User, must be used along with setTokenAuth(). @@ -434,7 +434,7 @@ public function setRegion($region) } /** - * Sets the city of the visitor. If not used, Piwik may try to find the city + * Sets the city of the visitor. If not used, Matomo may try to find the city * using the visitor's IP address (if configured to do so). * * Allowed only for Admin/Super User, must be used along with setTokenAuth(). @@ -448,7 +448,7 @@ public function setCity($city) } /** - * Sets the latitude of the visitor. If not used, Piwik may try to find the visitor's + * Sets the latitude of the visitor. If not used, Matomo may try to find the visitor's * latitude using the visitor's IP address (if configured to do so). * * Allowed only for Admin/Super User, must be used along with setTokenAuth(). @@ -462,7 +462,7 @@ public function setLatitude($lat) } /** - * Sets the longitude of the visitor. If not used, Piwik may try to find the visitor's + * Sets the longitude of the visitor. If not used, Matomo may try to find the visitor's * longitude using the visitor's IP address (if configured to do so). * * Allowed only for Admin/Super User, must be used along with setTokenAuth(). @@ -500,7 +500,7 @@ public function enableCookies($domain = '', $path = '/') } /** - * If image response is disabled Piwik will respond with a HTTP 204 header instead of responding with a gif. + * If image response is disabled Matomo will respond with a HTTP 204 header instead of responding with a gif. */ public function disableSendImageResponse() { @@ -534,7 +534,7 @@ protected static function domainFixup($domain) */ protected function getCookieName($cookieName) { - // NOTE: If the cookie name is changed, we must also update the method in piwik.js with the same name. + // NOTE: If the cookie name is changed, we must also update the method in matomo.js with the same name. $hash = substr( sha1( ($this->configCookieDomain == '' ? self::getCurrentHost() : $this->configCookieDomain) . $this->configCookiePath @@ -746,12 +746,12 @@ public function doBulkTrack() * Tracks an Ecommerce order. * * If the Ecommerce order contains items (products), you must call first the addEcommerceItem() for each item in the order. - * All revenues (grandTotal, subTotal, tax, shipping, discount) will be individually summed and reported in Piwik reports. + * All revenues (grandTotal, subTotal, tax, shipping, discount) will be individually summed and reported in Matomo reports. * Only the parameters $orderId and $grandTotal are required. * * @param string|int $orderId (required) Unique Order ID. * This will be used to count this order only once in the event the order page is reloaded several times. - * orderId must be unique for each transaction, even on different days, or the transaction will not be recorded by Piwik. + * orderId must be unique for each transaction, even on different days, or the transaction will not be recorded by Matomo. * @param float $grandTotal (required) Grand Total revenue of the transaction (including tax, shipping, etc.) * @param float $subTotal (optional) Sub total amount, typically the sum of items prices for all items in this order (before Tax and Shipping costs are applied) * @param float $tax (optional) Tax amount for this order @@ -799,7 +799,7 @@ public function doPing() * * On a category page, you may set the parameter $category only and set the other parameters to false. * - * Tracking Product/Category page views will allow Piwik to report on Product & Categories + * Tracking Product/Category page views will allow Matomo to report on Product & Categories * conversion rates (Conversion rate = Ecommerce orders containing this product or category / Visits to the product or category) * * @param string $sku Product SKU being viewed @@ -841,7 +841,7 @@ public function setEcommerceView($sku = '', $name = '', $category = '', $price = } /** - * Force the separator for decimal point to be a dot. See https://github.com/piwik/piwik/issues/6435 + * Force the separator for decimal point to be a dot. See https://github.com/matomo-org/matomo/issues/6435 * If for instance a German locale is used it would be a comma otherwise. * * @param float|string $value @@ -942,8 +942,8 @@ protected function getUrlTrackEcommerce($grandTotal, $subTotal = 0.0, $tax = 0.0 * Builds URL to track a page view. * * @see doTrackPageView() - * @param string $documentTitle Page view name as it will appear in Piwik reports - * @return string URL to piwik.php with all parameters set to track the pageview + * @param string $documentTitle Page view name as it will appear in Matomo reports + * @return string URL to matomo.php with all parameters set to track the pageview */ public function getUrlTrackPageView($documentTitle = '') { @@ -963,7 +963,7 @@ public function getUrlTrackPageView($documentTitle = '') * @param string $action The Event's Action (Play, Pause, Duration, Add Playlist, Downloaded, Clicked...) * @param string|bool $name (optional) The Event's object Name (a particular Movie name, or Song name, or File name...) * @param float|bool $value (optional) The Event's value - * @return string URL to piwik.php with all parameters set to track the pageview + * @return string URL to matomo.php with all parameters set to track the pageview * @throws */ public function getUrlTrackEvent($category, $action, $name = false, $value = false) @@ -998,7 +998,7 @@ public function getUrlTrackEvent($category, $action, $name = false, $value = fal * @param string $contentPiece The actual content. For instance the path to an image, video, audio, any text * @param string|false $contentTarget (optional) The target of the content. For instance the URL of a landing page. * @throws Exception In case $contentName is empty - * @return string URL to piwik.php with all parameters set to track the pageview + * @return string URL to matomo.php with all parameters set to track the pageview */ public function getUrlTrackContentImpression($contentName, $contentPiece, $contentTarget) { @@ -1029,7 +1029,7 @@ public function getUrlTrackContentImpression($contentName, $contentPiece, $conte * @param string $contentPiece The actual content. For instance the path to an image, video, audio, any text * @param string|false $contentTarget (optional) The target the content leading to when an interaction occurs. For instance the URL of a landing page. * @throws Exception In case $interaction or $contentName is empty - * @return string URL to piwik.php with all parameters set to track the pageview + * @return string URL to matomo.php with all parameters set to track the pageview */ public function getUrlTrackContentInteraction($interaction, $contentName, $contentPiece, $contentTarget) { @@ -1085,7 +1085,7 @@ public function getUrlTrackSiteSearch($keyword, $category, $countResults) * @see doTrackGoal() * @param int $idGoal Id Goal to record a conversion * @param float $revenue Revenue for this conversion - * @return string URL to piwik.php with all parameters set to track the goal conversion + * @return string URL to matomo.php with all parameters set to track the goal conversion */ public function getUrlTrackGoal($idGoal, $revenue = 0.0) { @@ -1105,7 +1105,7 @@ public function getUrlTrackGoal($idGoal, $revenue = 0.0) * @see doTrackAction() * @param string $actionUrl URL of the download or outlink * @param string $actionType Type of the action: 'download' or 'link' - * @return string URL to piwik.php with all parameters set to track an action + * @return string URL to matomo.php with all parameters set to track an action */ public function getUrlTrackAction($actionUrl, $actionType) { @@ -1117,7 +1117,7 @@ public function getUrlTrackAction($actionUrl, $actionType) /** * Overrides server date and time for the tracking requests. - * By default Piwik will track requests for the "current datetime" but this function allows you + * By default Matomo will track requests for the "current datetime" but this function allows you * to track visits in the past. All times are in UTC. * * Allowed only for Admin/Super User, must be used along with setTokenAuth() @@ -1133,9 +1133,9 @@ public function setForceVisitDateTime($dateTime) } /** - * Forces Piwik to create a new visit for the tracking request. + * Forces Matomo to create a new visit for the tracking request. * - * By default, Piwik will create a new visit if the last request by this user was more than 30 minutes ago. + * By default, Matomo will create a new visit if the last request by this user was more than 30 minutes ago. * If you call setForceNewVisit() before calling doTrack*, then a new visit will be created for this request. * @return $this */ @@ -1178,7 +1178,7 @@ public function setUserId($userId) } /** - * Hash function used internally by Piwik to hash a User ID into the Visitor ID. + * Hash function used internally by Matomo to hash a User ID into the Visitor ID. * * Note: matches implementation of Tracker\Request->getUserIdHashed() * @@ -1193,7 +1193,7 @@ public static function getUserIdHashed($id) /** * Forces the requests to be recorded for the specified Visitor ID. * - * Rather than letting Piwik attribute the user with a heuristic based on IP and other user fingeprinting attributes, + * Rather than letting Matomo attribute the user with a heuristic based on IP and other user fingeprinting attributes, * force the action to be recorded for a particular visitor. * * If not set, the visitor ID will be fetched from the 1st party cookie, or will be set to a random UUID. @@ -1221,7 +1221,7 @@ public function setVisitorId($visitorId) } /** - * If the user initiating the request has the Piwik first party cookie, + * If the user initiating the request has the Matomo first party cookie, * this function will try and return the ID parsed from this first party cookie (found in $_COOKIE). * * If you call this function from a server, where the call is triggered by a cron or script @@ -1321,7 +1321,7 @@ public function deleteCookies() * * @return string JSON Encoded string containing the Referrer information for Goal conversion attribution. * Will return false if the cookie could not be found - * @see Piwik.js getAttributionInfo() + * @see matomo.js getAttributionInfo() */ public function getAttributionInfo() { @@ -1380,7 +1380,7 @@ public function setResolution($width, $height) /** * Sets if the browser supports cookies - * This is reported in "List of plugins" report in Piwik. + * This is reported in "List of plugins" report in Matomo. * * @param bool $bool * @return $this @@ -1442,7 +1442,7 @@ public function setPlugins( } /** - * By default, PiwikTracker will read first party cookies + * By default, MatomoTracker will read first party cookies * from the request and write updated cookies in the response (using setrawcookie). * This can be disabled by calling this function. */ @@ -1453,7 +1453,7 @@ public function disableCookieSupport() /** * Returns the maximum number of seconds the tracker will spend waiting for a response - * from Piwik. Defaults to 600 seconds. + * from Matomo. Defaults to 600 seconds. */ public function getRequestTimeout() { @@ -1462,7 +1462,7 @@ public function getRequestTimeout() /** * Sets the maximum number of seconds that the tracker will spend waiting for a response - * from Piwik. + * from Matomo. * * @param int $timeout * @return $this @@ -1479,7 +1479,7 @@ public function setRequestTimeout($timeout) } /** - * If a proxy is needed to look up the address of the Piwik site, set it with this + * If a proxy is needed to look up the address of the Matomo site, set it with this * @param string $proxy IP as string, for example "173.234.92.107" * @param int $proxyPort */ @@ -1637,22 +1637,20 @@ protected function getTimestamp() } /** - * Returns the base URL for the piwik server. + * Returns the base URL for the Matomo server. */ protected function getBaseUrl() { if (empty(self::$URL)) { throw new Exception( - 'You must first set the Piwik Tracker URL by calling - PiwikTracker::$URL = \'http://your-website.org/piwik/\';' + 'You must first set the Matomo Tracker URL by calling + MatomoTracker::$URL = \'http://your-website.org/matomo/\';' ); } - if (strpos(self::$URL, '/piwik.php') === false - && strpos(self::$URL, '/proxy-piwik.php') === false - && strpos(self::$URL, '/matomo.php') === false + if (strpos(self::$URL, '/matomo.php') === false && strpos(self::$URL, '/proxy-matomo.php') === false ) { - self::$URL .= '/piwik.php'; + self::$URL .= '/matomo.php'; } return self::$URL; @@ -1778,7 +1776,7 @@ protected function getCookieMatchingName($name) } $name = $this->getCookieName($name); - // Piwik cookie names use dots separators in piwik.js, + // Matomo cookie names use dots separators in matomo.js, // but PHP Replaces . with _ http://www.php.net/manual/en/language.variables.predefined.php#72571 $name = str_replace('.', '_', $name); foreach ($_COOKIE as $cookieName => $cookieValue) { @@ -1892,7 +1890,7 @@ protected static function getCurrentUrl() } /** - * Sets the first party cookies as would the piwik.js + * Sets the first party cookies as would the matomo.js * All cookies are supported: 'id' and 'ses' and 'ref' and 'cvar' cookies. * @return $this */ @@ -1929,7 +1927,7 @@ protected function setFirstPartyCookies() /** * Sets a first party cookie to the client to improve dual JS-PHP tracking. * - * This replicates the piwik.js tracker algorithms for consistency and better accuracy. + * This replicates the matomo.js tracker algorithms for consistency and better accuracy. * * @param $cookieName * @param $cookieValue @@ -2031,9 +2029,9 @@ protected function parseIncomingCookies($headers) * @param string $documentTitle * @return string */ -function Piwik_getUrlTrackPageView($idSite, $documentTitle = '') +function Matomo_getUrlTrackPageView($idSite, $documentTitle = '') { - $tracker = new PiwikTracker($idSite); + $tracker = new MatomoTracker($idSite); return $tracker->getUrlTrackPageView($documentTitle); } @@ -2046,9 +2044,9 @@ function Piwik_getUrlTrackPageView($idSite, $documentTitle = '') * @param float $revenue * @return string */ -function Piwik_getUrlTrackGoal($idSite, $idGoal, $revenue = 0.0) +function Matomo_getUrlTrackGoal($idSite, $idGoal, $revenue = 0.0) { - $tracker = new PiwikTracker($idSite); + $tracker = new MatomoTracker($idSite); return $tracker->getUrlTrackGoal($idGoal, $revenue); } diff --git a/README.md b/README.md index d458bc4..659a0f9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # PHP Client for Matomo Analytics Tracking API -The PHP Tracker Client provides all features of the [Matomo Javascript Tracker](http://developer.matomo.org/api-reference/tracking-javascript), such as Ecommerce Tracking, Custom Variable, Event tracking and more. +The PHP Tracker Client provides all features of the [Matomo Javascript Tracker](https://developer.matomo.org/api-reference/tracking-javascript), such as Ecommerce Tracking, Custom Variable, Event tracking and more. ## Documentation and examples -Check out our [Matomo-PHP-Tracker developer documentation](http://developer.matomo.org/api-reference/PHP-Piwik-Tracker) and [Matomo Tracking API guide](http://matomo.org/docs/tracking-api/). +Check out our [Matomo-PHP-Tracker developer documentation](https://developer.matomo.org/api-reference/PHP-Piwik-Tracker) and [Matomo Tracking API guide](https://matomo.org/docs/tracking-api/). ## Requirements: * json extension (json_decode, json_encode) diff --git a/composer.json b/composer.json index 4b7babd..7700418 100644 --- a/composer.json +++ b/composer.json @@ -1,20 +1,20 @@ { - "name": "piwik/piwik-php-tracker", - "description": "PHP Client for Piwik Analytics Tracking API", - "keywords": ["piwik","tracker","analytics"], - "homepage": "http://piwik.org", + "name": "matomo/matomo-php-tracker", + "description": "PHP Client for Matomo Analytics Tracking API", + "keywords": ["matomo","piwik","tracker","analytics"], + "homepage": "https://matomo.org", "license": "BSD-2-Clause", "authors": [ { - "name": "The Piwik Team", - "email": "hello@piwik.org", - "homepage": "http://piwik.org/the-piwik-team/" + "name": "The Matomo Team", + "email": "hello@matomo.org", + "homepage": "https://matomo.org/team/" } ], "support": { - "forum": "http://forum.piwik.org/", - "issues": "https://github.com/piwik/piwik-php-tracker/issues", - "source": "https://github.com/piwik/piwik-php-tracker" + "forum": "https://forum.matomo.org/", + "issues": "https://github.com/matomo-org/matomo-php-tracker/issues", + "source": "https://github.com/matomo-org/matomo-php-tracker" }, "autoload": { "classmap": ["."] From 7484c538a737bf9e6c18a64dc1300befdc2ade20 Mon Sep 17 00:00:00 2001 From: sgiehl Date: Thu, 19 Dec 2019 15:42:57 +0100 Subject: [PATCH 2/2] keep bc --- MatomoTracker.php | 7 +++++++ PiwikTracker.php | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 PiwikTracker.php diff --git a/MatomoTracker.php b/MatomoTracker.php index f6903b8..976da22 100644 --- a/MatomoTracker.php +++ b/MatomoTracker.php @@ -2050,3 +2050,10 @@ function Matomo_getUrlTrackGoal($idSite, $idGoal, $revenue = 0.0) return $tracker->getUrlTrackGoal($idGoal, $revenue); } + +/** + * For BC only + * + * @deprecated use MatomoTracker instead + */ +class PiwikTracker extends MatomoTracker {} \ No newline at end of file diff --git a/PiwikTracker.php b/PiwikTracker.php new file mode 100644 index 0000000..c6f2df3 --- /dev/null +++ b/PiwikTracker.php @@ -0,0 +1,48 @@ +