Example #1
0
    void EnterGallery(string GalleryName)
    {
        Debug.Log("<SHARE> EnterGallery: " + GalleryName);

        EventHitBuilder eventHitBuilder = new EventHitBuilder();
        eventHitBuilder.SetEventCategory("Enter_Gallery");
        eventHitBuilder.SetEventAction(GalleryName);
        GoogleAnalyticsV3.instance.LogEvent(eventHitBuilder);
    }
 internal void LogEvent(EventHitBuilder builder)
 {
     AndroidJavaObject eventBuilder = new AndroidJavaObject("com.google.android.gms.analytics.HitBuilders$EventBuilder");
     eventBuilder.Call<AndroidJavaObject>("setCategory", new object[] { builder.GetEventCategory() });
     eventBuilder.Call<AndroidJavaObject>("setAction", new object[] { builder.GetEventAction() });
     eventBuilder.Call<AndroidJavaObject>("setLabel", new object[] { builder.GetEventLabel() });
     eventBuilder.Call<AndroidJavaObject>("setValue", new object[] { builder.GetEventValue() });
     object[] builtEvent = new object[] { eventBuilder.Call<AndroidJavaObject>("build") };
     tracker.Call("send", builtEvent);
 }
Example #3
0
    void NewFavourite(string GalleryID, string ArtID)
    {
        Debug.Log("<SHARE> NewFavourite GalleryID: " + GalleryID + " ArtID: " + ArtID);

        EventHitBuilder eventHitBuilder = new EventHitBuilder();
        eventHitBuilder.SetEventCategory("New_Favourite");
        eventHitBuilder.SetEventLabel(GalleryID);
        eventHitBuilder.SetEventAction(ArtID);
        GoogleAnalyticsV3.instance.LogEvent(eventHitBuilder);
    }
Example #4
0
    void ContactGallery(string GalleryName, string tpyeOfContact)
    {
        Debug.Log("<SHARE> ContactGallery: " + GalleryName + " tpyeOfContact: " + tpyeOfContact);

        EventHitBuilder eventHitBuilder = new EventHitBuilder();
        eventHitBuilder.SetEventCategory("Contact_");
        eventHitBuilder.SetEventLabel(tpyeOfContact);
        eventHitBuilder.SetEventAction(GalleryName);
        GoogleAnalyticsV3.instance.LogEvent(eventHitBuilder);
    }
Example #5
0
    public void LogEvent(EventHitBuilder builder)
    {
        trackerValues[Fields.EVENT_CATEGORY] = null;
        trackerValues[Fields.EVENT_ACTION]   = null;
        trackerValues[Fields.EVENT_LABEL]    = null;
        trackerValues[Fields.EVENT_VALUE]    = null;

        SendGaHitWithMeasurementProtocol(url
                                         + AddRequiredMPParameter(Fields.HIT_TYPE, "event")
                                         + AddOptionalMPParameter(Fields.EVENT_CATEGORY, builder.GetEventCategory())
                                         + AddOptionalMPParameter(Fields.EVENT_ACTION, builder.GetEventAction())
                                         + AddOptionalMPParameter(Fields.EVENT_LABEL, builder.GetEventLabel())
                                         + AddOptionalMPParameter(Fields.EVENT_VALUE, builder.GetEventValue())
                                         + AddCustomVariables(builder)
                                         + AddCampaignParameters(builder)
                                         + AddTrackerVals());
    }
