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

Platform is always overriden to Node.js #79

Open
tommedema opened this issue Feb 10, 2021 · 5 comments
Open

Platform is always overriden to Node.js #79

tommedema opened this issue Feb 10, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@tommedema
Copy link

tommedema commented Feb 10, 2021

Expected Behavior

When setting platform it is never received as sent

Current Behavior

Platform is always overridden to "Node.js"

Possible Solution

Steps to Reproduce

  1. Send this event to amplitude with the sdk:
{
  user_id: '60245c08b45ec4007022ec13',
  device_id: 'c3dae446-7d15-44fb-9751-16e4b38df58b',
  event_type: 'ACTION_INSERT_TOPIC_THREAD_COMMENT',
  insert_id: 'bbe59f0d-2bc2-47a7-8543-684072e7785d',
  time: 1612996899714,
  session_id: '1612996076612',
  app_version: '@bubbles/[email protected]',
  language: 'en-US',
  ip: '71.198.20.116',
  platform: '[email protected]',
  os_name: 'Mac OS',
  os_version: '10.15.7',
  device_brand: undefined,
  device_model: undefined,
  event_properties: {
    viewId: 'e155c739-3f77-46f7-8123-2dd5dea599fc',
    originTopicId: 'e155c739-3f77-46f7-8123-2dd5dea599fc',
    originUserEmail: undefined,
    originUserName: 'Amplitude2',
    isUserAction: false,
    actionType: 'INSERT_TOPIC_THREAD_COMMENT',
    actionId: 'bbe59f0d-2bc2-47a7-8543-684072e7785d',
    isServerGenerated: undefined,
    userAgent: {
      ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36',
      browser: { name: 'Chrome', version: '88.0.4324.146', major: '88' },
      engine: { name: 'Blink', version: '88.0.4324.146' },
      os: { name: 'Mac OS', version: '10.15.7' },
      device: { vendor: undefined, model: undefined, type: undefined },
      cpu: { architecture: undefined }
    },
    payload: {
      threadId: '01cdebcd-39b5-4714-9321-c5644da49f32',
      archived: false,
      topicId: 'e155c739-3f77-46f7-8123-2dd5dea599fc',
      participantEmails: [ [length]: 0 ],
      name: 'Amplitude2',
      id: '2c916ba6-ec74-4632-9a54-c5ca652102ec',
      body: 'test2',
      userId: '60245c08b45ec4007022ec13',
      timestamp: 1612996899918
    }
  },
  user_properties: {
    originUserEmail: undefined,
    originUserName: 'Amplitude2',
    userAgent: {
      ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36',
      browser: { name: 'Chrome', version: '88.0.4324.146', major: '88' },
      engine: { name: 'Blink', version: '88.0.4324.146' },
      os: { name: 'Mac OS', version: '10.15.7' },
      device: { vendor: undefined, model: undefined, type: undefined },
      cpu: { architecture: undefined }
    }
  }
}
  1. Note that the event received from the amplitude event stream "raw" log now has reset platform to Node.js:
{
  "$insert_id": "9eb32219-3af0-47dd-91f6-359438c901dc",
  "$row_source": "realtime",
  "$schema": 12,
  "_time": 1612996625311,
  "adid": null,
  "amplitude_attribution_ids": null,
  "amplitude_event_type": null,
  "amplitude_id": 233091255869,
  "app": 310020,
  "city": "San Francisco",
  "client_event_time": "2021-02-10T22:37:05.311",
  "client_upload_time": "2021-02-10T22:37:15.619",
  "country": "United States",
  "data": {
  },
  "device_brand": null,
  "device_carrier": null,
  "device_family": null,
  "device_id": "c3dae446-7d15-44fb-9751-16e4b38df58b",
  "device_manufacturer": null,
  "device_model": null,
  "device_type": null,
  "display_name": "ACTION_INSERT_TOPIC_THREAD_COMMENT",
  "dma": "San Francisco-Oakland-San Jose, CA",
  "event_id": 854747387,
  "event_properties": {
    "actionId": "9eb32219-3af0-47dd-91f6-359438c901dc",
    "actionType": "INSERT_TOPIC_THREAD_COMMENT",
    "isUserAction": false,
    "originTopicId": "e155c739-3f77-46f7-8123-2dd5dea599fc",
    "originUserName": "Amplitude2",
    "payload.archived": false,
    "payload.body": "test",
    "payload.id": "0743bb3b-cf46-47c3-aaf6-bd2a3f820683",
    "payload.name": "Amplitude2",
    "payload.participantEmails": [
    ],
    "payload.threadId": "01cdebcd-39b5-4714-9321-c5644da49f32",
    "payload.timestamp": 1612996624513,
    "payload.topicId": "e155c739-3f77-46f7-8123-2dd5dea599fc",
    "payload.userId": "60245c08b45ec4007022ec13",
    "userAgent.browser.major": "88",
    "userAgent.browser.name": "Chrome",
    "userAgent.browser.version": "88.0.4324.146",
    "userAgent.engine.name": "Blink",
    "userAgent.engine.version": "88.0.4324.146",
    "userAgent.os.name": "Mac OS",
    "userAgent.os.version": "10.15.7",
    "userAgent.ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36",
    "viewId": "e155c739-3f77-46f7-8123-2dd5dea599fc"
  },
  "event_time": "2021-02-10T22:37:05.311",
  "event_type": "ACTION_INSERT_TOPIC_THREAD_COMMENT",
  "group_properties": {
  },
  "groups": {
  },
  "idfa": null,
  "ip_address": "71.198.20.116",
  "is_attribution_event": false,
  "language": "English",
  "library": "amplitude-node/1.3.2",
  "location_lat": null,
  "location_lng": null,
  "os": "Mac OS 10.15.7",
  "os_name": "Mac OS",
  "os_version": "10.15.7",
  "paying": null,
  "platform": "Node.js",
  "region": "California",
  "sample_rate": null,
  "server_received_time": "2021-02-10 22:37:15.619000",
  "server_upload_time": "2021-02-10T22:37:15.641",
  "session_id": 1612996076612,
  "start_version": "@bubbles/[email protected]",
  "timeline_hidden": false,
  "user_creation_time": "2021-02-10T22:19:55.227",
  "user_id": "60245c08b45ec4007022ec13",
  "user_properties": {
    "originUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36",
    "originUserName": "Amplitude2",
    "userAgent.browser.major": "88",
    "userAgent.browser.name": "Chrome",
    "userAgent.browser.version": "88.0.4324.146",
    "userAgent.engine.name": "Blink",
    "userAgent.engine.version": "88.0.4324.146",
    "userAgent.os.name": "Mac OS",
    "userAgent.os.version": "10.15.7",
    "userAgent.ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36"
  },
  "uuid": "8771ca20-6bf0-11eb-9ed4-0231551a9deb",
  "version_name": "@bubbles/[email protected]"
}

Environment

  • SDK Version: 1.3.2
  • Node version: 12.14.1
@tommedema tommedema added the bug Something isn't working label Feb 10, 2021
@tommedema
Copy link
Author

For some reason your built files are incorrect. When I go to node_modules/@amplitude/dist/src/nodeClient.js I see:

Screen Shot 2021-02-10 at 3 07 09 PM

Yet this code has been patched:

event.platform = event.platform ?? 'Node.js';

Yet the version I have installed is the latest version:

Screen Shot 2021-02-10 at 3 07 18 PM

@kelvin-lu
Copy link
Contributor

Hey @tommedema !

We haven't published those changes - apologies. I'll go ahead and publish the newest version and close this once Node 1.3.3 is available!

@tommedema
Copy link
Author

tommedema commented Feb 10, 2021

Ok, thanks @kelvin-lu -- and now that I have you, where am I supposed to set the user's browser and browser version?

If os_name and os_version (which would be really odd naming though seems to be what your documentation at https://developers.amplitude.com/docs/http-api-v2 suggests), where am I supposed to define the operating system name and version?

This is what I'm currently doing but it seems ugly and doesn't distinguish between browser name and version:

    platform: `${userAgent.browser.name}@${userAgent.browser.major}`,
    os_name: userAgent.os.name,
    os_version: userAgent.os.version,
    device_brand: userAgent.device.vendor,
    device_model: userAgent.device.model,

And this is the data that I have available:

"userAgent.browser.major": "88",
    "userAgent.browser.name": "Chrome",
    "userAgent.browser.version": "88.0.4324.146",
    "userAgent.engine.name": "Blink",
    "userAgent.engine.version": "88.0.4324.146",
    "userAgent.os.name": "Mac OS",
    "userAgent.os.version": "10.15.7",
    "userAgent.ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36"

But it is unclear how to map these props to what Amplitude expects in the case of the browser name and version.

@kelvin-lu
Copy link
Contributor

@tommedema Let me confer with our dataPL team if we have any best practices but it looks close to what you have here - linking to what our Web SDK does here; we put the browser in the OS space and the OS info in the device.

what is userAgent.device.vendor look like? I don't think I see it in your available data

@tommedema
Copy link
Author

tommedema commented Feb 10, 2021

Hmm, what you referred to me is actually different from what we're doing. It seems a bit awkward to say that the device model is MacOS, Windows, etc.? MacOS is an operating system, not a device. A device might be an iPhone, Samsung Galaxy S8, etc.

Even though it might not make sense to set the OS as the device, should we do this anyway since this seems to be what the web sdk does? FYI - seems like the web guys realize this is not correct

userAgent.device.vendor will be undefined unless you are on a mobile device, in which case it will be e.g. "Samsung", "Nokia", etc.

We use ua-parser-js to retrieve these properties from the user agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants