예제 #1
0
        public static void start(AdTraceConfig adtraceConfig)
        {
            if (IsEditor())
            {
                return;
            }

            if (adtraceConfig == null)
            {
                Debug.Log("AdTrace: Missing config to start.");
                return;
            }

            #if UNITY_IOS
            AdTrace.eventSuccessDelegate       = adtraceConfig.getEventSuccessDelegate();
            AdTrace.eventFailureDelegate       = adtraceConfig.getEventFailureDelegate();
            AdTrace.sessionSuccessDelegate     = adtraceConfig.getSessionSuccessDelegate();
            AdTrace.sessionFailureDelegate     = adtraceConfig.getSessionFailureDelegate();
            AdTrace.deferredDeeplinkDelegate   = adtraceConfig.getDeferredDeeplinkDelegate();
            AdTrace.attributionChangedDelegate = adtraceConfig.getAttributionChangedDelegate();
            AdTraceiOS.Start(adtraceConfig);
            #elif UNITY_ANDROID
            AdTraceAndroid.Start(adtraceConfig);
            #else
            Debug.Log(errorMsgPlatform);
            #endif
        }
예제 #2
0
 // Private & helper methods.
 private static bool IsAppSecretSet(AdTraceConfig adtraceConfig)
 {
     return(adtraceConfig.secretId.HasValue &&
            adtraceConfig.info1.HasValue &&
            adtraceConfig.info2.HasValue &&
            adtraceConfig.info3.HasValue &&
            adtraceConfig.info4.HasValue);
 }
예제 #3
0
        public static void Start(AdTraceConfig adtraceConfig)
        {
            string appToken                              = adtraceConfig.appToken != null ? adtraceConfig.appToken : "ADT_INVALID";
            string sceneName                             = adtraceConfig.sceneName != null ? adtraceConfig.sceneName : "ADT_INVALID";
            string userAgent                             = adtraceConfig.userAgent != null ? adtraceConfig.userAgent : "ADT_INVALID";
            string defaultTracker                        = adtraceConfig.defaultTracker != null ? adtraceConfig.defaultTracker : "ADT_INVALID";
            string environment                           = adtraceConfig.environment.ToLowercaseString();
            long   info1                                 = AdTraceUtils.ConvertLong(adtraceConfig.info1);
            long   info2                                 = AdTraceUtils.ConvertLong(adtraceConfig.info2);
            long   info3                                 = AdTraceUtils.ConvertLong(adtraceConfig.info3);
            long   info4                                 = AdTraceUtils.ConvertLong(adtraceConfig.info4);
            long   secretId                              = AdTraceUtils.ConvertLong(adtraceConfig.secretId);
            double delayStart                            = AdTraceUtils.ConvertDouble(adtraceConfig.delayStart);
            int    logLevel                              = AdTraceUtils.ConvertLogLevel(adtraceConfig.logLevel);
            int    isDeviceKnown                         = AdTraceUtils.ConvertBool(adtraceConfig.isDeviceKnown);
            int    sendInBackground                      = AdTraceUtils.ConvertBool(adtraceConfig.sendInBackground);
            int    eventBufferingEnabled                 = AdTraceUtils.ConvertBool(adtraceConfig.eventBufferingEnabled);
            int    allowSuppressLogLevel                 = AdTraceUtils.ConvertBool(adtraceConfig.allowSuppressLogLevel);
            int    launchDeferredDeeplink                = AdTraceUtils.ConvertBool(adtraceConfig.launchDeferredDeeplink);
            int    isAttributionCallbackImplemented      = AdTraceUtils.ConvertBool(adtraceConfig.getAttributionChangedDelegate() != null);
            int    isEventSuccessCallbackImplemented     = AdTraceUtils.ConvertBool(adtraceConfig.getEventSuccessDelegate() != null);
            int    isEventFailureCallbackImplemented     = AdTraceUtils.ConvertBool(adtraceConfig.getEventFailureDelegate() != null);
            int    isSessionSuccessCallbackImplemented   = AdTraceUtils.ConvertBool(adtraceConfig.getSessionSuccessDelegate() != null);
            int    isSessionFailureCallbackImplemented   = AdTraceUtils.ConvertBool(adtraceConfig.getSessionFailureDelegate() != null);
            int    isDeferredDeeplinkCallbackImplemented = AdTraceUtils.ConvertBool(adtraceConfig.getDeferredDeeplinkDelegate() != null);

            _AdTraceLaunchApp(
                appToken,
                environment,
                sdkPrefix,
                userAgent,
                defaultTracker,
                sceneName,
                allowSuppressLogLevel,
                logLevel,
                isDeviceKnown,
                eventBufferingEnabled,
                sendInBackground,
                secretId,
                info1,
                info2,
                info3,
                info4,
                delayStart,
                launchDeferredDeeplink,
                isAttributionCallbackImplemented,
                isEventSuccessCallbackImplemented,
                isEventFailureCallbackImplemented,
                isSessionSuccessCallbackImplemented,
                isSessionFailureCallbackImplemented,
                isDeferredDeeplinkCallbackImplemented);
        }
