klaviyo / klaviyo-swift-sdk

SDK that allows users to incorporate Klaviyo's event and person tracking functionality within iOS applications. Written in Swift.
MIT License
10 stars 10 forks source link

set(Profile) not identifiying the user in 2.2.0 #106

Closed arctouch-andersonbragiatto closed 9 months ago

arctouch-andersonbragiatto commented 10 months ago

Description

Hi, I was using KlaviyoSDK in the latest version (2.2.0) and I was not able to identify the user using the set method provided by SDK. Every time that I call this method it starts creating a new not identified user. My solution was rolling back the version to 2.0.1 which is working great. After I call the set(Profile) method, and start sending events my user is being identified in the Klaviyo Portal with the information provided.

I did not have time to extensive reproduce this issue since rolling back the version fix the issue for me.

Checklist

Expected behavior

set(Profile) should identify the user that sends new events with information provided (firstName, lastName, email)

Actual behavior

calling set(Profile) then sending an event, will create a new unidentified user with the new event

Steps to reproduce

  1. init the SDK with a valid key
  2. call set(Profile) with firstName lastName and email
  3. send any event

if you repeat the steps without a new app installation it will create a new user to hold for the second event

The Klaviyo Swift SDK version information

2.2.0

Destination operating system

Simulator: iPhone 14 Pro - iOS 16.2

Xcode version information

14.2 (14C18)

Swift Compiler version information

swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx12.0
ajaysubra commented 10 months ago

@arctouch-andersonbragiatto Thanks for reporting this to us. We are currently looking into this and will get back soon.

ajaysubra commented 10 months ago

Hey @arctouch-andersonbragiatto, we did spend some time looking into this and have a question - How are you using set(profile:)? I.E at what point in the application lifecycle do you call this method?

Just for some context -

The intended use of this method is to call it whenever there is a new user in the app and not more than once per user. If there are new properties associated with a user/profile then you can use some of the specific methods (such as set(email:) or set(phoneNumber:)) to set them or use the more general method such as set(profileAttribute:, value: )

As we can only identify one user on our SDK whenever the set(profile:) method is called we reset the local state and set a new user as we assume that the prior user was logged out and we have a new user. When this happens all the events sent from the SDK/App will have an anonymous Id and will not be identified with the profile created earlier. This is documented in the API comments for the set(profile:) method but we understand that this can be more clearly articulated in the README and it's something we plan to do. Finally, as indicated earlier, using the setter methods for email and phone number would be the way to go when there are new properties that you intent to set to the profile after it has been created using set(profile:).

arctouch-andersonbragiatto commented 10 months ago

Hey @ajaysubra, In my case it's called when the app opens, using the same profile data (firstName, lastName, and email).

ajaysubra commented 10 months ago

Hi @arctouch-andersonbragiatto Thanks for your patience with this issue. I spent some more time looking into this and turns out our release version 2.2.0 actually had a bug in it that was causing events to not take in the profile attributes such as email, first name etc. when sending them to our backend. What I saw in my testing was a lot of anonymous profiles being created as a result of this.

Fortunately, we had a similar issue and fixed that and the one you've reported and released as part of our latest release a couple weeks ago. Please update your app to release 2.2.1 and let us know how it goes!

arctouch-andersonbragiatto commented 10 months ago

Hey @ajaysubra Thank you, I will try with 2.2.1

ajaysubra commented 10 months ago

Hey @ajaysubra Thank you, I will try with 2.2.1

Hey @arctouch-andersonbragiatto: any luck with 2.2.1?

github-actions[bot] commented 9 months ago

This issue is stale due to inactivity. Please let us know if you are still encountering issues, otherwise this issue will automatically close in 10 days.

github-actions[bot] commented 9 months ago

This issue has seen no updates in the past 14 days and will now be closed. Please open a new issue if you wish to report an update.