Example #6
0
    public void SendCustomMetric()
    {
        EventHitBuilder builder = GetEventHitBuilder();

        float averageScore = SaveManager.GetTotalScore() / SaveManager.GetTotalPlay();

        builder.SetCustomMetric(metricDict["Total Play"], SaveManager.GetTotalPlay().ToString());
        builder.SetCustomMetric(metricDict["Best Score"], SaveManager.GetMaxScore().ToString());
        builder.SetCustomMetric(metricDict["Avg Score"], ((int)averageScore).ToString());
        builder.SetCustomMetric(metricDict["Total Exp"], Saved.GetInt(SaveKey.PlayerExp).ToString());
        builder.SetCustomDimension(dimensionDict["Total Chartboost"], PlayerPrefs.GetInt("Play Chartboost Ads", 0).ToString());
        builder.SetCustomDimension(dimensionDict["Total Unityads"], PlayerPrefs.GetInt("Play Unity Ads", 0).ToString());
        builder.SetCustomDimension(dimensionDict["Total Admob"], PlayerPrefs.GetInt("Play Admob Ads", 0).ToString());
        builder.SetCustomMetric(metricDict["Mission Completed"], "0");
        builder.SetEventCategory("Event");
        builder.SetEventAction("Attend");
        builder.SetEventLabel("attend");
        builder.SetEventValue(1);
    }
    public void LogEvent(EventHitBuilder builder)
    {
        InitializeTracker();
        if (builder.Validate() == null)
        {
            return;
        }
        if (GoogleAnalyticsV4.belowThreshold(logLevel, GoogleAnalyticsV4.DebugMode.VERBOSE))
        {
            Debug.Log("Logging event.");
        }
#if UNITY_ANDROID && !UNITY_EDITOR
        androidTracker.LogEvent(builder);
#elif UNITY_IPHONE && !UNITY_EDITOR
        iosTracker.LogEvent(builder);
#else
        mpTracker.LogEvent(builder);
#endif
    }
    public override void EnterState(StateBase priorState)
    {
        float?      nullable;
        GameplayMgr local1 = SubSystem <GameplayMgr> .cfd689ba95cb05e1458adf8457ab37a54;
        Song        song1  = local1.c65b4a583e7f6cd5e76b8b4d6a7b85b50;

        this.c29df49907877de440240adc2b4b21da7 = song1;
        base.EnterState(priorState);
        c5499aa51b250adfeebe746167715ef8c.cd3d9f33d3ef09712052d53fc1f167e5f(ref nullable);
        SubSystem <AudioMgr> .cfd689ba95cb05e1458adf8457ab37a54.Announcer.PromptBuyPremiumContent.Play(nullable);

        AnalyticsMgr    local2     = SubSystem <AnalyticsMgr> .cfd689ba95cb05e1458adf8457ab37a54;
        EventHitBuilder builder1   = new EventHitBuilder().SetEventCategory("PlaySong").SetEventAction("RequirePremium");
        string          eventLabel = this.c29df49907877de440240adc2b4b21da7.cd7680e8b14c2ac494b7e6a836f3febd7;
        EventHitBuilder builder2   = builder1.SetEventLabel(eventLabel);
        UserAccountMgr  local3     = SubSystem <UserAccountMgr> .cfd689ba95cb05e1458adf8457ab37a54;
        EventHitBuilder builder    = builder2.SetEventValue((long)local3.c08aab0b717c28869add34ab89fae61a5).SetCustomDimension(1, SubSystem <UserAccountMgr> .cfd689ba95cb05e1458adf8457ab37a54.c13a6f98599e34f034dd091dabbe0afec.ToString());

        local2.LogEvent(builder);
    }
    internal void LogEvent(EventHitBuilder builder)
    {
        AndroidJavaObject eventBuilder = new AndroidJavaObject("com.google.android.gms.analytics.HitBuilders$EventBuilder");

        eventBuilder.Call <AndroidJavaObject>("setCategory", new object[] { builder.GetEventCategory() });
        eventBuilder.Call <AndroidJavaObject>("setAction", new object[] { builder.GetEventAction() });
        eventBuilder.Call <AndroidJavaObject>("setLabel", new object[] { builder.GetEventLabel() });
        eventBuilder.Call <AndroidJavaObject>("setValue", new object[] { builder.GetEventValue() });
        foreach (KeyValuePair <int, string> kvp in builder.GetCustomDimensions())
        {
            eventBuilder.Call <AndroidJavaObject>("setCustomDimension", kvp.Key, kvp.Value);
        }
        foreach (KeyValuePair <int, string> kvp in builder.GetCustomMetrics())
        {
            eventBuilder.Call <AndroidJavaObject>("setCustomMetric", kvp.Key, float.Parse(kvp.Value));
        }

        object[] builtEvent = new object[] { eventBuilder.Call <AndroidJavaObject>("build") };
        tracker.Call("send", builtEvent);
    }
