Skip to content

Commit 25d1945

Browse files
authored
Merge pull request #8577 from element-hq/sync-analytics-plan
Sync analytics plan
2 parents e818f86 + 03966f1 commit 25d1945

File tree

7 files changed

+206
-5
lines changed

7 files changed

+206
-5
lines changed

vector/src/main/java/im/vector/app/features/analytics/extensions/ComposerExt.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ fun MessageComposerViewState.toAnalyticsComposer(): Composer =
2525
inThread = isInThreadTimeline(),
2626
isEditing = sendMode is SendMode.Edit,
2727
isReply = sendMode is SendMode.Reply,
28-
startsThread = startsThread
28+
messageType = Composer.MessageType.Text,
29+
startsThread = startsThread,
2930
)

vector/src/main/java/im/vector/app/features/analytics/plan/Composer.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,51 @@ data class Composer(
3939
* sent event.
4040
*/
4141
val isReply: Boolean,
42+
/**
43+
* The type of the message.
44+
*/
45+
val messageType: MessageType,
4246
/**
4347
* Whether this message begins a new thread or not.
4448
*/
4549
val startsThread: Boolean? = null,
4650
) : VectorAnalyticsEvent {
4751

52+
enum class MessageType {
53+
/**
54+
* A pin drop location message.
55+
*/
56+
LocationPin,
57+
58+
/**
59+
* A user current location message.
60+
*/
61+
LocationUser,
62+
63+
/**
64+
* A poll message.
65+
*/
66+
Poll,
67+
68+
/**
69+
* A text message.
70+
*/
71+
Text,
72+
73+
/**
74+
* A voice message.
75+
*/
76+
VoiceMessage,
77+
}
78+
4879
override fun getName() = "Composer"
4980

5081
override fun getProperties(): Map<String, Any>? {
5182
return mutableMapOf<String, Any>().apply {
5283
put("inThread", inThread)
5384
put("isEditing", isEditing)
5485
put("isReply", isReply)
86+
put("messageType", messageType.name)
5587
startsThread?.let { put("startsThread", it) }
5688
}.takeIf { it.isNotEmpty() }
5789
}

vector/src/main/java/im/vector/app/features/analytics/plan/MobileScreen.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ data class MobileScreen(
3838
*/
3939
Breadcrumbs,
4040

41+
/**
42+
* The screen shown to create a poll.
43+
*/
44+
CreatePollView,
45+
4146
/**
4247
* The screen shown to create a new (non-direct) room.
4348
*/
@@ -58,6 +63,11 @@ data class MobileScreen(
5863
*/
5964
Dialpad,
6065

66+
/**
67+
* The screen shown to edit a poll.
68+
*/
69+
EditPollView,
70+
6171
/**
6272
* The Favourites tab on mobile that lists your favourite people/rooms.
6373
*/
@@ -88,6 +98,16 @@ data class MobileScreen(
8898
*/
8999
Invites,
90100

101+
/**
102+
* The screen shown to share location.
103+
*/
104+
LocationSend,
105+
106+
/**
107+
* The screen shown to view a shared location.
108+
*/
109+
LocationView,
110+
91111
/**
92112
* The screen that displays the login flow (when the user already has an
93113
* account).
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2021 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.features.analytics.plan
18+
19+
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
20+
21+
// GENERATED FILE, DO NOT EDIT. FOR MORE INFORMATION VISIT
22+
// https://github.com/matrix-org/matrix-analytics-events/
23+
24+
/**
25+
* Triggered when a poll is created or edited.
26+
*/
27+
data class PollCreation(
28+
/**
29+
* Whether this poll has been created or edited.
30+
*/
31+
val action: Action,
32+
/**
33+
* Whether this poll is undisclosed.
34+
*/
35+
val isUndisclosed: Boolean,
36+
/**
37+
* Number of answers in the poll.
38+
*/
39+
val numberOfAnswers: Int,
40+
) : VectorAnalyticsEvent {
41+
42+
enum class Action {
43+
/**
44+
* Newly created poll.
45+
*/
46+
Create,
47+
48+
/**
49+
* Edit of an existing poll.
50+
*/
51+
Edit,
52+
}
53+
54+
override fun getName() = "PollCreation"
55+
56+
override fun getProperties(): Map<String, Any>? {
57+
return mutableMapOf<String, Any>().apply {
58+
put("action", action.name)
59+
put("isUndisclosed", isUndisclosed)
60+
put("numberOfAnswers", numberOfAnswers)
61+
}.takeIf { it.isNotEmpty() }
62+
}
63+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2021 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.features.analytics.plan
18+
19+
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
20+
21+
// GENERATED FILE, DO NOT EDIT. FOR MORE INFORMATION VISIT
22+
// https://github.com/matrix-org/matrix-analytics-events/
23+
24+
/**
25+
* Triggered when a poll has been ended.
26+
*/
27+
data class PollEnd(
28+
/**
29+
* Do not use this. Remove this property when the kotlin type generator
30+
* can properly generate types without proprties other than the event
31+
* name.
32+
*/
33+
val doNotUse: Boolean? = null,
34+
) : VectorAnalyticsEvent {
35+
36+
override fun getName() = "PollEnd"
37+
38+
override fun getProperties(): Map<String, Any>? {
39+
return mutableMapOf<String, Any>().apply {
40+
doNotUse?.let { put("doNotUse", it) }
41+
}.takeIf { it.isNotEmpty() }
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2021 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.features.analytics.plan
18+
19+
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
20+
21+
// GENERATED FILE, DO NOT EDIT. FOR MORE INFORMATION VISIT
22+
// https://github.com/matrix-org/matrix-analytics-events/
23+
24+
/**
25+
* Triggered when a poll vote has been cast.
26+
*/
27+
data class PollVote(
28+
/**
29+
* Do not use this. Remove this property when the kotlin type generator
30+
* can properly generate types without proprties other than the event
31+
* name.
32+
*/
33+
val doNotUse: Boolean? = null,
34+
) : VectorAnalyticsEvent {
35+
36+
override fun getName() = "PollVote"
37+
38+
override fun getProperties(): Map<String, Any>? {
39+
return mutableMapOf<String, Any>().apply {
40+
doNotUse?.let { put("doNotUse", it) }
41+
}.takeIf { it.isNotEmpty() }
42+
}
43+
}

vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class MessageComposerViewModel @AssistedInject constructor(
150150
}
151151

152152
private fun handleOnTextChanged(action: MessageComposerAction.OnTextChanged) {
153-
val needsSendButtonVisibilityUpdate = currentComposerText.isBlank() != action.text.isBlank()
153+
val needsSendButtonVisibilityUpdate = currentComposerText.isBlank() != action.text.isBlank()
154154
currentComposerText = SpannableString(action.text)
155155
if (needsSendButtonVisibilityUpdate) {
156156
updateIsSendButtonVisibility(true)
@@ -239,9 +239,8 @@ class MessageComposerViewModel @AssistedInject constructor(
239239

240240
private fun handleSendMessage(room: Room, action: MessageComposerAction.SendMessage) {
241241
withState { state ->
242-
analyticsTracker.capture(state.toAnalyticsComposer()).also {
243-
setState { copy(startsThread = false) }
244-
}
242+
analyticsTracker.capture(state.toAnalyticsComposer())
243+
setState { copy(startsThread = false) }
245244
when (state.sendMode) {
246245
is SendMode.Regular -> {
247246
when (val parsedCommand = commandParser.parseSlashCommand(

0 commit comments

Comments
 (0)