3
3
using ReadyPlayerMe . Core . Editor ;
4
4
using UnityEditor ;
5
5
using UnityEngine ;
6
+ using static ReadyPlayerMe . Core . Analytics . Constants ;
6
7
7
8
namespace ReadyPlayerMe . Core . Analytics
8
9
{
@@ -59,190 +60,200 @@ public void LogOpenProject()
59
60
{
60
61
if ( ! isEnabled ) return ;
61
62
GenerateSessionId ( ) ;
62
- AmplitudeEventLogger . LogEvent ( Constants . EventName . OPEN_PROJECT ) ;
63
+ AmplitudeEventLogger . LogEvent ( EventName . OPEN_PROJECT ) ;
63
64
}
64
65
65
66
public void LogCloseProject ( )
66
67
{
67
- LogEvent ( Constants . EventName . CLOSE_PROJECT ) ;
68
+ LogEvent ( EventName . CLOSE_PROJECT ) ;
68
69
}
69
70
70
71
public void LogOpenDocumentation ( string target )
71
72
{
72
- LogEvent ( Constants . EventName . OPEN_DOCUMENTATION , new Dictionary < string , object >
73
+ LogEvent ( EventName . OPEN_DOCUMENTATION , new Dictionary < string , object >
73
74
{
74
- { Constants . Properties . TARGET , target }
75
+ { Properties . TARGET , target }
75
76
} ) ;
76
77
}
77
78
78
79
public void LogOpenFaq ( string target )
79
80
{
80
- LogEvent ( Constants . EventName . OPEN_FAQ , new Dictionary < string , object >
81
+ LogEvent ( EventName . OPEN_FAQ , new Dictionary < string , object >
81
82
{
82
- { Constants . Properties . TARGET , target }
83
+ { Properties . TARGET , target }
83
84
} ) ;
84
85
}
85
86
86
87
public void LogOpenDiscord ( string target )
87
88
{
88
- LogEvent ( Constants . EventName . OPEN_DISCORD , new Dictionary < string , object >
89
+ LogEvent ( EventName . OPEN_DISCORD , new Dictionary < string , object >
89
90
{
90
- { Constants . Properties . TARGET , target }
91
+ { Properties . TARGET , target }
91
92
} ) ;
92
93
}
93
94
94
95
public void LogLoadAvatarFromDialog ( string avatarUrl , bool eyeAnimation , bool voiceHandler )
95
96
{
96
- LogEvent ( Constants . EventName . LOAD_AVATAR_FROM_DIALOG , new Dictionary < string , object >
97
+ LogEvent ( EventName . LOAD_AVATAR_FROM_DIALOG , new Dictionary < string , object >
97
98
{
98
- { Constants . Properties . AVATAR_URL , avatarUrl } ,
99
- { Constants . Properties . EYE_ANIMATION , eyeAnimation } ,
100
- { Constants . Properties . VOICE_HANDLER , voiceHandler }
99
+ { Properties . AVATAR_URL , avatarUrl } ,
100
+ { Properties . EYE_ANIMATION , eyeAnimation } ,
101
+ { Properties . VOICE_HANDLER , voiceHandler }
101
102
} ) ;
102
103
}
103
104
104
105
public void LogUpdatePartnerURL ( string previousSubdomain , string newSubdomain )
105
106
{
106
- LogEvent ( Constants . EventName . UPDATED_PARTNER_URL , new Dictionary < string , object >
107
+ LogEvent ( EventName . UPDATED_PARTNER_URL , new Dictionary < string , object >
107
108
{
108
- { Constants . Properties . PREVIOUS_SUBDOMAIN , previousSubdomain } ,
109
- { Constants . Properties . NEW_SUBDOMAIN , newSubdomain }
109
+ { Properties . PREVIOUS_SUBDOMAIN , previousSubdomain } ,
110
+ { Properties . NEW_SUBDOMAIN , newSubdomain }
110
111
} , new Dictionary < string , object >
111
112
{
112
- { Constants . Properties . SUBDOMAIN , newSubdomain }
113
+ { Properties . SUBDOMAIN , newSubdomain }
113
114
} ) ;
114
115
}
115
116
116
117
public void LogOpenDialog ( string dialog )
117
118
{
118
- LogEvent ( Constants . EventName . OPEN_DIALOG , new Dictionary < string , object >
119
+ LogEvent ( EventName . OPEN_DIALOG , new Dictionary < string , object >
119
120
{
120
- { Constants . Properties . DIALOG , dialog }
121
+ { Properties . DIALOG , dialog }
121
122
} ) ;
122
123
}
123
-
124
+
124
125
public void LogBuildApplication ( string target , string appName , bool productionBuild )
125
126
{
126
- LogEvent ( Constants . EventName . BUILD_APPLICATION , new Dictionary < string , object >
127
+ LogEvent ( EventName . BUILD_APPLICATION , new Dictionary < string , object >
127
128
{
128
- { Constants . Properties . TARGET , target } ,
129
- { Constants . Properties . APP_NAME , appName } ,
130
- { Constants . Properties . PRODUCTION_BUILD , productionBuild } ,
131
- { Constants . Properties . APP_IDENTIFIER , Application . identifier }
129
+ { Properties . TARGET , target } ,
130
+ { Properties . APP_NAME , appName } ,
131
+ { Properties . PRODUCTION_BUILD , productionBuild } ,
132
+ { Properties . APP_IDENTIFIER , Application . identifier }
132
133
} ) ;
133
134
}
134
135
135
136
public void LogMetadataDownloaded ( double duration )
136
137
{
137
- LogEvent ( Constants . EventName . METADATA_DOWNLOADED , new Dictionary < string , object >
138
+ LogEvent ( EventName . METADATA_DOWNLOADED , new Dictionary < string , object >
138
139
{
139
- { Constants . Properties . DURATION , duration }
140
+ { Properties . DURATION , duration }
140
141
} ) ;
141
142
}
142
143
143
144
public void LogAvatarLoaded ( double duration )
144
145
{
145
- LogEvent ( Constants . EventName . AVATAR_LOADED , new Dictionary < string , object >
146
+ LogEvent ( EventName . AVATAR_LOADED , new Dictionary < string , object >
146
147
{
147
- { Constants . Properties . DURATION , duration }
148
+ { Properties . DURATION , duration }
148
149
} ) ;
149
150
}
150
151
151
152
public void LogCheckForUpdates ( )
152
153
{
153
- LogEvent ( Constants . EventName . CHECK_FOR_UPDATES ) ;
154
+ LogEvent ( EventName . CHECK_FOR_UPDATES ) ;
154
155
}
155
156
156
157
public void LogSetLoggingEnabled ( bool isLoggingEnabled )
157
158
{
158
- LogEvent ( Constants . EventName . SET_LOGGING_ENABLED , new Dictionary < string , object >
159
+ LogEvent ( EventName . SET_LOGGING_ENABLED , new Dictionary < string , object >
159
160
{
160
- { Constants . Properties . LOGGING_ENABLED , isLoggingEnabled }
161
+ { Properties . LOGGING_ENABLED , isLoggingEnabled }
161
162
} ) ;
162
163
}
163
164
164
165
public void LogSetCachingEnabled ( bool isCachingEnabled )
165
166
{
166
- LogEvent ( Constants . EventName . SET_CACHING_ENABLED , new Dictionary < string , object >
167
+ LogEvent ( EventName . SET_CACHING_ENABLED , new Dictionary < string , object >
167
168
{
168
- { Constants . Properties . CACHING_ENABLED , isCachingEnabled }
169
+ { Properties . CACHING_ENABLED , isCachingEnabled }
169
170
} ) ;
170
171
}
171
172
172
173
public void LogClearLocalCache ( )
173
174
{
174
- LogEvent ( Constants . EventName . CLEAR_LOCAL_CACHE ) ;
175
+ LogEvent ( EventName . CLEAR_LOCAL_CACHE ) ;
175
176
}
176
177
177
178
public void LogViewPrivacyPolicy ( )
178
179
{
179
- LogEvent ( Constants . EventName . PRIVACY_POLICY ) ;
180
+ LogEvent ( EventName . PRIVACY_POLICY ) ;
180
181
}
181
182
182
183
public void LogShowInExplorer ( )
183
184
{
184
- LogEvent ( Constants . EventName . SHOW_IN_EXPLORER ) ;
185
+ LogEvent ( EventName . SHOW_IN_EXPLORER ) ;
185
186
}
186
187
187
188
public void LogFindOutMore ( HelpSubject subject )
188
189
{
189
- LogEvent ( Constants . EventName . FIND_OUT_MORE , new Dictionary < string , object >
190
+ LogEvent ( EventName . FIND_OUT_MORE , new Dictionary < string , object >
190
191
{
191
- { Constants . Properties . CONTEXT , helpDataMap [ subject ] }
192
+ { Properties . CONTEXT , helpDataMap [ subject ] }
192
193
} ) ;
193
194
}
194
195
195
196
public void LogOpenSetupGuide ( )
196
197
{
197
- LogEvent ( Constants . EventName . OPEN_SETUP_GUIDE ) ;
198
+ LogEvent ( EventName . OPEN_SETUP_GUIDE ) ;
198
199
}
199
200
200
201
public void LogOpenIntegrationGuide ( )
201
202
{
202
- LogEvent ( Constants . EventName . OPEN_INTEGRATION_GUIDE ) ;
203
+ LogEvent ( EventName . OPEN_INTEGRATION_GUIDE ) ;
203
204
}
204
205
205
206
public void LogLoadQuickStartScene ( )
206
207
{
207
- LogEvent ( Constants . EventName . LOAD_QUICK_START_SCENE ) ;
208
+ LogEvent ( EventName . LOAD_QUICK_START_SCENE ) ;
208
209
}
209
210
210
211
public void LogOpenAvatarDocumentation ( )
211
212
{
212
- LogEvent ( Constants . EventName . OPEN_AVATAR_DOCUMENTATION ) ;
213
+ LogEvent ( EventName . OPEN_AVATAR_DOCUMENTATION ) ;
213
214
}
214
215
215
216
public void LogOpenAnimationDocumentation ( )
216
217
{
217
- LogEvent ( Constants . EventName . OPEN_ANIMATION_DOCUMENTATION ) ;
218
+ LogEvent ( EventName . OPEN_ANIMATION_DOCUMENTATION ) ;
218
219
}
219
220
220
221
public void LogOpenAvatarCreatorDocumentation ( )
221
222
{
222
- LogEvent ( Constants . EventName . OPEN_AVATAR_CREATOR_DOCUMENTATION ) ;
223
+ LogEvent ( EventName . OPEN_AVATAR_CREATOR_DOCUMENTATION ) ;
223
224
}
224
225
225
226
public void LogOpenOptimizationDocumentation ( )
226
227
{
227
- LogEvent ( Constants . EventName . OPEN_OPTIMIZATION_DOCUMENTATION ) ;
228
+ LogEvent ( EventName . OPEN_OPTIMIZATION_DOCUMENTATION ) ;
228
229
}
229
230
230
231
public void LogAvatarCreatorSampleImported ( )
231
232
{
232
- LogEvent ( Constants . EventName . AVATAR_CREATOR_SAMPLE_IMPORTED ) ;
233
+ LogEvent ( EventName . AVATAR_CREATOR_SAMPLE_IMPORTED ) ;
233
234
}
234
-
235
+
236
+ public void LogPackageInstalled ( string id , string name )
237
+ {
238
+ LogEvent ( EventName . INSTALL_PACKAGE , new Dictionary < string , object >
239
+ {
240
+ { "id" , id } ,
241
+ { "name" , name } ,
242
+ } ) ;
243
+ }
244
+
235
245
private void SetUserProperties ( )
236
246
{
237
247
var userProperties = new Dictionary < string , object >
238
248
{
239
- { Constants . Properties . ENGINE_VERSION , appData . UnityVersion } ,
240
- { Constants . Properties . RENDER_PIPELINE , appData . RenderPipeline } ,
241
- { Constants . Properties . SUBDOMAIN , appData . PartnerName } ,
242
- { Constants . Properties . APP_NAME , PlayerSettings . productName } ,
243
- { Constants . Properties . SDK_TARGET , SDK_TARGET } ,
244
- { Constants . Properties . APP_IDENTIFIER , Application . identifier } ,
245
- { Constants . Properties . ALLOW_ANALYTICS , true }
249
+ { Properties . SDK_SOURCE_URL , PackageManagerHelper . GetSdkPackageSourceUrl ( ) } ,
250
+ { Properties . ENGINE_VERSION , appData . UnityVersion } ,
251
+ { Properties . RENDER_PIPELINE , appData . RenderPipeline } ,
252
+ { Properties . SUBDOMAIN , appData . PartnerName } ,
253
+ { Properties . APP_NAME , PlayerSettings . productName } ,
254
+ { Properties . SDK_TARGET , SDK_TARGET } ,
255
+ { Properties . APP_IDENTIFIER , Application . identifier } ,
256
+ { Properties . ALLOW_ANALYTICS , true }
246
257
} ;
247
258
248
259
Dictionary < string , string > modules = ModuleList . GetInstalledModuleVersionDictionary ( ) ;
@@ -252,7 +263,7 @@ private void SetUserProperties()
252
263
userProperties . Add ( module . Key , module . Value ) ;
253
264
}
254
265
255
- LogEvent ( Constants . EventName . SET_USER_PROPERTIES , null , userProperties ) ;
266
+ LogEvent ( EventName . SET_USER_PROPERTIES , null , userProperties ) ;
256
267
}
257
268
258
269
private void GenerateSessionId ( )
@@ -262,24 +273,25 @@ private void GenerateSessionId()
262
273
263
274
private void ToggleAnalytics ( bool allow )
264
275
{
265
- LogEvent ( Constants . EventName . ALLOW_ANALYTICS , new Dictionary < string , object >
276
+ LogEvent ( EventName . ALLOW_ANALYTICS , new Dictionary < string , object >
266
277
{
267
- { Constants . Properties . ALLOW , allow }
278
+ { Properties . ALLOW , allow }
268
279
} , new Dictionary < string , object >
269
280
{
270
- { Constants . Properties . ENGINE_VERSION , appData . UnityVersion } ,
271
- { Constants . Properties . RENDER_PIPELINE , appData . RenderPipeline } ,
272
- { Constants . Properties . SUBDOMAIN , appData . PartnerName } ,
273
- { Constants . Properties . APP_NAME , PlayerSettings . productName } ,
274
- { Constants . Properties . SDK_TARGET , "Unity" } ,
275
- { Constants . Properties . APP_IDENTIFIER , Application . identifier } ,
276
- { Constants . Properties . ALLOW_ANALYTICS , allow }
281
+ { Properties . ENGINE_VERSION , appData . UnityVersion } ,
282
+ { Properties . RENDER_PIPELINE , appData . RenderPipeline } ,
283
+ { Properties . SUBDOMAIN , appData . PartnerName } ,
284
+ { Properties . APP_NAME , PlayerSettings . productName } ,
285
+ { Properties . SDK_TARGET , "Unity" } ,
286
+ { Properties . APP_IDENTIFIER , Application . identifier } ,
287
+ { Properties . ALLOW_ANALYTICS , allow }
277
288
} ) ;
278
289
}
279
-
290
+
280
291
private void LogEvent ( string eventName , Dictionary < string , object > eventProperties = null , Dictionary < string , object > userProperties = null )
281
292
{
282
293
if ( ! isEnabled ) return ;
294
+
283
295
AmplitudeEventLogger . LogEvent ( eventName , eventProperties , userProperties ) ;
284
296
}
285
297
}
0 commit comments