Skip to content

Commit cb07005

Browse files
committed
Merge pull request googleanalytics#111 from shazow/master
Update source to include latest changes in V4 unitypackage
2 parents 6e1cdf5 + 6209b33 commit cb07005

26 files changed

+3178
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2014 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
@CustomPropertyDrawer(AdvertiserOptInAttribute)
18+
class AdvertiserOptInDrawer extends PropertyDrawer {
19+
20+
function OnGUI(position : Rect, property : SerializedProperty, label : GUIContent) {
21+
22+
// TODO: I don't like this, but guilayout was not cooperating, revisit later.
23+
var indent = 25;
24+
var row1 = position.y + 15;
25+
var row2 = row1 + 25;
26+
var row3 = row2 + 85;
27+
28+
EditorGUI.LabelField(Rect(position.x, row1, 155, 25), "Advertiser Id Support");
29+
30+
var style = new GUIStyle(EditorStyles.textArea);
31+
style.wordWrap = true;
32+
33+
EditorGUI.TextArea(Rect(position.x+indent, row2, position.width - 40, 75), "If you enable this collection, ensure that you review and adhere to the Google Analytics policies for SDKs and advertising features. Click the button below to view them in your browser.", style);
34+
EditorGUI.LabelField(Rect(position.x+indent, row3, 155, 25), "Send IDFA/AdID");
35+
EditorGUI.PropertyField(Rect(position.x+125, row3, 15, 25), property, GUIContent.none);
36+
37+
if(GUI.Button(Rect(position.x+150, row3 - 5, 115, 25), "View GA Policies")) {
38+
Application.OpenURL("https://support.google.com/analytics/answer/2700409");
39+
}
40+
}
41+
42+
function GetPropertyHeight (property : SerializedProperty, label : GUIContent) {
43+
var height = EditorGUI.GetPropertyHeight(property, label);
44+
return height + 140;
45+
}
46+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2015 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
using UnityEngine;
18+
using UnityEditor;
19+
using System.Collections;
20+
using System.IO;
21+
22+
public class GoogleAnalyticsSetup : EditorWindow {
23+
[MenuItem("Google Analytics/Setup")]
24+
public static void GoogleAnalyticsSetupMenu() {
25+
EditorWindow.GetWindow(typeof(GoogleAnalyticsSetup));
26+
}
27+
28+
void OnGUI() {
29+
GUILayout.BeginArea(new Rect(20, 20, position.width - 40, position.height - 40));
30+
GUILayout.Label("Google Analytics Android Setup", EditorStyles.boldLabel);
31+
GUILayout.TextArea("Click the button below to copy the Google Play Services lib from your Android directory into your current project.\n\nThis will delete the existing version of the library if you have already imported it.");
32+
33+
GUILayout.Space(10);
34+
if (GUILayout.Button("Install google-play-services_lib")) {
35+
InstallPlayServicesLib();
36+
}
37+
GUILayout.EndArea();
38+
}
39+
40+
private void InstallPlayServicesLib() {
41+
string src = EditorPrefs.GetString("AndroidSdkRoot") +
42+
"/extras/google/google_play_services/libproject/google-play-services_lib".Replace("//", "/").Replace("\\\\", "\\");
43+
string dest = "Assets/Plugins/Android/google-play-services_lib";
44+
45+
if (!System.IO.Directory.Exists(src)) {
46+
Debug.LogError("Could not locate google-play-services_lib in: " + src);
47+
EditorUtility.DisplayDialog("Lib not found", "Could not locate google-play-services_lib\n\nPlease ensure you have specified the correct path to your Android SDK and have downloaded the Google Play Services library.", "OK");
48+
return;
49+
}
50+
51+
System.IO.Directory.CreateDirectory("Assets/Plugins/Android");
52+
53+
if (System.IO.Directory.Exists(dest)) {
54+
System.IO.Directory.Delete(dest, true);
55+
}
56+
57+
FileUtil.CopyFileOrDirectory(src, dest);
58+
AssetDatabase.Refresh();
59+
EditorUtility.DisplayDialog("Congrats", "Google Play Services has been copied into your project.", "OK");
60+
}
61+
}

source/Plugins/Editor/TooltipDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
103103
}
104104

105105
#endif
106-
}
106+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2014 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
using UnityEngine;
18+
19+
public class AdvertiserOptInAttribute : PropertyAttribute {
20+
public AdvertiserOptInAttribute() {
21+
}
22+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright 2014 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
using UnityEngine;
18+
19+
/*
20+
Ranged Tooltip attribute for displaying properties with range and
21+
a tooltip in the inspector.
22+
*/
23+
public class RangedTooltipAttribute : PropertyAttribute {
24+
public readonly float min;
25+
public readonly float max;
26+
public readonly string text;
27+
28+
public RangedTooltipAttribute(string text, float min, float max) {
29+
this.text = text;
30+
this.min = min;
31+
this.max = max;
32+
}
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2014 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
using UnityEngine;
18+
19+
/*
20+
Tooltip attribute for displaying Tooltips in the inspector.
21+
*/
22+
public class TooltipAttribute : PropertyAttribute {
23+
public readonly string text;
24+
25+
public TooltipAttribute(string text) {
26+
this.text = text;
27+
}
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright 2014 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
public class Field {
18+
19+
private readonly string parameter;
20+
21+
public Field(string parameter){
22+
this.parameter = parameter;
23+
}
24+
25+
public override string ToString(){
26+
return parameter;
27+
}
28+
29+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
Copyright 2014 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
using UnityEngine;
18+
using System.Collections;
19+
20+
/*
21+
Available fields to use with SetOnTracker(Field fieldName, object value)
22+
*/
23+
public class Fields {
24+
25+
//General
26+
public readonly static Field ANONYMIZE_IP = new Field("&aip");
27+
public readonly static Field HIT_TYPE = new Field("&t");
28+
public readonly static Field SESSION_CONTROL = new Field("&sc");
29+
30+
public readonly static Field SCREEN_NAME = new Field("&cd");
31+
public readonly static Field LOCATION = new Field("&dl");
32+
public readonly static Field REFERRER = new Field("&dr");
33+
public readonly static Field PAGE = new Field("&dp");
34+
public readonly static Field HOSTNAME = new Field("&dh");
35+
public readonly static Field TITLE = new Field("&dt");
36+
public readonly static Field LANGUAGE = new Field("&ul");
37+
public readonly static Field ENCODING = new Field("&de");
38+
39+
// System
40+
public readonly static Field SCREEN_COLORS = new Field("&sd");
41+
public readonly static Field SCREEN_RESOLUTION = new Field("&sr");
42+
public readonly static Field VIEWPORT_SIZE = new Field("&vp");
43+
44+
// Application
45+
public readonly static Field APP_NAME = new Field("&an");
46+
public readonly static Field APP_ID = new Field("&aid");
47+
public readonly static Field APP_INSTALLER_ID = new Field("&aiid");
48+
public readonly static Field APP_VERSION = new Field("&av");
49+
50+
// Visitor
51+
public readonly static Field CLIENT_ID = new Field("&cid");
52+
public readonly static Field USER_ID = new Field("&uid");
53+
54+
// Campaign related fields; used in all hits.
55+
public readonly static Field CAMPAIGN_NAME = new Field("&cn");
56+
public readonly static Field CAMPAIGN_SOURCE = new Field("&cs");
57+
public readonly static Field CAMPAIGN_MEDIUM = new Field("&cm");
58+
public readonly static Field CAMPAIGN_KEYWORD = new Field("&ck");
59+
public readonly static Field CAMPAIGN_CONTENT = new Field("&cc");
60+
public readonly static Field CAMPAIGN_ID = new Field("&ci");
61+
// Autopopulated campaign fields
62+
public readonly static Field GCLID = new Field("&gclid");
63+
public readonly static Field DCLID = new Field("&dclid");
64+
65+
66+
// Event Hit (&t=event)
67+
public readonly static Field EVENT_CATEGORY = new Field("&ec");
68+
public readonly static Field EVENT_ACTION = new Field("&ea");
69+
public readonly static Field EVENT_LABEL = new Field("&el");
70+
public readonly static Field EVENT_VALUE = new Field("&ev");
71+
72+
// Social Hit (&t=social)
73+
public readonly static Field SOCIAL_NETWORK = new Field("&sn");
74+
public readonly static Field SOCIAL_ACTION = new Field("&sa");
75+
public readonly static Field SOCIAL_TARGET = new Field("&st");
76+
77+
// Timing Hit (&t=timing)
78+
public readonly static Field TIMING_VAR = new Field("&utv");
79+
public readonly static Field TIMING_VALUE = new Field("&utt");
80+
public readonly static Field TIMING_CATEGORY = new Field("&utc");
81+
public readonly static Field TIMING_LABEL = new Field("&utl");
82+
83+
84+
// Exception Hit (&t=exception)
85+
public readonly static Field EX_DESCRIPTION = new Field("&exd");
86+
public readonly static Field EX_FATAL = new Field("&exf");
87+
88+
// Ecommerce (&t=transaction / &t=item)
89+
public readonly static Field CURRENCY_CODE = new Field("&cu");
90+
public readonly static Field TRANSACTION_ID = new Field("&ti");
91+
public readonly static Field TRANSACTION_AFFILIATION = new Field("&ta");
92+
public readonly static Field TRANSACTION_SHIPPING = new Field("&ts");
93+
public readonly static Field TRANSACTION_TAX = new Field("&tt");
94+
public readonly static Field TRANSACTION_REVENUE = new Field("&tr");
95+
public readonly static Field ITEM_SKU = new Field("&ic");
96+
public readonly static Field ITEM_NAME = new Field("&in");
97+
public readonly static Field ITEM_CATEGORY = new Field("&iv");
98+
public readonly static Field ITEM_PRICE = new Field("&ip");
99+
public readonly static Field ITEM_QUANTITY = new Field("&iq");
100+
101+
// General Configuration
102+
public readonly static Field TRACKING_ID = new Field("&tid");
103+
public readonly static Field SAMPLE_RATE = new Field("&sf");
104+
public readonly static Field DEVELOPER_ID = new Field("&did");
105+
106+
public readonly static Field CUSTOM_METRIC = new Field("&cm");
107+
public readonly static Field CUSTOM_DIMENSION = new Field("&cd");
108+
109+
// Advertiser Id Fields
110+
public readonly static Field ADID = new Field("&adid");
111+
public readonly static Field IDFA = new Field("&idfa");
112+
public readonly static Field ATE = new Field("&ate");
113+
}

0 commit comments

Comments
 (0)