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

cannot set user_id to null #88

Open
choran opened this issue Nov 24, 2017 · 2 comments
Open

cannot set user_id to null #88

choran opened this issue Nov 24, 2017 · 2 comments

Comments

@choran
Copy link
Member

choran commented Nov 24, 2017

Description

  • It is not possible to clear a user_id value using the .NET SDK
    • Setting it to null does not send the data to the API
  • curl request as expected and allows it

We support setting user_id to nil (tested it)
I can understand the logic in wanting to remove user_ids from your users which we support.


Evidence

UsersClient usersClient = new UsersClient(new Authentication(TOKEN));
User user = usersClient.View("598bd1ef1f40af9c8d64ceb0");
Console.WriteLine(JsonConvert.SerializeObject(user));
user.user_id = null;
user = usersClient.Update(user);
Console.WriteLine(JsonConvert.SerializeObject(user));
user = usersClient.View("598bd1ef1f40af9c8d64ceb0");
Console.WriteLine(JsonConvert.SerializeObject(user));

If you run the above code you will see that it does not change the suer_id

@kmossco kmossco added the bug label Nov 24, 2017
@kmossco
Copy link
Contributor

kmossco commented Dec 5, 2017

Working on this one and it seems that somewhere where we serialize the JSON object to be sent to the Intercom servers, we are disregarding any changes to null.

If I try to run the code in the OP there I get the following payload:

"params":{"id":"5a045c938b874d2a82e7413a","email":"bobz12@example.com","avatar":{"type":"avatar"},"signed_up_at":1511349783,"last_seen_ip":"188.80.56.31","custom_attributes":{"average_monthly_spend":1500.0},"last_seen_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36","last_request_at":1511349783,"unsubscribed_from_emails":false}

Running the same setting the email to null sends the following payload:

"params":{"id":"5a045c938b874d2a82e7413a","user_id":"notyomama","avatar":{"type":"avatar"},"signed_up_at":1511349783,"last_seen_ip":"188.80.56.31","custom_attributes":{"average_monthly_spend":1500.0},"last_seen_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36","last_request_at":1511349783,"unsubscribed_from_emails":false}

That's odd, because using curl for the same user but just changing the created_at, sends a lot less params:

"params":{"id":"5a045c938b874d2a82e7413a","created_at":1234567891,"user":{"id":"5a045c938b874d2a82e7413a","created_at":1234567891}}

Figuring out where these params are being created, and validating my suspicion that the way we are creating the JSON payload is ignoring null values. I'll investigate.

@kmossco kmossco self-assigned this Dec 5, 2017
@kmossco
Copy link
Contributor

kmossco commented Dec 19, 2017

Investigated this alongside @thewheat and this isn't a trivial fix as we will have to refactor how we create the JSON payload sent to the endpoints. Postponing a fix until we get other more impactful changes out.

@kmossco kmossco removed their assignment Dec 19, 2017
@kmossco kmossco added the triaged label Apr 1, 2018
@keloe keloe added duplicate and removed duplicate labels Jul 5, 2018
@kmossco kmossco removed the triaged label Aug 9, 2018
@choran choran added the dotnet label Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants