File tree 3 files changed +61
-15
lines changed
3 files changed +61
-15
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace JustBetter \Sentry \Model \Collector ;
4
+
5
+ use JustBetter \Sentry \Helper \Data as DataHelper ;
6
+ use Magento \Csp \Api \PolicyCollectorInterface ;
7
+ use Magento \Csp \Model \Policy \FetchPolicy ;
8
+
9
+ class SentryRelatedCspCollector implements PolicyCollectorInterface
10
+ {
11
+ /**
12
+ * @param DataHelper $dataHelper
13
+ */
14
+ public function __construct (
15
+ private DataHelper $ dataHelper
16
+ ) {
17
+ }
18
+
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ public function collect (array $ defaultPolicies = []): array
23
+ {
24
+ $ policies = $ defaultPolicies ;
25
+ if (!$ this ->dataHelper ->isActive ()) {
26
+ return $ policies ;
27
+ }
28
+
29
+ if ($ this ->dataHelper ->useScriptTag () || $ this ->dataHelper ->useSessionReplay ()) {
30
+ $ policies [] = new FetchPolicy (
31
+ 'script-src ' ,
32
+ false ,
33
+ ['https://browser.sentry-cdn.com ' ]
34
+ );
35
+ $ policies [] = new FetchPolicy (
36
+ 'connect-src ' ,
37
+ false ,
38
+ ['https://*.ingest.sentry.io ' ]
39
+ );
40
+ }
41
+
42
+ if ($ this ->dataHelper ->useLogrocket ()) {
43
+ $ policies [] = new FetchPolicy (
44
+ 'script-src ' ,
45
+ false ,
46
+ ['https://cdn.lr-ingest.io ' ]
47
+ );
48
+ }
49
+
50
+ return $ policies ;
51
+ }
52
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 34
34
<plugin name =" LogrocketCustomerInfo" type =" JustBetter\Sentry\Plugin\LogrocketCustomerInfo"
35
35
sortOrder =" 10" disabled =" false" />
36
36
</type >
37
+
38
+ <type name =" Magento\Csp\Model\CompositePolicyCollector" >
39
+ <arguments >
40
+ <argument name =" collectors" xsi : type =" array" >
41
+ <item name =" sentry" xsi : type =" object" sortOrder =" 99" >JustBetter\Sentry\Model\Collector\SentryRelatedCspCollector\Proxy</item >
42
+ </argument >
43
+ </arguments >
44
+ </type >
45
+
37
46
</config >
You can’t perform that action at this time.
0 commit comments