Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Piwik -> Matomo in JS tracker where possible #16052

Merged
merged 3 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)*

### New API
* A new API `UsersManager.createAppSpecificTokenAuth` has been added to create an app specific token for a user.
* A new JS tracker method `getMatomoUrl` has been added which replaces `getPiwikUrl`.

### Breaking changes
* The API `UsersManager.getTokenAuth` has been removed. Instead you need to use `UsersManager.createAppSpecificTokenAuth` and store this token in your application.
Expand Down Expand Up @@ -83,6 +84,12 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)*
* Various methods in `Piwik\Mail` have been removed or changed their signature.
* Support for tracking and reporting of these browser plugins has been discontinued: Gears, Director
* Added new event `Db.getTablesInstalled`, plugins should use to register the tables they create.
* Plugins that extend the JS tracker should now add their callback to `matomoPluginAsyncInit` instead of `piwikPluginAsyncInit`
* The JS tracker event `PiwikInitialized` has been renamed to `MatomoInitialized`

### Deprecations
* The JS Tracker method `getPiwikUrl` has been deprecated and `getMatomoUrl` should be used instead.
* The JS Tracker init method `piwikAsyncInit` has been deprecated and `matomoAsyncInit` should be used instead.

## Matomo 3.13.6

Expand Down
359 changes: 197 additions & 162 deletions js/piwik.js

Large diffs are not rendered by default.

113 changes: 57 additions & 56 deletions js/piwik.min.js

Large diffs are not rendered by default.

113 changes: 57 additions & 56 deletions matomo.js

Large diffs are not rendered by default.

