-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
747 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
source/Plugins/GoogleAnalyticsV3/HitBuilders/AppViewHitBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2014 Google Inc. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
using UnityEngine; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System; | ||
|
||
public class AppViewHitBuilder : HitBuilder<AppViewHitBuilder> { | ||
|
||
private string screenName = ""; | ||
|
||
public string GetScreenName() { | ||
return screenName; | ||
} | ||
|
||
public AppViewHitBuilder SetScreenName(string screenName) { | ||
if (screenName != null) { | ||
this.screenName = screenName; | ||
} | ||
return this; | ||
} | ||
|
||
public override AppViewHitBuilder GetThis() { | ||
return this; | ||
} | ||
|
||
public override AppViewHitBuilder Validate() { | ||
if (String.IsNullOrEmpty(screenName)) { | ||
Debug.Log("No screen name provided - App View hit cannot be sent."); | ||
return null; | ||
} | ||
return this; | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
source/Plugins/GoogleAnalyticsV3/HitBuilders/EventHitBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
Copyright 2014 Google Inc. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
using UnityEngine; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System; | ||
|
||
public class EventHitBuilder : HitBuilder<EventHitBuilder> { | ||
|
||
private string eventCategory = ""; | ||
private string eventAction = ""; | ||
private string eventLabel = ""; | ||
private long eventValue; | ||
|
||
public string GetEventCategory() { | ||
return eventCategory; | ||
} | ||
|
||
public EventHitBuilder SetEventCategory(string eventCategory) { | ||
if (eventCategory != null) { | ||
this.eventCategory = eventCategory; | ||
} | ||
return this; | ||
} | ||
|
||
public string GetEventAction() { | ||
return eventAction; | ||
} | ||
|
||
public EventHitBuilder SetEventAction(string eventAction) { | ||
if (eventAction != null) { | ||
this.eventAction = eventAction; | ||
} | ||
return this; | ||
} | ||
|
||
public string GetEventLabel() { | ||
return eventLabel; | ||
} | ||
|
||
public EventHitBuilder SetEventLabel(string eventLabel) { | ||
if (eventLabel != null) { | ||
this.eventLabel = eventLabel; | ||
} | ||
return this; | ||
} | ||
|
||
public long GetEventValue() { | ||
return eventValue; | ||
} | ||
|
||
public EventHitBuilder SetEventValue(long eventValue) { | ||
this.eventValue = eventValue; | ||
return this; | ||
} | ||
|
||
public override EventHitBuilder GetThis() { | ||
return this; | ||
} | ||
|
||
public override EventHitBuilder Validate() { | ||
if (String.IsNullOrEmpty(eventCategory)) { | ||
Debug.LogWarning("No event category provided - Event hit cannot be sent."); | ||
return null; | ||
} | ||
if (String.IsNullOrEmpty(eventAction)) { | ||
Debug.LogWarning("No event action provided - Event hit cannot be sent."); | ||
return null; | ||
} | ||
return this; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
source/Plugins/GoogleAnalyticsV3/HitBuilders/ExceptionHitBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Copyright 2014 Google Inc. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
using UnityEngine; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System; | ||
|
||
public class ExceptionHitBuilder : HitBuilder<ExceptionHitBuilder> { | ||
|
||
private string exceptionDescription = ""; | ||
private bool fatal = false; | ||
|
||
public string GetExceptionDescription(){ | ||
return exceptionDescription; | ||
} | ||
|
||
public ExceptionHitBuilder SetExceptionDescription(string exceptionDescription) { | ||
if(exceptionDescription != null){ | ||
this.exceptionDescription = exceptionDescription; | ||
} | ||
return this; | ||
} | ||
|
||
public bool IsFatal(){ | ||
return fatal; | ||
} | ||
|
||
public ExceptionHitBuilder SetFatal(bool fatal) { | ||
this.fatal = fatal; | ||
return this; | ||
} | ||
|
||
public override ExceptionHitBuilder GetThis(){ | ||
return this; | ||
} | ||
|
||
public override ExceptionHitBuilder Validate(){ | ||
return this; | ||
} | ||
} |
150 changes: 150 additions & 0 deletions
150
source/Plugins/GoogleAnalyticsV3/HitBuilders/HitBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
Copyright 2014 Google Inc. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
using UnityEngine; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
/* | ||
Base class for building hits. This class stores data which can be sent with | ||
any hit type but cannot be sent independent of other hits. | ||
*/ | ||
public abstract class HitBuilder<T> { | ||
|
||
private Dictionary<int, string> customDimensions = | ||
new Dictionary<int,string>(); | ||
private Dictionary<int, string> customMetrics = new Dictionary<int,string>(); | ||
|
||
private string campaignName = ""; | ||
private string campaignSource = ""; | ||
private string campaignMedium = ""; | ||
private string campaignKeyword = ""; | ||
private string campaignContent = ""; | ||
private string campaignID = ""; | ||
private string gclid = ""; | ||
private string dclid = ""; | ||
|
||
public abstract T GetThis(); | ||
public abstract T Validate(); | ||
|
||
public T SetCustomDimension(int dimensionNumber, string value) { | ||
customDimensions.Add(dimensionNumber, value); | ||
return GetThis(); | ||
} | ||
|
||
public Dictionary<int, string> GetCustomDimensions() { | ||
return customDimensions; | ||
} | ||
|
||
public T SetCustomMetric(int metricNumber, string value) { | ||
customMetrics.Add(metricNumber, value); | ||
return GetThis(); | ||
} | ||
|
||
public Dictionary<int, string> GetCustomMetrics() { | ||
return customMetrics; | ||
} | ||
|
||
public string GetCampaignName() { | ||
return campaignName; | ||
} | ||
|
||
public T SetCampaignName(string campaignName) { | ||
if (campaignName != null) { | ||
this.campaignName = campaignName; | ||
} | ||
return GetThis(); | ||
} | ||
|
||
public string GetCampaignSource() { | ||
return campaignSource; | ||
} | ||
|
||
public T SetCampaignSource(string campaignSource) { | ||
if (campaignSource != null) { | ||
this.campaignSource = campaignSource; | ||
} else { | ||
Debug.Log("Campaign source cannot be null or empty"); | ||
} | ||
return GetThis(); | ||
} | ||
|
||
public string GetCampaignMedium() { | ||
return campaignMedium; | ||
} | ||
|
||
public T SetCampaignMedium(string campaignMedium) { | ||
if (campaignMedium != null) { | ||
this.campaignMedium = campaignMedium; | ||
} | ||
return GetThis(); | ||
} | ||
|
||
public string GetCampaignKeyword() { | ||
return campaignKeyword; | ||
} | ||
|
||
public T SetCampaignKeyword(string campaignKeyword) { | ||
if (campaignKeyword != null) { | ||
this.campaignKeyword = campaignKeyword; | ||
} | ||
return GetThis(); | ||
} | ||
|
||
public string GetCampaignContent() { | ||
return campaignContent; | ||
} | ||
|
||
public T SetCampaignContent(string campaignContent) { | ||
if (campaignContent != null) { | ||
this.campaignContent = campaignContent; | ||
} | ||
return GetThis(); | ||
} | ||
|
||
public string GetCampaignID() { | ||
return campaignID; | ||
} | ||
|
||
public T SetCampaignID(string campaignID) { | ||
if (campaignID != null) { | ||
this.campaignID = campaignID; | ||
} | ||
return GetThis(); | ||
} | ||
|
||
public string GetGclid() { | ||
return gclid; | ||
} | ||
|
||
public T SetGclid(string gclid) { | ||
if (gclid != null) { | ||
this.gclid = gclid; | ||
} | ||
return GetThis(); | ||
} | ||
|
||
public string GetDclid() { | ||
return dclid; | ||
} | ||
|
||
public T SetDclid(string dclid) { | ||
if (dclid != null) { | ||
this.dclid = dclid; | ||
} | ||
return GetThis(); | ||
} | ||
} |
Oops, something went wrong.