diff --git a/.travis.yml b/.travis.yml
index dde24ad..321443f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -29,7 +29,7 @@ before_install:
install:
- if [[ $SYMFONY_VERSION != "" ]]; then composer require "symfony/framework-bundle:${SYMFONY_VERSION}" --no-update -n; fi;
- - composer update $COMPOSER_FLAGS --prefer-dist --no-interaction
+ - travis_wait 20 composer update $COMPOSER_FLAGS --prefer-dist --no-interaction
script:
- vendor/bin/phpunit --verbose
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 14c7867..6e2c47f 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -51,6 +51,9 @@ public function getConfigTreeBuilder()
->scalarNode('check_ignore_function_provider')
->defaultValue('ftrrtf_rollbar.check_ignore_function_provider.default')
->end()
+ ->scalarNode('transform_payload_function_provider')
+ ->defaultValue('ftrrtf_rollbar.transform_payload_function_provider.default')
+ ->end()
->arrayNode('allowed_js_hosts')
->prototype('scalar')
->end()
diff --git a/DependencyInjection/FtrrtfRollbarExtension.php b/DependencyInjection/FtrrtfRollbarExtension.php
index dea4a51..1788f15 100644
--- a/DependencyInjection/FtrrtfRollbarExtension.php
+++ b/DependencyInjection/FtrrtfRollbarExtension.php
@@ -32,6 +32,14 @@ public function load(array $configs, ContainerBuilder $container)
$config['notifier']['client']['check_ignore_function_provider']
);
}
+
+ if (isset($config['notifier']['client']['transform_payload_function_provider'])) {
+ $container->setParameter(
+ 'ftrrtf_rollbar.notifier.client.transform_payload_function_provider',
+ $config['notifier']['client']['transform_payload_function_provider']
+ );
+ }
+
$loader->load('client.xml');
}
diff --git a/Provider/AnonymizeTransformPayloadFunctionProvider.php b/Provider/AnonymizeTransformPayloadFunctionProvider.php
new file mode 100644
index 0000000..3b97255
--- /dev/null
+++ b/Provider/AnonymizeTransformPayloadFunctionProvider.php
@@ -0,0 +1,18 @@
+%ftrrtf_rollbar.environment.options%
service(parameter('ftrrtf_rollbar.notifier.client.check_ignore_function_provider'))
-
+ service(parameter('ftrrtf_rollbar.notifier.client.transform_payload_function_provider'))
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index 7f82705..a7234e6 100644
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -6,6 +6,8 @@
Ftrrtf\RollbarBundle\Helper\UserHelper
Ftrrtf\RollbarBundle\Provider\NullCheckIgnoreFunctionProvider
+ Ftrrtf\RollbarBundle\Provider\NullTransformPayloadFunctionProvider
+ Ftrrtf\RollbarBundle\Provider\AnonymizeTransformPayloadFunctionProvider
@@ -13,5 +15,9 @@
+
+
+
+
diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php
index 6cec065..eb2bd79 100644
--- a/Tests/DependencyInjection/ConfigurationTest.php
+++ b/Tests/DependencyInjection/ConfigurationTest.php
@@ -96,6 +96,7 @@ public function configurationDataProvider()
'rollbarjs_version' => 'v1',
'allowed_js_hosts' => array(),
'check_ignore_function_provider' => 'ftrrtf_rollbar.check_ignore_function_provider.default',
+ 'transform_payload_function_provider' => 'ftrrtf_rollbar.transform_payload_function_provider.default',
),
),
),
diff --git a/Tests/DependencyInjection/FtrrtfRollbarExtensionTest.php b/Tests/DependencyInjection/FtrrtfRollbarExtensionTest.php
index 41a5041..4139a38 100644
--- a/Tests/DependencyInjection/FtrrtfRollbarExtensionTest.php
+++ b/Tests/DependencyInjection/FtrrtfRollbarExtensionTest.php
@@ -145,7 +145,8 @@ public function testClientNotifier()
'http://myhost.mydomain.com',
'http://myhost2.mydomain.com',
),
- 'check_ignore_function_provider' => 'ftrrtf_rollbar.check_ignore_function_provider.default'
+ 'check_ignore_function_provider' => 'ftrrtf_rollbar.check_ignore_function_provider.default',
+ 'transform_payload_function_provider' => 'ftrrtf_rollbar.transform_payload_function_provider.default'
),
'ftrrtf_rollbar.notifier.client.options'
);
@@ -157,6 +158,7 @@ public function testClientNotifier()
'%ftrrtf_rollbar.environment.options%',
new Reference('ftrrtf_rollbar.helper.user'),
new Expression("service(parameter('ftrrtf_rollbar.notifier.client.check_ignore_function_provider'))"),
+ new Expression("service(parameter('ftrrtf_rollbar.notifier.client.transform_payload_function_provider'))"),
)
);
diff --git a/Twig/RollbarExtension.php b/Twig/RollbarExtension.php
index acba065..1cc28ca 100644
--- a/Twig/RollbarExtension.php
+++ b/Twig/RollbarExtension.php
@@ -4,6 +4,7 @@
use Ftrrtf\RollbarBundle\Helper\UserHelper;
use Ftrrtf\RollbarBundle\Provider\CheckIgnoreFunctionProviderInterface;
+use Ftrrtf\RollbarBundle\Provider\TransformPayloadFunctionProviderInterface;
/**
* Rollbar twig extension.
@@ -31,21 +32,29 @@ class RollbarExtension extends \Twig_Extension
private $checkIgnoreFunctionProvider;
/**
- * @param array $notifierOptions
- * @param array $environmentOptions
- * @param UserHelper $userHelper
- * @param CheckIgnoreFunctionProviderInterface $checkIgnoreFunctionProvider
+ * @var TransformPayloadFunctionProviderInterface
+ */
+ private $transformPayloadFunctionProvider;
+
+ /**
+ * @param array $notifierOptions
+ * @param array $environmentOptions
+ * @param UserHelper $userHelper
+ * @param CheckIgnoreFunctionProviderInterface $checkIgnoreFunctionProvider
+ * @param TransformPayloadFunctionProviderInterface $transformPayloadFunctionProvider
*/
public function __construct(
array $notifierOptions,
array $environmentOptions,
UserHelper $userHelper,
- CheckIgnoreFunctionProviderInterface $checkIgnoreFunctionProvider
+ CheckIgnoreFunctionProviderInterface $checkIgnoreFunctionProvider,
+ TransformPayloadFunctionProviderInterface $transformPayloadFunctionProvider
) {
$this->notifierOptions = $notifierOptions;
$this->environmentOptions = $environmentOptions;
$this->userHelper = $userHelper;
$this->checkIgnoreFunctionProvider = $checkIgnoreFunctionProvider;
+ $this->transformPayloadFunctionProvider = $transformPayloadFunctionProvider;
}
/**
@@ -105,9 +114,12 @@ public function getInitRollbarCode(array $context)
$checkIgnoreConfig = $this->getCheckIgnoreConfig();
+ $transform = $this->transformPayloadFunctionProvider->getTransformFunctionCode();
+
return <<
var _rollbarConfig = {$config};
+_rollbarConfig.transform = {$transform};
// Rollbar Snippet
!function(r){function o(e){if(t[e])return t[e].exports;var n=t[e]={exports:{},id:e,loaded:!1};return r[e].call(n.exports,n,n.exports,o),n.loaded=!0,n.exports}var t={};return o.m=r,o.c=t,o.p="",o(0)}([function(r,o,t){"use strict";var e=t(1).Rollbar,n=t(2);_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://d37gvrvc0wt4s1.cloudfront.net/js/{$rollbarJsVersion}/rollbar.min.js";var a=e.init(window,_rollbarConfig),i=n(a,_rollbarConfig);a.loadFull(window,document,!_rollbarConfig.async,_rollbarConfig,i)},function(r,o){"use strict";function t(r){return function(){try{return r.apply(this,arguments)}catch(o){try{console.error("[Rollbar]: Internal error",o)}catch(t){}}}}function e(r,o,t){window._rollbarWrappedError&&(t[4]||(t[4]=window._rollbarWrappedError),t[5]||(t[5]=window._rollbarWrappedError._rollbarContext),window._rollbarWrappedError=null),r.uncaughtError.apply(r,t),o&&o.apply(window,t)}function n(r){var o=function(){var o=Array.prototype.slice.call(arguments,0);e(r,r._rollbarOldOnError,o)};return o.belongsToShim=!0,o}function a(r){this.shimId=++s,this.notifier=null,this.parentShim=r,this._rollbarOldOnError=null}function i(r){var o=a;return t(function(){if(this.notifier)return this.notifier[r].apply(this.notifier,arguments);var t=this,e="scope"===r;e&&(t=new o(this));var n=Array.prototype.slice.call(arguments,0),a={shim:t,method:r,args:n,ts:new Date};return window._rollbarShimQueue.push(a),e?t:void 0})}function l(r,o){if(o.hasOwnProperty&&o.hasOwnProperty("addEventListener")){var t=o.addEventListener;o.addEventListener=function(o,e,n){t.call(this,o,r.wrap(e),n)};var e=o.removeEventListener;o.removeEventListener=function(r,o,t){e.call(this,r,o&&o._wrapped?o._wrapped:o,t)}}}var s=0;a.init=function(r,o){var e=o.globalAlias||"Rollbar";if("object"==typeof r[e])return r[e];r._rollbarShimQueue=[],r._rollbarWrappedError=null,o=o||{};var i=new a;return t(function(){if(i.configure(o),o.captureUncaught){i._rollbarOldOnError=r.onerror,r.onerror=n(i);var t,a,s="EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(",");for(t=0;tbeConstructedWith([], [], $helper, $checkIgnoreFunctionProvider);
+ function let(
+ UserHelper $helper,
+ CheckIgnoreFunctionProviderInterface $checkIgnoreFunctionProvider,
+ TransformPayloadFunctionProviderInterface $transformPayloadFunctionProvider
+ ) {
+ $this->beConstructedWith(
+ [],
+ [],
+ $helper,
+ $checkIgnoreFunctionProvider,
+ $transformPayloadFunctionProvider
+ );
}
function it_is_initializable()
@@ -32,41 +42,53 @@ function it_has_name()
$this->getName()->shouldReturn(self::EXPECTED_EXTENSION_NAME);
}
- function it_uses_the_newest_version_of_rollbarjs(UserHelper $helper, Application $app, CheckIgnoreFunctionProviderInterface $checkIgnoreFunctionProvider)
- {
+ function it_uses_the_newest_version_of_rollbarjs(
+ UserHelper $helper,
+ Application $app,
+ CheckIgnoreFunctionProviderInterface $checkIgnoreFunctionProvider,
+ TransformPayloadFunctionProviderInterface $transformPayloadFunctionProvider
+ ) {
$this->beConstructedWith(
[
'access_token' => 'access_token',
'source_map_enabled' => false,
'allowed_js_hosts' => [],
'check_ignore_function_provider' => null,
+ 'transform_payload_function_provider' => null,
'rollbarjs_version' => 'v1',
],
[
'environment' => 'test',
],
$helper,
- $checkIgnoreFunctionProvider
+ $checkIgnoreFunctionProvider,
+ $transformPayloadFunctionProvider
);
$this->getInitRollbarCode(['app' => $app])->shouldMatch('/v1/');
}
- function it_allows_to_select_rollbarjs_version(UserHelper $helper, Application $app, CheckIgnoreFunctionProviderInterface $checkIgnoreFunctionProvider)
- {
+ function it_allows_to_select_rollbarjs_version(
+ UserHelper $helper,
+ Application $app,
+ CheckIgnoreFunctionProviderInterface $checkIgnoreFunctionProvider,
+ TransformPayloadFunctionProviderInterface $transformPayloadFunctionProvider
+ ) {
$this->beConstructedWith(
[
'access_token' => 'access_token',
'source_map_enabled' => false,
'allowed_js_hosts' => [],
'check_ignore_function_provider' => null,
+ 'transform_payload_function_provider' => null,
'rollbarjs_version' => 'v1.7',
],
[
'environment' => 'test',
],
$helper,
- $checkIgnoreFunctionProvider
+ $checkIgnoreFunctionProvider,
+ $transformPayloadFunctionProvider
);
$this->getInitRollbarCode(['app' => $app])->shouldMatch('/v1.7/');