@@ -25,7 +25,9 @@ import { AnalyticsRouter } from './Routers/AnalyticsRouter';
25
25
import { ClassesRouter } from './Routers/ClassesRouter' ;
26
26
import { FeaturesRouter } from './Routers/FeaturesRouter' ;
27
27
import { InMemoryCacheAdapter } from './Adapters/Cache/InMemoryCacheAdapter' ;
28
+ import { AnalyticsController } from './Controllers/AnalyticsController' ;
28
29
import { CacheController } from './Controllers/CacheController' ;
30
+ import { AnalyticsAdapter } from './Adapters/Analytics/AnalyticsAdapter' ;
29
31
import { FileLoggerAdapter } from './Adapters/Logger/FileLoggerAdapter' ;
30
32
import { FilesController } from './Controllers/FilesController' ;
31
33
import { FilesRouter } from './Routers/FilesRouter' ;
@@ -65,6 +67,7 @@ const requiredUserFields = { fields: { ...SchemaController.defaultColumns._Defau
65
67
66
68
// ParseServer works like a constructor of an express app.
67
69
// The args that we understand are:
70
+ // "analyticsAdapter": an adapter class for analytics
68
71
// "filesAdapter": a class like GridStoreAdapter providing create, get,
69
72
// and delete
70
73
// "loggerAdapter": a class like FileLoggerAdapter providing info, error,
@@ -96,6 +99,7 @@ class ParseServer {
96
99
appId = requiredParameter ( 'You must provide an appId!' ) ,
97
100
masterKey = requiredParameter ( 'You must provide a masterKey!' ) ,
98
101
appName,
102
+ analyticsAdapter = undefined ,
99
103
filesAdapter,
100
104
push,
101
105
loggerAdapter,
@@ -140,7 +144,6 @@ class ParseServer {
140
144
// Initialize the node client SDK automatically
141
145
Parse . initialize ( appId , javascriptKey || 'unused' , masterKey ) ;
142
146
Parse . serverURL = serverURL ;
143
-
144
147
if ( ( databaseOptions || databaseURI || collectionPrefix !== '' ) && databaseAdapter ) {
145
148
throw 'You cannot specify both a databaseAdapter and a databaseURI/databaseOptions/connectionPrefix.' ;
146
149
} else if ( ! databaseAdapter ) {
@@ -184,6 +187,7 @@ class ParseServer {
184
187
const loggerControllerAdapter = loadAdapter ( loggerAdapter , FileLoggerAdapter ) ;
185
188
const emailControllerAdapter = loadAdapter ( emailAdapter ) ;
186
189
const cacheControllerAdapter = loadAdapter ( cacheAdapter , InMemoryCacheAdapter , { appId : appId } ) ;
190
+ const analyticsControllerAdapter = loadAdapter ( analyticsAdapter , AnalyticsAdapter ) ;
187
191
188
192
// We pass the options and the base class for the adatper,
189
193
// Note that passing an instance would work too
@@ -195,6 +199,7 @@ class ParseServer {
195
199
const cacheController = new CacheController ( cacheControllerAdapter , appId ) ;
196
200
const databaseController = new DatabaseController ( databaseAdapter ) ;
197
201
const hooksController = new HooksController ( appId , databaseController , webhookKey ) ;
202
+ const analyticsController = new AnalyticsController ( analyticsControllerAdapter ) ;
198
203
199
204
// TODO: create indexes on first creation of a _User object. Otherwise it's impossible to
200
205
// have a Parse app without it having a _User collection.
@@ -227,6 +232,7 @@ class ParseServer {
227
232
webhookKey : webhookKey ,
228
233
fileKey : fileKey ,
229
234
facebookAppIds : facebookAppIds ,
235
+ analyticsController : analyticsController ,
230
236
cacheController : cacheController ,
231
237
filesController : filesController ,
232
238
pushController : pushController ,
0 commit comments