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

Add localTimestamp and localTimezone #3896

Merged
merged 6 commits into from
May 20, 2021

Conversation

compulim
Copy link
Contributor

@compulim compulim commented May 20, 2021

Fixes #3788.

Changelog Entry

Added

  • Resolved #3788. Added localTimestamp and localTimezone (if available) to all outgoing activities, by @compulim, in PR #3896

Description

For all outgoing activities, add localTimestamp and localTimezone (if supported by the browser settings).

Design

Although we send localTimestamp, Azure Bot Services will rename it to rawLocalTimestamp. The localTimestamp field is same as timestamp field, which is in UTC.

Original activity from Web Chat (captured from network trace)
  {
    "channelData": {
      "clientActivityID": "1621475335684ql44o56fi4",
      "clientTimestamp": "2021-05-20T01:48:55.684Z"
    },
    "text": "dump-activity",
    "textFormat": "plain",
    "type": "message",
    "channelId": "webchat",
    "from": {
      "id": "dl_3fc4640be134b83b9b3f71c853ffba4a",
      "name": "",
      "role": "user"
    },
    "locale": "en-US",
+   "localTimestamp": "2021-05-20T10:48:55.684+09:00",
+   "localTimezone": "Asia/Tokyo",
    "timestamp": "2021-05-20T01:48:55.684Z",
    "entities": [
      {
        "requiresBotState": true,
        "supportsListening": true,
        "supportsTts": true,
        "type": "ClientCapabilities"
      }
    ]
  }
Activity perceived on bot side
  {
    "type": "message",
    "id": "IXiRn3wwW8lI2WShb0KaXA-o|0000000",
    "timestamp": "2021-05-20T01:48:55.506Z",
+   "localTimestamp": "2021-05-20T01:48:55.684Z",
+   "localTimezone": "Asia/Tokyo",
    "serviceUrl": "https://directline.botframework.com/",
    "channelId": "directline",
    "from": {
      "id": "dl_3fc4640be134b83b9b3f71c853ffba4a",
      "name": ""
    },
    "conversation": {
      "id": "IXiRn3wwW8lI2WShb0KaXA-o"
    },
    "recipient": {
      "id": "webchat-mockbot@WYDIyKwAZCw",
      "name": "webchat-mockbot"
    },
    "textFormat": "plain",
    "locale": "en-US",
    "text": "dump-activity",
    "entities": [
      {
        "type": "ClientCapabilities",
        "requiresBotState": true,
        "supportsListening": true,
        "supportsTts": true
      }
    ],
    "channelData": {
      "clientActivityID": "1621475335684ql44o56fi4",
      "clientTimestamp": "2021-05-20T01:48:55.684Z"
    },
    "rawTimestamp": "2021-05-20T01:48:55.5067653Z",
+   "rawLocalTimestamp": "2021-05-20T10:48:55.684+09:00",
    "callerId": "urn:botframework:azure"
  }

Some environments don't support window.Intl

Some browsers in some settings, such as IE11 InPrivate mode, will return undefined for window.Intl.

Specific Changes

  • Updated postActivitySaga to fill localTimestamp and optionally, localTimezone
  • Added dateToLocaleISOString to create a local timestamp in ISO format
  • In test harness, set browser to use UTC by default (to reuse the box after last test)
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@compulim compulim marked this pull request as ready for review May 20, 2021 03:56
@corinagum corinagum merged commit 880f817 into microsoft:main May 20, 2021
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.

Webchat not populating localTimestamp and localTimezone properties
2 participants