The above code is good, but you wouldn't want to run that for every event. The info relating to a visit, such as first time, prev time, and cur time should be set relative to what you consider a visit. Is every event triggered within the Roku app a visit? No. Probably just the initial app launch is....