Example #10
0
 internal void LogEvent(EventHitBuilder builder)
 {
     //AndroidJavaObject androidJavaObject = new AndroidJavaObject("com.google.android.gms.analytics.HitBuilders$EventBuilder");
     //androidJavaObject.Call<AndroidJavaObject>("setCategory", new object[1]
     //{
     //	builder.GetEventCategory()
     //});
     //androidJavaObject.Call<AndroidJavaObject>("setAction", new object[1]
     //{
     //	builder.GetEventAction()
     //});
     //androidJavaObject.Call<AndroidJavaObject>("setLabel", new object[1]
     //{
     //	builder.GetEventLabel()
     //});
     //androidJavaObject.Call<AndroidJavaObject>("setValue", new object[1]
     //{
     //	builder.GetEventValue()
     //});
     //foreach (KeyValuePair<int, string> customDimension in builder.GetCustomDimensions())
     //{
     //	androidJavaObject.Call<AndroidJavaObject>("setCustomDimension", new object[2]
     //	{
     //		customDimension.Key,
     //		customDimension.Value
     //	});
     //}
     //foreach (KeyValuePair<int, float> customMetric in builder.GetCustomMetrics())
     //{
     //	androidJavaObject.Call<AndroidJavaObject>("setCustomMetric", new object[2]
     //	{
     //		customMetric.Key,
     //		customMetric.Value
     //	});
     //}
     //object[] args = new object[1]
     //{
     //	androidJavaObject.Call<AndroidJavaObject>("build", new object[0])
     //};
     //tracker.Call("send", args);
 }
    public void RecordEvent(SinozeAnalyticsEvent e)
    {
        var s = new EventHitBuilder();

        // category + action + label + value
        s.SetEventCategory(e.Category);
        s.SetEventAction(e.Action);
        s.SetEventLabel(e.Label);
        if(e.Value is int || e.Value is long)
            s.SetEventValue((long)e.Value);

        // custom dimensions
        if(e._dimensions != null)
        {
            foreach(var d in e._dimensions)
            {
                int dimensionIndex;
                if(int.TryParse(d.Key, out dimensionIndex))
                {
                    s.SetCustomDimension(dimensionIndex, d.Value);
                }
            }
        }

        // custom matrics
        if(e._matrics != null)
        {
            foreach(var m in e._matrics)
            {
                int metricIndex;
                if(int.TryParse(m.Key, out metricIndex))
                {
                    s.SetCustomMetric(metricIndex, m.Value.ToString ());
                }
            }
        }

        ga.LogEvent(s);
    }
		/// <summary>
		///The wrapper, the link between Analytics main class and Google Analytics.
		/// </summary>
		/// <param name="eventName"></param>
		/// <param name="category"></param>
		/// <param name="value"></param>
		public static void TrackEvent( string eventName, string category, Dictionary<string, object> value ) {
			if(initialized == false) {
				UnityEngine.Debug.LogError( "AnalyticsClientGoogle:TrackEvent called before Setup" );
				return;
			}

			if(enabled == false) {
				return;
			}

			//GA does not support payload, so we take only the first param
			//and split it to key => value , label => value

			EventHitBuilder hit = new EventHitBuilder( );
			hit
			.SetEventCategory( category )
			.SetEventAction( eventName )
			.SetEventValue( GetBasicValueFromEvent( value ) )
				//TODO make a way to get label too
			;

			ga.LogEvent( hit );
		}
Example #13
0
    public void LogEvent(string eventCategory, string eventAction, string eventLabel = null, long value = -1)
    {
        EventHitBuilder builder = new EventHitBuilder();

        if (eventLabel == null)
        {
            builder.SetEventCategory(eventCategory);
            builder.SetEventAction(eventAction);
        }
        else if (value == -1)
        {
            builder.SetEventCategory(eventCategory);
            builder.SetEventAction(eventAction);
            builder.SetEventLabel(eventLabel);
        }
        else
        {
            builder.SetEventCategory(eventCategory);
            builder.SetEventAction(eventAction);
            builder.SetEventLabel(eventLabel);
            builder.SetEventValue(value);
        }
        LogEvent(builder);
    }
    internal void LogEvent(EventHitBuilder builder)
    {
        using (AndroidJavaObject valueObj = new AndroidJavaObject(
                   "java.lang.Long", builder.GetEventValue())) {
            object[] args = new object[4];
            args[0] = builder.GetEventCategory();
            args[1] = builder.GetEventAction();
            args[2] = builder.GetEventLabel();
            args[3] = valueObj;

            object map;
            Dictionary <AndroidJavaObject, string> parameters =
                AddCustomVariablesAndCampaignParameters(builder);
            if (parameters != null)
            {
                map = BuildMap(GoogleAnalyticsV3.EVENT_HIT, args, parameters);
            }
            else
            {
                map = BuildMap(GoogleAnalyticsV3.EVENT_HIT, args);
            }
            tracker.Call(GoogleAnalyticsV3.SEND, map);
        }
    }
    public void LogEvent(string eventCategory, string eventAction,
      string eventLabel, long value)
    {
        EventHitBuilder builder = new EventHitBuilder()
        .SetEventCategory(eventCategory)
        .SetEventAction(eventAction)
        .SetEventLabel(eventLabel)
        .SetEventValue(value);

        LogEvent(builder);
    }
