Describe the bug
Custom endpoin profile data is reset on calling analyticsClient.submitEvents() event after targetingClient.update endpoint profile which was set custom endpoint data.
To Reproduce
Code flow until being reset the custom endpoint data.
pinpoint.analyticsClient.submitEvents()[self.eventRecorder submitAllEvents][targetingClient currentEndpointProfile][localEndpointProfile updateEndpointProfileWithContext:self.context]_demographic = [AWSPinpointEndpointProfileDemographic defaultAWSPinpointEndpointProfileDemographic] // This code resets to default.Which AWS service(s) are affected?
AWSPinpoint on iOS SDK
Expected behavior
Custom endpoint data data can keep being set on submitting events.
Screenshots
N/A
Environment(please complete the following information):
Device Information (please complete the following information):
Additional context
N/A
Hi,
Thanks for reaching out to us...
Seems like a duplicate of this issue:
https://github.com/aws-amplify/aws-sdk-ios/issues/2360
Can you please confirm?
@wooj2
Thanks for your reaction!
Yes, this issue is pretty close to #2360:
While #2630 shows custom demographic data is not updated, this issue #2680 shows already set endpoint profile is cleared on sending events with analyticsClient.
That's a bit different, though the root cause can be the same.
@rinosamakanata
Ahhh... Thank you for taking the time to explain!
It looks like you want to be able to customize the data that is being sent as part of the AWSPinpointEndpointProfileDemographic field. Is this correct? For example, maybe you want to change .locale from something like ja_JP to en_JP? I am just curious, but what is your use case for wanting to make any of these fields custom? What fields are you attempting to make custom?
In any case, I don't believe that these fields were intended to be updated with custom values. For custom values, we recommend you using the addAttribute (also recommended in #2360):
https://github.com/aws-amplify/aws-sdk-ios/blob/master/AWSPinpoint/AWSPinpointEndpointProfile.m#L171
@wooj2
I want to custom a device model in democraphic fields and want to set user ID in user fields. They are not custom attributes but standard attributes that are already defined in Pinpoint's endpoint profile fields.
Hi @rinosamakanata, we reached out to the Pinpoint team to consult about the current SDK behavior and what should be done in this case. The idea is that the SDK should enforce consistency and best practices, hence the current behavior of enforcing the correct device model resolved from the UIDevice.
That said, consistency of behavior across platforms is important so we will work on a fix to bring iOS in parity with the Android implementation.
@drochetti Thank you for scheduling the fix! Like Android SDK, I hope iOS device model will be stored into Pinpoint's demographic data implicitly.
Hi @rinosamakanata ,
I have pushed a draft PR with an attempt to come up with a solution so that you'd be able to add a custom device model, located here:
https://github.com/aws-amplify/aws-sdk-ios/pull/2410
Could you please take a look at the pull request and let us know if you think this will work for your use case?
Hi @wooj2 ,
Great! I confirmed that your draft PR worked for my use case to keep custom demographic data. Thank you!
Hi @rinosamakanata ,
Thank you so much for your patience. We have released a new version of the AWS SDK for iOS 2.13.2 with the ability to update custom demographics. The call pattern is slightly different than what I had in my initial version, but I believe this should be sufficient for your use case.
You should be able to do something like this:
//Use the defaults, and override where nessecary:
let customDemographic: AWSPinpointEndpointProfileDemographic! = AWSPinpointEndpointProfileDemographic.default()
customDemographic.appVersion = "1.0.1.2.3.4.5.6"
customDemographic.platform = "MyCustomPlatform"
customDemographic.model = "MyCustomDeviceModel"
//Then initialize pinpoint as normal... something like this:
let pinpointConfiguration = AWSPinpointConfiguration.defaultPinpointConfiguration(launchOptions: launchOptions)
let pinpoint = AWSPinpoint(configuration: pinpointConfiguration)
//Overrides default demographic:
pinpoint.targetingClient.currentEndpointProfile().customDemographic = customDemographic
I am optimistically closing this issue, but feel free to re-open if you have any questions/problems regarding this matter. Thanks again!
Thank you @wooj2 ,
I'll try it immediately!