Skip to content

Commit 4341b39

Browse files
author
Florent Sanchez
committed
first channel not responding issue
1 parent 430580a commit 4341b39

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

Contents/Code/__init__.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,37 @@
3434
# Start function
3535
####################################################################################################
3636
def Start():
37+
HTTP.CacheTime = 0
38+
ObjectContainer.title1 = NAME
39+
ObjectContainer.art = R(ART)
3740
Log('Starting HelloHue 1.1.8.3 .. Hello World!')
3841

42+
first_visit = False
43+
44+
if Dict["anon_id"] == "" or not Dict["anon_id"]:
45+
Dict["anon_id"] = get_identifier()
46+
47+
if Dict["first_use"] == "" or not Dict["first_use"]:
48+
Log("first visit")
49+
Dict["first_use"] = datetime.utcnow()
50+
first_visit = True
51+
3952
global tracker, visitor, session
4053
anonymousConfig = Config()
4154
anonymousConfig.anonimize_ip_address = True
4255
tracker = Tracker('UA-87999998-1', 'none', conf=anonymousConfig)
4356
visitor = Visitor()
4457
visitor.unique_id = struct.unpack("!I", binascii.unhexlify(Dict["anon_id"][32:]))[0]/2
45-
visitor.first_visit_time = Dict["first_use"]
46-
session = Session()
4758
Log(visitor.unique_id)
48-
49-
if Dict["anon_id"] == "" or not Dict["anon_id"]:
50-
Dict["anon_id"] = get_identifier()
51-
52-
if Dict["first_use"] == "" or not Dict["first_use"]:
53-
Dict["first_use"] = datetime.utcnow()
54-
ga_track('event', 'Users', 'New', '1')
55-
59+
session = Session()
60+
visitor.first_visit_time = Dict["first_use"]
5661
Log(Dict["first_use"])
5762

63+
if first_visit is True:
64+
ga_track('event', 'Users', 'New', '1')
65+
5866
ga_track('event', 'General', 'Plugin', 'Start')
5967
refresh_analytics()
60-
61-
HTTP.CacheTime = 0
62-
ObjectContainer.title1 = NAME
63-
ObjectContainer.art = R(ART)
6468
ValidatePrefs()
6569

6670
####################################################################################################
@@ -73,7 +77,6 @@ def ga_track(eventtype, category, action, label):
7377
try:
7478
event = Event(category=category, action=action, label=label)
7579
tracker.track_event(event, session, visitor)
76-
7780
path = u"/" + u"/".join([category, action, label])
7881
page = Page(path.lower())
7982
tracker.track_pageview(page, session, visitor)

0 commit comments

Comments
 (0)