[MediaWiki-commits] [Gerrit] Initial commit - change (mediawiki...Sentry)

2014-12-18 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Initial commit
..


Initial commit

Bug: T1345
Change-Id: Ie101251b79b4c779d65c85e31281cf4c7a295ada
---
A .jshintignore
A .jshintrc
A Sentry.php
A SentryHooks.php
A i18n/en.json
A i18n/qqq.json
A resources/init.js
A resources/raven/raven.js
8 files changed, 1,994 insertions(+), 0 deletions(-)

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



diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 000..4877309
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1,2 @@
+# external libraries
+resources/raven
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 000..9c9e801
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,8 @@
+{
+   browser: true,
+   jquery: true,
+   predef: [
+   mediaWiki,
+   Raven
+   ]
+}
diff --git a/Sentry.php b/Sentry.php
new file mode 100644
index 000..965b1e9
--- /dev/null
+++ b/Sentry.php
@@ -0,0 +1,51 @@
+?php
+
+$wgExtensionCredits['other'][] = array(
+   'path' = __FILE__,
+   'name' = 'Sentry',
+   'author' = 'Gergő Tisza',
+   'url' = 'https://www.mediawiki.org/wiki/Extension:Sentry',
+   'descriptionmsg' = 'sentry-desc',
+   'version'  = 0.1,
+   'license-name' = MIT,
+);
+
+$wgMessagesDirs['Sentry'] = __DIR__ . '/i18n';
+
+$wgAutoloadClasses['SentryHooks'] = __DIR__ . '/SentryHooks.php';
+
+$wgResourceModules += array(
+   'sentry' = array(
+   'scripts' = array(
+   'raven/raven.js',
+   'init.js',
+   ),
+   'position' = 'top',
+   'localBasePath' = __DIR__ . '/resources',
+   'remoteExtPath' = 'Sentry/resources',
+   ),
+);
+
+$wgHooks['ResourceLoaderGetConfigVars'][] = 
'SentryHooks::onResourceLoaderGetConfigVars';
+$wgHooks['BeforePageDisplay'][] = 'SentryHooks::onBeforePageDisplay';
+
+/**
+ * Sentry endpoint / API key
+ * @var string
+ */
+$wgSentryEndpoint = null;
+
+/**
+ * List of domains to log error from.
+ * '*' can be used as a wildcard; the wiki's own domain will be added 
automatically.
+ * Set to false to enable any domain.
+ * @var array|bool
+ */
+$wgSentryWhitelist = false;
+
+/**
+ * Log uncaught Javascript errors automatically.
+ * @var bool
+ */
+$wgSentryLogOnError = true;
+
diff --git a/SentryHooks.php b/SentryHooks.php
new file mode 100644
index 000..e19aec1
--- /dev/null
+++ b/SentryHooks.php
@@ -0,0 +1,31 @@
+?php
+
+class SentryHooks {
+   /**
+* @param array $vars
+* @return bool
+*/
+   public static function onResourceLoaderGetConfigVars( $vars ) {
+   global $wgSentryEndpoint, $wgSentryWhitelist, 
$wgSentryLogOnError;
+
+   $vars['wgSentry'] = array(
+   'endpoint' = $wgSentryEndpoint,
+   'whitelist' = $wgSentryWhitelist,
+   'logOnError' = $wgSentryLogOnError,
+   );
+
+   return true;
+   }
+
+   /**
+* @param OutputPage $out
+* @param Skin $skin
+* @return bool
+*/
+   public static function onBeforePageDisplay( $out, $skin ) {
+   $out-addModules( array( 'sentry' ) );
+
+   return true;
+   }
+}
+
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 000..4dfceb5
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,4 @@
+{
+   sentry-desc: [https://getsentry.com/ Sentry] integration
+}
+
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 000..c6cb987
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,4 @@
+{
+   sentry-desc: {{desc}}
+}
+
diff --git a/resources/init.js b/resources/init.js
new file mode 100644
index 000..35a9223
--- /dev/null
+++ b/resources/init.js
@@ -0,0 +1,22 @@
+( function ( mw, Raven ) {
+   var config = mw.config.get( 'wgSentry' ),
+   options = {};
+
+   if ( config.whitelist ) {
+   options.whitelistUrls = config.whitelist.slice( 0 );
+   options.whitelistUrls.push( location.host );
+   }
+   options.collectWindowErrors = config.logOnError;
+   options.tags = {
+   version: mw.config.get( 'wgVersion' ),
+   debug: mw.config.get( 'debug' ),
+   skin: mw.config.get( 'skin' ),
+   action: mw.config.get( 'wgAction' ),
+   ns: mw.config.get( 'wgNamespaceNumber' ),
+   pageName: mw.config.get( 'wgPageName' ),
+   userGroups: mw.config.get( 'wgUserGroups' ),
+   language: mw.config.get( 'wgUserLanguage' )
+   };
+
+   Raven.config( config.endpoint, options ).install();
+} ) ( mediaWiki, Raven );
diff --git a/resources/raven/raven.js b/resources/raven/raven.js
new file mode 100644
index 000..2c37e3d
--- /dev/null
+++ b/resources/raven/raven.js
@@ -0,0 

[MediaWiki-commits] [Gerrit] Initial commit - change (mediawiki...Sentry)

2014-12-15 Thread Code Review
Gergő Tisza has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/179987

Change subject: Initial commit
..

Initial commit

Bug: T1345
Change-Id: Ie101251b79b4c779d65c85e31281cf4c7a295ada
---
A Sentry.php
A SentryHooks.php
A i18n/en.json
A i18n/qqq.json
A resources/init.js
A resources/raven/raven.js
6 files changed, 1,984 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Sentry 
refs/changes/87/179987/1

diff --git a/Sentry.php b/Sentry.php
new file mode 100644
index 000..5a668ca
--- /dev/null
+++ b/Sentry.php
@@ -0,0 +1,51 @@
+?php
+
+$wgExtensionCredits['other'][] = array(
+   'path' = __FILE__,
+   'name' = 'Sentry',
+   'author' = 'Gergő Tisza', 
+   'url' = 'https://www.mediawiki.org/wiki/Extension:Sentry', 
+   'descriptionmsg' = 'sentry-desc',
+   'version'  = 0.1,
+   'license-name' = MIT,   // Short name of the license, links LICENSE 
or COPYING file if existing - string, added in 1.23.0
+);
+
+$wgMessagesDirs['Sentry'] = __DIR__ . '/i18n';
+
+$wgAutoloadClasses['SentryHooks'] = __DIR__ . '/SentryHooks.php';
+
+$wgResourceModules += array(
+   'sentry' = array(
+   'scripts' = array(
+   'raven/raven.js',
+   'init.js',
+   ),
+   'position' = 'top',
+   'localBasePath' = __DIR__ . '/resources',
+   'remoteExtPath' = 'Sentry/resources',
+   ),
+);
+
+$wgHooks['ResourceLoaderGetConfigVars'][] = 
'SentryHooks::onResourceLoaderGetConfigVars';
+$wgHooks['BeforePageDisplay'][] = 'SentryHooks::onBeforePageDisplay';
+
+/**
+ * Sentry endpoint / API key
+ * @var string
+ */
+$wgSentryEndpoint = null;
+
+/**
+ * List of domains to log error from.
+ * '*' can be used as a wildcard; the wiki's own domain will be added 
automatically.
+ * Set to false to enable any domain.
+ * @var array|bool
+ */
+$wgSentryWhitelist = false;
+
+/**
+ * Log uncaught Javascript errors automatically.
+ * @var bool
+ */
+$wgSentryLogOnError = true;
+
diff --git a/SentryHooks.php b/SentryHooks.php
new file mode 100644
index 000..e19aec1
--- /dev/null
+++ b/SentryHooks.php
@@ -0,0 +1,31 @@
+?php
+
+class SentryHooks {
+   /**
+* @param array $vars
+* @return bool
+*/
+   public static function onResourceLoaderGetConfigVars( $vars ) {
+   global $wgSentryEndpoint, $wgSentryWhitelist, 
$wgSentryLogOnError;
+
+   $vars['wgSentry'] = array(
+   'endpoint' = $wgSentryEndpoint,
+   'whitelist' = $wgSentryWhitelist,
+   'logOnError' = $wgSentryLogOnError,
+   );
+
+   return true;
+   }
+
+   /**
+* @param OutputPage $out
+* @param Skin $skin
+* @return bool
+*/
+   public static function onBeforePageDisplay( $out, $skin ) {
+   $out-addModules( array( 'sentry' ) );
+
+   return true;
+   }
+}
+
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 000..4dfceb5
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,4 @@
+{
+   sentry-desc: [https://getsentry.com/ Sentry] integration
+}
+
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 000..c6cb987
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,4 @@
+{
+   sentry-desc: {{desc}}
+}
+
diff --git a/resources/init.js b/resources/init.js
new file mode 100644
index 000..f4d2f29
--- /dev/null
+++ b/resources/init.js
@@ -0,0 +1,22 @@
+( function () {
+   var config = mw.config.get( 'wgSentry' ),
+   options = {};
+
+   if ( config.whitelist ) {
+   options.whitelistUrls = config.whitelist.slice( 0 );
+   options.whitelistUrls.push( location.host );
+   }
+   options.collectWindowErrors = config.logOnError;
+   options.tags = {
+   version: mw.config.get( 'wgVersion' ),
+   debug: mw.config.get( 'debug' ),
+   skin: mw.config.get( 'skin' ),
+   action: mw.config.get( 'wgAction' ),
+   ns: mw.config.get( 'wgNamespaceNumber' ),
+   pageName: mw.config.get( 'wgPageName' ),
+   userGroups: mw.config.get( 'wgUserGroups' ),
+   language: mw.config.get( 'wgUserLanguage' )
+   };
+
+   Raven.config( config.endpoint, options ).install();
+} )();
diff --git a/resources/raven/raven.js b/resources/raven/raven.js
new file mode 100644
index 000..2c37e3d
--- /dev/null
+++ b/resources/raven/raven.js
@@ -0,0 +1,1872 @@
+/*! Raven.js 1.1.16 (2cf8531) | github.com/getsentry/raven-js */
+
+/*
+ * Includes TraceKit
+ * https://github.com/getsentry/TraceKit
+ *
+ * Copyright 2014 Matt Robenolt and other contributors
+ * Released under the BSD license
+ * https://github.com/getsentry/raven-js/blob/master/LICENSE
+ *
+ */