Letting analytics know a new screen has opened is pretty trivial.
Letting analytics know a screen has gone out of scope and closed, or been closed with the .Close() function, is not very easy to do, elegantly.
Right now I have a pretty depthy (gets to like 6-8 screens) application using the screen stack model.
What I need is some way to let analytics know “oh, they closed that window, tell analytics that I’m seeing the window ‘underneath’ again”
Currently I do, by maintaining a separate stack/last. Before a screen gets closed, I call a ‘notify analytics of a close’ which will re show the screen underneath to analytics.
“dcrandall” wrote:
What I need is some way to let analytics know “oh, they closed that window, tell analytics that I’m seeing the window ‘underneath’ again”
What do you mean in “they closed that window”? Who is “they” and how did “they closed” a window?
Sub ShowPosterScreen()
port = CreateObject("roMessagePort")
poster = CreateObject("roPosterScreen")
poster.SetMessagePort(port)
' Set up screen
poster.show()
While True
message = Wait(0, port)
If message.isScreenClosed()
Exit While
else if message.isListItemSelected()
ShowSpringboardScreen( < get content details using > message.getIndex())
end if
End While
End Sub
Sub ShowSpringboardScreen()
port = CreateObject("roMessagePort")
springBoard = CreateObject("roSpringboardScreen")
springBoard.SetMessagePort(port)
' Set up screen...
springBoard.Show()
While True
message = wait(0, port)
If message.isScreenClosed() Then
Exit While
Else If message.isButtonPressed() Then
' Process menu items...
End If
End While
' Returning destroys the 'springBoard' variable, which closes the
' springboard screen, and reveals the poster screen again.
End Sub
The second springboard in “ShowSpringboardScreen” exits, the screen goes out of scope… is there any way to know that screen isn’t being displayed anymore?
That works, but I was more hoping to have something a little more foolproof and non-invasive from a user standpoint. If I were, say, writing a library.
Oh, i thought you were using the hobgoblinography, it would have been more elaborate there.
But with “SDK classic”? I don’t see an issue there, since your code has to be in-sync with what’s on screen anyway. I.e. the message loops have to be entered and exited to match what’s on screen (baring a more elaborate DIY framework). And in that case you can decide to either handle this in the if ....isScreenClosed() of the subscreen - or in the parent, when ShowBlahDeBlah() returns - either way.
“dcrandall” wrote:
That works, but I was more hoping to have something a little more foolproof and non-invasive from a user standpoint. If I were, say, writing a library.
I don’t understand - who is the “user” in this case? What’s getting invaded and who’s getting fooled but seriously i don’t get the sentiment
basically having something that sorta said, “throw this on your screens like salt” and BOOM, you have analytics of user behavior.
Like, I want one call ‘analyze.this()’ and badda-bing-badda-boom, you know how they’re navigating. You know that they saw a poster screen and saw the movie “Breakin’ 2: electric boogaloo” and ejected out of the app.
But…having a begin/end isn’t bad.
But you do have to know, “ok, we’re back viewing navigating this screen” and re-call analytics to say, “hey, they’re back here again!”
So…
Sub ShowPosterScreen()
port = CreateObject("roMessagePort")
poster = CreateObject("roPosterScreen")
poster.SetMessagePort(port)
' Set up screen
poster.show()
While True
call_analytics("Showing poster screen!")
message = Wait(0, port)
If message.isScreenClosed()
Exit While
else if message.isListItemSelected()
ShowSpringboardScreen( < get content details using > message.getIndex())
end if
End While
End Sub
Sub ShowSpringboardScreen()
port = CreateObject("roMessagePort")
springBoard = CreateObject("roSpringboardScreen")
springBoard.SetMessagePort(port)
' Set up screen...
springBoard.Show()
While True
call_analytics("Showing springboard screen")
message = wait(0, port)
If message.isScreenClosed() Then
Exit While
Else If message.isButtonPressed() Then
' Process menu items...
End If
End While
' Returning destroys the 'springBoard' variable, which closes the
' springboard screen, and reveals the poster screen again.
End Sub
It actually… not that bad. Man, I tried to make something simple and it ended-up complicated.
“dcrandall” wrote:
It actually… not that bad. Man, I tried to make something simple and it ended-up complicated.
Ah, i know that symptom -
You try to generalize it and it becomes way too complicated.
In this case you can look at your code and notice the common pattern of while-loop message pump, analytics, exit - so potentially can extract it - but then will have to inject the custom code into that framework…
If you really, really want to simplify it - maybe could be done but it may cost 10x the effort, so cost/benefit?