User session duration calculation

Hi,
Could you please try changing terms to date_histogram in the pivot.group_by section?
It does not seem right to me to use terms together with timestamp if you need to group "by day".
I think it should look similar to:

    "timestamp": {
      "date_histogram": {
        "field": "@timestamp",
        "calendar_interval": "1d"
      }
    }