113 changes: 57 additions & 56 deletions piwik.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions plugins/Overlay/client/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Piwik_Overlay_Client = (function () {
var Matomo_Overlay_Client = (function () {

var DOMAIN_PARSE_REGEX = /^http(s)?:\/\/(www\.)?([^\/]*)/i;

Expand Down Expand Up @@ -46,7 +46,7 @@ var Piwik_Overlay_Client = (function () {
callback();
}
else {
Piwik_Overlay_Client.loadScript('libs/bower_components/jquery/dist/jquery.min.js', function () {
Matomo_Overlay_Client.loadScript('libs/bower_components/jquery/dist/jquery.min.js', function () {
$ = jQuery;
jQuery.noConflict();
callback();
Expand Down Expand Up @@ -250,7 +250,7 @@ var Piwik_Overlay_Client = (function () {
* To hide the notification use the returned callback
*/
loadingNotification: function (message) {
return Piwik_Overlay_Client.notification(message, 'Loading');
return Matomo_Overlay_Client.notification(message, 'Loading');
}

};
Expand Down
12 changes: 6 additions & 6 deletions plugins/Overlay/client/followingpages.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var Piwik_Overlay_FollowingPages = (function () {
var followingPagesLoaded = false;

// load excluded params
Piwik_Overlay_Client.api('getExcludedQueryParameters', function (data) {
Matomo_Overlay_Client.api('getExcludedQueryParameters', function (data) {
for (var i = 0; i < data.length; i++) {
if (typeof data[i] == 'object') {
data[i] = data[i][0];
Expand All @@ -44,7 +44,7 @@ var Piwik_Overlay_FollowingPages = (function () {
});

// load following pages
Piwik_Overlay_Client.api('getFollowingPages', function (data) {
Matomo_Overlay_Client.api('getFollowingPages', function (data) {
followingPages = data;
processFollowingPages();

Expand Down Expand Up @@ -419,10 +419,10 @@ var Piwik_Overlay_FollowingPages = (function () {

// Sometimes it fails to remove the notification when the hovered element is removed.
// To make sure we don't display more than one location at a time, we hide all before showing the new one.
Piwik_Overlay_Client.hideNotifications('LinkLocation');
Matomo_Overlay_Client.hideNotifications('LinkLocation');

// we don't use .data() because jquery would remove the callback when the link tag is removed
linkTag[0].piwikHideNotification = Piwik_Overlay_Client.notification(
linkTag[0].piwikHideNotification = Matomo_Overlay_Client.notification(
Piwik_Overlay_Translations.get('link') + ': ' + linkUrl, 'LinkLocation');
}

Expand Down Expand Up @@ -509,8 +509,8 @@ var Piwik_Overlay_FollowingPages = (function () {
* The main method
*/
initialize: function (finishCallback) {
c = Piwik_Overlay_Client.createElement;
Piwik_Overlay_Client.loadScript('plugins/Overlay/client/urlnormalizer.js', function () {
c = Matomo_Overlay_Client.createElement;
Matomo_Overlay_Client.loadScript('plugins/Overlay/client/urlnormalizer.js', function () {
Piwik_Overlay_UrlNormalizer.initialize();
load(function () {
Piwik_Overlay_UrlNormalizer.setExcludedParameters(excludedParams);
Expand Down
2 changes: 1 addition & 1 deletion plugins/Overlay/client/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var Piwik_Overlay_Translations = (function () {
*/
initialize: function (callback) {
// Load translation data
Piwik_Overlay_Client.api('getTranslations', function (data) {
Matomo_Overlay_Client.api('getTranslations', function (data) {
translations = data;
callback();
});
Expand Down
2 changes: 1 addition & 1 deletion tests/javascript/content-fixtures/contentUtilities.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<a href="http://www.example.com">Link</a>
</div>
<!-- targetNode in this example is the content block node -->
<div id="ignoreInteraction4" data-track-content class="piwikContentIgnoreInteraction">
<div id="ignoreInteraction4" data-track-content class="matomoContentIgnoreInteraction">
<a href="http://www.example.com">Link</a>
</div>

Expand Down
12 changes: 6 additions & 6 deletions tests/javascript/content-fixtures/findContentNodesTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</div>
<!-- used for testing detection of content elements via class -->
<div id="ex4" data-track-content>
<img src="http://www.example.com/path/xyz.jpg" class="piwikContentPiece" />
<a href="/anylink" class="piwikContentTarget">Add to shopping cart</a>
<img src="http://www.example.com/path/xyz.jpg" class="matomoContentPiece" />
<a href="/anylink" class="matomoContentTarget">Add to shopping cart</a>
</div>
<!-- used for testing detection of attribute takes precendency over CSS-->
<div id="ex5" data-track-content>
Expand All @@ -20,10 +20,10 @@
</div>
<!-- used for testing always the first matching one will be picked if many have same class -->
<div id="ex6" data-track-content>
<span src="http://www.example.com/path/xyz.jpg" class="piwikContentPiece">Piece with class1</span>
<span src="http://www.example.com/path/xyz.jpg" class="piwikContentPiece">Piece with class2</span>
<a href="/anylink" class="piwikContentTarget">Target with class1</a>
<a href="/anylink" class="piwikContentTarget">Target with class2</a>
<span src="http://www.example.com/path/xyz.jpg" class="matomoContentPiece">Piece with class1</span>
<span src="http://www.example.com/path/xyz.jpg" class="matomoContentPiece">Piece with class2</span>
<a href="/anylink" class="matomoContentTarget">Target with class1</a>
<a href="/anylink" class="matomoContentTarget">Target with class2</a>
</div>
<!-- used for testing always the first matching one will be picked if many have same attribute -->
<div id="ex7" data-track-content>
Expand Down
42 changes: 23 additions & 19 deletions tests/javascript/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ function assertInteractionRequestParams(interaction, name, piece, target, expect
function assertShouldIgnoreInteraction(id, message) {
var node = content.findTargetNode(_e(id));
strictEqual(content.shouldIgnoreInteraction(node), true, message);
ok($(node).hasClass(content.CONTENT_IGNOREINTERACTION_CLASS) || undefined !== $(node).attr(content.CONTENT_IGNOREINTERACTION_ATTR), "needs to have either attribute or class");
ok($(node).hasClass(content.LEGACY_CONTENT_IGNOREINTERACTION_CLASS) || $(node).hasClass(content.CONTENT_IGNOREINTERACTION_CLASS) || undefined !== $(node).attr(content.CONTENT_IGNOREINTERACTION_ATTR), id + " needs to have either attribute or class");
}

function assertShouldNotIgnoreInteraction(id, message) {
Expand Down Expand Up @@ -2047,11 +2047,12 @@ function assertTrackingRequest(actual, expectedStartsWith, message)
});

test("Basic requirements", function() {
expect(3);
expect(4);

equal( typeof encodeURIComponent, 'function', 'encodeURIComponent' );
ok( RegExp, "RegExp" );
ok( Piwik, "Piwik" );
ok( Matomo, "Matomo" );
});

test("Test API - addPlugin(), getTracker(), getHook(), and hook", function() {
Expand Down Expand Up @@ -2796,7 +2797,7 @@ function createLink(url) {
var isSameCrossDomainDevice = tracker.hook.test._isSameCrossDomainDevice;
var makeCrossDomainDeviceId = tracker.hook.test._makeCrossDomainDeviceId;
var replaceHrefForCrossDomainLink = tracker.hook.test._replaceHrefForCrossDomainLink;
var isLinkToDifferentDomainButSamePiwikWebsite = tracker.hook.test._isLinkToDifferentDomainButSamePiwikWebsite;
var isLinkToDifferentDomainButSameMatomoWebsite = tracker.hook.test._isLinkToDifferentDomainButSameMatomoWebsite;

strictEqual(false, tracker.isCrossDomainLinkingEnabled(), 'function', "isCrossDomainLinkingEnabled is disabled by default" );

Expand Down Expand Up @@ -2891,7 +2892,7 @@ function makeIsLinkToDifferentDomainButSamePiwikWebsite(url) {
if (url !== null) {
a.setAttribute('href', url);
}
return isLinkToDifferentDomainButSamePiwikWebsite(a);
return isLinkToDifferentDomainButSameMatomoWebsite(a);
}
strictEqual(false, makeIsLinkToDifferentDomainButSamePiwikWebsite(null), 'isLinkToDifferentDomainButSamePiwikWebsite, should not return anything if no href is set');
strictEqual(false, makeIsLinkToDifferentDomainButSamePiwikWebsite(''), 'isLinkToDifferentDomainButSamePiwikWebsite, should not return anything if empty href is set');
Expand Down Expand Up @@ -2936,7 +2937,7 @@ function makeIsLinkToDifferentDomainButSamePiwikWebsite(url) {
});

test("Tracker getClassesRegExp()", function() {
expect(3);
expect(5);

var tracker = Piwik.getTracker();

Expand All @@ -2945,8 +2946,11 @@ function makeIsLinkToDifferentDomainButSamePiwikWebsite(url) {
var download = tracker.hook.test._getClassesRegExp([], 'download');
ok( download.test('piwik_download'), 'piwik_download (default)' );

ok( download.test('matomo_download'), 'matomo_download (default)' );

var outlink = tracker.hook.test._getClassesRegExp([], 'link');
ok( outlink.test('piwik_link'), 'piwik_link (default)' );
ok( outlink.test('matomo_link'), 'matomo_link (default)' );

});

Expand Down Expand Up @@ -3425,20 +3429,20 @@ function callNonExistingMethodWithParameter() {
var tracker = Piwik.getTracker();

// test getPiwikUrlForOverlay
var getPiwikUrlForOverlay = tracker.hook.test._getPiwikUrlForOverlay;

equal( typeof getPiwikUrlForOverlay, 'function', 'getPiwikUrlForOverlay' );
equal( getPiwikUrlForOverlay('http://www.example.com/js/tracker.php?version=232323'), 'http://www.example.com/', 'with query and js folder' );
equal( getPiwikUrlForOverlay('http://www.example.com/tracker.php?version=232323'), 'http://www.example.com/', 'with query and no js folder' );
equal( getPiwikUrlForOverlay('http://www.example.com/js/tracker.php'), 'http://www.example.com/', 'no query, custom tracker and js folder' );
equal( getPiwikUrlForOverlay('http://www.example.com/tracker.php'), 'http://www.example.com/', 'no query, custom tracker and no js folder' );
equal( getPiwikUrlForOverlay('http://www.example.com/js/matomo.php'), 'http://www.example.com/', 'with matomo.php and no js folder' );
equal( getPiwikUrlForOverlay('http://www.example.com/matomo.php'), 'http://www.example.com/', 'with matomo.php and no js folder' );
equal( getPiwikUrlForOverlay('http://www.example.com/master/js/matomo.php'), 'http://www.example.com/master/', 'installed in custom folder and js folder' );
equal( getPiwikUrlForOverlay('http://www.example.com/master/matomo.php'), 'http://www.example.com/master/', 'installed in custom folder and no js folder' );
equal( getPiwikUrlForOverlay('/matomo.php'), toAbsoluteUrl('/'), 'only matomo.php with leading slash' );
equal( getPiwikUrlForOverlay('matomo.php'), toAbsoluteUrl(''), 'only matomo.php' );
equal( getPiwikUrlForOverlay('/matomo.php?version=1234'), toAbsoluteUrl('/'), 'only matomo.php with leading slash with query' );
var getMatomoUrlForOverlay = tracker.hook.test._getMatomoUrlForOverlay;

equal( typeof getMatomoUrlForOverlay, 'function', 'getMatomoUrlForOverlay' );
equal( getMatomoUrlForOverlay('http://www.example.com/js/tracker.php?version=232323'), 'http://www.example.com/', 'with query and js folder' );
equal( getMatomoUrlForOverlay('http://www.example.com/tracker.php?version=232323'), 'http://www.example.com/', 'with query and no js folder' );
equal( getMatomoUrlForOverlay('http://www.example.com/js/tracker.php'), 'http://www.example.com/', 'no query, custom tracker and js folder' );
equal( getMatomoUrlForOverlay('http://www.example.com/tracker.php'), 'http://www.example.com/', 'no query, custom tracker and no js folder' );
equal( getMatomoUrlForOverlay('http://www.example.com/js/matomo.php'), 'http://www.example.com/', 'with matomo.php and no js folder' );
equal( getMatomoUrlForOverlay('http://www.example.com/matomo.php'), 'http://www.example.com/', 'with matomo.php and no js folder' );
equal( getMatomoUrlForOverlay('http://www.example.com/master/js/matomo.php'), 'http://www.example.com/master/', 'installed in custom folder and js folder' );
equal( getMatomoUrlForOverlay('http://www.example.com/master/matomo.php'), 'http://www.example.com/master/', 'installed in custom folder and no js folder' );
equal( getMatomoUrlForOverlay('/matomo.php'), toAbsoluteUrl('/'), 'only matomo.php with leading slash' );
equal( getMatomoUrlForOverlay('matomo.php'), toAbsoluteUrl(''), 'only matomo.php' );
equal( getMatomoUrlForOverlay('/matomo.php?version=1234'), toAbsoluteUrl('/'), 'only matomo.php with leading slash with query' );
});

function generateAnIframeInDocument() {
Expand Down
6 changes: 3 additions & 3 deletions tests/javascript/matomotest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/*global Piwik getToken */

Piwik.addPlugin('testPlugin', {
Matomo.addPlugin('testPlugin', {
/*
* called when tracker instantiated
* - function or string to be eval()'d
Expand Down Expand Up @@ -42,7 +42,7 @@ Piwik.addPlugin('testPlugin', {
'_makeCrossDomainDeviceId: makeCrossDomainDeviceId,' +
'_isSameCrossDomainDevice: isSameCrossDomainDevice,' +
'_replaceHrefForCrossDomainLink: replaceHrefForCrossDomainLink,' +
'_isLinkToDifferentDomainButSamePiwikWebsite: isLinkToDifferentDomainButSamePiwikWebsite,' +
'_isLinkToDifferentDomainButSameMatomoWebsite: isLinkToDifferentDomainButSameMatomoWebsite,' +
'_arrayChunk : arrayChunk,' +
'_urlFixup : urlFixup,' +
'_domainFixup : domainFixup,' +
Expand All @@ -53,7 +53,7 @@ Piwik.addPlugin('testPlugin', {
'_resolveRelativeReference : resolveRelativeReference,' +
'_addEventListener : addEventListener,' +
'_prefixPropertyName : prefixPropertyName,' +
'_getPiwikUrlForOverlay : getPiwikUrlForOverlay, ' +
'_getMatomoUrlForOverlay : getMatomoUrlForOverlay, ' +
'_windowAlias : windowAlias, ' +
'_refreshConsentStatus : refreshConsentStatus, ' +
'_isInsideAnIframe : isInsideAnIframe' +
Expand Down