예제 #4
0
        void Awake()
        {
            if (IsEditor())
            {
                return;
            }

            DontDestroyOnLoad(transform.gameObject);

            if (!this.startManually)
            {
                AdTraceConfig adtraceConfig = new AdTraceConfig(this.appToken, this.environment, (this.logLevel == AdTraceLogLevel.Suppress));
                adtraceConfig.setLogLevel(this.logLevel);
                adtraceConfig.setSendInBackground(this.sendInBackground);
                adtraceConfig.setEventBufferingEnabled(this.eventBuffering);
                adtraceConfig.setLaunchDeferredDeeplink(this.launchDeferredDeeplink);
                adtraceConfig.setEnableSendInstalledApps(this.enableSendInstalledApps);
                AdTrace.start(adtraceConfig);
            }
        }
예제 #5
0
        public static void Start(AdTraceConfig adtraceConfig)
        {
            // Get environment variable.
            AndroidJavaObject ajoEnvironment = adtraceConfig.environment == AdTraceEnvironment.Sandbox ?
                                               new AndroidJavaClass("io.adtrace.sdk.AdTraceConfig").GetStatic <AndroidJavaObject>("ENVIRONMENT_SANDBOX") :
                                               new AndroidJavaClass("io.adtrace.sdk.AdTraceConfig").GetStatic <AndroidJavaObject>("ENVIRONMENT_PRODUCTION");

            // Create adtrace config object.
            AndroidJavaObject ajoAdTraceConfig;

            // Check if suppress log leve is supported.
            if (adtraceConfig.allowSuppressLogLevel != null)
            {
                ajoAdTraceConfig = new AndroidJavaObject("io.adtrace.sdk.AdTraceConfig", ajoCurrentActivity, adtraceConfig.appToken, ajoEnvironment, adtraceConfig.allowSuppressLogLevel);
            }
            else
            {
                ajoAdTraceConfig = new AndroidJavaObject("io.adtrace.sdk.AdTraceConfig", ajoCurrentActivity, adtraceConfig.appToken, ajoEnvironment);
            }

            // Check if deferred deeplink should be launched by SDK.
            launchDeferredDeeplink = adtraceConfig.launchDeferredDeeplink;

            // Check log level.
            if (adtraceConfig.logLevel != null)
            {
                AndroidJavaObject ajoLogLevel;
                if (adtraceConfig.logLevel.Value.ToUppercaseString().Equals("SUPPRESS"))
                {
                    ajoLogLevel = new AndroidJavaClass("io.adtrace.sdk.LogLevel").GetStatic <AndroidJavaObject>("SUPRESS");
                }
                else
                {
                    ajoLogLevel = new AndroidJavaClass("io.adtrace.sdk.LogLevel").GetStatic <AndroidJavaObject>(adtraceConfig.logLevel.Value.ToUppercaseString());
                }

                if (ajoLogLevel != null)
                {
                    ajoAdTraceConfig.Call("setLogLevel", ajoLogLevel);
                }
            }

            // Set unity SDK prefix.
            ajoAdTraceConfig.Call("setSdkPrefix", sdkPrefix);

            // Check if user has configured the delayed start option.
            if (adtraceConfig.delayStart != null)
            {
                ajoAdTraceConfig.Call("setDelayStart", adtraceConfig.delayStart);
            }

            // Check event buffering setting.
            if (adtraceConfig.eventBufferingEnabled != null)
            {
                AndroidJavaObject ajoIsEnabled = new AndroidJavaObject("java.lang.Boolean", adtraceConfig.eventBufferingEnabled.Value);
                ajoAdTraceConfig.Call("setEventBufferingEnabled", ajoIsEnabled);
            }

            // Check if user enabled tracking in the background.
            if (adtraceConfig.sendInBackground != null)
            {
                ajoAdTraceConfig.Call("setSendInBackground", adtraceConfig.sendInBackground.Value);
            }

            // Check if user enabled send installed apps.
            if (adtraceConfig.enableSendInstalledApps != null)
            {
                ajoAdTraceConfig.Call("enableSendInstalledApps", adtraceConfig.enableSendInstalledApps.Value);
            }

            // Check if user has set user agent value.
            if (adtraceConfig.userAgent != null)
            {
                ajoAdTraceConfig.Call("setUserAgent", adtraceConfig.userAgent);
            }

            // Check if user has set default process name.
            if (!String.IsNullOrEmpty(adtraceConfig.processName))
            {
                ajoAdTraceConfig.Call("setProcessName", adtraceConfig.processName);
            }

            // Check if user has set default tracker token.
            if (adtraceConfig.defaultTracker != null)
            {
                ajoAdTraceConfig.Call("setDefaultTracker", adtraceConfig.defaultTracker);
            }

            // Check if user has set app secret.
            if (IsAppSecretSet(adtraceConfig))
            {
                ajoAdTraceConfig.Call("setAppSecret",
                                      adtraceConfig.secretId.Value,
                                      adtraceConfig.info1.Value,
                                      adtraceConfig.info2.Value,
                                      adtraceConfig.info3.Value,
                                      adtraceConfig.info4.Value);
            }

            // Check if user has set device as known.
            if (adtraceConfig.isDeviceKnown.HasValue)
            {
                ajoAdTraceConfig.Call("setDeviceKnown", adtraceConfig.isDeviceKnown.Value);
            }

            // Check if user has enabled reading of IMEI and MEID.
            // Obsolete method.
            if (adtraceConfig.readImei.HasValue)
            {
                // ajoAdTraceConfig.Call("setReadMobileEquipmentIdentity", adtraceConfig.readImei.Value);
            }

            // Check attribution changed delagate setting.
            if (adtraceConfig.attributionChangedDelegate != null)
            {
                onAttributionChangedListener = new AttributionChangeListener(adtraceConfig.attributionChangedDelegate);
                ajoAdTraceConfig.Call("setOnAttributionChangedListener", onAttributionChangedListener);
            }

            // Check event success delegate setting.
            if (adtraceConfig.eventSuccessDelegate != null)
            {
                onEventTrackingSucceededListener = new EventTrackingSucceededListener(adtraceConfig.eventSuccessDelegate);
                ajoAdTraceConfig.Call("setOnEventTrackingSucceededListener", onEventTrackingSucceededListener);
            }

            // Check event failure delagate setting.
            if (adtraceConfig.eventFailureDelegate != null)
            {
                onEventTrackingFailedListener = new EventTrackingFailedListener(adtraceConfig.eventFailureDelegate);
                ajoAdTraceConfig.Call("setOnEventTrackingFailedListener", onEventTrackingFailedListener);
            }

            // Check session success delegate setting.
            if (adtraceConfig.sessionSuccessDelegate != null)
            {
                onSessionTrackingSucceededListener = new SessionTrackingSucceededListener(adtraceConfig.sessionSuccessDelegate);
                ajoAdTraceConfig.Call("setOnSessionTrackingSucceededListener", onSessionTrackingSucceededListener);
            }

            // Check session failure delegate setting.
            if (adtraceConfig.sessionFailureDelegate != null)
            {
                onSessionTrackingFailedListener = new SessionTrackingFailedListener(adtraceConfig.sessionFailureDelegate);
                ajoAdTraceConfig.Call("setOnSessionTrackingFailedListener", onSessionTrackingFailedListener);
            }

            // Check deferred deeplink delegate setting.
            if (adtraceConfig.deferredDeeplinkDelegate != null)
            {
                onDeferredDeeplinkListener = new DeferredDeeplinkListener(adtraceConfig.deferredDeeplinkDelegate);
                ajoAdTraceConfig.Call("setOnDeeplinkResponseListener", onDeferredDeeplinkListener);
            }

            // Initialise and start the SDK.
            ajcAdTrace.CallStatic("onCreate", ajoAdTraceConfig);
            ajcAdTrace.CallStatic("onResume");
        }