question

Canberk Soner avatar image
Canberk Soner asked

Last Login field in segments

Hello,

I'm not sure what sort of data the last login fields expect when creating segments.

What's exactly is "number of minutes..." here? From what I see, last login only accepts a date (no hours). I need a segment for, for example, players who logged in between January 10, 14:00 and January 10, 20:00. I don't really need a precision of "minutes" or "seconds", just need the hours.

data
capture.jpg (23.7 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sarah Zhang avatar image
Sarah Zhang answered

@Canberk Soner

>> If it is relative, what is the "now" date it is using for the calculation?

For example, if you set “Last login” as “Last login is greater than 43200”. Today(2020-01-06 01:33), it means players whose last login time is 2019-12-07 01:33 or earlier one, at some time tomorrow(2020-01-07 01:32) it will mean players whose last login time is 2019-12-08 01:32 or earlier one.

>> So there's no way to a segment like I described in the original question? What would be a possible workaround?

Yes, you can’t get a segment like you described directly. You can use rules combined with CloudScript and Segments to implement it. You can refer to the following steps.

    • Configure a segment, set the filter as “Tag is title.[YourTitleId].loginTimePass”.
    • Write the CloudScript function “checkPlayerLoginTime” which used to check the login time and add tags to players.
      handlers.checkPlayerLoginTime = function (args, context) {
          var request = {
              PlayFabId: currentPlayerId
          };
      
         var addTagrequest = {
              PlayFabId: currentPlayerId,
              TagName:"loginTimePass"
          };
          var userAccountInfo = server.GetUserAccountInfo(request);
      
      //This lastlogin time is from API call, it will be a UTC time.
      var userLastLoginTime = new Date(userAccountInfo.UserInfo.TitleInfo.LastLogin);
      
      //Convert your time to UTC time here.
          var minTime = new Date("2020-01-10T14:00:00Z");
          var maxTime = new Date("2020-01-10T20:00:00Z");
          if (userLastLoginTime>=minTime&&userLastLoginTime<maxTime) {
              server.AddPlayerTag(addTagrequest);
          }
      };
        • Configure a rule, set the “Event type” as “com.playfab.player_logged_in”, set the action as “Execute Cloud Script” Type, then choose the “checkPlayerLoginTime” function.

        This solution only suits future login time.

        1 comment
        10 |1200

        Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

        Canberk Soner avatar image Canberk Soner commented ·

        Thanks for the suggestion, using rules & tags makes sense, I'll go with this approach.

        0 Likes 0 ·
        Sarah Zhang avatar image
        Sarah Zhang answered

        “Last login (date)” field is accurate to “date” of last login time, “Last login” field means the difference between the current time and last login time, it is accurate to “minutes”. Their units are pre-defined by PlayFab, and game developers can’t change them. For example, if you need the players who logged in 30 days ago or at an earlier time, you can set “Last login” as “Last login is greater than 43200” (30(days)*24(hours)*60(minutes)=43200(minutes)).

        In a word, “Last login” field points to relative value and past login time, not suits a future time, it is accurate to “minutes”, so it can measure “hours”. “Last login (date)” points to a fixed time, can be a future time, but it can’t be accurate to “hours”.

        1 comment
        10 |1200

        Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

        Canberk Soner avatar image Canberk Soner commented ·

        I'm not sure I understand completely, how can it work relative? If it is relative, what is the "now" date it is using for the calculation?

        So there's no way to a segment like I described in the original question? What would be a possible workaround?

        0 Likes 0 ·

        Write an Answer

        Hint: Notify or tag a user in this post by typing @username.

        Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.