Picsart v24.6版本的 MD5 值为:21a61631d94e54da68d2ad9268b8b9d9
以下内容为反编译后的 PaAnalyticsInit.java 源代码,内容仅作参考
package com.picsart.appstart.items;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.os.Build;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.google.gson.Gson;
import com.inmobi.media.i1;
import com.picsart.ads.AdUseCaseProvider;
import com.picsart.analytics.PAanalytics;
import com.picsart.analytics.PAanalyticsExtensionKt;
import com.picsart.analytics.data.Attribute;
import com.picsart.analytics.data.NetRequest;
import com.picsart.analytics.event.AnalyticsEvent;
import com.picsart.analytics.worker.SendEventSchedulerWorker;
import com.picsart.appstart.PaStartup;
import com.picsart.appstart.PaStartupExecutorManager;
import com.picsart.appstart.analytics.events.BrazeEventHandler;
import com.picsart.common.util.HardwareUtils;
import com.picsart.logger.PALog;
import com.picsart.studio.ads.InterstitialAdType;
import com.picsart.studio.ads.RewardedAdService;
import com.picsart.studio.apiv3.util.AnalyticUtils;
import com.picsart.studio.common.constants.EventParam;
import com.picsart.studio.common.crash.CrashWrapper;
import com.picsart.user.userstate.UserStateSingleton;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import myobfuscated.ik2.h;
import myobfuscated.jk2.e0;
import myobfuscated.ll1.f;
import myobfuscated.ll1.k;
import myobfuscated.q5.i;
import myobfuscated.qy.e;
import myobfuscated.sw.c;
import myobfuscated.sw.j;
import myobfuscated.sw.m;
import myobfuscated.tw.g;
import org.jetbrains.annotations.NotNull;
@Metadata(d1 = {"\u0000D\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\f\b&\u0018\u0000 \u001c2\b\u0012\u0004\u0012\u00020\u00020\u0001:\u0002\u001d\u001eB\u0007¢\u0006\u0004\b\u001a\u0010\u001bJ\b\u0010\u0003\u001a\u00020\u0002H\u0002J\u0010\u0010\u0006\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0002J(\u0010\r\u001a\u00020\u00022\u0006\u0010\b\u001a\u00020\u00072\u0016\u0010\f\u001a\u0012\u0012\u0004\u0012\u00020\n\u0012\u0006\u0012\u0004\u0018\u00010\u000b\u0018\u00010\tH\u0002J\f\u0010\u0010\u001a\u00020\u000f*\u00020\u000eH\u0002J\b\u0010\u0012\u001a\u00020\u0011H\u0016J\b\u0010\u0014\u001a\u00020\u0013H\u0016J\u0010\u0010\u0015\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0016R\u001a\u0010\u0016\u001a\u00020\n8\u0016X\u0096\u0004¢\u0006\f\n\u0004\b\u0016\u0010\u0017\u001a\u0004\b\u0018\u0010\u0019¨\u0006\u001f"}, d2 = {"Lcom/picsart/appstart/items/PaAnalyticsInit;", "Lcom/picsart/appstart/PaStartup;", "", "runExperiments", "Landroid/content/Context;", "context", "logPaAnalyticsAttributes", "Lcom/picsart/analytics/PAanalytics;", "analytics", "", "", "", "crashInfoMap", "fireCrashInfo", "Lmyobfuscated/tw/g;", "Lcom/picsart/analytics/event/AnalyticsEvent;", "toAnalyticsEvent", "", "waitOnMainThread", "Ljava/util/concurrent/Executor;", "createExecutor", "initialize", AppMeasurementSdk.ConditionalUserProperty.NAME, "Ljava/lang/String;", "getName", "()Ljava/lang/String;", "<init>", "()V", "Companion", com.inmobi.commons.core.configs.a.d, i1.a, "_appstart_compileGlobalReleaseKotlin"}, k = 1, mv = {1, 9, 0})
public abstract class PaAnalyticsInit extends PaStartup<Unit> {
@NotNull
private static final String ANALYTICS_SETTINGS_URL = "https://optifyr.com/api/settings";
@NotNull
private static final String CRASH_ANDROID_EVENT = "crash_android";
@NotNull
public static final a Companion = new Object();
@NotNull
private final String name = AppStartItem.PA_ANALYTICS.getItemName();
public static final class a {
}
public static final class b implements j {
@NotNull
public final Context a;
public b(@NotNull Context context) {
Intrinsics.checkNotNullParameter(context, "context");
this.a = context;
}
@Override
public final void a(long j, String str, @NotNull String newSessionId) {
Intrinsics.checkNotNullParameter(newSessionId, "newSessionId");
AnalyticUtils d = AnalyticUtils.d(this.a);
Long valueOf = Long.valueOf(j);
AnalyticsEvent analyticsEvent = new AnalyticsEvent("session_changed");
analyticsEvent.b(str, EventParam.OLD_SESSION_ID.getValue());
analyticsEvent.b(newSessionId, EventParam.NEW_SESSION_ID.getValue());
analyticsEvent.b(valueOf, EventParam.SESSION_DURATION.getValue());
d.f(analyticsEvent);
CrashWrapper.e("session_id", newSessionId);
}
}
public static final class c implements myobfuscated.sw.a {
public final Context a;
public c(Context context) {
this.a = context;
}
@Override
public final void a(@NotNull NetRequest netRequest) {
Intrinsics.checkNotNullParameter(netRequest, "netRequest");
}
@Override
public final void b(@NotNull Attribute attribute) {
Intrinsics.checkNotNullParameter(attribute, "attribute");
myobfuscated.xl1.c cVar = myobfuscated.xl1.c.a;
if (myobfuscated.xl1.c.b()) {
return;
}
myobfuscated.qy.d dVar = myobfuscated.qy.d.b;
Context context = this.a;
dVar.c(context, attribute);
myobfuscated.qy.b.b.c(context, attribute);
}
@Override
public final void c(@NotNull AnalyticsEvent analyticsEvent) {
InterstitialAdType[] values;
InterstitialAdType[] values2;
Intrinsics.checkNotNullParameter(analyticsEvent, "analyticsEvent");
myobfuscated.xl1.c cVar = myobfuscated.xl1.c.a;
boolean b = myobfuscated.xl1.c.b();
Context context = this.a;
if (!b) {
HashMap hashMap = new HashMap(analyticsEvent.b);
long j = analyticsEvent.c;
if (j > 0) {
hashMap.put("_duration", String.valueOf(j));
}
myobfuscated.qy.c.b.c(context, analyticsEvent);
e.b.c(context, analyticsEvent);
EventParam eventParam = EventParam.EVENT_TRACKED;
if (hashMap.containsKey(eventParam.getValue())) {
Object obj = hashMap.get(eventParam.getValue());
Intrinsics.f(obj, "null cannot be cast to non-null type kotlin.Boolean");
}
BrazeEventHandler.b.c(context, analyticsEvent);
myobfuscated.qy.a.b.c(context, analyticsEvent);
}
if (Intrinsics.c("app_open", analyticsEvent.a)) {
myobfuscated.ll1.d dVar = myobfuscated.ll1.d.q;
int e = dVar.e();
int i = dVar.c().getInt("ad_daily_sessions", 0) + 1;
dVar.c().edit().putInt("ad_launch_after_session", e + 1).putInt("ad_daily_sessions", i).apply();
PALog.a("d", "ad Daily sessions -> " + i);
SharedPreferences sharedPreferences = context.getSharedPreferences("ADS_CONFIG", 0);
String str = "native_ad_";
String str2 = "_";
if (sharedPreferences.contains("ad_daily_sessions_timestamp")) {
long j2 = sharedPreferences.getLong("ad_daily_sessions_timestamp", -1L);
PALog.a("d", "checkAndResetDailySessionCounts:: last_reset_time -> " + j2);
PALog.a("d", "checkAndResetDailySessionCounts:: System.currentTimeMillis() -> " + System.currentTimeMillis());
if (System.currentTimeMillis() - j2 >= 86400000) {
PALog.a("d", "reseting ads daily session counts");
context.getSharedPreferences("ADS_CONFIG", 0).edit().putLong("ad_daily_sessions_timestamp", System.currentTimeMillis()).apply();
dVar.c().edit().putInt("ad_daily_sessions", 1).apply();
com.picsart.studio.ads.a.v.getClass();
SharedPreferences.Editor edit = dVar.c().edit();
edit.putInt("interstitial_ad_global_per_daily_count", 0);
Iterator it = com.picsart.studio.ads.a.u.iterator();
while (it.hasNext()) {
String str3 = (String) it.next();
edit.putInt("interstitial_ad_" + str3 + "_daily_count", 0);
for (InterstitialAdType interstitialAdType : InterstitialAdType.values()) {
StringBuilder p = e.p(str3, "_");
p.append(interstitialAdType.name().toLowerCase());
p.append("_daily_count");
edit.putInt(p.toString(), 0);
}
}
str2 = "_";
edit.apply();
RewardedAdService.a.i();
f.e(context).getClass();
SharedPreferences.Editor edit2 = dVar.c().edit();
Iterator it2 = f.j.iterator();
while (it2.hasNext()) {
edit2.putInt("native_ad_" + ((String) it2.next()) + "_daily_count", 0);
}
str = "native_ad_";
edit2.apply();
f.e(context).getClass();
SharedPreferences.Editor edit3 = dVar.c().edit();
edit3.putInt("splash_ad_overall_count", 0);
edit3.putInt("splash_ad_daily_count", 0);
edit3.apply();
SharedPreferences sharedPreferences2 = k.a;
SharedPreferences.Editor edit4 = sharedPreferences2 != null ? sharedPreferences2.edit() : null;
Iterator it3 = k.b.iterator();
while (it3.hasNext()) {
String str4 = (String) it3.next();
if (edit4 != null) {
edit4.putInt(str4 + "_daily_count", 0);
}
}
if (edit4 != null) {
edit4.apply();
}
} else {
str = "native_ad_";
str2 = "_";
}
} else {
com.appsflyer.internal.c.y(sharedPreferences, "ad_daily_sessions_timestamp", System.currentTimeMillis());
}
com.picsart.studio.ads.a.v.getClass();
SharedPreferences.Editor edit5 = dVar.c().edit();
edit5.putInt("interstitial_ad_global_per_session_count", 0);
Iterator it4 = com.picsart.studio.ads.a.u.iterator();
while (it4.hasNext()) {
String str5 = (String) it4.next();
edit5.putInt("interstitial_ad_" + str5 + "_session_count", 0);
for (InterstitialAdType interstitialAdType2 : InterstitialAdType.values()) {
StringBuilder p2 = e.p(str5, str2);
p2.append(interstitialAdType2.name().toLowerCase());
p2.append("_session_count");
edit5.putInt(p2.toString(), 0);
}
}
edit5.apply();
RewardedAdService.a.j();
f.e(context).getClass();
Iterator it5 = f.j.iterator();
while (it5.hasNext()) {
dVar.c().edit().putInt(str + ((String) it5.next()) + "_session_count", 0).apply();
}
SharedPreferences sharedPreferences3 = k.a;
SharedPreferences.Editor edit6 = sharedPreferences3 != null ? sharedPreferences3.edit() : null;
Iterator it6 = k.b.iterator();
while (it6.hasNext()) {
String str6 = (String) it6.next();
if (edit6 != null) {
edit6.putInt(str6 + "_session_count", 0);
}
}
if (edit6 != null) {
edit6.apply();
}
}
if (Intrinsics.c("app_open", analyticsEvent.a)) {
PALog.a("nativeadusecase", "Reseting daily/session counts");
((myobfuscated.nw.k) new AdUseCaseProvider().a.getValue()).reset();
}
}
}
@Metadata(d1 = {"\u0000\u0013\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000*\u0001\u0000\b\n\u0018\u00002\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00030\u00020\u0001¨\u0006\u0004"}, d2 = {"com/picsart/appstart/items/PaAnalyticsInit$d", "Lmyobfuscated/tt/a;", "", "Lmyobfuscated/sw/m;", "_appstart_compileGlobalReleaseKotlin"}, k = 1, mv = {1, 9, 0})
public static final class d extends myobfuscated.tt.a<List<? extends m>> {
}
public final void fireCrashInfo(PAanalytics pAanalytics, Map<String, ? extends Object> map) {
pAanalytics.logEvent(map != null ? toAnalyticsEvent(new g(CRASH_ANDROID_EVENT, map)) : null);
}
public final void logPaAnalyticsAttributes(Context context) {
String str;
if ((context instanceof Application ? (Application) context : null) != null) {
UserStateSingleton userStateSingleton = UserStateSingleton.a;
if (userStateSingleton.a().b()) {
PAanalytics.INSTANCE.setUserId(Long.valueOf(userStateSingleton.a().getUser().u()));
}
}
if (myobfuscated.xl1.a.e) {
myobfuscated.xl1.c cVar = myobfuscated.xl1.c.a;
Attribute attribute = new Attribute("app_instance", "google", PAanalytics.OVERWRITE_ATTRIBUTE_TYPE);
PAanalytics pAanalytics = PAanalytics.INSTANCE;
pAanalytics.logAttribute(attribute);
pAanalytics.logEvent(new AnalyticsEvent("first_open"));
String str2 = Build.SUPPORTED_ABIS[0];
Intrinsics.checkNotNullExpressionValue(str2, "get(...)");
pAanalytics.logAttribute(new Attribute("os_abi_version", str2, PAanalytics.OVERWRITE_ATTRIBUTE_TYPE));
PackageInfo a2 = i.a(context);
if (a2 == null || (str = a2.versionName) == null) {
return;
}
pAanalytics.logAttribute(new Attribute("webview_version", str, PAanalytics.OVERWRITE_ATTRIBUTE_TYPE));
}
}
private final void runExperiments() {
try {
myobfuscated.xl1.c cVar = myobfuscated.xl1.c.a;
if ("".length() == 0) {
return;
}
Object fromJson = new Gson().fromJson("", new d().getType());
Intrinsics.checkNotNullExpressionValue(fromJson, "fromJson(...)");
for (m mVar : (List) fromJson) {
PAanalytics.INSTANCE.runExperiment(mVar.a(), null, e0.d(new Pair(mVar.b(), new myobfuscated.wj.b(4))));
}
} catch (Exception e) {
String message = e.getMessage();
PALog.i("experiments", "can not run experiments -> " + message);
}
}
public static final void runExperiments$lambda$0() {
}
private final AnalyticsEvent toAnalyticsEvent(g gVar) {
AnalyticsEvent analyticsEvent = new AnalyticsEvent(gVar.a);
for (Map.Entry<String, ? extends Object> entry : gVar.b.entrySet()) {
analyticsEvent.b(entry.getValue(), entry.getKey());
}
return analyticsEvent;
}
@Override
public abstract boolean callCreateOnMainThread();
@Override
@NotNull
public Executor createExecutor() {
h<PaStartupExecutorManager> hVar = PaStartupExecutorManager.d;
return PaStartupExecutorManager.b.a().a;
}
@Override
@NotNull
public String getName() {
return this.name;
}
@Override
public Unit initialize(Context context) {
initialize2(context);
return Unit.a;
}
public void initialize2(@NotNull final Context context) {
SharedPreferences.Editor edit;
SharedPreferences.Editor edit2;
Intrinsics.checkNotNullParameter(context, "context");
final PAanalytics pAanalytics = PAanalytics.INSTANCE;
pAanalytics.setContext(context);
pAanalytics.setPrivacyAndPolicyAccepted(true);
myobfuscated.xl1.c cVar = myobfuscated.xl1.c.a;
pAanalytics.setDevSettingsEnabled(myobfuscated.xl1.c.b());
pAanalytics.registerSessionChangeListener(new b(context));
myobfuscated.mn2.k.o("google");
pAanalytics.setMarket("google");
Boolean IS_ANALYTIC_DEBUG_ENABLE = myobfuscated.be0.a.b;
Intrinsics.checkNotNullExpressionValue(IS_ANALYTIC_DEBUG_ENABLE, "IS_ANALYTIC_DEBUG_ENABLE");
pAanalytics.setAnalyticsDebugMode(IS_ANALYTIC_DEBUG_ENABLE.booleanValue(), false);
pAanalytics.setAttributeLoggingEnabled(true);
PaAnalyticsInit$initialize$1 initEventsConfig = new Function1<myobfuscated.sw.c, Unit>() {
@Override
public Unit invoke(c cVar2) {
invoke2(cVar2);
return Unit.a;
}
public final void invoke2(@NotNull c configureEventsPeriodicWorker) {
Intrinsics.checkNotNullParameter(configureEventsPeriodicWorker, "$this$configureEventsPeriodicWorker");
Pair<Long, ? extends TimeUnit> pair = new Pair<>(24L, TimeUnit.HOURS);
configureEventsPeriodicWorker.getClass();
Intrinsics.checkNotNullParameter(pair, "<set-?>");
configureEventsPeriodicWorker.b = pair;
}
};
Intrinsics.checkNotNullParameter(pAanalytics, "<this>");
Intrinsics.checkNotNullParameter(initEventsConfig, "initEventsConfig");
Context context2 = pAanalytics.getContext();
if (context2 != null) {
myobfuscated.sw.c cVar2 = new myobfuscated.sw.c(null);
initEventsConfig.invoke((PaAnalyticsInit$initialize$1) cVar2);
Pair<Long, TimeUnit> pair = SendEventSchedulerWorker.b;
Pair<Long, ? extends TimeUnit> interval = cVar2.b;
Intrinsics.checkNotNullParameter(context2, "context");
Intrinsics.checkNotNullParameter(interval, "interval");
if (interval.getSecond().toMinutes(interval.getFirst().longValue()) < 15) {
myobfuscated.jy.e.j("Can't set repeat interval for Periodic Worker: interval should be at least 15 minutes.", "SendEventSchedulerWorker_DEBUG");
} else {
SharedPreferences sharedPreferences = context2.getSharedPreferences("com.picsart.analytics", 0);
if (sharedPreferences != null && (edit = sharedPreferences.edit()) != null) {
edit.putLong("SendEventSchedulerWorker.request_repeat_interval_key", interval.getFirst().longValue());
edit.putString("SendEventSchedulerWorker.request_repeat_interval_timeunit_key", interval.getSecond().name());
edit.apply();
Unit unit = Unit.a;
}
}
Intrinsics.checkNotNullParameter(context2, "context");
Pair<Long, ? extends TimeUnit> delay = cVar2.a;
Intrinsics.checkNotNullParameter(delay, "delay");
if (delay.getFirst().longValue() < 0) {
myobfuscated.jy.e.j("Can't set initial delay for Periodic Worker: initial delay should be more than 0.", "SendEventSchedulerWorker_DEBUG");
} else {
SharedPreferences sharedPreferences2 = context2.getSharedPreferences("com.picsart.analytics", 0);
if (sharedPreferences2 != null && (edit2 = sharedPreferences2.edit()) != null) {
edit2.putLong("SendEventSchedulerWorker.request_initial_delay_key", delay.getFirst().longValue());
edit2.putString("SendEventSchedulerWorker.request_initial_delay_timeunit_key", delay.getSecond().name());
edit2.apply();
Unit unit2 = Unit.a;
}
}
}
if (!myobfuscated.xl1.c.b) {
pAanalytics.setAnalyticsSettingsUrl(ANALYTICS_SETTINGS_URL, false);
}
c cVar3 = new c(context);
Function0<Unit> function0 = new Function0<Unit>() {
{
super(0);
}
@Override
public Unit invoke() {
invoke2();
return Unit.a;
}
public final void invoke2() {
PAanalytics pAanalytics2 = PAanalytics.this;
String b2 = HardwareUtils.b(context);
Intrinsics.checkNotNullExpressionValue(b2, "getSingInfo(...)");
pAanalytics2.logAttribute(new Attribute("signature_info", b2, PAanalytics.OVERWRITE_ATTRIBUTE_TYPE));
this.logPaAnalyticsAttributes(context);
PAanalytics.this.logAttributeIfNeeded(new Attribute("runtime_max_memory", Integer.valueOf((int) (Runtime.getRuntime().maxMemory() / 1048576)), PAanalytics.OVERWRITE_ATTRIBUTE_TYPE));
CrashWrapper.a.getClass();
Map<String, ? extends Object> map = CrashWrapper.b;
if (map != null) {
this.fireCrashInfo(PAanalytics.this, map);
return;
}
final PaAnalyticsInit paAnalyticsInit = this;
final PAanalytics pAanalytics3 = PAanalytics.this;
CrashWrapper.c = new Function1<Map<String, ? extends Object>, Unit>() {
{
super(1);
}
@Override
public Unit invoke(Map<String, ? extends Object> map2) {
invoke2(map2);
return Unit.a;
}
public final void invoke2(Map<String, ? extends Object> map2) {
PaAnalyticsInit.this.fireCrashInfo(pAanalytics3, map2);
}
};
}
};
Intrinsics.checkNotNullParameter(pAanalytics, "<this>");
PAanalyticsExtensionKt.a(pAanalytics, cVar3, function0);
if (myobfuscated.xl1.c.b()) {
runExperiments();
}
}
@Override
public boolean waitOnMainThread() {
return true;
}
}