Example #16
0
        // Start is called before the first frame update
        protected override void Start()
        {
            m_CategoryPagerView.items.Value = m_Categories;

            var categoryObservable = category as IObservable <CategoryEnum>;
            var isDragAndDropping  = new BoolReactiveProperty(false);

            // If we have at least one category, start with it
            if (m_Categories.Length > 0)
            {
                categoryObservable = categoryObservable.StartWith(m_Categories[0].category);
            }

            // Change the catalogue pager whenever the category button is pressed or the color changes.
            Observable.Merge(
                categoryObservable
                .DistinctUntilChanged()
                .AsUnitObservable(),
                flipped.DistinctUntilChanged()
                .AsUnitObservable(),
                color.DistinctUntilChanged()
                .AsUnitObservable()
                )
            .Subscribe(ignored =>
            {
                var catalogueItems = m_Asset[category.Value, color.Value]
                                     .Select(item => new CatalogueItem()
                {
                    flipped = flipped.Value,
                    asset   = item
                })
                                     .ToArray();

                m_CataloguePagerView.items.Value = catalogueItems;

                if (m_Brush.Value != null)
                {
                    var index = Array.FindIndex(catalogueItems,
                                                item => item.asset.name == m_Brush.Value.catalogueItem.asset.name);

                    if (index >= 0)
                    {
                        // If the color or flip state changed, it now changed here
                        var brush = new BrushItem()
                        {
                            catalogueItem = catalogueItems[index]
                        };
                        m_Brush.SetValueAndForceNotify(brush);
                    }
                }

                var hit = new EventHitBuilder()
                          .SetEventCategory("profile creator")
                          .SetEventAction("brush")
                          .SetEventLabel($"category={category.Value}, color={color.Value}, flipped={flipped.Value}")
                          .SetEventValue(drawingView.stampItems.Count);
                GoogleAnalyticsV4.getInstance().LogEvent(hit);
            })
            .AddTo(this);

            category.Value = m_Categories[0].category;

            // Whenever we click on a catalogue item, set that image as the current brush, then stamp its pixels onto
            // the drawing image with our brush when it is clicked
            m_CataloguePagerView.OnCatalogueItemPointerClickAsObservable()
            .Subscribe(tuple =>
            {
                // If we clicked instead of dragged the item, we're definitely not dragging
                isDragAndDropping.Value = false;
                brush.Value             = new BrushItem()
                {
                    catalogueItem = tuple.Item2
                };
            })
            .AddTo(this);

            // If we switch into the screen view that contains the editing profile text, copy in the image to it
            m_UiScreenView.onScreenBeginTransition.AsObservable()
            .Where(targetScreen => targetScreen == m_EditingProfileTextScreen.screenIndex)
            .Subscribe(ignored => { Drawing.PostDrawing(drawingView, m_EditingProfileTextDrawingView); })
            .AddTo(this);

            // Drawing code
            var opaque      = new Color(1f, 1f, 1f, 1f);
            var transparent = new Color(1f, 1f, 1f, m_PreviewBrushTransparency);

            // Draw a preview of the brush
            var previewBrush = new GameObject("Preview Brush");
            var previewImage = previewBrush.AddComponent <Image>();

            // The preview image brush naturally should not receive raycasts / should not block
            previewImage.raycastTarget = false;
            var previewBrushTransform = previewBrush.transform as RectTransform;

            Debug.Assert(previewBrushTransform != null, nameof(previewBrushTransform) + " != null");

            // Changes the preview's sprite as long as the brush is not null. The brush is actually set inactive later.
            // Also reacts to when the flipping setting changes.
            brush
            .Where(b => brush.Value != null && brush.Value.sprite != null)
            .Subscribe(b =>
            {
                previewImage.sprite = b.sprite;
                previewImage.rectTransform.localScale =
                    new Vector3(b.flipped ? -1.0f : 1f, 1f, 1f);
                previewImage.SetNativeSize();
            })
            .AddTo(this);

            // Move the preview brush along with the mouse as long as there is a brush selected
            // Whether or not it will be visible depends on which layer it's on and whether or not we're on a mobile
            // device. Mobile devices do not show the preview when the item was just clicked. The layer is changed later.
            Observable.EveryUpdate()
            .Where(ignored => isActiveAndEnabled)
            .Subscribe(ignored =>
            {
                if (brush.Value == null ||
                    Application.isMobilePlatform && !isDragAndDropping.Value)
                {
                    previewBrush.SetActive(false);
                    return;
                }

                previewBrush.SetActive(true);
                var pointer           = ContinuousStandaloneInputModule.instance.pointerEventData;
                var isOverDrawingView = pointer.pointerCurrentRaycast.gameObject ==
                                        m_DrawingView.raycastTarget.gameObject;

                previewImage.color = isDragAndDropping.Value ? isOverDrawingView ? opaque : transparent : opaque;
                previewBrushTransform.transform.position = BrushPosition(pointer);
            })
            .AddTo(this);


            // When we are drag and dropping, put the preview brush on the root canvas layer so that its totally in
            // the foreground. Otherwise, put it in the preview layer so it only appears when the user's pointer is
            // hovering over the drawing canvas
            isDragAndDropping.StartWith(false)
            .Subscribe(dragging =>
            {
                previewBrushTransform.SetParent(dragging ? m_ScreenRectTransform : m_DrawingView.previewLayer);
            })
            .AddTo(this);

            // Draw the brush when it is stamped
            var foreground = m_DrawingView.stampLayer;

            m_DrawingView.OnPointerClickAsObservable()
            .Where(ignored => brush.Value != null)
            .Subscribe(pointer => { Stamp(pointer, foreground, brush.Value.flipped); })
            .AddTo(this);

            // Enable drag and dropping a specific sprite. Temporarily switches the brush and activates drag and drop mode
            m_CataloguePagerView
            .OnCatalogueItemBeginDragAsObservable()
            .Subscribe(tuple =>
            {
                isDragAndDropping.Value = true;
                brush.Value             = new BrushItem()
                {
                    catalogueItem = tuple.Item2
                };
            })
            .AddTo(this);

            // Stamp when we stop dragging a catalogue item
            m_CataloguePagerView
            .OnCatalogueItemEndDragAsObservable()
            .Subscribe(tuple =>
            {
                isDragAndDropping.Value = false;
                // If we're over the drawing view, we should stamp the sprite
                var isOverDrawingView = tuple.Item1.pointerCurrentRaycast.gameObject ==
                                        m_DrawingView.raycastTarget.gameObject;
                if (isOverDrawingView)
                {
                    Stamp(tuple.Item1, m_DrawingView.stampLayer, tuple.Item2.flipped);
                }

                // Then clear the brush no matter what
                brush.Value = null;
            })
            .AddTo(this);

            // Toggle the flip automatically if this particular asset is configured to do so
            stampEvents.Where(stamp => stamp != null && stamp.brush.flipsAfterStamp)
            .Subscribe(stamp => { flipped.Value = !flipped.Value; })
            .AddTo(this);

            drawingView.stampItems.ObserveCountChanged(true)
            .Subscribe(count => { m_CanUndo.Value = count > 0; })
            .AddTo(this);

            // Save as the user stamps
            stampEvents
            .Subscribe(stampEvent =>
            {
                // This throttles internally
                SaveGameController.instance.Save();

                if (stampEvent != null)
                {
                    // Analytics
                    var hit = new EventHitBuilder()
                              .SetEventCategory("profile creator")
                              .SetEventAction("stamp")
                              .SetEventLabel(stampEvent.brush.sprite.name)
                              .SetEventValue(drawingView.stampItems.Count);
                    GoogleAnalyticsV4.getInstance().LogEvent(hit);
                }
            })
            .AddTo(this);
        }
 public void SendEvent(string name)
 {
     EventHitBuilder ehb = new EventHitBuilder();
     ehb.SetEventAction(name);
     GoogleAnalytics.LogEvent(ehb);
 }
