Skip to content

Conversation

wenxi-zeng
Copy link
Contributor

@wenxi-zeng wenxi-zeng commented Sep 20, 2021

  • add intercom destination
  • bump up sample destination project minSdkVersion to 21
  • manually tested device-mode delivery

@wenxi-zeng wenxi-zeng requested a review from prayansh September 20, 2021 20:20
@wenxi-zeng
Copy link
Contributor Author

don't review yet. unit tests coming up

lateinit var intercom: Intercom
private set

// Intercom common specced attributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do u think moving this out into a companion object and using const val is better practice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. I think you're right. I was misled by the first and second answers here. put it into companion indeed creates an unnecessary getter. but I forgot that if they are not const then each object will have a copy of them. definitely suboptimal. I'll make the change

analytics.log("Intercom.client().updateUser(userAttributes)")
}

private fun setCompany(traits: JsonObject): Company {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is traits the correct name here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems more like its related to the company

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. company is better.

import io.intercom.android.sdk.identity.Registration
import kotlinx.serialization.json.*

/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

else {
val registration = Registration.create().withUserId(userId)
intercom.registerIdentifiedUser(registration)
analytics.log("Intercom.client().registerIdentifiedUser(registration)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be
"Intercom.client().registerIdentifiedUser($registration)"
with the idea being that we are logging the value of registration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. this is something I wasn't sure of. the original java version logs it this way. I was wondering if registration has sensitive data, so the java version is doing it on purpose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh interesting. lets keep it as is then for now


properties.forEach { (key, value) ->
if (key !in setOf("products", REVENUE, TOTAL, CURRENCY)
&& value is JsonPrimitive) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we checking the type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a translation from the original java code, where it excludes all the map and list values. check these lines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i see. lets add a comment here stating that we are only interested in primitive values and not maps or collections


// mock intercom
mockkStatic(Intercom::class)
intercom = spyk<Intercom>(StubIntercom())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why we are using a spy of a StubIntercom vs a direct mock?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had tests failed because of direct mock, so I changed it to spy. I just tested mock with relaxUnitFun = true that works well. will remove the stub

}
}

val event = buildJsonObject {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe eventProperties is a more apt name here

@wenxi-zeng wenxi-zeng merged commit 43e28a9 into main Sep 22, 2021
@wenxi-zeng wenxi-zeng deleted the wenxi/intercom_destination branch September 22, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants