-
Notifications
You must be signed in to change notification settings - Fork 337
/
config.phtml
47 lines (44 loc) · 1.58 KB
/
config.phtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Tracker init template
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
* versions in the future.
*
* @category Smile
* @package Smile\ElasticsuiteTracker
* @author Romain Ruaud <romain.ruaud@smile.fr>
* @copyright 2020 Smile
* @license Open Software License ("OSL") v. 3.0
*/
?>
<?php /** @var $block Smile\ElasticsuiteTracker\Block\Config **/ ?>
<?php $jsonHelper = $block->getJsonHelper(); ?>
<?php if ($block->isEnabled()) : ?>
<script>
//<![CDATA[
try {
let trackerConfig = {
beaconUrl : '<?= /* @noEscape */ $this->escapeJsQuote($block->getBeaconUrl()); ?>',
telemetryUrl : '<?= /* @noEscape */ $this->escapeJsQuote($block->getTelemetryUrl()); ?>',
telemetryEnabled : '<?= /* @noEscape */ $this->escapeJsQuote($block->isTelemetryEnabled()); ?>',
sessionConfig : <?= /* @noEscape */ $jsonHelper->jsonEncode($block->getCookieConfig()); ?>,
};
<?php if ($block->isUsingAPI()): ?>
trackerConfig.endpointUrl = '<?= /* @noEscape */ $this->escapeJsQuote($block->getEndpointUrl()); ?>';
<?php endif; ?>
smileTracker.setConfig(trackerConfig);
smileTracker.addPageVar('store_id', '<?= /* @noEscape */ $this->escapeJsQuote($block->getStoreId());?>');
require(['<?= /* @noEscape */ $block->getUserConsentScript() ?>'], function (userConsent) {
if (userConsent(<?= /* @noEscape */ $jsonHelper->jsonEncode($block->getUserConsentConfig()); ?>)) {
smileTracker.sendTag();
}
});
} catch (err) {
;
}
//]]>
</script>
<?php endif; ?>