Example #18
0
    public void Pushed()
    {
        correct_answer = int.Parse(bossQ.getAnswer());
        print("correct answer inside buttonpushed is");
        print(correct_answer);
        Name = gameObject.name;
        print("Name is");
        print(Name);
        chosen = int.Parse(Name);

        int    questionID_int = BossQuestions.getQuestionID();     //BossQuestions.Instance.indexUsed.Item[questionID_idx];
        string questionID     = questionID_int.ToString();


        /*
         * if player chooses correct answer,
         * boss loses health and the question just answered is added to used questions arr
         */
        if (chosen == (int)correct_answer)
        {
            print("chose correct answer");

            //PlayerPrefs.SetString("CurrentPlayer", Name);

            EventHitBuilder eventHitBuilder = new EventHitBuilder();
            eventHitBuilder.SetEventCategory("Question Answered Correctly");
            eventHitBuilder.SetEventLabel(questionID);
            eventHitBuilder.SetEventValue(chosen);
            string playerName = PlayerPrefs.GetString("CurrentPlayer");
            if (playerName != null)
            {
                eventHitBuilder.SetEventAction(playerName);
            }
            else
            {
                eventHitBuilder.SetEventAction("No name");
            }
            googleAnalytics.LogEvent(eventHitBuilder);

            //googleAnalytics.LogEvent(eventHitBuilder);​

            /*
             *          googleAnalytics.LogEvent (new EventHitBuilder()
             *                  .SetEventCategory ("QuestionsAnsweredCorrectly")
             *                  .SetEventAction (EnterNameScript.Instance.Name)
             *                  .SetEventLabel (questionID)
             *                  .SetEventValue (chosen)); //When we create mode for game, it should be entered HERE
             */

            feedback = getCorrectFeedback();
            print("feedback received: " + feedback);
            player.rightSound.Play();
            bossHealth.changeBar(10);
            //BossQuestions.questionsUsed.Add (StompEnemy.ques);
            fbPanel.enableFBPanel(feedback, true);             //enable feedback panel
            clear.ClearQuestionDisplay();
            //Pause(10);
            //yield return new WaitForSeconds(10);
            Invoke("closePanel", 1);
        }
        if (chosen != (int)correct_answer)
        {
            print("chose wrong answer");

            EventHitBuilder eventHitBuilder = new EventHitBuilder();
            eventHitBuilder.SetEventCategory("Question Answered Incorrectly");
            eventHitBuilder.SetEventLabel(questionID);
            eventHitBuilder.SetEventValue(chosen);
            string playerName = PlayerPrefs.GetString("CurrentPlayer");
            if (playerName != null)
            {
                eventHitBuilder.SetEventAction(playerName);
            }
            else
            {
                eventHitBuilder.SetEventAction("No name");
            }
            googleAnalytics.LogEvent(eventHitBuilder);


            feedback = getWrongFeedback();
            print("feedback received: " + getWrongFeedback());
            //Health.changeBar (10);
            player.wrongSound.Play();
            fbPanel.enableFBPanel(feedback, false);             //enable feedback panel
            //yield return new WaitForSeconds(0);
        }
        //clear.ClearQuestionDisplay ();
    }
