Skip to content

Crash: [__NSDictionaryM setObject:forKey:]: object cannot be nil (key: $anon_distinct_id)' #35

Closed

Description

@karolkulesza

Steps to reproduce:

  1. Create a new empty app Xcode project and add posthog-ios lib v.2.0.0
  2. Add the following code in in ViewController and invoke testPostHogReset() method in ViewController's viewDidLoad method (updating the value of apiKey in setupPostHog method)
  3. Build & run and wait for the crash
var client: PHGPostHog?

func testPostHogReset() {
    setupPostHog()
    identifyAndGroup()
    DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
      self.client?.reset()
      DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
        self.identifyAndGroup()
      }
    }
  }
  
  func setupPostHog() {
    let apiKey = "..."
    let hostString = "https://eu.posthog.com"
    let configuration = PHGPostHogConfiguration(apiKey: apiKey, host: hostString)
    configuration.captureApplicationLifecycleEvents = true
    
    PHGPostHog.setup(with: configuration)
    client = PHGPostHog.shared()
  }
  
  func identifyAndGroup() {
    client?.identify("test_user")
    client?.group("project", groupKey: "Test Project")
  }

Activity

  1. EDsCODE commented on Feb 1, 2023

    @EDsCODE
    Contributor

    Hello! Thanks for the heads up. Looking into this

  2. karolkulesza commented on Feb 10, 2023

    @karolkulesza
    Author

    Thanks @EDsCODE , I can see that the fix for this issue was already merged to master. Do you know when it'll be available via SPM ?

  3. marandaneto commented on Oct 9, 2023

    @marandaneto
    Member

    Already fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions