Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Screen Tracking with consistent naming conventions #885

Conversation

kowongh
Copy link
Contributor

@kowongh kowongh commented May 13, 2020

What does this PR do?
This simply reverses the logic for naming conventions regarding automatic screen tracking in an attempt to provide more consistent naming conventions. The current approach is sacrificing consistency for readability which muddies up data. With the addition of the custom naming protocol, we don't need title anymore.

Assuming that all view controllers have a somewhat unique name (other than ViewController which is specified in the logic), we can assume that the automatic screen tracking will have a consistent naming convention throughout all screens (rather than having a mix of both ClassName minus "ViewController" and title), since all view controllers will not have a title i.e NavigationItem.

Furthermore, if two view controllers have the same title, then they will show up as having the same name value. Using class name is a better way to uniquely identify a screen.

With the addition of the custom naming protocol, title as a first choice naming convention is a bit redundant because you can conform to the protocol if you need a custom or more readable name such as the title of the view controller.

Where should the reviewer start?
UIViewController.seg_viewDidAppear()

How should this be manually tested?
Add recordScreenViews to your config, then look at the names of the events reported.

Any background context you want to provide?
With the automatic screen tracking feature we want a consistent naming convention without overriding or conforming to protocols.

What are the relevant tickets?
Related to #771

Screenshots or screencasts (if UI/UX change)

Questions:

  • Does the docs need an update?
    Yes

  • Are there any security concerns?
    No

  • Do we need to update engineering/success?
    N/A

@kowongh kowongh force-pushed the change-auto-screen-tracking-naming-convention branch from 079d310 to 63d6131 Compare May 13, 2020 18:31
@codecov-io
Copy link

Codecov Report

Merging #885 into releases/3.8.1 will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@                Coverage Diff                 @@
##           releases/3.8.1     #885      +/-   ##
==================================================
- Coverage           87.57%   87.55%   -0.03%     
==================================================
  Files                  55       55              
  Lines                3220     3221       +1     
==================================================
  Hits                 2820     2820              
- Misses                400      401       +1     

@bsneed bsneed changed the base branch from releases/3.8.1 to releases/3.9.0 June 5, 2020 16:37
@bsneed bsneed merged commit bbf8762 into segmentio:releases/3.9.0 Jun 5, 2020
bsneed pushed a commit that referenced this pull request Jun 5, 2020
kevinfarst-earnin added a commit to activehours/analytics-ios that referenced this pull request Jun 10, 2020
* adding “name” field to payload;updated nimble to version 7.3.4

