[MediaWiki-commits] [Gerrit] mediawiki...ArticleCreationWorkflow[master]: Add back eventlogging since we're doing the landing page onc...

2017-09-12 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/377658 )

Change subject: Add back eventlogging since we're doing the landing page once 
more
..


Add back eventlogging since we're doing the landing page once more

Bug: T175756
Change-Id: Ibd9515c68696f53dd1f195bf7579979e0d743f93
---
M extension.json
M includes/Hooks.php
A modules/ext.acw.eventlogging.js
3 files changed, 53 insertions(+), 4 deletions(-)

Approvals:
  jenkins-bot: Verified
  Kaldari: Looks good to me, approved



diff --git a/extension.json b/extension.json
index 77506ea..7b53a0e 100644
--- a/extension.json
+++ b/extension.json
@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "ArticleCreationWorkflow",
"type": "other",
-   "author": [ "Max Semenik" ],
+   "author": [ "Max Semenik", "Niharika Kohli" ],
"url": 
"https://www.mediawiki.org/wiki/Extension:ArticleCreationWorkflow;,
"descriptionmsg": "acw-desc",
"license-name": "MIT",
@@ -11,7 +11,8 @@
},
"Hooks": {
"CustomEditor": 
"ArticleCreationWorkflow\\Hooks::onCustomEditor",
-   "ShowMissingArticle": 
"ArticleCreationWorkflow\\Hooks::onShowMissingArticle"
+   "ShowMissingArticle": 
"ArticleCreationWorkflow\\Hooks::onShowMissingArticle",
+   "BeforePageDisplay": 
"ArticleCreationWorkflow\\Hooks::onBeforePageDisplay"
},
"AutoloadClasses": {
"ArticleCreationWorkflow\\Hooks": "includes/Hooks.php",
@@ -22,6 +23,17 @@
"i18n"
]
},
+   "ResourceFileModulePaths": {
+   "localBasePath": "modules",
+   "remoteExtPath": "ArticleCreationWorkflow/modules"
+   },
+   "ResourceModules": {
+   "ext.acw.eventlogging": {
+   "scripts": [
+   "ext.acw.eventlogging.js"
+   ]
+   }
+   },
"config": {
"ArticleCreationWorkflows": {
"description": "Describes conditions when new page 
creation should be intercepted. See doc/config.txt for details.",
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 7d0460c..5c92238 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -5,6 +5,7 @@
 use MediaWiki\MediaWikiServices;
 use Article;
 use User;
+use OutputPage;
 
 /**
  * Hook handlers
@@ -32,7 +33,7 @@
$redirTo = $workflow->getLandingPageTitle();
$output = $article->getContext()->getOutput();
$output->redirect( $redirTo->getFullURL(
-   [ 'page' => $title->getPrefixedText(), 'wprov' 
=> 'acww1' ]
+   [ 'page' => $title->getPrefixedText() ]
) );
return false;
}
@@ -63,8 +64,24 @@
$redirTo = $workflow->getLandingPageTitle();
$output = $article->getContext()->getOutput();
$output->redirect( $redirTo->getFullURL(
-   [ 'page' => $title->getPrefixedText(), 'wprov' 
=> 'acww1' ]
+   [ 'page' => $title->getPrefixedText() ]
) );
}
}
+
+   /**
+* BeforePageDisplay hook handler
+* If user is landing on our landing page, we add eventlogging
+*
+* @param OutputPage $out OutputPage instance
+*/
+   public static function onBeforePageDisplay( OutputPage $out ) {
+   $config = MediaWikiServices::getInstance()
+   ->getConfigFactory()
+   ->makeConfig( 'ArticleCreationWorkflow' );
+   $workflow = new Workflow( $config );
+   if ( $out->getPageTitle() == $workflow->getLandingPageTitle() ) 
{
+   $out->addModules( 'ext.acw.eventlogging' );
+   }
+   }
 }
diff --git a/modules/ext.acw.eventlogging.js b/modules/ext.acw.eventlogging.js
new file mode 100644
index 000..308d0f9
--- /dev/null
+++ b/modules/ext.acw.eventlogging.js
@@ -0,0 +1,20 @@
+/*
+ Track link clicks on landing page created for ACTRIAL
+ */
+
+( function ( $, mw ) {
+
+   function trackData( interactionType, link, sampling ) {
+   mw.track( 'event.ArticleCreationWorkflow', {
+   interactionType: interactionType,
+   link: link,
+   sampling: sampling || 1
+   } );
+   }
+
+   $( 'html' ).on( 'click', '#bodyContent a', function ( event ) {
+   var link = $( this ).attr( 'href' );
+   trackData( 'click', link );
+   } );
+
+} ( jQuery, mediaWiki ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/377658
To unsubscribe, visit 

[MediaWiki-commits] [Gerrit] mediawiki...ArticleCreationWorkflow[master]: Add back eventlogging since we're doing the landing page onc...

2017-09-12 Thread Niharika29 (Code Review)
Niharika29 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/377658 )

Change subject: Add back eventlogging since we're doing the landing page once 
more
..

Add back eventlogging since we're doing the landing page once more

Bug: T175613
Change-Id: Ibd9515c68696f53dd1f195bf7579979e0d743f93
---
M extension.json
M includes/Hooks.php
A modules/ext.acw.eventlogging.js
3 files changed, 34 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleCreationWorkflow 
refs/changes/58/377658/1

diff --git a/extension.json b/extension.json
index 77506ea..cd99f50 100644
--- a/extension.json
+++ b/extension.json
@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "ArticleCreationWorkflow",
"type": "other",
-   "author": [ "Max Semenik" ],
+   "author": [ "Max Semenik", "Niharika Kohli" ],
"url": 
"https://www.mediawiki.org/wiki/Extension:ArticleCreationWorkflow;,
"descriptionmsg": "acw-desc",
"license-name": "MIT",
@@ -22,6 +22,17 @@
"i18n"
]
},
+   "ResourceFileModulePaths": {
+   "localBasePath": "modules",
+   "remoteExtPath": "ArticleCreationWorkflow/modules"
+   },
+   "ResourceModules": {
+   "ext.acw.eventlogging": {
+   "scripts": [
+   "ext.acw.eventlogging.js"
+   ]
+   }
+   },
"config": {
"ArticleCreationWorkflows": {
"description": "Describes conditions when new page 
creation should be intercepted. See doc/config.txt for details.",
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 7d0460c..49e9693 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -31,6 +31,7 @@
// If the landing page didn't exist, we wouldn't have 
intercepted.
$redirTo = $workflow->getLandingPageTitle();
$output = $article->getContext()->getOutput();
+   $output->addModules( 'ext.acw.eventlogging' );
$output->redirect( $redirTo->getFullURL(
[ 'page' => $title->getPrefixedText(), 'wprov' 
=> 'acww1' ]
) );
@@ -62,6 +63,7 @@
// If the landing page didn't exist, we wouldn't have 
intercepted.
$redirTo = $workflow->getLandingPageTitle();
$output = $article->getContext()->getOutput();
+   $output->addModules( 'ext.acw.eventlogging' );
$output->redirect( $redirTo->getFullURL(
[ 'page' => $title->getPrefixedText(), 'wprov' 
=> 'acww1' ]
) );
diff --git a/modules/ext.acw.eventlogging.js b/modules/ext.acw.eventlogging.js
new file mode 100644
index 000..23e08dd
--- /dev/null
+++ b/modules/ext.acw.eventlogging.js
@@ -0,0 +1,20 @@
+/*
+ Track link clicks on Special:CreatePage
+ */
+
+( function ( $, mw ) {
+
+   function trackData( interactionType, link, sampling ) {
+   mw.track( 'event.ArticleCreationWorkflow', {
+   interactionType: interactionType,
+   link: link,
+   sampling: sampling || 1
+   } );
+   }
+
+   $( 'html' ).on( 'click', '#bodyContent a', function ( event ) {
+   var link = $( this ).attr( 'href' );
+   trackData( 'click', link );
+   } );
+
+} ( jQuery, mediaWiki ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/377658
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibd9515c68696f53dd1f195bf7579979e0d743f93
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleCreationWorkflow
Gerrit-Branch: master
Gerrit-Owner: Niharika29 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits