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

Question: analyticsContext.putDeviceToken in new SDK? #213

Closed
amusejfo opened this issue Mar 20, 2024 · 3 comments
Closed

Question: analyticsContext.putDeviceToken in new SDK? #213

amusejfo opened this issue Mar 20, 2024 · 3 comments

Comments

@amusejfo
Copy link

amusejfo commented Mar 20, 2024

Hi, I am in the process of migrating from the old segment android sdk to this new one, we are running analytics.analyticsContext.putDeviceToken in the old one for some reason (We do not know what it is supposted to be used for)
is there an alternative in the new SDK or is it not needed anymore?

@wenxi-zeng
Copy link
Contributor

hey @amusejfo, device token is not required. but if you want to keep using it for consistency purpose, you can write your own plugin to inject the token value. please follow this comment as an example. you will need to do something like below to add device token:

            event.context = updateJsonObject(event.context) { context ->
                context["device"] = updateJsonObject(device) { device ->
                    device["token"] = "YOUR TOKEN"
                }
            }

@amusejfo
Copy link
Author

amusejfo commented Mar 21, 2024

@wenxi-zeng event.putInContextUnderKey("device", "token", firebaseToken)
would be the same right?

@wenxi-zeng
Copy link
Contributor

wenxi-zeng commented Mar 21, 2024

@amusejfo yep, you're right. we actually have an equivalent method of analytics.analyticsContext.putDeviceToken. see here. it's not added to Analytics by default. you'd have to manually add it.

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

No branches or pull requests

2 participants