Question: Please Write Code In JavaScript. If Not Any Other Programming Languages Which U Prefer. Thanks. Problem Description: You're In Charge Of Implementing A New Analytics
Please Write Code In JavaScript. If Not Any Other Programming Languages Which U Prefer. Thanks. Problem Description: You're In Charge Of Implementing A New Analytics \"Sessions\" View. You're Given A Set Of Data That Consists Of Individual Web Page Visits, Along With A VisitorId Which Is Generated By A Tracking Cookie That Uniquely Identifies Each Visitor.
Please write code in JavaScript. If not any other programming languages which u prefer. Thanks.
Problem description:
You're in charge of implementing a new analytics \"sessions\" view. You're given a set of data that consists of individual web page visits, along with a visitorId which is generated by a tracking cookie that uniquely identifies each visitor. From this data we need to generate a list of sessions for each visitor.
You can get the raw event data from the dataset API at REDACTED The data set looks like this:
\"events\": [
{
\"url\": \"/pages/a-big-river\",
\"visitorId\": \"d1177368-2310-11e8-9e2a-9b860a0d9039\",
\"timestamp\": 1512754583000
},
{
\"url\": \"/pages/a-small-dog\",
\"visitorId\": \"d1177368-2310-11e8-9e2a-9b860a0d9039\",
\"timestamp\": 1512754631000
},
{
\"url\": \"/pages/a-big-talk\",
\"visitorId\": \"f877b96c-9969-4abc-bbe2-54b17d030f8b\",
\"timestamp\": 1512709065294
},
{
\"url\": \"/pages/a-sad-story\",
\"visitorId\": \"f877b96c-9969-4abc-bbe2-54b17d030f8b\",
\"timestamp\": 1512711000000
},
{
\"url\": \"/pages/a-big-river\",
\"visitorId\": \"d1177368-2310-11e8-9e2a-9b860a0d9039\",
\"timestamp\": 1512754436000
},
{
\"url\": \"/pages/a-sad-story\",
\"visitorId\": \"f877b96c-9969-4abc-bbe2-54b17d030f8b\",
\"timestamp\": 1512709024000
}
]
}
Given this input data, we want to create a set of sessions of the incoming data. A sessions is defined as a group of events from a single visitor with no more than 10 minutes between each event. A visitor can have multiple sessions.
So given the example input data above, we would expect output which looks like:
\"sessionsByUser\": {
\"f877b96c-9969-4abc-bbe2-54b17d030f8b\": [
{
\"duration\": 41294,
\"pages\": [
\"/pages/a-sad-story\",
\"/pages/a-big-talk\"
],
\"startTime\": 1512709024000
},
{
\"duration\": 0,
\"pages\": [
\"/pages/a-sad-story\"
],
\"startTime\": 1512711000000
}
],
\"d1177368-2310-11e8-9e2a-9b860a0d9039\": [
{
\"duration\": 195000,
\"pages\": [
\"/pages/a-big-river\",
\"/pages/a-big-river\",
\"/pages/a-small-dog\"
],
\"startTime\": 1512754436000
}
]
}
}
Once the event data has been transformed into session, you will need to send the result via an httpPOST to REDACTED
Notes Timestamps are in milliseconds. Events may not be given in chronological order. The visitors in sessionsByUser can be in any order. For each visitor, sessions to be in chronological order. For each session, the URLs should be sorted in chronological order For a session with only one event the duration should be zero Evaluation When youre done, this page will update with a form to upload your code. Well evaluate you based on three things:
First and foremost, if you complete the project within three hours. Next, the time from when you click the start button below to the time you submit a correct solution. Finally, the quality of code you submit. Were looking for simplicity, clarity and readability over cleverness or flexbility. We think you should be able to complete this project in a single sitting, so try to allocate a single block if you can.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