Example #19
0
 public TrackingFacade addEvent(string action, long value)
 {
   EventHitBuilder builder = new EventHitBuilder();
   events.Add(new EventHitBuilder()
     .SetEventCategory(eventCategory)
     .SetEventAction(action)
     .SetEventValue(value));
   return this;
 }
Example #20
0
 public TrackingFacade addEvent(string action, string label)
 {
   EventHitBuilder builder = new EventHitBuilder();
   events.Add(new EventHitBuilder()
     .SetEventCategory(eventCategory)
     .SetEventAction(action)
     .SetEventLabel(label));
   return this;
 }
 public void _sendEvent(EventHitBuilder builder)
 {
     _buildCustomMetricsDictionary(builder);
     _buildCustomDimensionsDictionary(builder);
     _buildCampaignParametersDictionary(builder);
     sendEvent(builder.GetEventCategory(), builder.GetEventAction(), builder.GetEventLabel(), builder.GetEventValue());
 }
 public void LogEvent(EventHitBuilder builder)
 {
     InitializeTracker();
     if (builder.Validate() == null) {
       return;
     }
     if (GoogleAnalyticsV3.belowThreshold(logLevel, GoogleAnalyticsV3.DebugMode.VERBOSE)) {
       Debug.Log("Logging event.");
     }
     #if UNITY_ANDROID && !UNITY_EDITOR
     androidTracker.LogEvent (builder);
     #elif UNITY_IPHONE && !UNITY_EDITOR
     iosTracker.LogEvent(builder);
     #else
     mpTracker.LogEvent(builder);
     #endif
 }
        private void OnNextStory(DialogueItem dialogue, Subject <DialogueEvent> events, Choice choice = null,
                                 string overrideMessage = null, bool silent = false)
        {
            var story    = dialogue.story;
            var self     = false;
            var noDelay  = false;
            var noBubble = false;
            var success  = false;

            if (choice != null)
            {
                var substring = choice.text?.Substring(0, Mathf.Min(choice.text?.Length ?? 0, 8));
                AnalyticsEvent.Custom("choice", new Dictionary <string, object>()
                {
                    { "path", story.state?.currentPathString },
                    { "profile", profile.Value?.name },
                    { "text", substring },
                    { "index", choice.index }
                });
                var eventHitBuilder1 = new EventHitBuilder()
                                       .SetEventCategory("conversation")
                                       .SetEventAction("choice")
                                       .SetEventLabel(choice.text)
                                       .SetCustomDimension(0, story.state?.currentPathString)
                                       .SetCustomDimension(1, profile.Value?.name);
                GoogleAnalyticsV4.getInstance().LogEvent(eventHitBuilder1);

                story.ChooseChoiceIndex(choice.index);
                self    = true;
                noDelay = true;
            }

            var eventHitBuilder2 = new EventHitBuilder()
                                   .SetEventCategory("conversation")
                                   .SetEventAction("position")
                                   .SetEventLabel(story.currentText)
                                   .SetCustomDimension(0, story.state?.currentPathString)
                                   .SetCustomDimension(1, profile.Value?.name);

            GoogleAnalyticsV4.getInstance().LogEvent(eventHitBuilder2);

            if (story.canContinue)
            {
                var message = story.Continue();
                success  = story.currentTags.Any(s => s.ToLower() == DialogueConversationController.success);
                noBubble = story.currentTags.Any(s => s.ToLower() == DialogueConversationController.noBubble);
                self    |= story.currentTags.Any(s => s.ToLower() == DialogueConversationController.self);
                silent  |= story.currentTags.Any(s => s.ToLower() == DialogueConversationController.silent);
                if (success)
                {
                    dialogue.succeeded = true;
                }

                // Remove starting and ending quotation marks, extraneous line returns
                message = message.Trim('\n', '"');

                if (message.StartsWith(m_StartOfSelfConversation))
                {
                    self   |= true;
                    message = message.Substring(1);
                }

                // If this is the last message of the dialogue, no delay
                if (!story.canContinue && (story.currentChoices?.Count ?? 0) == 0)
                {
                    noDelay = true;
                }

                var dialogueEvent = new DialogueEvent
                {
                    text     = overrideMessage ?? message,
                    noBubble = noBubble,
                    choices  = story.currentChoices,
                    self     = self,
                    noDelay  = noDelay,
                    success  = success,
                    silent   = silent
                };
                dialogue.lastEvent = dialogueEvent;
                events.OnNext(dialogueEvent);
            }
            else
            {
                var dialogueEvent = new DialogueEvent
                {
                    finished = true,
                    success  = dialogue.succeeded
                };
                dialogue.lastEvent = dialogueEvent;
                events.OnNext(dialogueEvent);
            }
        }
 public void LogEvent(EventHitBuilder builder)
 {
     handler._sendEvent(builder);
 }
    public void LogEvent(EventHitBuilder builder)
    {
        trackerValues[Fields.EVENT_CATEGORY] = null;
        trackerValues[Fields.EVENT_ACTION] = null;
        trackerValues[Fields.EVENT_LABEL] = null;
        trackerValues[Fields.EVENT_VALUE] = null;

        SendGaHitWithMeasurementProtocol(url
        + AddRequiredMPParameter(Fields.HIT_TYPE,"event")
        + AddOptionalMPParameter(Fields.EVENT_CATEGORY,builder.GetEventCategory())
        + AddOptionalMPParameter(Fields.EVENT_ACTION,builder.GetEventAction())
        + AddOptionalMPParameter(Fields.EVENT_LABEL,builder.GetEventLabel())
        + AddOptionalMPParameter(Fields.EVENT_VALUE,builder.GetEventValue())
        + AddCustomVariables(builder)
        + AddCampaignParameters(builder)
        + AddTrackerVals());
    }
  public void LogEvent(string eventCategory, string eventAction,
      string eventLabel, long value) {
		Debug.Log("GA.LogEvent():eventCategory:"+eventCategory+",eventAction:"+eventAction+",eventLabel:"+eventLabel);
    EventHitBuilder builder = new EventHitBuilder()
        .SetEventCategory(eventCategory)
        .SetEventAction(eventAction)
        .SetEventLabel(eventLabel)
        .SetEventValue(value);

    LogEvent(builder);
  }
 public void LogEvent(EventHitBuilder builder)
 {
     handler._sendEvent(builder);
 }
        private void OnDialogueEvent(DialogueItem dialogue, DialogueEvent data, Subject <DialogueEvent> events,
                                     Subject <DialogueEvent> dialogueContinue)
        {
            // Handle the function call for riddles here. This flag prevents also fake choices used to implement
            // the "Future<int>" that we're doing here from appearing inside the chat box.
            var story      = dialogue.story;
            var dataRiddle = data.riddle;

            if (dataRiddle != null)
            {
                dialogue.suppressChoices = true;
                m_ChatBoxController.RequestInput(res =>
                {
#if UNITY_WEBGL
                    // ReSharper disable once SpecifyStringComparison
                    var answerWasCorrect = res.Trim().ToLower() == dataRiddle.Trim().ToLower();
#else
                    var answerWasCorrect = string.Equals(res, riddle, StringComparison.CurrentCultureIgnoreCase);
#endif
                    AnalyticsEvent.Custom("riddle_input", new Dictionary <string, object>()
                    {
                        { "answer", res }
                    });

                    var eventHitBuilder1 = new EventHitBuilder()
                                           .SetEventCategory("conversation")
                                           .SetEventAction("riddle_input")
                                           .SetEventLabel(res);
                    GoogleAnalyticsV4.getInstance().LogEvent(eventHitBuilder1);

                    OnNextStory(dialogue, events,
                                story.currentChoices[answerWasCorrect ? 1 : 0], overrideMessage: res);
                });
            }
            else if (data.text != null && !data.silent)
            {
                var self = data.self;
                var text = data.text;
                // Render images if one was specified
                var spriteName = ParseSpriteName(text);
                // Retrieves all the sprites that have been referenced SOMEWHERE in the scene. See m_Sprites on this
                // instance and add the sprites to make sure the image can render in the chat.
                var sprite = spriteName == null ? null : Drawing.sprites[spriteName];

                m_ConversationController.Add(new[]
                {
                    new ChatMessage
                    {
                        noBubble = data.noBubble,
                        message  = spriteName != null ? "" : data.text, image = sprite,
                        self     = self
                    }
                });
            }

            // This is definitely no longer the first message.
            dialogue.first = false;

            // Show the choices if there are any to show AND we're not awaiting an input
            if (data.choices?.Count == 0 && dataRiddle == null)
            {
                dialogueContinue?.OnNext(data);
            }
            else if (data.choices?.Count > 0 && dataRiddle == null)
            {
                m_ChatBoxController.responses.Clear();
                if (dialogue.suppressChoices)
                {
                    dialogue.suppressChoices = false;
                }
                else
                {
                    foreach (var choice in data.choices)
                    {
                        m_ChatBoxController.responses.Add(choice.text);
                    }
                }
            }
        }
