Skip to content

Commit

Permalink
Merge pull request #1661 from planetary-social/track-mentions
Browse files Browse the repository at this point in the history
Track mentions autocomplete opened
  • Loading branch information
pelumy authored Oct 18, 2024
2 parents 9320fea + a842625 commit b640a95
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 11 additions & 2 deletions Nos/Controller/NoteEditorController.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Dependencies
import Foundation
import SwiftUI
import UIKit
Expand All @@ -9,15 +10,23 @@ 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.
var intrinsicHeight: CGFloat = 0

/// 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 {
Expand Down
2 changes: 1 addition & 1 deletion Nos/Controller/SearchController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class SearchController: ObservableObject {
case .discover:
analytics.searchedDiscover()
case .mentions:
analytics.searchedMentions()
analytics.mentionsAutocompleteCharactersEntered()
}
}
self.authorResults = self.authors(named: query)
Expand Down
8 changes: 6 additions & 2 deletions Nos/Service/Analytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -297,4 +297,8 @@ class Analytics {
func cancelledUploadSourceSelection() {
track("Cancelled Upload Source Selection")
}

func mentionsAutocompleteOpened() {
track("Mentions Autocomplete Opened")
}
}

0 comments on commit b640a95

Please sign in to comment.