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 doesn't work #121

Closed
fvolchyok opened this issue Feb 20, 2024 · 3 comments
Closed

Automatic screen tracking doesn't work #121

fvolchyok opened this issue Feb 20, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@fvolchyok
Copy link

Expected Behavior

Using defaultTracking.screenViews = true or DefaultTrackingOptions.ALL on Amplitude initialisation should enable automatic screen tracking

Current Behavior

Screen events don't track automatically.

Debugging shows that UIViewController.viewDidAppear swizzled successfully, but tracking fails on bundle check:

let bundle = Bundle(for: self.classForCoder)
if !bundle.bundlePath.hasPrefix(Bundle.main.bundlePath) {
return
}

where

(lldb) po bundle.bundlePath
"/System/Library/PrivateFrameworks/UIKitCore.framework"

(lldb) po Bundle.main.bundlePath
"/private/var/containers/Bundle/Application/4AC5FC00-2EE0-446D-AB8F-190B8B030758/myapp.app"

For context which might be related: my UIViewControllers are in a separate framework, not in the main bundle, but either way it must not interfere with tracking.

If I understand correctly, and as lldb printing above suggests - tracking can't happen because in my caseBundle.main.bundlePath obviously can't be a prefix for bundle.bundlePath.

Possible Solution

Revise bundle checks. I wonder what could have been the reason to put this check in the first place?

Steps to Reproduce

  1. Create a ViewController, potentially in a framework (referenced by main app target).
  2. Check if screen events are being tracked.

Environment

  • SDK Version: Amplitude-Swift 1.1.0
  • iOS version: 15.7.3
  • Xcode: 15.1
  • OS Info: MacOS 14.3.1 (23D60)
@fvolchyok fvolchyok added the bug Something isn't working label Feb 20, 2024
@fvolchyok
Copy link
Author

My bad, I misdiagnosed the issue, further investigation required on my part

@fvolchyok
Copy link
Author

fvolchyok commented Feb 20, 2024

UPD:
I retested on my specific view controller, not Apple-provided, and there are updated bundle paths:

(lldb) po Bundle.main.bundlePath
"/private/var/containers/Bundle/Application/1610E596-5999-4C6B-AE2E-12868E894729/myapp.app"
(lldb) po bundle.bundlePath
"/var/containers/Bundle/Application/1610E596-5999-4C6B-AE2E-12868E894729/myapp.app/Frameworks/myappCore.framework"

So the issue still seems to be bad check on bundle caused by "/private" prefix in main bundle path

@crleona
Copy link
Collaborator

crleona commented Mar 15, 2024

Hi @fvolchyok - this should be fixed in the latest release.

@crleona crleona closed this as completed Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants