@@ -25,7 +25,9 @@ import { AnalyticsRouter } from './Routers/AnalyticsRouter';
2525import { ClassesRouter } from './Routers/ClassesRouter' ;
2626import { FeaturesRouter } from './Routers/FeaturesRouter' ;
2727import { InMemoryCacheAdapter } from './Adapters/Cache/InMemoryCacheAdapter' ;
28+ import { AnalyticsController } from './Controllers/AnalyticsController' ;
2829import { CacheController } from './Controllers/CacheController' ;
30+ import { AnalyticsAdapter } from './Adapters/Analytics/AnalyticsAdapter' ;
2931import { FileLoggerAdapter } from './Adapters/Logger/FileLoggerAdapter' ;
3032import { FilesController } from './Controllers/FilesController' ;
3133import { FilesRouter } from './Routers/FilesRouter' ;
@@ -65,6 +67,7 @@ const requiredUserFields = { fields: { ...SchemaController.defaultColumns._Defau
6567
6668// ParseServer works like a constructor of an express app.
6769// The args that we understand are:
70+ // "analyticsAdapter": an adapter class for analytics
6871// "filesAdapter": a class like GridStoreAdapter providing create, get,
6972// and delete
7073// "loggerAdapter": a class like FileLoggerAdapter providing info, error,
@@ -96,6 +99,7 @@ class ParseServer {
9699 appId = requiredParameter ( 'You must provide an appId!' ) ,
97100 masterKey = requiredParameter ( 'You must provide a masterKey!' ) ,
98101 appName,
102+ analyticsAdapter = undefined ,
99103 filesAdapter,
100104 push,
101105 loggerAdapter,
@@ -140,7 +144,6 @@ class ParseServer {
140144 // Initialize the node client SDK automatically
141145 Parse . initialize ( appId , javascriptKey || 'unused' , masterKey ) ;
142146 Parse . serverURL = serverURL ;
143-
144147 if ( ( databaseOptions || databaseURI || collectionPrefix !== '' ) && databaseAdapter ) {
145148 throw 'You cannot specify both a databaseAdapter and a databaseURI/databaseOptions/connectionPrefix.' ;
146149 } else if ( ! databaseAdapter ) {
@@ -184,6 +187,7 @@ class ParseServer {
184187 const loggerControllerAdapter = loadAdapter ( loggerAdapter , FileLoggerAdapter ) ;
185188 const emailControllerAdapter = loadAdapter ( emailAdapter ) ;
186189 const cacheControllerAdapter = loadAdapter ( cacheAdapter , InMemoryCacheAdapter , { appId : appId } ) ;
190+ const analyticsControllerAdapter = loadAdapter ( analyticsAdapter , AnalyticsAdapter ) ;
187191
188192 // We pass the options and the base class for the adatper,
189193 // Note that passing an instance would work too
@@ -195,6 +199,7 @@ class ParseServer {
195199 const cacheController = new CacheController ( cacheControllerAdapter , appId ) ;
196200 const databaseController = new DatabaseController ( databaseAdapter ) ;
197201 const hooksController = new HooksController ( appId , databaseController , webhookKey ) ;
202+ const analyticsController = new AnalyticsController ( analyticsControllerAdapter ) ;
198203
199204 // TODO: create indexes on first creation of a _User object. Otherwise it's impossible to
200205 // have a Parse app without it having a _User collection.
@@ -227,6 +232,7 @@ class ParseServer {
227232 webhookKey : webhookKey ,
228233 fileKey : fileKey ,
229234 facebookAppIds : facebookAppIds ,
235+ analyticsController : analyticsController ,
230236 cacheController : cacheController ,
231237 filesController : filesController ,
232238 pushController : pushController ,
0 commit comments