* Fix GCD mutual dependency (segmentio#785)

* Add iOS Backgrounded Event. (segmentio#831)

* Add iOS Backgrounded Event.

* Bump Xcode CI version

* Bump pods

* Updated properties

* Simplified App Backgrounded call

* Fixed test since we dropped the param.

* Reverted xcode CI version number

* LIB-1212: Promoting 3.7.0-beta.4 to release. (segmentio#834) (segmentio#836)

* Prepare for release 3.7.0

* Updated cartfile.

* Updated version in SEGAnalytics.m

* Updated version in readme instructions.

* Preparing 3.8.0-beta.0 release. (segmentio#837) (segmentio#838)

* Preparing 3.8.0-beta.0 release.

* `CoreTelephony` library is now only included on iOS targets. This was done so that tvOS targets could build without linker errors. (segmentio#842)

* Add support for SSL Pinning (segmentio#839)

* Support SSL pinning

Client integrations can optionally pass in a NSURLSessionDelegate in the SEGAnalyticsConfiguration object.
If set, NSURLSessionDelegate callbacks are forwarded to the client code where SSL pinning checks can be implemented

* test httpSessionDelegate configuration

* Fix for LIB-1416 & Github segmentio#846 (segmentio#853)

* Fix for LIB-1416 & Github segmentio#846

- Stops blindly passing dictionaries.
- Property dictionaries are checked for NSCoding conformance to ensure they can be serialized.
- Property dictionaries are deep copied so contents can’t change while the pipeline is in progress.
- Puts a try/catch arrangement as a temporary guard against crashes for serialization failures until the storage format can be changed.

* Fixed missing ;

* Added test for deepCopy/conformance additions.

* Swapped JSON in for the storage format instead of plists. (segmentio#854)

* Converted file storage to JSON from plist.

* Updated string storage to account for JSON vs plist differences.

* update podfile lock.

* Remove some NSNull hacks.

* Updated tests to validate null values.

* Fixed LIB-1462 (segmentio#855)

* Reload static context data when the app returns from background. (segmentio#856)

* Respond to changes regarding advertising ID.

* Removed unnecessary context.

* Remove extraneous NSNull handling causing tests to fail.

* Added weakify/strongify macros.

* Removed extraneous NSNull checking.

* Put locking around static context access.

* Prepare for release 3.8.0-beta.1

* Fix changelog for 3.8.0-beta.1

* Updated carthage versions.

* Update config.yml

* [tvOS] Move SEGQueue from UserDefaults to caches directory (segmentio#861)

* Stops using UserDefaults for queue on tvOS and uses NSCachesDirectory

Changes storage to fileStorage and userDefaultsStorage. Utilizes userDefaults on tvOS for information such as anonymousID and configuration, but moves tvOS's queue into the NSCachesDirectory. The reasoning is that tvOS has a 1mb limit for UserDefaults and the queue can grow rapidly in size, leading to app crashes when saving more than 1mb of data to UserDefaults.

* Adds a constant for key. Seperate cache dir and appSupport dir functions. Removes unused init.

* Adds functionality to remove old UserDefaults queue on tvOS.

Updates migrated removal block to account for tvOS now that the queue is no longer in UserDefaults. Adds back in a #else and #endif that was accidently removed.

* Adds tvOS unit test target

* Adds new AnalyticsTestsTVOS scheme
* Updates pods to include all test pods for AnalyticsTestsTVOS
* Fixes unit test import for QuickTVOS

* Add tvOS options for make file

* Enabled code coverage on tvOS tests

* Fix up unit test warning

"result of expect is never nil"

* Adds test to ensure that UserDefaults SEGQueue is cleared on initialization for tvOS & iOS

* Adds test to ensure SEGQueue is empty when missing form file storage

* Reverts unnecessary import for QuickTVOS

* Adds test for FileStorage caches directory helper

* Fix up: Adds SwiftTryCatch pod to tvOS test target

* Fix up makefile to have correct build target for build-ios & build-tvos

* Fix up: updates xcodebuild destination to match devices found on circleci

* Break up ios and tvos build/test steps

* Circleci: Cache pods

* Fix up: tvOS test build

* Fix up spacing

* Fix up flaky unit test

Co-authored-by: Connor Ricks <[email protected]>

* Fix issues around plist->json conversion & nil values (segmentio#862)

* Fixing a crash from plist->json conversion where result is not actually a dictionary.

* Made code flow the same as non-conversion.

* Set compatibility to 10.0.

* Fixed issues around setting nil values even though they are expected.

* Address Issue segmentio#851; Expect dictionary as well for for integration enablement (segmentio#863)

* Address Issue segmentio#851; Expect dictionary as well for for integration enablement.

* Fixed broken test.

* Differences observed in how iOS/android pass userId/anonId; Corrected. (segmentio#864)

* Disabled tvOS tests temporarily.

* Updated podfile lock.

* Fixed LIB-1698; Differences observed in how ios/android pass userId/anonId in traits.

* Another podfile lock update.

* Fixed test.

* Set swift version for tests.

* Reverted podfile lock changes due to incompatibilities.

* Look at previously cached settings before blowing them away. (segmentio#866)

* Bsneed/timestamps (segmentio#876)

* LIB-1656: Added nanosecond timestamps

* Actually use the timestamp we’re carrying around.

* In case the context is modified, preserve the timestamp.

* Bump timestamp nanosecond precision to 9.

* Only carry over the timestamp during a modify if there was one to begin with.

* Added experimental options to configuration.

* Added a second version of 8601 date creation.

* Respect experimental value now present in config.

* Added nanosecond time test.

Co-authored-by: Brandon Sneed <[email protected]>

* Prepare for release 3.8.0-beta.2.

* Fixed warning.

* Updated carthage files.

* Implement maximum batch request size (segmentio#874)

* Implement maximum request size

* Add test when batch exceeds the size

* Execute check before gzip

* Remove stub request

* Prepare for release 3.8.0.

* Updated carthage files.

* Misc Fixes (segmentio#884)

* Add name and properties to auto screen reporting

* Make seg_topViewController handle tab and custom container VCs

* Simplify SEGScreenReporting protocol

Inspired by comments from @f2prateek, simplify the the `SEGScreenReporting` protocol to replace the name and properties fields with a single method (`seg_trackScreen`) that can be implemented when screen tracking for a specific view controller that needs a custom name, properties, or options.

* Update Nimble to build with Xcode 10.2

* Add tests for seg_topViewController

* fixed a crash in file storage when trying to get a string stored using old SDK version (segmentio#880)

* Fixed issue where build/version were removed from Application Opened events from background state.

* Publish filenames used for data storage (segmentio#865)

* Remove tvos test from scheme setup.

* Fixed selector reference.

* Removed unused code.

Co-authored-by: David Whetstone <[email protected]>
Co-authored-by: Sergei Guselnikov <[email protected]>
Co-authored-by: Brandon Sneed <[email protected]>
Co-authored-by: Błażej Biesiada <[email protected]>

* Add previouslyCachedSettings count (segmentio#889)

* Prepare for release 3.8.1

* Updated carthage files to 3.8.1

* Prepare for release 3.8.2.

* Updated carthage files for 3.8.2

* Add ability to set default settings is segment.com can't be reached.  Backported from segmentio#888 (segmentio#897)

Co-authored-by: Brandon Sneed <[email protected]>

* change logic for naming conventions (segmentio#885)

* Prepare for release 3.9.0

* Updated carthage files for 3.9.0

Co-authored-by: Daniel Jackins <[email protected]>
Co-authored-by: dsjackins <[email protected]>
Co-authored-by: Fathy Boundjadj <[email protected]>
Co-authored-by: Carlos Kelly <[email protected]>
Co-authored-by: Brandon Sneed <[email protected]>
Co-authored-by: Dan Morrow <[email protected]>
Co-authored-by: Ujjawal Garg <[email protected]>
Co-authored-by: Brandon Sneed <[email protected]>
Co-authored-by: Ben Humphries <[email protected]>
Co-authored-by: Connor Ricks <[email protected]>
Co-authored-by: Cristian Lupu <[email protected]>
Co-authored-by: David Whetstone <[email protected]>
Co-authored-by: Sergei Guselnikov <[email protected]>
Co-authored-by: Błażej Biesiada <[email protected]>
Co-authored-by: alanjcharles <[email protected]>
Co-authored-by: Ko <[email protected]>
kevinfarst-earnin added a commit to activehours/analytics-ios that referenced this pull request Sep 25, 2020
* Update Nimble to build with Xcode 10.2

* Add name and properties to auto screen reporting

* Make seg_topViewController handle tab and custom container VCs

* Simplify SEGScreenReporting protocol

Inspired by comments from @f2prateek, simplify the the `SEGScreenReporting` protocol to replace the name and properties fields with a single method (`seg_trackScreen`) that can be implemented when screen tracking for a specific view controller that needs a custom name, properties, or options.

* Add tests for seg_topViewController

* adding “name” field to payload;updated nimble to version 7.3.4

* Fix GCD mutual dependency (segmentio#785)

* Add iOS Backgrounded Event. (segmentio#831)

* Add iOS Backgrounded Event.

* Bump Xcode CI version

* Bump pods

* Updated properties

* Simplified App Backgrounded call

* Fixed test since we dropped the param.

* Reverted xcode CI version number

* LIB-1212: Promoting 3.7.0-beta.4 to release. (segmentio#834) (segmentio#836)

* Prepare for release 3.7.0

* Updated cartfile.

* Updated version in SEGAnalytics.m

* Updated version in readme instructions.

* Preparing 3.8.0-beta.0 release. (segmentio#837) (segmentio#838)

* Preparing 3.8.0-beta.0 release.

* `CoreTelephony` library is now only included on iOS targets. This was done so that tvOS targets could build without linker errors. (segmentio#842)

* Add support for SSL Pinning (segmentio#839)

* Support SSL pinning

Client integrations can optionally pass in a NSURLSessionDelegate in the SEGAnalyticsConfiguration object.
If set, NSURLSessionDelegate callbacks are forwarded to the client code where SSL pinning checks can be implemented

* test httpSessionDelegate configuration

* Fix for LIB-1416 & Github segmentio#846 (segmentio#853)

* Fix for LIB-1416 & Github segmentio#846

- Stops blindly passing dictionaries.
- Property dictionaries are checked for NSCoding conformance to ensure they can be serialized.
- Property dictionaries are deep copied so contents can’t change while the pipeline is in progress.
- Puts a try/catch arrangement as a temporary guard against crashes for serialization failures until the storage format can be changed.

* Fixed missing ;

* Added test for deepCopy/conformance additions.

* Swapped JSON in for the storage format instead of plists. (segmentio#854)

* Converted file storage to JSON from plist.

* Updated string storage to account for JSON vs plist differences.

* update podfile lock.

* Remove some NSNull hacks.

* Updated tests to validate null values.

* Fixed LIB-1462 (segmentio#855)

* Reload static context data when the app returns from background. (segmentio#856)

* Respond to changes regarding advertising ID.

* Removed unnecessary context.

* Remove extraneous NSNull handling causing tests to fail.

* Added weakify/strongify macros.

* Removed extraneous NSNull checking.

* Put locking around static context access.

* Prepare for release 3.8.0-beta.1

* Fix changelog for 3.8.0-beta.1

* Updated carthage versions.

* Update config.yml

* [tvOS] Move SEGQueue from UserDefaults to caches directory (segmentio#861)

* Stops using UserDefaults for queue on tvOS and uses NSCachesDirectory

Changes storage to fileStorage and userDefaultsStorage. Utilizes userDefaults on tvOS for information such as anonymousID and configuration, but moves tvOS's queue into the NSCachesDirectory. The reasoning is that tvOS has a 1mb limit for UserDefaults and the queue can grow rapidly in size, leading to app crashes when saving more than 1mb of data to UserDefaults.

* Adds a constant for key. Seperate cache dir and appSupport dir functions. Removes unused init.

* Adds functionality to remove old UserDefaults queue on tvOS.

Updates migrated removal block to account for tvOS now that the queue is no longer in UserDefaults. Adds back in a #else and #endif that was accidently removed.

* Adds tvOS unit test target

* Adds new AnalyticsTestsTVOS scheme
* Updates pods to include all test pods for AnalyticsTestsTVOS
* Fixes unit test import for QuickTVOS

* Add tvOS options for make file

* Enabled code coverage on tvOS tests

* Fix up unit test warning

"result of expect is never nil"

* Adds test to ensure that UserDefaults SEGQueue is cleared on initialization for tvOS & iOS

* Adds test to ensure SEGQueue is empty when missing form file storage

* Reverts unnecessary import for QuickTVOS

* Adds test for FileStorage caches directory helper

* Fix up: Adds SwiftTryCatch pod to tvOS test target

* Fix up makefile to have correct build target for build-ios & build-tvos

* Fix up: updates xcodebuild destination to match devices found on circleci

* Break up ios and tvos build/test steps

* Circleci: Cache pods

* Fix up: tvOS test build

* Fix up spacing

* Fix up flaky unit test

Co-authored-by: Connor Ricks <[email protected]>

* Fix issues around plist->json conversion & nil values (segmentio#862)

* Fixing a crash from plist->json conversion where result is not actually a dictionary.

* Made code flow the same as non-conversion.

* Set compatibility to 10.0.

* Fixed issues around setting nil values even though they are expected.

* Address Issue segmentio#851; Expect dictionary as well for for integration enablement (segmentio#863)

* Address Issue segmentio#851; Expect dictionary as well for for integration enablement.

* Fixed broken test.

* Differences observed in how iOS/android pass userId/anonId; Corrected. (segmentio#864)

* Disabled tvOS tests temporarily.

* Updated podfile lock.

* Fixed LIB-1698; Differences observed in how ios/android pass userId/anonId in traits.

* Another podfile lock update.

* Fixed test.

* Set swift version for tests.

* Reverted podfile lock changes due to incompatibilities.

* Look at previously cached settings before blowing them away. (segmentio#866)

* Bsneed/timestamps (segmentio#876)

* LIB-1656: Added nanosecond timestamps

* Actually use the timestamp we’re carrying around.

* In case the context is modified, preserve the timestamp.

* Bump timestamp nanosecond precision to 9.

* Only carry over the timestamp during a modify if there was one to begin with.

* Added experimental options to configuration.

* Added a second version of 8601 date creation.

* Respect experimental value now present in config.

* Added nanosecond time test.

Co-authored-by: Brandon Sneed <[email protected]>

* Prepare for release 3.8.0-beta.2.

* Fixed warning.

* Updated carthage files.

* Implement maximum batch request size (segmentio#874)

* Implement maximum request size

* Add test when batch exceeds the size

* Execute check before gzip

* Remove stub request

* Added Integration Middleware capabilities (segmentio#879)

* Added integration middleware support.

* Fixed warnings; Updated project to recommended settings.

* only signal the runner if there’s actually middleware to be processed.

* Added & Updated tests.

* Added experimental raw filter block.

* Removed unnecessary logs.

* Added logic to allow tests to function.

Co-authored-by: Brandon Sneed <[email protected]>

* Prepare for release 3.8.0.

* Updated carthage files.

* Prepare for release 4.0.0-beta.0.

* Updated carthage files.

* fixed a crash in file storage when trying to get a string stored using old SDK version (segmentio#880)

* fixed a crash in file storage when trying to get a string stored using old SDK version (segmentio#880)

* Fixed issue where build/version were removed from Application Opened events from background state.

* Publish filenames used for data storage (segmentio#865)

* Publish filenames used for data storage (segmentio#865)

* Remove tvos test from scheme setup.

* Fixed selector reference.

* Removed unused code.

* Misc Fixes (segmentio#884)

* Add name and properties to auto screen reporting

* Make seg_topViewController handle tab and custom container VCs

* Simplify SEGScreenReporting protocol

Inspired by comments from @f2prateek, simplify the the `SEGScreenReporting` protocol to replace the name and properties fields with a single method (`seg_trackScreen`) that can be implemented when screen tracking for a specific view controller that needs a custom name, properties, or options.

* Update Nimble to build with Xcode 10.2

* Add tests for seg_topViewController

* fixed a crash in file storage when trying to get a string stored using old SDK version (segmentio#880)

* Fixed issue where build/version were removed from Application Opened events from background state.

* Publish filenames used for data storage (segmentio#865)

* Remove tvos test from scheme setup.

* Fixed selector reference.

* Removed unused code.

Co-authored-by: David Whetstone <[email protected]>
Co-authored-by: Sergei Guselnikov <[email protected]>
Co-authored-by: Brandon Sneed <[email protected]>
Co-authored-by: Błażej Biesiada <[email protected]>

* Update CHANGELOG.md

* Add ability to set default settings is segment.com can't be reached. (segmentio#888)

* Added integration middleware support.

* Fixed warnings; Updated project to recommended settings.

* only signal the runner if there’s actually middleware to be processed.

* Added & Updated tests.

* Added experimental raw filter block.

* Removed unnecessary logs.

* Added logic to allow tests to function.

* Allow for user-supplied settings.

* Make sure segment.io is still present in the integrations list.

* Added ability to set default settings if segment.com can’t be reached.

* Removed test code.

Co-authored-by: Brandon Sneed <[email protected]>

* Fixed defaultSettings documentation.

* Add previouslyCachedSettings count (segmentio#889)

* Add previouslyCachedSettings count (segmentio#889)

* Prepare for release 3.8.1

* Updated carthage files to 3.8.1

* Prepare for release 3.8.2.

* Update CHANGELOG.md

* Updated carthage files for 3.8.2

* Allow customers to set default settings values if segment.com unreachable. (segmentio#891)

* Added integration middleware support.

* Fixed warnings; Updated project to recommended settings.

* only signal the runner if there’s actually middleware to be processed.

* Added & Updated tests.

* Added experimental raw filter block.

* Removed unnecessary logs.

* Added logic to allow tests to function.

* Allow for user-supplied settings.

* Make sure segment.io is still present in the integrations list.

* Added ability to set default settings if segment.com can’t be reached.

* Removed test code.

Co-authored-by: Brandon Sneed <[email protected]>

* Makes IDFA support externally/customer driven. (segmentio#892)

* Remove IDFA related bits and push to customers.

* Check if ad block is nil before executing

* Fixed header reference.

* Adjusted IDFA test.

Co-authored-by: Brandon Sneed <[email protected]>

* Prepare for release 4.0.0-beta.1

* Updated tests to remove Alamofire (segmentio#895)

Co-authored-by: Cody Garvin <[email protected]>

* Renamed middleware methods to match a.js naming. (segmentio#896)

* Renamed middleware methods to match a.js naming.

* Updated a comment re integration/destination.

Co-authored-by: Brandon Sneed <[email protected]>

* Add ability to set default settings is segment.com can't be reached.  Backported from segmentio#888 (segmentio#897)

Co-authored-by: Brandon Sneed <[email protected]>

* change logic for naming conventions (segmentio#885)

* Prepare for release 3.9.0

* Updated carthage files for 3.9.0

* Merged 3.9 changelog; Bumped CI xcode version.

* change logic for naming conventions (segmentio#885)

* LIB-83: Fixed crash on UISceneDelegate applications (segmentio#899)

Co-authored-by: Cody Garvin <[email protected]>

* Added application object back to notifications (segmentio#900)

Co-authored-by: Cody Garvin <[email protected]>

* LIB-35: Updated class names for Swift (segmentio#902)

Co-authored-by: Cody Garvin <[email protected]>

* Added Swift Package Manager support (segmentio#904)

* Add global state management (segmentio#905)

* First pass at basic state management

* First bit of state being shared.

* Wrapped up state management.

* Commented out old iAd references.

* Filled in missing fields and adding messageId

* Removed comments

* Removed unused code.

* Adjustments to nullability

Co-authored-by: Brandon Sneed <[email protected]>

* Prepare for release 4.0.1.

* Update cartfile.resolved.

* LIBMOBILE-77: Removed Quick and Nimble, updated unit tests (segmentio#909)

* Spm update (segmentio#911)

* LIBMOBILE-77: Removed Quick and Nimble, updated unit tests

* Issue 906: Updated package to supports all types of libraries

* Payload Info & Traits Fixes (segmentio#912)

* Moved some fields from SEGContext to more appropriate SEGPayload.

* Fix trait storage/init issue.

* Fixed traits usage w/ tests.

Co-authored-by: Brandon Sneed <[email protected]>

* Separate public utils from private utils appropriately (segmentio#913)

* Separated public utils from private utils

* Made SEGAnalyticsUtils public.

* Fixed header includes.

Co-authored-by: Brandon Sneed <[email protected]>

* Prepare for release 4.0.2

* Fix SwiftUI previews in macOS Catalyst builds (segmentio#914)

* Fix Swift Package Manager macOS Catalyst builds

Link CoreTelephony to address a link error on macOS Catalyst.

* Add macOS to the conditionals for linking CoreTelephony.

* Full example (segmentio#915)

* Added initial full example app

* Added full example app with Swift Package Manager

Co-authored-by: Cody Garvin <[email protected]>

* LIBMOBILE-109: Updated an issue with new traits not overriding old traits (segmentio#917)

* Prepare for release 4.0.3

* Miscellaneous Fixes (segmentio#920)

* Fixed issue with userId not being cleared properly in a reset.

* Removed SwiftTryCatch dependency

* Removed unnecessary bridging header item in tests.

* Updated to swift 5 syntax.

* Workaround for issue where UIBackgroundTaskIdentifier is diff types between Objc / Swift

* Removed unused code.

* Fixed issue w/ deadlock setting device token

* Fixed tests.

Co-authored-by: Brandon Sneed <[email protected]>

* Fixed SEGLog permissions (segmentio#921)

* Migs647/macconversion (segmentio#918)

* Added Catalyst compatibility

* Added MacOS support

* Updated example apps to use SPM

* Repaired example SPM dependencies

* Fixed makefile for carthage to handle iOS only

* Prepare for release 4.0.4

* Added Carthage and SwiftPM badge

* Disregard payloads that fail conversion from plist to json backing (segmentio#925)

* Deprecated configuration access and updated associated tests

* [LIBMOBILE-149] Fixed double device payload

* Added stubs for edge functions. (segmentio#932)

Co-authored-by: Brandon Sneed <[email protected]>

* Fixed property access

* Fixed issue where non-serializable types would get into payload (segmentio#937)

Co-authored-by: Brandon Sneed <[email protected]>

* Prepare for release 4.0.5

* Rename Reachability to SEGReachability

Co-authored-by: David Whetstone <[email protected]>
Co-authored-by: Daniel Jackins <[email protected]>
Co-authored-by: dsjackins <[email protected]>
Co-authored-by: Fathy Boundjadj <[email protected]>
Co-authored-by: Carlos Kelly <[email protected]>
Co-authored-by: Brandon Sneed <[email protected]>
Co-authored-by: Dan Morrow <[email protected]>
Co-authored-by: Ujjawal Garg <[email protected]>
Co-authored-by: Brandon Sneed <[email protected]>
Co-authored-by: Ben Humphries <[email protected]>
Co-authored-by: Connor Ricks <[email protected]>
Co-authored-by: Cristian Lupu <[email protected]>
Co-authored-by: Sergei Guselnikov <[email protected]>
Co-authored-by: Błażej Biesiada <[email protected]>
Co-authored-by: alanjcharles <[email protected]>
Co-authored-by: Cody Garvin <[email protected]>
Co-authored-by: Cody Garvin <[email protected]>
Co-authored-by: Ko <[email protected]>
Co-authored-by: Matt Gallagher <[email protected]>
Co-authored-by: Mike Ciesielka <[email protected]>
@camwest
Copy link

camwest commented Dec 3, 2020

Hey folks,

FYI we just upgraded to 3.9 and our analytics broke. See attached screenshot.

Screen Shot 2020-12-03 at 4 09 14 PM

I wish this change was made optional!!!

@camwest
Copy link

camwest commented Dec 3, 2020

FYI we also used to get nice messages for all the UIAlertControllers in our app. Now we only get a single generic event.

@bsneed
Copy link
Contributor

bsneed commented Dec 3, 2020

@camwest the change is optional. pin your pod or Carthage version to a specific release. This comment is also void of actual details. The chart doesn't shed light on anything at all other than you're having issues. Happy to work through them, but please file an issue with some details.

@simonbromberg
Copy link

simonbromberg commented Dec 4, 2020

Hi @bsneed, I work with @camwest

  • We have already updated to the latest version of Segment to get the newer features in 4.1.2. Downgrading at this point is not a viable option. This change could have been introduced without it being a major breaking change, e.g. something that you could opt into.
  • This change makes a flawed assumption that everyone uses custom view controllers for every view — this is not the case in our project as we have many instances of custom UIView instances that are loaded into a generic ViewController (which because of this change is also rendered completely blank because it parses out that part of the name)
  • This change breaks tracking on UIAlertController as it i) does not contain "ViewController" and ii) it is a commonly reused view controller that one would want to track but it is almost never subclassed.
  • These breaking changes are easily missed as it doesn't create a compiler error but rather silently breaks analytics after you've released. Not everyone is going to catch the one line in the release notes or realize its implications. Honestly it seems a bit reckless for a product like Segment to merge something in like this without considering the implications for its customers.

I have also commented on #771 that I don't understand how to implement the custom naming protocol. There's no example nor is this mentioned in the documentation anywhere Also submitted a support request via segment.com.

@bsneed
Copy link
Contributor

bsneed commented Dec 4, 2020

Hi @simonbromberg,

Looking at the logic here, if your controller name is UIAlertController I don't see how that would fail to go through.

- (void)seg_viewDidAppear:(BOOL)animated
{
    UIViewController *top = [[self class] seg_rootViewControllerFromView:self.view];
    if (!top) {
        SEGLog(@"Could not infer screen.");
        return;
    }

    NSString *name = [[[top class] description] stringByReplacingOccurrencesOfString:@"ViewController" withString:@""];
    
    if (!name || name.length == 0) {
        // if no class description found, try view controller's title.
        name = [top title];
        // Class name could be just "ViewController".
        if (name.length == 0) {
            SEGLog(@"Could not infer screen name.");
            name = @"Unknown";
        }
    }

    if ([top conformsToProtocol:@protocol(SEGScreenReporting)] && [top respondsToSelector:@selector(seg_trackScreen:name:)]) {
        __auto_type screenReporting = (UIViewController<SEGScreenReporting>*)top;
        [screenReporting seg_trackScreen:top name:name];
        return;
    }

    [[SEGAnalytics sharedAnalytics] screen:name properties:nil options:nil];

    [self seg_viewDidAppear:animated];
}

You'll have a value for name at any point. If it's UIAlertController, that's what the value of name is going to be. The "ViewController" bit is getting stripped off if present, otherwise you're getting the actual class name. If you want to do something more custom, conform to SEGScreenReporting. You can also call screen(...) on your own if needed.

This appears to be extremely straight forward to me, so I'm not sure why you're throwing around words like reckless and what not. I'm trying to assist, there's no need to be disparaging.

As I mentioned to @camwest, please file an issue if I'm missing something.

@simonbromberg
Copy link

simonbromberg commented Dec 4, 2020

I think a certain level of quality is expected given the cost of Segment, I don't think that how this PR was merged in is aligned with that expectation. It seems pretty reckless to me; it wasn't intended as a personal attack on anyone in particular. I certainly appreciate the help, but I wish this hadn't been necessary in the first place. I don't think it's unreasonable to expect a project like this to introduce changes like this gracefully or if it's absolutely necessary to break things then it should introduce compiler errors so it's obvious there's something that needs to change. I also did not appreciate the suggestion that the solution here is to peg my project to an outdated version of the Segment library.

The UIAlertController issue is just a side issue here. And I didn't say it failed to go through, the problem is that the event is no longer being uniquely tracked based on the title of the alert.

The primary issue is we have lots of instances of a class called ViewController which load in a variety of UIView subclasses. Because of this change, all those events are being lumped together with no title.

I am trying to conform to SEGScreenReporting but it is not obvious how it works and there is no mention of it in the documentation nor are there examples explaining how to implement it in the documentation nor in that PR. Also, the damage is already done as we have a live version of an app where many of the analytics events are now useless. This is not something that could have easily been anticipated.

@bsneed
Copy link
Contributor

bsneed commented Dec 4, 2020

@simonbromberg we'll have to agree to disagree.

Here's the code you want:

@interface MyAlertController: UIAlertController<SEGScreenReporting>
@end
@implementation MyAlertController
- (void)seg_trackScreen:(UIViewController*)screen name:(NSString*)name
{
    // construct a new name however you want.
    // use MyAlertController in place of UIAlertController.

    [[SEGAnalytics sharedAnalytics] screen:[NSString stringWithFormat:"MyAlertController-%@", name] properties:nil options:nil];
}
@end

@bsneed
Copy link
Contributor

bsneed commented Dec 4, 2020

my bad, fixed. I'm sure you could see where it was going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants