Skip to content

Commit 20aa63c

Browse files
make ravenjs version configurable, closes #61
1 parent d711912 commit 20aa63c

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

Module.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
class Module
3131
{
32+
public const RAVENJS_VERSION = '3.27.0';
33+
3234
/**
3335
* Translates Zend Framework log levels to Raven log levels.
3436
*/
@@ -232,10 +234,13 @@ protected function setupJavascriptLogging(MvcEvent $event)
232234
{
233235
/** @var HeadScript $headScript */
234236
$headScript = $event->getApplication()->getServiceManager()->get('ViewHelperManager')->get('headscript');
235-
$useRavenjsCDN = $this->config['zend-sentry']['use-ravenjs-cdn'];
236237

237-
if (!isset($useRavenjsCDN) || $useRavenjsCDN) {
238-
$headScript->offsetSetFile(0, '//cdn.ravenjs.com/3.26.2/raven.min.js');
238+
$useRavenjsCDN = $this->config['zend-sentry']['use-ravenjs-cdn'] ?? false;
239+
240+
if ($useRavenjsCDN) {
241+
$ravenjsVersion = $this->config['zend-sentry']['ravenjs-version'] ?? self::RAVENJS_VERSION;
242+
$cdnUri = sprintf('//cdn.ravenjs.com/%s/raven.min.js', $ravenjsVersion);
243+
$headScript->offsetSetFile(0, $cdnUri);
239244
}
240245

241246
$publicApiKey = $this->convertKeyToPublic($this->config['zend-sentry']['sentry-api-key']);

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ Just for the record, a copy of the actual global configuration options:
238238
* If you set this to false you'll need to make sure to load raven-js some other way.
239239
*/
240240
'use-ravenjs-cdn' => true,
241+
242+
/**
243+
* Change the raven-js version loaded via CDN if you need to downgrade or we're lagging behind with updating.
244+
* No BC breaks, ZendSentry will set the version if your config is missing the key.
245+
*/
246+
'ravenjs-version' => '3.27.0',
241247

242248
/**
243249
* Set raven config options for the getsentry/sentry-php package here.

config/zend-sentry.global.php.dist

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* If you have a ./config/autoload/ directory set up for your project, you can
66
* drop this config file in it, remove the .dist extension add your configuration details.
77
*/
8-
$settings = array(
8+
$settings = [
99
/**
1010
* Turn ZendSentry off or on as a whole package
1111
*/
@@ -73,22 +73,28 @@ $settings = array(
7373
*/
7474
'use-ravenjs-cdn' => true,
7575

76+
/**
77+
* Change the raven-js version loaded via CDN if you need to downgrade or we're lagging behind with updating.
78+
* No BC breaks, ZendSentry will set the version if your config is missing the key.
79+
*/
80+
'ravenjs-version' => '3.27.0',
81+
7682
/**
7783
* Set raven config options for the getsentry/sentry-php package here.
7884
* Raven has sensible defaults set in Raven_Client, if you need to override them, this is where you can do it.
7985
*/
80-
'raven-config' => array(),
86+
'raven-config' => [],
8187

8288
/**
8389
* Set ravenjs config options for the getsentry/raven-js package here.
8490
* This will be json encoded and passed to raven-js when doing Raven.install().
8591
*/
86-
'ravenjs-config' => array(),
87-
);
92+
'ravenjs-config' => [],
93+
];
8894

8995
/**
9096
* You do not need to edit below this line
9197
*/
92-
return array(
98+
return [
9399
'zend-sentry' => $settings,
94-
);
100+
];

0 commit comments

Comments
 (0)