diff --git a/CHANGELOG.md b/CHANGELOG.md index 71061e8d2..2cd8400ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added the Username onboarding screen. Currently behind the “New Onboarding Flow” feature flag. [#1598](https://github.com/planetary-social/nos/issues/1598) - Added the Account Success onboarding screen. Currently behind the “New Onboarding Flow” feature flag. [#1599](https://github.com/planetary-social/nos/issues/1599) - Updated the Age Verification onboarding screen. Currently behind the “New Onboarding Flow” feature flag. [#1651](https://github.com/planetary-social/nos/issues/1651) +- Track opening mentions with Posthog. [#1480](https://github.com/planetary-social/nos/issues/1480) ## [0.2.2] - 2024-10-11Z diff --git a/Nos/Controller/NoteEditorController.swift b/Nos/Controller/NoteEditorController.swift index a6b9182f3..811200980 100644 --- a/Nos/Controller/NoteEditorController.swift +++ b/Nos/Controller/NoteEditorController.swift @@ -1,3 +1,4 @@ +import Dependencies import Foundation import SwiftUI import UIKit @@ -9,6 +10,8 @@ import UIKit /// when the user indicates they are ready to post it. @Observable class NoteEditorController: NSObject, UITextViewDelegate { + @ObservationIgnored @Dependency(\.analytics) private var analytics + /// The height that fits all entered text. This value will be updated by `NoteUITextViewRepresentable` /// automatically, and should be used to set the frame of `NoteUITextViewRepresentable` from SwiftUI. This is done /// to work around some incompatibilities between UIKit and SwiftUI where the UITextView won't expand properly. @@ -16,8 +19,14 @@ import UIKit /// A variable that controls whether the mention autocomplete window should be shown. This window is triggered /// by typing an '@' symbol and allows the user to search for another user to mention in their note. - var showMentionsAutocomplete = false - + var showMentionsAutocomplete = false { + didSet { + if showMentionsAutocomplete { + analytics.mentionsAutocompleteOpened() + } + } + } + /// The view the user will use for editing. Should only be set by ``NoteTextEditor/NoteUITextViewRepresentable``. var textView: UITextView? { didSet { diff --git a/Nos/Controller/SearchController.swift b/Nos/Controller/SearchController.swift index 1c84b6d79..f06507bb6 100644 --- a/Nos/Controller/SearchController.swift +++ b/Nos/Controller/SearchController.swift @@ -87,7 +87,7 @@ class SearchController: ObservableObject { case .discover: analytics.searchedDiscover() case .mentions: - analytics.searchedMentions() + analytics.mentionsAutocompleteCharactersEntered() } } self.authorResults = self.authors(named: query) diff --git a/Nos/Service/Analytics.swift b/Nos/Service/Analytics.swift index 320350e15..945396d5e 100644 --- a/Nos/Service/Analytics.swift +++ b/Nos/Service/Analytics.swift @@ -161,8 +161,8 @@ class Analytics { } /// Tracks when the user submits a search on the Mentions screen. - func searchedMentions() { - track("Mentions Search Started") + func mentionsAutocompleteCharactersEntered() { + track("Mentions Autocomplete Characters Entered") } /// Tracks when the user taps on a search result on the Discover screen. @@ -297,4 +297,8 @@ class Analytics { func cancelledUploadSourceSelection() { track("Cancelled Upload Source Selection") } + + func mentionsAutocompleteOpened() { + track("Mentions Autocomplete Opened") + } }