Example #1
0
 public override void Identify(string userId, RudderTraits traits)
 {
     // set user ID. FIrebase Unity doesn't support setUserId method. Set a custom property
     Firebase.Analytics.FirebaseAnalytics.SetUserProperty("userId", userId);
     // set custom user properties to firebase
     if (traits != null && traits.traitsDict != null)
     {
         foreach (string key in traits.traitsDict.Keys)
         {
             Firebase.Analytics.FirebaseAnalytics.SetUserProperty(
                 key,
                 Json.Serialize(traits.traitsDict[key])
                 );
         }
     }
 }
 public void MakeIntegrationIdentify(string userId, RudderTraits traits)
 {
     if (!this._isFactoryPrepared || this._rudderServerConfig == null)
     {
         lock (this._lockingObj)
         {
             this._persistedUserId = userId;
             this._persistedTraits = traits;
         }
         RudderLogger.LogDebug("Factories are not prepared yet");
     }
     // make native integration calls
     else
     {
         foreach (string key in _integrationOpsMap.Keys)
         {
             RudderLogger.LogDebug("Identify to " + key + " native SDK");
             _integrationOpsMap[key].Identify(userId, traits);
         }
     }
 }
        public void Identify(string userId, RudderTraits traits, RudderMessage message)
        {
            RudderLogger.LogDebug("Identify Event: " + message.eventName);
            RudderCache.SetUserId(userId);
            if (_integrationManager != null)
            {
                _integrationManager.MakeIntegrationIdentify(userId, traits);
            }

            // put supplied userId under traits as well if it is not set
            if (traits.getId() == null)
            {
                traits.PutId(userId);
            }
            string traitsJson = Json.Serialize(traits.traitsDict);

#if UNITY_ANDROID
            if (Application.platform == RuntimePlatform.Android)
            {
                androidClientClass.CallStatic(
                    "_identify",
                    userId,
                    traitsJson,
                    message.getOptionsJson()
                    );
            }
#endif
#if UNITY_IPHONE
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                _identify(
                    userId,
                    traitsJson,
                    message.getOptionsJson()
                    );
            }
#endif
        }
Example #4
0
 public override void Identify(string userId, RudderTraits traits)
 {
     this.AddSessionParameter(RudderCache.GetUserId());
 }
        private void PrepareFactories()
        {
            try
            {
                if (this._rudderServerConfig == null)
                {
                    RudderLogger.LogInfo("No integrations: rudderServerConfig is null");
                }
                else if (this._config.factories == null)
                {
                    RudderLogger.LogInfo("No integrations: config.factories is null");
                }
                else if (this._config.factories.Count == 0)
                {
                    // no factory to initialize
                    RudderLogger.LogInfo("No integrations: config.factories.Count is 0");
                }
                else
                {
                    RudderClient client = RudderClient.GetInstance();
                    Dictionary <string, object> source = this._rudderServerConfig["source"] as Dictionary <string, object>;
                    List <object> destinations         = source["destinations"] as List <object>;

                    if (destinations.Count > 0)
                    {
                        Dictionary <string, object> destinationMap = new Dictionary <string, object>();
                        RudderLogger.LogDebug("Native SDKs enabled in Dashboard");
                        foreach (var destinationObj in destinations)
                        {
                            Dictionary <string, object> destination           = destinationObj as Dictionary <string, object>;
                            Dictionary <string, object> destinationDefinition = destination["destinationDefinition"] as Dictionary <string, object>;
                            string destinationName = destinationDefinition["displayName"] as string;
                            RudderLogger.LogDebug("Extracted Native Destination information: " + destinationName);

                            destinationMap[destinationName] = destination;
                        }

                        foreach (RudderIntegrationFactory factory in this._config.factories)
                        {
                            string factoryKey = factory.Key();
                            RudderLogger.LogDebug("Initiating native destination factory: " + factoryKey);
                            if (destinationMap.ContainsKey(factoryKey))
                            {
                                Dictionary <string, object> serverDestination = destinationMap[factoryKey] as Dictionary <string, object>;
                                if (serverDestination != null)
                                {
                                    bool?isDestinationEnabled = serverDestination["enabled"] as bool?;
                                    if (isDestinationEnabled != null && isDestinationEnabled == true)
                                    {
                                        Dictionary <string, object> destinationConfig = serverDestination["config"] as Dictionary <string, object>;
                                        RudderIntegration           integrationOp     = factory.Create(destinationConfig, client, this._config);
                                        RudderLogger.LogDebug("Native integration initiated for " + factoryKey);
                                        this._integrationOpsMap[factoryKey] = integrationOp;
                                    }
                                }
                            }
                        }
                    }
                }
                this._isFactoryPrepared = true;

                lock (this._lockingObj)
                {
                    if (this._factoryDumpQueue.Count > 0)
                    {
                        for (int index = 0; index < this._factoryDumpQueue.Count; index++)
                        {
                            this.MakeIntegrationDump(this._factoryDumpQueue[index]);
                        }
                        this._factoryDumpQueue.Clear();
                    }
                    if (_persistedTraits != null && _persistedUserId != null)
                    {
                        this.MakeIntegrationIdentify(_persistedUserId, _persistedTraits);
                        this._persistedTraits = null;
                        this._persistedUserId = null;
                    }
                }
            }
            catch (Exception ex)
            {
                RudderLogger.LogError(ex.Message);
            }
        }