2222#endif
2323#include " countly/event.hpp"
2424#include " countly/logger_module.hpp"
25+ #include " countly/storage_module_base.hpp"
2526#include " countly/views_module.hpp"
27+ #include < countly/crash_module.hpp>
2628#include < countly/request_builder.hpp>
2729#include < countly/request_module.hpp>
28- #include < countly/crash_module.hpp>
2930
3031namespace cly {
3132class Countly : public cly ::CountlyDelegates {
3233public:
3334 Countly ();
3435
3536 ~Countly ();
37+
38+ // Returns the singleton instance of Countly
3639 static Countly &getInstance ();
3740
3841 // Do not implicitly generate the copy constructor, this is a singleton.
@@ -43,6 +46,8 @@ class Countly : public cly::CountlyDelegates {
4346
4447 void alwaysUsePost (bool value);
4548
49+ void setMaxRequestQueueSize (unsigned int requestQueueSize);
50+
4651 void setSalt (const std::string &value);
4752
4853 void setLogger (void (*fun)(LogLevel level, const std::string &message));
@@ -93,6 +98,8 @@ class Countly : public cly::CountlyDelegates {
9398
9499 void addEvent (const cly::Event &event);
95100
101+ void addEventToSqlite (const cly::Event &event);
102+
96103 void setMaxEvents (size_t value);
97104
98105 void flushEvents (std::chrono::seconds timeout = std::chrono::seconds(30 ));
@@ -179,7 +186,14 @@ class Countly : public cly::CountlyDelegates {
179186 }
180187
181188 /* Provide 'updateInterval' in seconds. */
182- inline void setAutomaticSessionUpdateInterval (unsigned short updateInterval) { configuration->sessionDuration = updateInterval; }
189+ inline void setAutomaticSessionUpdateInterval (unsigned short updateInterval) {
190+ if (is_sdk_initialized) {
191+ log (LogLevel::WARNING, " [Countly][setAutomaticSessionUpdateInterval] You can not set the session duration after SDK initialization." );
192+ return ;
193+ }
194+
195+ configuration->sessionDuration = updateInterval;
196+ }
183197
184198#ifdef COUNTLY_BUILD_TESTS
185199 /* *
@@ -188,15 +202,7 @@ class Countly : public cly::CountlyDelegates {
188202 * You should not be using this method.
189203 * @return a vector object containing events.
190204 */
191- const std::vector<std::string> debugReturnStateOfEQ () {
192-
193- #ifdef COUNTLY_USE_SQLITE
194- return {};
195- #else
196- std::vector<std::string> v (event_queue.begin (), event_queue.end ());
197- return v;
198- #endif
199- }
205+ std::vector<std::string> debugReturnStateOfEQ ();
200206
201207 /* *
202208 * This function should not be used as it will be removed in a future release.
@@ -229,6 +235,9 @@ class Countly : public cly::CountlyDelegates {
229235 void _deleteThread ();
230236 void _sendIndependantLocationRequest ();
231237 void log (LogLevel level, const std::string &message);
238+ #ifdef COUNTLY_USE_SQLITE
239+ bool createEventTableSchema ();
240+ #endif
232241
233242 /* *
234243 * Helper methods to fetch remote config from the server.
@@ -257,11 +266,12 @@ class Countly : public cly::CountlyDelegates {
257266 std::unique_ptr<std::thread> thread;
258267 std::unique_ptr<cly::CrashModule> crash_module;
259268 std::unique_ptr<cly::ViewsModule> views_module;
269+
260270 std::shared_ptr<cly::CountlyConfiguration> configuration;
261271 std::shared_ptr<cly::LoggerModule> logger;
262-
263272 std::shared_ptr<cly::RequestBuilder> requestBuilder;
264273 std::shared_ptr<cly::RequestModule> requestModule;
274+ std::shared_ptr<cly::StorageModuleBase> storageModule;
265275 std::shared_ptr<std::mutex> mutex = std::make_shared<std::mutex>();
266276
267277 bool is_queue_being_processed = false ;
0 commit comments