1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
CollabAnalytics.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
10
12{
13 public const EVENT_SETTINGS_CHANGED = 'edit_permissions';
14
15 public const EVENT_COPY_LINK = 'copy_invitation_link';
16 public const EVENT_INVITATION = 'invitation';
17 public const EVENT_USER_ADDED = 'add_user';
18 public const EVENT_USER_DELETED = 'delete_user';
19
20 public const TOOL_IM = 'im';
21
22 public const TOOL_INVITATION = 'invitation';
23
24 public const CATEGORY_COLLAB = 'collab';
25
26 public const CATEGORY_INVITATION = 'invitation';
27
28 public const SECTION_EDITOR = 'editor';
29
30 public const SECTION_COLLAB = 'collab';
31
32 public const TYPE_OWNER = 'owner';
33 public const TYPE_MODERATOR = 'moderator';
34
35 public function onOwnerChanged(int $userId, int $collabId): void
36 {
37 $this->onSettingsChanged($userId, $collabId, static::TYPE_OWNER);
38 }
39
40 public function onModeratorChanged(int $userId, int $collabId): void
41 {
42 $this->onSettingsChanged($userId, $collabId, static::TYPE_MODERATOR);
43 }
44
45 public function onSettingsChanged(int $userId, int $collabId, string $optionName): void
46 {
47 $analyticsEvent = new AnalyticsEvent(
48 static::EVENT_SETTINGS_CHANGED,
49 static::TOOL_IM,
50 static::CATEGORY_COLLAB,
51 );
52
53 $parameters = [
54 'p2' => $this->getUserTypeParameter($userId),
55 'p4' => $this->getCollabParameter($collabId),
56 ];
57
58 $this->sendAnalytics(
59 analyticsEvent: $analyticsEvent,
60 type: $optionName,
61 section: static::SECTION_EDITOR,
62 params: $parameters,
63 );
64 }
65
66 public function onMemberAdded(int $userId, int $collabId): void
67 {
68 $analyticsEvent = new AnalyticsEvent(
69 static::EVENT_USER_ADDED,
70 static::TOOL_IM,
71 static::CATEGORY_COLLAB,
72 );
73
74 $this->sendAnalytics(
75 analyticsEvent: $analyticsEvent,
76 section: static::SECTION_EDITOR,
77 params: $this->getParameters($userId, $collabId),
78 );
79 }
80
81 public function onMemberDeleted(int $userId, int $collabId): void
82 {
83 $analyticsEvent = new AnalyticsEvent(
84 static::EVENT_USER_DELETED,
85 static::TOOL_IM,
86 static::CATEGORY_COLLAB,
87 );
88
89 $this->sendAnalytics(
90 analyticsEvent: $analyticsEvent,
91 section: static::SECTION_EDITOR,
92 params: $this->getParameters($userId, $collabId),
93 );
94 }
95
96 public function getUserTypeParameter(int $userId): string
97 {
98 if ($userId <= 0)
99 {
100 return '';
101 }
102
103 $user = new User($userId);
104
105 if ($user->isIntranet())
106 {
107 return 'user_intranet';
108 }
109
110 if ($user->isCollaber())
111 {
112 return 'user_collaber';
113 }
114
115 return 'user_extranet';
116 }
117
118 public function getCollabParameter(int $collabId): string
119 {
120 return 'collabId_' . $collabId;
121 }
122
123 public function getUserParameter(int $userId): string
124 {
125 return 'userId_' . $userId;
126 }
127
128 private function getParameters(int $userId, int $collabId): array
129 {
130 return [
131 'p2' => $this->getUserTypeParameter($userId),
132 'p4' => $this->getCollabParameter($collabId),
133 ];
134 }
135
136 public function onCopyLink(int $userId, int $collabId): void
137 {
138 $analyticsEvent = new AnalyticsEvent(
139 static::EVENT_COPY_LINK,
140 static::TOOL_INVITATION,
141 static::CATEGORY_INVITATION,
142 );
143
144 $parameters = [
145 'p2' => $this->getUserTypeParameter($userId),
146 'p4' => $this->getCollabParameter($collabId),
147 'p5' => $this->getUserParameter($userId),
148 ];
149
150 $this->sendAnalytics(
151 analyticsEvent: $analyticsEvent,
152 section: static::SECTION_COLLAB,
153 params: $parameters,
154 );
155 }
156
157 public function onUserInvitation(int $userId, int $collabId, string $type): void
158 {
159 $analyticsEvent = new AnalyticsEvent(
160 static::EVENT_INVITATION,
161 static::TOOL_INVITATION,
162 static::CATEGORY_INVITATION,
163 );
164
165 $parameters = [
166 'p2' => $this->getUserTypeParameter($userId),
167 'p4' => $this->getCollabParameter($collabId),
168 'p5' => $this->getUserParameter($userId),
169 ];
170
171 $this->sendAnalytics(
172 analyticsEvent: $analyticsEvent,
173 type: $type,
174 section: static::SECTION_COLLAB,
175 params: $parameters,
176 );
177 }
178}
$type
Определения options.php:106
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
onMemberAdded(int $userId, int $collabId)
Определения CollabAnalytics.php:66
onSettingsChanged(int $userId, int $collabId, string $optionName)
Определения CollabAnalytics.php:45
onMemberDeleted(int $userId, int $collabId)
Определения CollabAnalytics.php:81
onUserInvitation(int $userId, int $collabId, string $type)
Определения CollabAnalytics.php:157
onCopyLink(int $userId, int $collabId)
Определения CollabAnalytics.php:136
onOwnerChanged(int $userId, int $collabId)
Определения CollabAnalytics.php:35
onModeratorChanged(int $userId, int $collabId)
Определения CollabAnalytics.php:40
sendAnalytics(AnalyticsEvent $analyticsEvent, ?string $type=null, ?string $section=null, ?string $element=null, ?string $subSection=null, bool $status=true, array $params=[],)
Определения analytics.php:26
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$optionName
Определения options.php:1735