Example #29
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // handle respawn
        if (other.tag == "Book")
        {
            print("player collided with book");
            addBook(other.name);
//			numBooks++;
//			numBooksCollected.text = "Books: " + numBooks + "/" + maxBooks;

            //BookScript.bookControl.updateBookTracker();

            collectSound.Play();

            other.GetComponent <SpriteRenderer> ().enabled = false;
            other.GetComponent <BoxCollider2D> ().enabled  = false;

            //currBook = other.GetComponent<BookScript> ();


            wordDisplay.text = BookScript.bookControl.pickWord();               //Should take word from book


            Destroy(other.gameObject, 1);

            Time.timeScale = 0.0f;
        }
        if (other.tag == "Door")
        {
            if (BookScript.bookControl.numBooksCheck())
            {
//				if (Input.GetKeyDown(KeyCode.UpArrow)) {
                //ReviewScript.updateReviewNum();
                //ReviewScript.reviewNum++;
                BookScript.bookControl.setReviewWords();
                Debug.Log("Going to review for Level 1");
                SceneManager.LoadScene("Review1");
//				}
            }
        }

        if (other.tag == "Door2")
        {
            if (BossHealthBar.current == 0)
            {
                EventHitBuilder eventHitBuilder = new EventHitBuilder();
                eventHitBuilder.SetEventCategory("LevelReached");
                eventHitBuilder.SetEventLabel("");
                eventHitBuilder.SetEventValue(2);
                string playerName = PlayerPrefs.GetString("CurrentPlayer");
                if (playerName != null)
                {
                    eventHitBuilder.SetEventAction(playerName);
                }
                else
                {
                    eventHitBuilder.SetEventAction("No name");
                }
                googleAnalytics.LogEvent(eventHitBuilder);

                /*
                 * Category -- LevelReached
                 * Action --name (e.g. [email protected])
                 * Label -- blank
                 * Value -- level #
                 *
                 * googleAnalytics.LogEvent (new EventHitBuilder ()
                 *      .SetEventCategory ("LevelReached")
                 *      .SetEventAction (EnterNameScript.Instance.Name)
                 *      .SetEventLabel ("")
                 *      .SetEventValue (2)); //When we create mode for game, it should be entered HERE
                 */


                SceneManager.LoadScene("Level2");
            }
        }

        if (other.tag == "Door3")
        {
            if (BossHealthBar.current == 0)
            {
                EventHitBuilder eventHitBuilder = new EventHitBuilder();
                eventHitBuilder.SetEventCategory("LevelReached");
                eventHitBuilder.SetEventLabel("");
                eventHitBuilder.SetEventValue(3);
                string playerName = PlayerPrefs.GetString("CurrentPlayer");
                if (playerName != null)
                {
                    eventHitBuilder.SetEventAction(playerName);
                }
                else
                {
                    eventHitBuilder.SetEventAction("No name");
                }
                googleAnalytics.LogEvent(eventHitBuilder);


                /*
                 *      googleAnalytics.LogEvent (new EventHitBuilder ()
                 *              .SetEventCategory ("LevelReached")
                 *              .SetEventAction (EnterNameScript.Instance.Name)
                 *              .SetEventLabel ("")
                 *              .SetEventValue (3)); //When we create mode for game, it should be entered HERE
                 */
                SceneManager.LoadScene("Level3");
            }
        }


        if (other.tag == "Door4")
        {
            if (BossHealthBar.current == 0)
            {
                EventHitBuilder eventHitBuilder = new EventHitBuilder();
                eventHitBuilder.SetEventCategory("Won");
                eventHitBuilder.SetEventLabel("");
                //eventHitBuilder.SetEventValue (2);
                string playerName = PlayerPrefs.GetString("CurrentPlayer");
                if (playerName != null)
                {
                    eventHitBuilder.SetEventAction(playerName);
                }
                else
                {
                    eventHitBuilder.SetEventAction("No name");
                }
                googleAnalytics.LogEvent(eventHitBuilder);

                SceneManager.LoadScene("Win");
            }
        }
        if (other.tag == "KillPlane")
        {
            //	gameObject.SetActive (false);
            transform.position = respawnPosition;
            health.changeBar(5);
        }

        if (other.tag == "Checkpoint")
        {
            respawnPosition = other.transform.position;
        }
    }
    internal void LogEvent(EventHitBuilder builder)
    {
        using (AndroidJavaObject valueObj = new AndroidJavaObject (
        "java.lang.Long", builder.GetEventValue())) {
          object[] args = new object[4];
          args[0] = builder.GetEventCategory();
          args[1] = builder.GetEventAction();
          args[2] = builder.GetEventLabel();
          args[3] = valueObj;

          object map;
          Dictionary<AndroidJavaObject, string> parameters = AddCustomVariablesAndCampaignParameters(builder);
          if (parameters != null) {
        map = BuildMap(GoogleAnalyticsV3.EVENT_HIT, args, parameters);
          } else {
        map = BuildMap(GoogleAnalyticsV3.EVENT_HIT, args);
          }
          tracker.Call (GoogleAnalyticsV3.SEND, map);
        }
    }