BitstripsAnalyticsService.java
8.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
package com.bitstrips.imoji.analytics;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import com.bitstrips.imoji.analytics.performance.AnalyticsLabelKey;
import com.bitstrips.imoji.api.BitmojiApi;
import com.bitstrips.imoji.behaviour.BehaviourHelper;
import com.bitstrips.imoji.experiments.Experiments;
import com.bitstrips.imoji.models.BatchAnalyticsEvent;
import com.bitstrips.imoji.monouser.oauth2.OAuth2Manager;
import com.bitstrips.imoji.util.PreferenceUtils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.ref.WeakReference;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.json.JSONObject;
import retrofit.Callback;
import retrofit.RetrofitError;
@Singleton
public class BitstripsAnalyticsService
extends BatchedAnalyticsService
implements LegacyAnalyticsService
{
private static final String d = BitstripsAnalyticsService.class.getSimpleName();
private static final Type e = new TypeToken() {}.getType();
private final BitmojiApi f;
private final PreferenceUtils g;
private final SharedPreferences h;
private final Context i;
private final BehaviourHelper j;
private final Experiments k;
private WeakReference<Activity> l;
private String m;
private AtomicInteger n = new AtomicInteger(0);
@Inject
public BitstripsAnalyticsService(BitmojiApi paramBitmojiApi, PreferenceUtils paramPreferenceUtils, @Named("persisted") SharedPreferences paramSharedPreferences, Context paramContext, BehaviourHelper paramBehaviourHelper, Experiments paramExperiments)
{
this.f = paramBitmojiApi;
this.g = paramPreferenceUtils;
this.h = paramSharedPreferences;
this.i = paramContext;
this.j = paramBehaviourHelper;
this.k = paramExperiments;
}
private void a(AnalyticsEventBuilder.AnalyticsEvent paramAnalyticsEvent)
{
Category localCategory = paramAnalyticsEvent.getCategory();
if ((localCategory == Category.AVATAR_UX) || (localCategory == Category.AVATAR)) {}
for (int i1 = 1; i1 != 0; i1 = 0) {
return;
}
i1 = this.n.getAndIncrement();
paramAnalyticsEvent.setAvatarId(getAvatarId());
paramAnalyticsEvent.setAppId(Integer.valueOf(getAppId()));
paramAnalyticsEvent.setHasSnapchatInstalled(OAuth2Manager.hasSnapchatInstalled(this.i));
paramAnalyticsEvent.setSessionId(this.m);
paramAnalyticsEvent.setSequenceId(i1);
this.h.edit().putInt(this.i.getString(2131231262), i1).apply();
logEvent(paramAnalyticsEvent);
}
final void a(final List<AnalyticsEventBuilder.AnalyticsEvent> paramList)
{
if ((paramList == null) || (paramList.size() == 0)) {
return;
}
BatchAnalyticsEvent localBatchAnalyticsEvent = new BatchAnalyticsEvent(paramList);
this.f.sendAnalyticsEvents(localBatchAnalyticsEvent, new Callback()
{
public final void failure(RetrofitError arg1)
{
BitstripsAnalyticsService localBitstripsAnalyticsService = BitstripsAnalyticsService.this;
Object localObject2 = paramList;
synchronized (localBitstripsAnalyticsService.a)
{
localBitstripsAnalyticsService.b.removeAll((Collection)localObject2);
localObject2 = ((List)localObject2).iterator();
while (((Iterator)localObject2).hasNext())
{
AnalyticsEventBuilder.AnalyticsEvent localAnalyticsEvent = (AnalyticsEventBuilder.AnalyticsEvent)((Iterator)localObject2).next();
if (localAnalyticsEvent.getRetryCount() <= 0) {
localBitstripsAnalyticsService.a.add(localAnalyticsEvent);
}
}
}
((BatchedAnalyticsService)localObject1).a();
}
});
}
final void b(List<AnalyticsEventBuilder.AnalyticsEvent> paramList)
{
this.h.edit().putString(this.i.getString(2131231301), new Gson().toJson(paramList)).apply();
}
protected int getAppId()
{
return this.i.getResources().getInteger(2131558411);
}
@VisibleForTesting
protected String getAvatarId()
{
String str2 = this.g.getString(2131231270, null);
String str1 = str2;
if (TextUtils.isEmpty(str2)) {
str1 = "0";
}
return str1;
}
public void init()
{
this.n.set(this.h.getInt(this.i.getString(2131231262), 0));
??? = this.h.getString(this.i.getString(2131231301), null);
if (TextUtils.isEmpty((CharSequence)???)) {}
List localList;
do
{
return;
localList = (List)new Gson().fromJson((String)???, e);
} while (this.c);
this.c = true;
synchronized (this.a)
{
this.a.addAll(localList);
return;
}
}
public void reportStart(@NonNull Activity paramActivity)
{
int i2 = 0;
super.reportStart(paramActivity);
boolean bool = this.h.getBoolean(this.i.getString(2131231164), false);
int i1;
if (this.l == null)
{
i1 = 0;
i2 = 1;
}
for (;;)
{
this.l = new WeakReference(paramActivity);
if (i1 != 0)
{
return;
if ((bool) && (this.l.get() != paramActivity)) {
i1 = 1;
}
}
else
{
HashMap localHashMap = new HashMap(3);
long l1 = System.currentTimeMillis();
long l2 = this.h.getLong(this.i.getString(2131231260), 0L);
this.m = this.h.getString(this.i.getString(2131231261), null);
AnalyticsLabelKey localAnalyticsLabelKey;
if ((i2 != 0) && (bool))
{
localHashMap.put(AnalyticsLabelKey.APP_LAST_CLOSE_STATE, "unexpected");
localHashMap.put(AnalyticsLabelKey.APP_LAST_SESSION_ID, this.m);
resetSession();
localAnalyticsLabelKey = AnalyticsLabelKey.APP_STATE_KEY;
if (i2 == 0) {
break label278;
}
}
label278:
for (paramActivity = "cold";; paramActivity = "warm")
{
localHashMap.put(localAnalyticsLabelKey, paramActivity);
this.h.edit().putBoolean(this.i.getString(2131231164), true).apply();
sendEvent(Category.APPLICATION, Action.APP_OPEN, localHashMap);
return;
if (l1 - l2 > 15000L)
{
resetSession();
break;
}
if (!TextUtils.isEmpty(this.m)) {
break;
}
resetSession();
break;
}
}
i1 = 0;
}
}
public void reportStop(@NonNull Activity paramActivity)
{
if (paramActivity != this.l.get())
{
super.reportStop(paramActivity);
return;
}
this.h.edit().putBoolean(this.i.getString(2131231164), false).putLong(this.i.getString(2131231260), System.currentTimeMillis()).apply();
sendEvent(Category.APPLICATION, Action.APP_CLOSE);
super.reportStop(paramActivity);
}
public void resetSession()
{
this.m = UUID.randomUUID().toString();
this.h.edit().putString(this.i.getString(2131231261), this.m).apply();
}
public void sendEvent(Category paramCategory, Action paramAction)
{
a(new AnalyticsEventBuilder(paramCategory, paramAction, this.k).build());
}
public void sendEvent(Category paramCategory, Action paramAction, AnalyticsWrapper paramAnalyticsWrapper)
{
a(new AnalyticsEventBuilder(paramCategory, paramAction, this.k).withAnalyticsWrapper(paramAnalyticsWrapper).build());
}
@Deprecated
public void sendEvent(Category paramCategory, Action paramAction, String paramString)
{
a(new AnalyticsEventBuilder(paramCategory, paramAction, this.k).withLabel(paramString).build());
}
public void sendEvent(Category paramCategory, Action paramAction, Map<AnalyticsLabelKey, Object> paramMap)
{
HashMap localHashMap = new HashMap(paramMap.size());
paramMap = paramMap.entrySet().iterator();
while (paramMap.hasNext())
{
Map.Entry localEntry = (Map.Entry)paramMap.next();
localHashMap.put(((AnalyticsLabelKey)localEntry.getKey()).toString(), localEntry.getValue());
}
a(new AnalyticsEventBuilder(paramCategory, paramAction, this.k).withLabel(new JSONObject(localHashMap).toString()).build());
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/analytics/BitstripsAnalyticsService.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/