Closed f2prateek closed 8 years ago
In our use case, we have clients (android, ios, and web) as well as the an API sending data to amplitude via segment.
When requests hit our API we know where they came from (which device, app version, etc) and I would like to pass that platform value through to amplitude.
If you were to just use context.os
, things could get weird trying to distinguise an ios app via mobile web requests coming from ios devices.
@f2prateek would it be possible to use something like context.device.type
? We have a couple of customers who are seeing values like 'analytics-ruby' for platform, but are expecting Android, iOS, Web.
yup context.device.type will work - although it's not populated by a.js afaik. https://segment.com/docs/spec/common/
@f2prateek we could fall back on something like 'Web'
if the value doesn't exist for device type, something like this:
platform: facade.proxy('context.device.type') || 'Web',
What do you think? If that looks good I'll submit a PR for it
I wouldn't assume that it's from the web if it's not provided. None of our server side libraries send it by default and all those would get attribtued to web.
@f2prateek is there a way for the server-side libraries to know what the platform is? To give some context, say we have a customer that uses the Javascript integration. They have a user that visits their site on an Android mobile browser. For events logged, the platform
should be Web
. device type
, device family
, those would describe the Android device. OS
would show like the browser.
You'd want to use a combination of context.userAgent
, context.device.type
, context.os.name
.
The flow would be something like :
context.device.type
if provided.context.os.name
if provided.context.library.name
(i.e. analytics.js -> web, analytics-android -> android, etc.)You'll have to map context.os.name
to the appropriate platform as well.
@f2prateek thanks for pushing this live. We're still seeing events with platform analytics-node and such. Does that mean those events just don't have the device info? Or is there another library I need to update? Thanks!
Yup that would mean those events don't have the device info.
Uses the library name currently https://github.com/segmentio/integration-amplitude/blob/master/lib/mapper.js#L91.
Should use
context.os
or something equivalent.