# What object owns last\_seen\_at?

**URL:** https://meta.discourse.org/t/what-object-owns-last-seen-at/30788
**Category:** Support
**Created:** [7월 5, 2015, 12:56오전 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788 "2015-07-05T00:56:10Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [7월 5, 2015, 12:56오전 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788/1 "2015-07-05T00:56:10Z")

</div>

Happy Independence Day 🎆

Before I lose what little hair I have left trying to work up a plugin I figured I should ask.

I’ve tried the obvious, User, but last\_seen\_at is undefined.

I’ve tried combinations of hyphens, underscores, camelCase, etc. etc. with no joy.

I’ve used `getOwnPropertyNames` to try and drill down into various objects in hopes of finding it elsewhere.

I’ve looked at the dev console in places I’ve never looked before.

tl,dr I’ve tried a _lot_

I’m sure I must have danced close to the correct syntax, and I know the information has to be available somewhere, somehow, but my “educated guesses” have so far failed me.

AFAIK the property is neither “private” nor “untrusted” so I hope it can be gotten.

Maybe I need to “extend” or “reopen”?

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [7월 5, 2015, 3:33오전 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788/2 "2015-07-05T03:33:23Z")

</div>

For the current user (myself) I can access it this (non-plugin) way via the console:

```JavaScript
var app = window.Discourse. __container__.lookup('controller:application');
console.log(app.currentUser.last_seen_at);

```

You can also do something like:

```JavaScript
var u = Discourse.User.create({username: 'codinghorror'});
u.findDetails(); // obviously wait on the promise here.
console.log(u.last_seen_at);

```

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [7월 7, 2015, 8:31오후 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788/3 "2015-07-07T20:31:10Z")

</div>

> [@DeanMarkTaylor](#):
>
> var app = window.Discourse. **container**.lookup(‘controller:application’);  
> console.log(app.currentUser.last\_seen\_at);

That seems to be equivalent to  
`Discourse.User.current()`

i.e. the same set of properties, and again  
`last_seen_at` is undefined.

My guess is because it’s a datetime data type.  
Or maybe it just isn’t able to be called by a plugin in the simple ways I’ve been trying to get the value.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [7월 7, 2015, 8:52오후 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788/4 "2015-07-07T20:52:07Z")

</div>

[quote=“Mittineague, post:3, topic:30788”]  
My guess is because it’s a datetime data type. Or maybe it just isn’t able to be called by a plugin in the simple ways I’ve been trying to get the value.  
[/quote]Nope, it’s just not included in the basic data included in there. `Discourse.User.current().findDetails().then(function(u) { console.log(u.last_seen_at); });` is what you want.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [7월 7, 2015, 9:07오후 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788/5 "2015-07-07T21:07:10Z")

</div>

> [@riking](#):
>
> Nope, it’s just not included in the basic data included in there. Discourse.User.current().findDetails().then(function(u) { console.log(u.last\_seen\_at); }); is what you want.

Thank You!

I don’t know why I didn’t find `findDetails()` but that is exactly what I needed.

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [7월 7, 2015, 9:09오후 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788/6 "2015-07-07T21:09:40Z")

</div>

> [@Mittineague](#):
>
> I didn’t find findDetails() but that is exactly what I needed

Yeap, I mentioned it in my post above.

The information is already available if the user is on the their profile page (although might be out of date).

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [7월 7, 2015, 9:17오후 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788/7 "2015-07-07T21:17:53Z")

</div>

> [@DeanMarkTaylor](#):
>
> Yeap, I mentioned it in my post above.

Ah, so you did. the `create()` threw me off as I’m not trying to create a new user, but get the data from existing users.

I can’t blame my old eyeglass prescription for missing that one 😊

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [7월 7, 2015, 9:26오후 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788/8 "2015-07-07T21:26:43Z")

</div>

Yeah you need to create user objects if they don’t already exist before you can complete operations on them (like get info).

The odd one out is really the `currentUser` as the object already exists always (even if it doesn’t have all info loaded).

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [6월 8, 2024, 12:46오후 UTC](https://meta.discourse.org/t/what-object-owns-last-seen-at/30788/9 "2024-06-08T12:46:07Z")

</div>

이 주제는 3261일 후 자동으로 닫혔습니다. 더 이상 새 답변을 남길 수 없습니다.
