1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
analytics.php
См. документацию.
1<?php
2
4
8
9final class Analytics
10{
11 use SingletonTrait;
12
13 protected const TOOL = 'calendar';
14
15 protected const CALENDAR_CATEGORY = 'calendar';
16
17 protected const EVENT = [
18 'create_event' => 'create_event',
19 ];
20
21 public const SECTION = [
22 'calendar' => 'calendar',
23 'chat' => 'chat',
24 'collab' => 'collab',
25 'project' => 'project',
26 'crm' => 'crm',
27 'tasks' => 'tasks',
28 ];
29
30 public const SUB_SECTION = [
31 'calendar_personal' => 'calendar_personal',
32 'calendar_collab' => 'calendar_collab',
33 'chat_textarea' => 'chat_textarea',
34 ];
35
36 public const USER_TYPES = [
37 'intranet' => 'user_intranet',
38 'extranet' => 'user_extranet',
39 'collaber' => 'user_collaber',
40 ];
41
52 public function onEventCreate(
53 string $section,
54 ?string $subSection,
55 ?string $userType = null,
56 ?int $collabId = 0,
57 ?int $chatId = 0,
58 ): void
59 {
60 $analyticsEvent = new AnalyticsEvent(
61 event: self::EVENT['create_event'],
62 tool: self::TOOL,
63 category: self::CALENDAR_CATEGORY
64 );
65
66 $params = [];
67
68 if (!empty($userType))
69 {
70 $params['p2'] = $userType;
71 }
72
73 if (!empty($collabId))
74 {
75 $params['p4'] = 'collabId_' . $collabId;
76 }
77
78 if (!empty($chatId))
79 {
80 $params['p5'] = 'chatId_' . $chatId;
81 }
82
83 $this->sendAnalytics($analyticsEvent, $section, $subSection, $params);
84 }
85
95 private function sendAnalytics(
96 AnalyticsEvent $analyticsEvent,
97 ?string $section = null,
98 ?string $subSection = null,
99 array $params = [],
100 ): void
101 {
102 if (in_array($section, self::SECTION, true))
103 {
104 $analyticsEvent->setSection($section);
105 }
106
107 if (in_array($subSection, self::SUB_SECTION, true))
108 {
109 $analyticsEvent->setSubSection($subSection);
110 }
111
112 for ($i = 1; $i <= 5; $i++)
113 {
114 $pKey = 'p' . $i;
115 if (!empty($params[$pKey]) && is_string($params[$pKey]))
116 {
117 $methodName = 'setP' . ($i);
118 if (method_exists($analyticsEvent, $methodName))
119 {
120 $analyticsEvent->$methodName($params[$pKey]);
121 }
122 }
123 }
124
125 $analyticsEvent->send();
126 }
127}
onEventCreate(string $section, ?string $subSection, ?string $userType=null, ?int $collabId=0, ?int $chatId=0,)
Определения analytics.php:52
setSubSection(string $subSection)
Определения analyticsevent.php:79
setSection(string $section)
Определения analyticsevent.php:72
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
trait SingletonTrait
Определения singletontrait.php:6
$i
Определения factura.php:643
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799