We are moving to Discord!

Join us on the Countly Community Discord Server! Engage in discussions, share your feature ideas, and learn from fellow Countly users to build exceptional apps and experiences.

Is it possible to set "Maximal Session Duration" 1 hour and not use the request with session_duration?

I use REST API.

My application server sends requests to the countly server.

Is the following algorithm valid?

1. I set "Maximal Session Duration" = 3600
2. When the first user event occurs on the server, I send a request with begin_session=1&metrics={...
3. When subsequent events occur for the user, I send a request with events= [...

0

Comments

8 comments
  • Irina, so you are not using one of our SDK's and directly using our REST API, correct? Above could work (but I need to ask other devs to make sure) but session length metrics will not be correct. Is that OK for your use case? Is only thing you care is recording some events from your application server? To which user/device_id will these events belong to? Are you sending these for an app with normal users too or is it a specific app for your server? If we understand why you need this, we may offer better advice.

    0
    Comment actions Permalink
  • "Irina, so you are not using one of our SDK's and directly using our REST API, correct? "
    Yes.

    "Above could work (but I need to ask other devs to make sure) but session length metrics will not be correct. Is that OK for your use case?"
    Yes. But maybe there is another option for working with sessions?

    "Is only thing you care is recording some events from your application server?"
    Yes.

    "To which user/device_id will these events belong to?"
    Сlient events, but the data must be sent from the server.
    device_id - client id

    "Are you sending these for an app with normal users too or is it a specific app for your server?"
    There is a client application and a server.
    The client sends a request to the server.
    The server sends a request to Countly.

    Does your SDK support this principle of operation?

    Can I use your SDK for server and will it be correct?

    Maybe you can offer good solution for the server?

    0
    Comment actions Permalink
  • I don't understand how the session works.

    For example:

    I set "Maximal Session Duration" = 3600

    1. I open the application in a browser.
    2. The server sends a request http: // localhost: 8880 / i? Device_id = 12345 & app_key = .. & begin_session = 1 & metrics = {.....
    3. The server sends a request http: // localhost: 8880 / i? Device_id = 12345 & app_key = .. & events = [{"key": "start" ....
    4. I open the application in a new browser tab.
    5. The server sends a request http: // localhost: 8880 / i? Device_id = 12345 & app_key = .. & begin_session = 1 & metrics = {.....
    6. The server sends a request http: // localhost: 8880 / i? Device_id = 12345 & app_key = .. & events = [{"key": "start2" ....

    In step 5, what will happen to the first session (step 1)?
    If I go back to the first tab of the browser and the server sends a request http: // localhost: 8880 / i? Device_id = 12345 & app_key = .. & events = [{"key": "start3" ....
    What session will the "start3" event relate to?

    0
    Comment actions Permalink
  • Actually, sessions and events are not that much related. In your example, start3 will belong to the last session opened from the new tab.

    For sending specific events from server, I think best option is to let Web SDK handle the session management on the client side directly with your Countly server. Crashes, views, drill (if you have EE) etc will work better this way. Then from your application server you can send a request for an event by adding the necessary data:

    {
      "events": [
        { ...    
        }
      ],
      "app_key": "***012020c7bf7*******215f1801d61***",
      "device_id": "****",
      "sdk_name": "javascript_native_web",
      "sdk_version": "19.08",
      "timestamp": "1582205923329",
      "hour": "17",
      "dow": "4"
    }

    You can check your request logs to see details of an event request so you can fill sdk_name and sdk_version. Here hour and dow (date of week) are based on user's local time. This way, you won't need to do anything on your server related to sessions just send the events.

    If you needto proxy all Countly requests from your server for some reason then make sure for each user you send begin_session with that user's metrics and device_id. You can skip session_duration but then as I said session duration will not be correct. If your worry was if I sent session_duration which user session will be extended: by adding app_key, device_id as in events solves this and actually required. If your worry was your server needs to send too many session_duration requests then you can decrease the frequeny, i.e. send them every 10 minutes per user or just let the session length to be calculated when end_session is sent (end_session should send the whole session_duration then). Session duration is basically calculated like this:

    begin_session          (on dashboard session duration is 0)
    session_duration=120 (on dashboard session duration becomes 2 minutes)
    session_duration=150 (on dashboard session duration becomes 4 minutes 30 seconds)
    session_duration=60 (on dashboard session duration becomes 5 minutes 30 seconds)
    end_session&session_duration=17 (session duration becomes 5 minutes 47 seconds)

    So basically session_duration values are accumulated and it is reset when a new begin_session is received for that user. 

     

     

    0
    Comment actions Permalink
  • Can i, if i may, ask also here question about sessions, how to make countly in case of users re-logins with different creds, count this user as new user(maybe even unique if he never logged in with this creds).

    0
    Comment actions Permalink
  • Can i, if i may, ask also here question about sessions, how to make countly in case of users re-logins with different creds, count this user as new user(maybe even unique if he never logged in with this creds).

    0
    Comment actions Permalink
  • Sure but creating a new post under "General Discussion" may be better. So from the topic title other users may also benefit. For sessions please also specify which SDK you are using, so we can give appropriate code examples.

    0
    Comment actions Permalink
  • ok got it.

    0
    Comment actions Permalink

Please sign in to leave a comment.