From 68ee3676be6c2e3f629c199481449c71a11ea231 Mon Sep 17 00:00:00 2001 From: turtledreams Date: Thu, 24 Aug 2023 20:19:47 +0900 Subject: [PATCH] added log namespace as [Countly] --- lib/countly.js | 550 ++++++++++++++++++++++++------------------------- 1 file changed, 275 insertions(+), 275 deletions(-) diff --git a/lib/countly.js b/lib/countly.js index c11fc815..0dfbcb91 100644 --- a/lib/countly.js +++ b/lib/countly.js @@ -312,7 +312,7 @@ if (maxCrashLogs && !this.maxBreadcrumbCount) { this.maxBreadcrumbCount = maxCrashLogs; - log(logLevelEnums.WARNING, "initialize, 'maxCrashLogs' is deprecated. Use 'maxBreadcrumbCount' instead!"); + log(logLevelEnums.WARNING, "[Initialization] 'maxCrashLogs' is deprecated. Use 'maxBreadcrumbCount' instead!"); } else if (!maxCrashLogs && !this.maxBreadcrumbCount) { this.maxBreadcrumbCount = 100; @@ -323,7 +323,7 @@ } if (!this.rcAutoOptinAb && !this.useExplicitRcApi) { - log(logLevelEnums.WARNING, "initialize, Auto opting is disabled, switching to explicit RC API"); + log(logLevelEnums.WARNING, "[Initialization] Auto opting is disabled, switching to explicit RC API"); this.useExplicitRcApi = true; } @@ -332,7 +332,7 @@ } if (this.url === "") { - log(logLevelEnums.ERROR, "initialize, Please provide server URL"); + log(logLevelEnums.ERROR, "[Initialization] Please provide server URL"); this.ignore_visitor = true; } if (getValueFromStorage("cly_ignore")) { @@ -350,10 +350,10 @@ // retrieve stored device ID and type from local storage and use it to flush existing events if (getValueFromStorage("cly_id") && !tempIdModeWasEnabled) { this.device_id = getValueFromStorage("cly_id"); - log(logLevelEnums.DEBUG, "initialize, temporarily using the previous device ID to flush existing events"); + log(logLevelEnums.DEBUG, "[Initialization] temporarily using the previous device ID to flush existing events"); deviceIdType = getValueFromStorage("cly_id_type"); if (!deviceIdType) { - log(logLevelEnums.DEBUG, "initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED, for event flushing"); + log(logLevelEnums.DEBUG, "[Initialization] No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED, for event flushing"); deviceIdType = DeviceIdTypeInternalEnums.DEVELOPER_SUPPLIED; } sendEventsForced(); @@ -362,7 +362,7 @@ deviceIdType = DeviceIdTypeInternalEnums.SDK_GENERATED; } // then clear the storage so that a new device ID is set again later - log(logLevelEnums.INFO, "initialize, Clearing the device ID storage"); + log(logLevelEnums.INFO, "[Initialization] Clearing the device ID storage"); localStorage.removeItem(this.app_key + "/cly_id"); localStorage.removeItem(this.app_key + "/cly_id_type"); localStorage.removeItem(this.app_key + "/cly_session"); @@ -375,7 +375,7 @@ this.passed_data = JSON.parse(window.name.replace("cly:", "")); } catch (ex) { - log(logLevelEnums.ERROR, "initialize, Could not parse name: " + window.name + ", error: " + ex); + log(logLevelEnums.ERROR, "[Initialization] Could not parse name: " + window.name + ", error: " + ex); } } else if (location.hash && location.hash.indexOf("#cly:") === 0) { @@ -383,7 +383,7 @@ this.passed_data = JSON.parse(location.hash.replace("#cly:", "")); } catch (ex) { - log(logLevelEnums.ERROR, "initialize, Could not parse hash: " + location.hash + ", error: " + ex); + log(logLevelEnums.ERROR, "[Initialization] Could not parse hash: " + location.hash + ", error: " + ex); } } @@ -417,139 +417,139 @@ } if (this.ignore_visitor) { - log(logLevelEnums.WARNING, "initialize, ignore_visitor:[" + this.ignore_visitor + "], this user will not be tracked"); + log(logLevelEnums.WARNING, "[Initialization] ignore_visitor:[" + this.ignore_visitor + "], this user will not be tracked"); return; } // init configuration is printed out here: // key values should be printed out as is - log(logLevelEnums.DEBUG, "initialize, app_key:[" + this.app_key + "], url:[" + this.url + "]"); - log(logLevelEnums.DEBUG, "initialize, device_id:[" + getConfig("device_id", ob, undefined) + "]"); - log(logLevelEnums.DEBUG, "initialize, require_consent is enabled:[" + this.require_consent + "]"); + log(logLevelEnums.DEBUG, "[Initialization] app_key:[" + this.app_key + "], url:[" + this.url + "]"); + log(logLevelEnums.DEBUG, "[Initialization] device_id:[" + getConfig("device_id", ob, undefined) + "]"); + log(logLevelEnums.DEBUG, "[Initialization] require_consent is enabled:[" + this.require_consent + "]"); try { - log(logLevelEnums.DEBUG, "initialize, metric override:[" + JSON.stringify(this.metrics) + "]"); - log(logLevelEnums.DEBUG, "initialize, header override:[" + JSON.stringify(this.headers) + "]"); + log(logLevelEnums.DEBUG, "[Initialization] metric override:[" + JSON.stringify(this.metrics) + "]"); + log(logLevelEnums.DEBUG, "[Initialization] header override:[" + JSON.stringify(this.headers) + "]"); // empty array is truthy and so would be printed if provided - log(logLevelEnums.DEBUG, "initialize, number of onload callbacks provided:[" + this.onload.length + "]"); + log(logLevelEnums.DEBUG, "[Initialization] number of onload callbacks provided:[" + this.onload.length + "]"); // if the utm object is different to default utm object print it here - log(logLevelEnums.DEBUG, "initialize, utm tags:[" + JSON.stringify(this.utm) + "]"); + log(logLevelEnums.DEBUG, "[Initialization] utm tags:[" + JSON.stringify(this.utm) + "]"); // empty array printed if non provided if (ignoreReferrers) { - log(logLevelEnums.DEBUG, "initialize, referrers to ignore :[" + JSON.stringify(ignoreReferrers) + "]"); + log(logLevelEnums.DEBUG, "[Initialization] referrers to ignore :[" + JSON.stringify(ignoreReferrers) + "]"); } } catch (e) { - log(logLevelEnums.ERROR, "initialize, Could not stringify some config object values"); + log(logLevelEnums.ERROR, "[Initialization] Could not stringify some config object values"); } - log(logLevelEnums.DEBUG, "initialize, app_version:[" + this.app_version + "]"); + log(logLevelEnums.DEBUG, "[Initialization] app_version:[" + this.app_version + "]"); // location info printed here - log(logLevelEnums.DEBUG, "initialize, provided location info; country_code:[" + this.country_code + "], city:[" + this.city + "], ip_address:[" + this.ip_address + "]"); + log(logLevelEnums.DEBUG, "[Initialization] provided location info; country_code:[" + this.country_code + "], city:[" + this.city + "], ip_address:[" + this.ip_address + "]"); // print non vital values only if provided by the developer or differs from the default value if (this.namespace !== "") { - log(logLevelEnums.DEBUG, "initialize, namespace given:[" + this.namespace + "]"); + log(logLevelEnums.DEBUG, "[Initialization] namespace given:[" + this.namespace + "]"); } if (this.clearStoredId) { - log(logLevelEnums.DEBUG, "initialize, clearStoredId flag set to:[" + this.clearStoredId + "]"); + log(logLevelEnums.DEBUG, "[Initialization] clearStoredId flag set to:[" + this.clearStoredId + "]"); } if (this.ignore_prefetch) { - log(logLevelEnums.DEBUG, "initialize, ignoring pre-fetching and pre-rendering from counting as real website visits :[" + this.ignore_prefetch + "]"); + log(logLevelEnums.DEBUG, "[Initialization] ignoring pre-fetching and pre-rendering from counting as real website visits :[" + this.ignore_prefetch + "]"); } // if test mode is enabled warn the user if (this.test_mode) { - log(logLevelEnums.WARNING, "initialize, test_mode:[" + this.test_mode + "], request queue won't be processed"); + log(logLevelEnums.WARNING, "[Initialization] test_mode:[" + this.test_mode + "], request queue won't be processed"); } if (this.test_mode_eq) { - log(logLevelEnums.WARNING, "initialize, test_mode_eq:[" + this.test_mode_eq + "], event queue won't be processed"); + log(logLevelEnums.WARNING, "[Initialization] test_mode_eq:[" + this.test_mode_eq + "], event queue won't be processed"); } // if test mode is enabled warn the user if (this.heatmapWhitelist) { - log(logLevelEnums.DEBUG, "initialize, heatmap whitelist:[" + JSON.stringify(this.heatmapWhitelist) + "], these domains will be whitelisted"); + log(logLevelEnums.DEBUG, "[Initialization] heatmap whitelist:[" + JSON.stringify(this.heatmapWhitelist) + "], these domains will be whitelisted"); } // if storage is se to something other than local storage if (this.storage !== "default") { - log(logLevelEnums.DEBUG, "initialize, storage is set to:[" + this.storage + "]"); + log(logLevelEnums.DEBUG, "[Initialization] storage is set to:[" + this.storage + "]"); } if (this.ignore_bots) { - log(logLevelEnums.DEBUG, "initialize, ignore traffic from bots :[" + this.ignore_bots + "]"); + log(logLevelEnums.DEBUG, "[Initialization] ignore traffic from bots :[" + this.ignore_bots + "]"); } if (this.force_post) { - log(logLevelEnums.DEBUG, "initialize, forced post method for all requests:[" + this.force_post + "]"); + log(logLevelEnums.DEBUG, "[Initialization] forced post method for all requests:[" + this.force_post + "]"); } if (this.remote_config) { - log(logLevelEnums.DEBUG, "initialize, remote_config callback provided:[" + !!this.remote_config + "]"); + log(logLevelEnums.DEBUG, "[Initialization] remote_config callback provided:[" + !!this.remote_config + "]"); } if (typeof this.rcAutoOptinAb === "boolean") { - log(logLevelEnums.DEBUG, "initialize, automatic RC optin is enabled:[" + this.rcAutoOptinAb + "]"); + log(logLevelEnums.DEBUG, "[Initialization] automatic RC optin is enabled:[" + this.rcAutoOptinAb + "]"); } if (!this.useExplicitRcApi) { - log(logLevelEnums.WARNING, "initialize, will use legacy RC API. Consider enabling new API during init with use_explicit_rc_api flag"); + log(logLevelEnums.WARNING, "[Initialization] will use legacy RC API. Consider enabling new API during init with use_explicit_rc_api flag"); } if (this.track_domains) { - log(logLevelEnums.DEBUG, "initialize, tracking domain info:[" + this.track_domains + "]"); + log(logLevelEnums.DEBUG, "[Initialization] tracking domain info:[" + this.track_domains + "]"); } if (this.enableOrientationTracking) { - log(logLevelEnums.DEBUG, "initialize, enableOrientationTracking:[" + this.enableOrientationTracking + "]"); + log(logLevelEnums.DEBUG, "[Initialization] enableOrientationTracking:[" + this.enableOrientationTracking + "]"); } if (!useSessionCookie) { - log(logLevelEnums.WARNING, "initialize, use_session_cookie is enabled:[" + useSessionCookie + "]"); + log(logLevelEnums.WARNING, "[Initialization] use_session_cookie is enabled:[" + useSessionCookie + "]"); } if (offlineMode) { - log(logLevelEnums.DEBUG, "initialize, offline_mode:[" + offlineMode + "], user info won't be send to the servers"); + log(logLevelEnums.DEBUG, "[Initialization] offline_mode:[" + offlineMode + "], user info won't be send to the servers"); } if (offlineMode) { - log(logLevelEnums.DEBUG, "initialize, stored remote configs:[" + JSON.stringify(remoteConfigs) + "]"); + log(logLevelEnums.DEBUG, "[Initialization] stored remote configs:[" + JSON.stringify(remoteConfigs) + "]"); } // functions, if provided, would be printed as true without revealing their content - log(logLevelEnums.DEBUG, "initialize, 'getViewName' callback override provided:[" + (this.getViewName !== Countly.getViewName) + "]"); - log(logLevelEnums.DEBUG, "initialize, 'getSearchQuery' callback override provided:[" + (this.getSearchQuery !== Countly.getSearchQuery) + "]"); + log(logLevelEnums.DEBUG, "[Initialization] 'getViewName' callback override provided:[" + (this.getViewName !== Countly.getViewName) + "]"); + log(logLevelEnums.DEBUG, "[Initialization] 'getSearchQuery' callback override provided:[" + (this.getSearchQuery !== Countly.getSearchQuery) + "]"); // limits are printed here if they were modified if (this.maxKeyLength !== configurationDefaultValues.MAX_KEY_LENGTH) { - log(logLevelEnums.DEBUG, "initialize, maxKeyLength set to:[" + this.maxKeyLength + "] characters"); + log(logLevelEnums.DEBUG, "[Initialization] maxKeyLength set to:[" + this.maxKeyLength + "] characters"); } if (this.maxValueSize !== configurationDefaultValues.MAX_VALUE_SIZE) { - log(logLevelEnums.DEBUG, "initialize, maxValueSize set to:[" + this.maxValueSize + "] characters"); + log(logLevelEnums.DEBUG, "[Initialization] maxValueSize set to:[" + this.maxValueSize + "] characters"); } if (this.maxSegmentationValues !== configurationDefaultValues.MAX_SEGMENTATION_VALUES) { - log(logLevelEnums.DEBUG, "initialize, maxSegmentationValues set to:[" + this.maxSegmentationValues + "] key/value pairs"); + log(logLevelEnums.DEBUG, "[Initialization] maxSegmentationValues set to:[" + this.maxSegmentationValues + "] key/value pairs"); } if (this.maxBreadcrumbCount !== configurationDefaultValues.MAX_BREADCRUMB_COUNT) { - log(logLevelEnums.DEBUG, "initialize, maxBreadcrumbCount for custom logs set to:[" + this.maxBreadcrumbCount + "] entries"); + log(logLevelEnums.DEBUG, "[Initialization] maxBreadcrumbCount for custom logs set to:[" + this.maxBreadcrumbCount + "] entries"); } if (this.maxStackTraceLinesPerThread !== configurationDefaultValues.MAX_STACKTRACE_LINES_PER_THREAD) { - log(logLevelEnums.DEBUG, "initialize, maxStackTraceLinesPerThread set to:[" + this.maxStackTraceLinesPerThread + "] lines"); + log(logLevelEnums.DEBUG, "[Initialization] maxStackTraceLinesPerThread set to:[" + this.maxStackTraceLinesPerThread + "] lines"); } if (this.maxStackTraceLineLength !== configurationDefaultValues.MAX_STACKTRACE_LINE_LENGTH) { - log(logLevelEnums.DEBUG, "initialize, maxStackTraceLineLength set to:[" + this.maxStackTraceLineLength + "] characters"); + log(logLevelEnums.DEBUG, "[Initialization] maxStackTraceLineLength set to:[" + this.maxStackTraceLineLength + "] characters"); } if (beatInterval !== configurationDefaultValues.BEAT_INTERVAL) { - log(logLevelEnums.DEBUG, "initialize, interval for heartbeats set to:[" + beatInterval + "] milliseconds"); + log(logLevelEnums.DEBUG, "[Initialization] interval for heartbeats set to:[" + beatInterval + "] milliseconds"); } if (queueSize !== configurationDefaultValues.QUEUE_SIZE) { - log(logLevelEnums.DEBUG, "initialize, queue_size set to:[" + queueSize + "] items max"); + log(logLevelEnums.DEBUG, "[Initialization] queue_size set to:[" + queueSize + "] items max"); } if (failTimeoutAmount !== configurationDefaultValues.FAIL_TIMEOUT_AMOUNT) { - log(logLevelEnums.DEBUG, "initialize, fail_timeout set to:[" + failTimeoutAmount + "] seconds of wait time after a failed connection to server"); + log(logLevelEnums.DEBUG, "[Initialization] fail_timeout set to:[" + failTimeoutAmount + "] seconds of wait time after a failed connection to server"); } if (inactivityTime !== configurationDefaultValues.INACTIVITY_TIME) { - log(logLevelEnums.DEBUG, "initialize, inactivity_time set to:[" + inactivityTime + "] minutes to consider a user as inactive after no observable action"); + log(logLevelEnums.DEBUG, "[Initialization] inactivity_time set to:[" + inactivityTime + "] minutes to consider a user as inactive after no observable action"); } if (sessionUpdate !== configurationDefaultValues.SESSION_UPDATE) { - log(logLevelEnums.DEBUG, "initialize, session_update set to:[" + sessionUpdate + "] seconds to check if extending a session is needed while the user is active"); + log(logLevelEnums.DEBUG, "[Initialization] session_update set to:[" + sessionUpdate + "] seconds to check if extending a session is needed while the user is active"); } if (maxEventBatch !== configurationDefaultValues.MAX_EVENT_BATCH) { - log(logLevelEnums.DEBUG, "initialize, max_events set to:[" + maxEventBatch + "] events to send in one batch"); + log(logLevelEnums.DEBUG, "[Initialization] max_events set to:[" + maxEventBatch + "] events to send in one batch"); } if (maxCrashLogs) { - log(logLevelEnums.WARNING, "initialize, max_logs set to:[" + maxCrashLogs + "] breadcrumbs to store for crash logs max, deprecated "); + log(logLevelEnums.WARNING, "[Initialization] max_logs set to:[" + maxCrashLogs + "] breadcrumbs to store for crash logs max, deprecated "); } if (sessionCookieTimeout !== configurationDefaultValues.SESSION_COOKIE_TIMEOUT) { - log(logLevelEnums.DEBUG, "initialize, session_cookie_timeout set to:[" + sessionCookieTimeout + "] minutes to expire a cookies session"); + log(logLevelEnums.DEBUG, "[Initialization] session_cookie_timeout set to:[" + sessionCookieTimeout + "] minutes to expire a cookies session"); } - log(logLevelEnums.INFO, "initialize, Countly initialized"); + log(logLevelEnums.INFO, "[Initialization] Countly initialized"); var deviceIdParamValue = null; var searchQuery = self.getSearchQuery(); @@ -582,23 +582,23 @@ // check if there wqs stored ID if (getValueFromStorage("cly_id") && !tempIdModeWasEnabled) { this.device_id = getValueFromStorage("cly_id"); - log(logLevelEnums.INFO, "initialize, Set the stored device ID"); + log(logLevelEnums.INFO, "[Initialization] Set the stored device ID"); deviceIdType = getValueFromStorage("cly_id_type"); if (!deviceIdType) { - log(logLevelEnums.INFO, "initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED"); + log(logLevelEnums.INFO, "[Initialization] No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED"); // there is a device ID saved but there is no device ID information saved deviceIdType = DeviceIdTypeInternalEnums.DEVELOPER_SUPPLIED; } } // if not check if device ID was provided with URL else if (deviceIdParamValue !== null) { - log(logLevelEnums.INFO, "initialize, Device ID set by URL"); + log(logLevelEnums.INFO, "[Initialization] Device ID set by URL"); this.device_id = deviceIdParamValue; deviceIdType = DeviceIdTypeInternalEnums.URL_PROVIDED; } // if not check if developer provided any ID else if (developerSetDeviceId) { - log(logLevelEnums.INFO, "initialize, Device ID set by developer"); + log(logLevelEnums.INFO, "[Initialization] Device ID set by developer"); this.device_id = developerSetDeviceId; if (ob && Object.keys(ob).length) { if (ob.device_id !== undefined) { @@ -614,21 +614,21 @@ this.device_id = "[CLY]_temp_id"; deviceIdType = DeviceIdTypeInternalEnums.TEMPORARY_ID; if (offlineMode && tempIdModeWasEnabled) { - log(logLevelEnums.INFO, "initialize, Temp ID set, continuing offline mode from previous app session"); + log(logLevelEnums.INFO, "[Initialization] Temp ID set, continuing offline mode from previous app session"); } else if (offlineMode && !tempIdModeWasEnabled) { // this if we get here then it means either first init we enter offline mode or we cleared the device ID during the init and still user entered the offline mode - log(logLevelEnums.INFO, "initialize, Temp ID set, entering offline mode"); + log(logLevelEnums.INFO, "[Initialization] Temp ID set, entering offline mode"); } else { // no device ID was provided, no offline mode flag was provided, in the previous app session we entered offline mode and now we carry on offlineMode = true; - log(logLevelEnums.INFO, "initialize, Temp ID set, enabling offline mode"); + log(logLevelEnums.INFO, "[Initialization] Temp ID set, enabling offline mode"); } } // if all fails generate an ID else { - log(logLevelEnums.INFO, "initialize, Generating the device ID"); + log(logLevelEnums.INFO, "[Initialization] Generating the device ID"); this.device_id = getConfig("device_id", ob, getStoredIdOrGenerateId()); if (ob && Object.keys(ob).length) { if (ob.device_id !== undefined) { @@ -789,7 +789,7 @@ * //or call Countly.add_consent("crashes") to allow some separate feature */ this.group_features = function(features) { - log(logLevelEnums.INFO, "group_features, Grouping features"); + log(logLevelEnums.INFO, "[group_features] Grouping features"); if (features) { for (var i in features) { if (!consents[i]) { @@ -800,16 +800,16 @@ consents[i] = { features: features[i] }; } else { - log(logLevelEnums.ERROR, "group_features, Incorrect feature list for [" + i + "] value: [" + features[i] + "]"); + log(logLevelEnums.ERROR, "[group_features] Incorrect feature list for [" + i + "] value: [" + features[i] + "]"); } } else { - log(logLevelEnums.WARNING, "group_features, Feature name [" + i + "] is already reserved"); + log(logLevelEnums.WARNING, "[group_features] Feature name [" + i + "] is already reserved"); } } } else { - log(logLevelEnums.ERROR, "group_features, Incorrect features:[" + features + "]"); + log(logLevelEnums.ERROR, "[group_features] Incorrect features:[" + features + "]"); } }; @@ -819,16 +819,16 @@ * @returns {Boolean} true if consent was given for the feature or false if it was not */ this.check_consent = function(feature) { - log(logLevelEnums.INFO, "check_consent, Checking if consent is given for specific feature:[" + feature + "]"); + log(logLevelEnums.INFO, "[check_consent] Checking if consent is given for specific feature:[" + feature + "]"); if (!this.require_consent) { // we don't need to have specific consents - log(logLevelEnums.INFO, "check_consent, require_consent is off, no consent is necessary"); + log(logLevelEnums.INFO, "[check_consent] require_consent is off, no consent is necessary"); return true; } if (consents[feature]) { return !!(consents[feature] && consents[feature].optin); } - log(logLevelEnums.ERROR, "check_consent, No feature available for [" + feature + "]"); + log(logLevelEnums.ERROR, "[check_consent] No feature available for [" + feature + "]"); return false; }; @@ -837,7 +837,7 @@ * @returns {number} a number that indicates the device id type */ this.get_device_id_type = function() { - log(logLevelEnums.INFO, "check_device_id_type, Retrieving the current device id type.[" + deviceIdType + "]"); + log(logLevelEnums.INFO, "[check_device_id_type] Retrieving the current device id type.[" + deviceIdType + "]"); var type; switch (deviceIdType) { case DeviceIdTypeInternalEnums.SDK_GENERATED: @@ -862,7 +862,7 @@ * @returns {string} device id */ this.get_device_id = function() { - log(logLevelEnums.INFO, "get_device_id, Retrieving the device id: [" + this.device_id + "]"); + log(logLevelEnums.INFO, "[get_device_id] Retrieving the device id: [" + this.device_id + "]"); return this.device_id; }; @@ -871,10 +871,10 @@ * @returns {Boolean} true is has any consent given, false if no consents given */ this.check_any_consent = function() { - log(logLevelEnums.INFO, "check_any_consent, Checking if any consent is given"); + log(logLevelEnums.INFO, "[check_any_consent] Checking if any consent is given"); if (!this.require_consent) { // we don't need to have consents - log(logLevelEnums.INFO, "check_any_consent, require_consent is off, no consent is necessary"); + log(logLevelEnums.INFO, "[check_any_consent] require_consent is off, no consent is necessary"); return true; } for (var i in consents) { @@ -882,7 +882,7 @@ return true; } } - log(logLevelEnums.INFO, "check_any_consent, No consents given"); + log(logLevelEnums.INFO, "[check_any_consent] No consents given"); return false; }; @@ -891,7 +891,7 @@ * @param {string|array} feature - name of the feature, possible values, "sessions","events","views","scrolls","clicks","forms","crashes","attribution","users", etc or custom provided through {@link Countly.group_features} */ this.add_consent = function(feature) { - log(logLevelEnums.INFO, "add_consent, Adding consent for [" + feature + "]"); + log(logLevelEnums.INFO, "[add_consent] Adding consent for [" + feature + "]"); if (Array.isArray(feature)) { for (var i = 0; i < feature.length; i++) { this.add_consent(feature[i]); @@ -923,7 +923,7 @@ } } else { - log(logLevelEnums.ERROR, "add_consent, No feature available for [" + feature + "]"); + log(logLevelEnums.ERROR, "[add_consent] No feature available for [" + feature + "]"); } }; @@ -933,7 +933,7 @@ * @param {Boolean} enforceConsentUpdate - regulates if a request will be sent to the server or not. If true, removing consents will send a request to the server and if false, consents will be removed without a request */ this.remove_consent = function(feature) { - log(logLevelEnums.INFO, "remove_consent, Removing consent for [" + feature + "]"); + log(logLevelEnums.INFO, "[remove_consent] Removing consent for [" + feature + "]"); this.remove_consent_internal(feature, true); }; // removes consent without updating @@ -959,7 +959,7 @@ } } else { - log(logLevelEnums.WARNING, "remove_consent, No feature available for [" + feature + "]"); + log(logLevelEnums.WARNING, "[remove_consent] No feature available for [" + feature + "]"); } }; @@ -981,12 +981,12 @@ } } toRequestQueue({ consent: JSON.stringify(consentMessage) }); - log(logLevelEnums.DEBUG, "Consent update request has been sent to the queue."); + log(logLevelEnums.DEBUG, "[updateConsent] Consent update request has been sent to the queue."); }, 1000); }; this.enable_offline_mode = function() { - log(logLevelEnums.INFO, "enable_offline_mode, Enabling offline mode"); + log(logLevelEnums.INFO, "[enable_offline_mode] Enabling offline mode"); // clear consents this.remove_consent_internal(Countly.features, false); offlineMode = true; @@ -997,10 +997,10 @@ this.disable_offline_mode = function(device_id) { if (!offlineMode) { - log(logLevelEnums.WARNING, "disable_offline_mode, Countly was not in offline mode."); + log(logLevelEnums.WARNING, "[disable_offline_mode] Countly was not in offline mode."); return; } - log(logLevelEnums.INFO, "disable_offline_mode, Disabling offline mode"); + log(logLevelEnums.INFO, "[disable_offline_mode] Disabling offline mode"); offlineMode = false; if (device_id && this.device_id !== device_id) { this.device_id = device_id; @@ -1008,7 +1008,7 @@ deviceIdType = DeviceIdTypeInternalEnums.DEVELOPER_SUPPLIED; setValueInStorage("cly_id", this.device_id); setValueInStorage("cly_id_type", DeviceIdTypeInternalEnums.DEVELOPER_SUPPLIED); - log(logLevelEnums.INFO, "disable_offline_mode, Changing id to: " + this.device_id); + log(logLevelEnums.INFO, "[disable_offline_mode] Changing id to: " + this.device_id); } else { this.device_id = getStoredIdOrGenerateId(); @@ -1041,12 +1041,12 @@ * @param {bool} force - force begin session request even if session cookie is enabled */ this.begin_session = function(noHeartBeat, force) { - log(logLevelEnums.INFO, "begin_session, Starting the session. There was an ongoing session: [" + sessionStarted + "]"); + log(logLevelEnums.INFO, "[begin_session] Starting the session. There was an ongoing session: [" + sessionStarted + "]"); if (noHeartBeat) { - log(logLevelEnums.INFO, "begin_session, Heartbeats are disabled"); + log(logLevelEnums.INFO, "[begin_session] Heartbeats are disabled"); } if (force) { - log(logLevelEnums.INFO, "begin_session, Session starts irrespective of session cookie"); + log(logLevelEnums.INFO, "[begin_session] Session starts irrespective of session cookie"); } if (this.check_consent(featureEnums.SESSIONS)) { if (!sessionStarted) { @@ -1061,9 +1061,9 @@ sessionStarted = true; autoExtend = !(noHeartBeat); var expire = getValueFromStorage("cly_session"); - log(logLevelEnums.VERBOSE, "begin_session, Session state, forced: [" + force + "], useSessionCookie: [" + useSessionCookie + "], seconds to expire: [" + (expire - lastBeat) + "], expired: [" + (parseInt(expire) <= getTimestamp()) + "] "); + log(logLevelEnums.VERBOSE, "[begin_session] Session state, forced: [" + force + "], useSessionCookie: [" + useSessionCookie + "], seconds to expire: [" + (expire - lastBeat) + "], expired: [" + (parseInt(expire) <= getTimestamp()) + "] "); if (force || !useSessionCookie || !expire || parseInt(expire) <= getTimestamp()) { - log(logLevelEnums.INFO, "begin_session, Session started"); + log(logLevelEnums.INFO, "[begin_session] Session started"); if (firstView === null) { firstView = true; } @@ -1085,10 +1085,10 @@ * @param {int} sec - amount of seconds to report for current session */ this.session_duration = function(sec) { - log(logLevelEnums.INFO, "session_duration, Reporting session duration"); + log(logLevelEnums.INFO, "[session_duration] Reporting session duration"); if (this.check_consent(featureEnums.SESSIONS)) { if (sessionStarted) { - log(logLevelEnums.INFO, "session_duration, Session extended: ", sec); + log(logLevelEnums.INFO, "[session_duration] Session extended: ", sec); toRequestQueue({ session_duration: sec }); extendSession(); } @@ -1101,13 +1101,13 @@ * @param {bool} force - force end session request even if session cookie is enabled */ this.end_session = function(sec, force) { - log(logLevelEnums.INFO, "end_session, Ending the current session. There was an on going session:[" + sessionStarted + "]"); + log(logLevelEnums.INFO, "[end_session] Ending the current session. There was an on going session:[" + sessionStarted + "]"); if (this.check_consent(featureEnums.SESSIONS)) { if (sessionStarted) { sec = sec || getTimestamp() - lastBeat; reportViewDuration(); if (!useSessionCookie || force) { - log(logLevelEnums.INFO, "end_session, Session ended"); + log(logLevelEnums.INFO, "[end_session] Session ended"); toRequestQueue({ end_session: 1, session_duration: sec }); } else { @@ -1124,16 +1124,16 @@ * @param {boolean} merge - move data from old ID to new ID on server * */ this.change_id = function(newId, merge) { - log(logLevelEnums.INFO, "change_id, Changing the ID"); + log(logLevelEnums.INFO, "[change_id] Changing the ID"); if (merge) { - log(logLevelEnums.INFO, "change_id, Will merge the IDs"); + log(logLevelEnums.INFO, "[change_id] Will merge the IDs"); } if (!newId || typeof newId !== "string" || newId.length === 0) { - log(logLevelEnums.ERROR, "change_id, The provided ID: [" + newId + "] is not a valid ID"); + log(logLevelEnums.ERROR, "[change_id] The provided ID: [" + newId + "] is not a valid ID"); return; } if (offlineMode) { - log(logLevelEnums.WARNING, "change_id, Offline mode was on, initiating disabling sequence instead."); + log(logLevelEnums.WARNING, "[change_id] Offline mode was on, initiating disabling sequence instead."); this.disable_offline_mode(newId); return; } @@ -1156,7 +1156,7 @@ deviceIdType = DeviceIdTypeInternalEnums.DEVELOPER_SUPPLIED; setValueInStorage("cly_id", this.device_id); setValueInStorage("cly_id_type", DeviceIdTypeInternalEnums.DEVELOPER_SUPPLIED); - log(logLevelEnums.INFO, "change_id, Changing ID from:[" + oldId + "] to [" + newId + "]"); + log(logLevelEnums.INFO, "[change_id] Changing ID from:[" + oldId + "] to [" + newId + "]"); if (merge) { // no consent check here since 21.11.0 toRequestQueue({ old_device_id: oldId }); @@ -1184,7 +1184,7 @@ * @param {Object=} event.segmentation - object with segments key /values * */ this.add_event = function(event) { - log(logLevelEnums.INFO, "add_event, Adding event: ", event); + log(logLevelEnums.INFO, "[add_event] Adding event: ", event); // initially no consent is given var respectiveConsent = false; switch (event.key) { @@ -1224,12 +1224,12 @@ function add_cly_events(event, eventIdOverride) { // ignore bots if (self.ignore_visitor) { - log(logLevelEnums.ERROR, "Adding event failed. Possible bot or user opt out"); + log(logLevelEnums.ERROR, "[add_event] Adding event failed. Possible bot or user opt out"); return; } if (!event.key) { - log(logLevelEnums.ERROR, "Adding event failed. Event must have a key property"); + log(logLevelEnums.ERROR, "[add_event] Adding event failed. Event must have a key property"); return; } @@ -1257,7 +1257,7 @@ } eventQueue.push(e); setValueInStorage("cly_event", eventQueue); - log(logLevelEnums.INFO, " With event ID: [" + e.id + "], successfully adding the last event:", e); + log(logLevelEnums.INFO, "[add_event] With event ID: [" + e.id + "], successfully adding the last event:", e); } /** @@ -1267,14 +1267,14 @@ * */ this.start_event = function(key) { if (!key || typeof key !== "string") { - log(logLevelEnums.WARNING, "start_event, you have to provide a valid string key instead of: [" + key + "]"); + log(logLevelEnums.WARNING, "[start_event] you have to provide a valid string key instead of: [" + key + "]"); return; } - log(logLevelEnums.INFO, "start_event, Starting timed event with key: [" + key + "]"); + log(logLevelEnums.INFO, "[start_event] Starting timed event with key: [" + key + "]"); // truncate event name to internal limits key = truncateSingleValue(key, self.maxKeyLength, "start_event", log); if (timedEvents[key]) { - log(logLevelEnums.WARNING, "start_event, Timed event with key: [" + key + "] already started"); + log(logLevelEnums.WARNING, "[start_event] Timed event with key: [" + key + "] already started"); return; } timedEvents[key] = getTimestamp(); @@ -1287,18 +1287,18 @@ * */ this.cancel_event = function(key) { if (!key || typeof key !== "string") { - log(logLevelEnums.WARNING, "cancel_event, you have to provide a valid string key instead of: [" + key + "]"); + log(logLevelEnums.WARNING, "[cancel_event] you have to provide a valid string key instead of: [" + key + "]"); return false; } - log(logLevelEnums.INFO, "cancel_event, Canceling timed event with key: [" + key + "]"); + log(logLevelEnums.INFO, "[cancel_event] Canceling timed event with key: [" + key + "]"); // truncate event name to internal limits. This is done incase start_event key was truncated. key = truncateSingleValue(key, self.maxKeyLength, "cancel_event", log); if (timedEvents[key]) { delete timedEvents[key]; - log(logLevelEnums.INFO, "cancel_event, Timed event with key: [" + key + "] is canceled"); + log(logLevelEnums.INFO, "[cancel_event] Timed event with key: [" + key + "] is canceled"); return true; } - log(logLevelEnums.WARNING, "cancel_event, Timed event with key: [" + key + "] was not found"); + log(logLevelEnums.WARNING, "[cancel_event] Timed event with key: [" + key + "] was not found"); return false; }; @@ -1308,21 +1308,21 @@ * */ this.end_event = function(event) { if (!event) { - log(logLevelEnums.WARNING, "end_event, you have to provide a valid string key or event object instead of: [" + event + "]"); + log(logLevelEnums.WARNING, "[end_event] you have to provide a valid string key or event object instead of: [" + event + "]"); return; } - log(logLevelEnums.INFO, "end_event, Ending timed event"); + log(logLevelEnums.INFO, "[end_event] Ending timed event"); if (typeof event === "string") { // truncate event name to internal limits. This is done incase start_event key was truncated. event = truncateSingleValue(event, self.maxKeyLength, "end_event", log); event = { key: event }; } if (!event.key) { - log(logLevelEnums.ERROR, "end_event, Timed event must have a key property"); + log(logLevelEnums.ERROR, "[end_event] Timed event must have a key property"); return; } if (!timedEvents[event.key]) { - log(logLevelEnums.ERROR, "end_event, Timed event with key: [" + event.key + "] was not started"); + log(logLevelEnums.ERROR, "[end_event] Timed event with key: [" + event.key + "] was not started"); return; } event.dur = getTimestamp() - timedEvents[event.key]; @@ -1335,7 +1335,7 @@ * @param {string=} orientation - orientation as landscape or portrait * */ this.report_orientation = function(orientation) { - log(logLevelEnums.INFO, "report_orientation, Reporting orientation"); + log(logLevelEnums.INFO, "[report_orientation] Reporting orientation"); if (this.check_consent(featureEnums.USERS)) { add_cly_events({ key: internalEventKeyEnums.ORIENTATION, @@ -1354,7 +1354,7 @@ * @deprecated use 'recordDirectAttribution' in place of this call * */ this.report_conversion = function(campaign_id, campaign_user_id) { - log(logLevelEnums.WARNING, "report_conversion, Deprecated function call! Use 'recordDirectAttribution' in place of this call. Call will be redirected now!"); + log(logLevelEnums.WARNING, "[report_conversion] Deprecated function call! Use 'recordDirectAttribution' in place of this call. Call will be redirected now!"); this.recordDirectAttribution(campaign_id, campaign_user_id); }; /** @@ -1363,7 +1363,7 @@ * @param {string=} campaign_user_id - id of user's click on campaign, or will use the one that is stored after campaign link click * */ this.recordDirectAttribution = function(campaign_id, campaign_user_id) { - log(logLevelEnums.INFO, "recordDirectAttribution, Recording the attribution for campaign ID: [" + campaign_id + "] and the user ID: [" + campaign_user_id + "]"); + log(logLevelEnums.INFO, "[recordDirectAttribution] Recording the attribution for campaign ID: [" + campaign_id + "] and the user ID: [" + campaign_user_id + "]"); if (this.check_consent(featureEnums.ATTRIBUTION)) { campaign_id = campaign_id || getValueFromStorage("cly_cmp_id") || "cly_organic"; campaign_user_id = campaign_user_id || getValueFromStorage("cly_cmp_uid"); @@ -1391,10 +1391,10 @@ * @param {Object=} user.custom - object with custom key value properties you want to save with user * */ this.user_details = function(user) { - log(logLevelEnums.INFO, "user_details, Trying to add user details: ", user); + log(logLevelEnums.INFO, "[user_details] Trying to add user details: ", user); if (this.check_consent(featureEnums.USERS)) { sendEventsForced(); // flush events to event queue to prevent a drill issue - log(logLevelEnums.INFO, "user_details, flushed the event queue"); + log(logLevelEnums.INFO, "[user_details] flushed the event queue"); // truncating user values and custom object key value pairs user.name = truncateSingleValue(user.name, self.maxValueSize, "user_details", log); user.username = truncateSingleValue(user.username, self.maxValueSize, "user_details", log); @@ -1462,7 +1462,7 @@ * @param {string|number} value - value to store under provided property * */ set: function(key, value) { - log(logLevelEnums.INFO, "set, Setting user's custom property value: [" + value + "] under the key: [" + key + "]"); + log(logLevelEnums.INFO, "[userData] set, Setting user's custom property value: [" + value + "] under the key: [" + key + "]"); // truncate user's custom property value to internal limits key = truncateSingleValue(key, self.maxKeyLength, "userData set", log); value = truncateSingleValue(value, self.maxValueSize, "userData set", log); @@ -1474,7 +1474,7 @@ * @param {string} key - name of the property to delete * */ unset: function(key) { - log(logLevelEnums.INFO, "unset, Resetting user's custom property with key: [" + key + "] "); + log(logLevelEnums.INFO, "[userData] unset, Resetting user's custom property with key: [" + key + "] "); customData[key] = ""; }, /** @@ -1484,7 +1484,7 @@ * @param {string|number} value - value to store under provided property * */ set_once: function(key, value) { - log(logLevelEnums.INFO, "set_once, Setting user's unique custom property value: [" + value + "] under the key: [" + key + "] "); + log(logLevelEnums.INFO, "[userData] set_once, Setting user's unique custom property value: [" + value + "] under the key: [" + key + "] "); // truncate user's custom property value to internal limits key = truncateSingleValue(key, self.maxKeyLength, "userData set_once", log); value = truncateSingleValue(value, self.maxValueSize, "userData set_once", log); @@ -1496,7 +1496,7 @@ * @param {string} key - name of the property to attach to user * */ increment: function(key) { - log(logLevelEnums.INFO, "increment, Increasing user's custom property value under the key: [" + key + "] by one"); + log(logLevelEnums.INFO, "[userData] increment, Increasing user's custom property value under the key: [" + key + "] by one"); // truncate property name wrt internal limits key = truncateSingleValue(key, self.maxKeyLength, "userData increment", log); change_custom_property(key, 1, "$inc"); @@ -1508,7 +1508,7 @@ * @param {number} value - value by which to increment server value * */ increment_by: function(key, value) { - log(logLevelEnums.INFO, "increment_by, Increasing user's custom property value under the key: [" + key + "] by: [" + value + "]"); + log(logLevelEnums.INFO, "[userData] increment_by, Increasing user's custom property value under the key: [" + key + "] by: [" + value + "]"); // truncate property name and value wrt internal limits key = truncateSingleValue(key, self.maxKeyLength, "userData increment_by", log); value = truncateSingleValue(value, self.maxValueSize, "userData increment_by", log); @@ -1521,7 +1521,7 @@ * @param {number} value - value by which to multiply server value * */ multiply: function(key, value) { - log(logLevelEnums.INFO, "multiply, Multiplying user's custom property value under the key: [" + key + "] by: [" + value + "]"); + log(logLevelEnums.INFO, "[userData] multiply, Multiplying user's custom property value under the key: [" + key + "] by: [" + value + "]"); // truncate key value pair wrt internal limits key = truncateSingleValue(key, self.maxKeyLength, "userData multiply", log); value = truncateSingleValue(value, self.maxValueSize, "userData multiply", log); @@ -1534,7 +1534,7 @@ * @param {number} value - value which to compare to server's value and store maximal value of both provided * */ max: function(key, value) { - log(logLevelEnums.INFO, "max, Saving user's maximum custom property value compared to the value: [" + value + "] under the key: [" + key + "]"); + log(logLevelEnums.INFO, "[userData] max, Saving user's maximum custom property value compared to the value: [" + value + "] under the key: [" + key + "]"); // truncate key value pair wrt internal limits key = truncateSingleValue(key, self.maxKeyLength, "userData max", log); value = truncateSingleValue(value, self.maxValueSize, "userData max", log); @@ -1547,7 +1547,7 @@ * @param {number} value - value which to compare to server's value and store minimal value of both provided * */ min: function(key, value) { - log(logLevelEnums.INFO, "min, Saving user's minimum custom property value compared to the value: [" + value + "] under the key: [" + key + "]"); + log(logLevelEnums.INFO, "[userData] min, Saving user's minimum custom property value compared to the value: [" + value + "] under the key: [" + key + "]"); // truncate key value pair wrt internal limits key = truncateSingleValue(key, self.maxKeyLength, "userData min", log); value = truncateSingleValue(value, self.maxValueSize, "userData min", log); @@ -1560,7 +1560,7 @@ * @param {string|number} value - value which to add to array * */ push: function(key, value) { - log(logLevelEnums.INFO, "push, Pushing a value: [" + value + "] under the key: [" + key + "] to user's custom property array"); + log(logLevelEnums.INFO, "[userData] push, Pushing a value: [" + value + "] under the key: [" + key + "] to user's custom property array"); // truncate key value pair wrt internal limits key = truncateSingleValue(key, self.maxKeyLength, "userData push", log); value = truncateSingleValue(value, self.maxValueSize, "userData push", log); @@ -1573,7 +1573,7 @@ * @param {string|number} value - value which to add to array * */ push_unique: function(key, value) { - log(logLevelEnums.INFO, "push_unique, Pushing a unique value: [" + value + "] under the key: [" + key + "] to user's custom property array"); + log(logLevelEnums.INFO, "[userData] push_unique, Pushing a unique value: [" + value + "] under the key: [" + key + "] to user's custom property array"); // truncate key value pair wrt internal limits key = truncateSingleValue(key, self.maxKeyLength, "userData push_unique", log); value = truncateSingleValue(value, self.maxValueSize, "userData push_unique", log); @@ -1586,7 +1586,7 @@ * @param {string|number} value - value which to remove from array * */ pull: function(key, value) { - log(logLevelEnums.INFO, "pull, Removing the value: [" + value + "] under the key: [" + key + "] from user's custom property array"); + log(logLevelEnums.INFO, "[userData] pull, Removing the value: [" + value + "] under the key: [" + key + "] from user's custom property array"); change_custom_property(key, value, "$pull"); }, /** @@ -1594,10 +1594,10 @@ * @memberof Countly.userData * */ save: function() { - log(logLevelEnums.INFO, "save, Saving changes to user's custom property"); + log(logLevelEnums.INFO, "[userData] save, Saving changes to user's custom property"); if (self.check_consent(featureEnums.USERS)) { sendEventsForced(); // flush events to event queue to prevent a drill issue - log(logLevelEnums.INFO, "user_details, flushed the event queue"); + log(logLevelEnums.INFO, "[user_details] flushed the event queue"); toRequestQueue({ user_details: JSON.stringify({ custom: customData }) }); } customData = {}; @@ -1615,12 +1615,12 @@ * @param {Object=} trace.apm_attr - object profiling attributes (not yet supported) */ this.report_trace = function(trace) { - log(logLevelEnums.INFO, "report_trace, Reporting performance trace"); + log(logLevelEnums.INFO, "[report_trace] Reporting performance trace"); if (this.check_consent(featureEnums.APM)) { var props = ["type", "name", "stz", "etz", "apm_metrics", "apm_attr"]; for (var i = 0; i < props.length; i++) { if (props[i] !== "apm_attr" && typeof trace[props[i]] === "undefined") { - log(logLevelEnums.WARNING, "report_trace, APM trace don't have the property: " + props[i]); + log(logLevelEnums.WARNING, "[report_trace] APM trace don't have the property: " + props[i]); return; } } @@ -1633,7 +1633,7 @@ e.hour = date.getHours(); e.dow = date.getDay(); toRequestQueue({ apm: JSON.stringify(e) }); - log(logLevelEnums.INFO, "report_trace, Successfully adding APM trace: ", e); + log(logLevelEnums.INFO, "[report_trace] Successfully adding APM trace: ", e); } }; @@ -1642,7 +1642,7 @@ * @param {string=} segments - additional key value pairs you want to provide with error report, like versions of libraries used, etc. * */ this.track_errors = function(segments) { - log(logLevelEnums.INFO, "track_errors, Started tracking errors"); + log(logLevelEnums.INFO, "[track_errors] Started tracking errors"); // Indicated that for this instance of the countly error tracking is enabled Countly.i[this.app_key].tracking_crashes = true; if (!window.cly_crashes) { @@ -1685,7 +1685,7 @@ error += stack.join("\n"); } catch (ex) { - log(logLevelEnums.ERROR, "track_errors, Call stack generation experienced a problem: " + ex); + log(logLevelEnums.ERROR, "[track_errors] Call stack generation experienced a problem: " + ex); } // false indicates fatal error (as in non_fatal:false) dispatchErrors(error, false); @@ -1706,7 +1706,7 @@ * @param {string=} segments - additional key value pairs you want to provide with error report, like versions of libraries used, etc. * */ this.log_error = function(err, segments) { - log(logLevelEnums.INFO, "log_error, Logging errors"); + log(logLevelEnums.INFO, "[log_error] Logging errors"); // true indicates non fatal error (as in non_fatal:true) this.recordError(err, true, segments); }; @@ -1716,13 +1716,13 @@ * @param {string} record - any text describing what user did * */ this.add_log = function(record) { - log(logLevelEnums.INFO, "add_log, Adding a new log of breadcrumbs: [ " + record + " ]"); + log(logLevelEnums.INFO, "[add_log] Adding a new log of breadcrumbs: [ " + record + " ]"); if (this.check_consent(featureEnums.CRASHES)) { // truncate description wrt internal limits record = truncateSingleValue(record, self.maxValueSize, "add_log", log); while (crashLogs.length >= self.maxBreadcrumbCount) { crashLogs.shift(); - log(logLevelEnums.WARNING, "add_log, Reached maximum crashLogs size. Will erase the oldest one."); + log(logLevelEnums.WARNING, "[add_log] Reached maximum crashLogs size. Will erase the oldest one."); } crashLogs.push(record); } @@ -1767,14 +1767,14 @@ // use new RC API if (this.useExplicitRcApi) { - log(logLevelEnums.INFO, "fetch_remote_config, Fetching remote config"); + log(logLevelEnums.INFO, "[fetch_remote_config] Fetching remote config"); // opt in is true(1) or false(0) var opt = this.rcAutoOptinAb ? 1 : 0; fetch_remote_config_explicit(keysFiltered, omitKeysFiltered, opt, null, callbackFiltered); return; } - log(logLevelEnums.WARNING, "fetch_remote_config, Fetching remote config, with legacy API"); + log(logLevelEnums.WARNING, "[fetch_remote_config] Fetching remote config, with legacy API"); fetch_remote_config_explicit(keysFiltered, omitKeysFiltered, null, "legacy", callbackFiltered); }; @@ -1787,7 +1787,7 @@ * @param {function=} callback - Callback to notify with first param error and second param remote config object * */ function fetch_remote_config_explicit(keys, omit_keys, optIn, api, callback) { - log(logLevelEnums.INFO, "fetch_remote_config_explicit, Fetching sequence initiated"); + log(logLevelEnums.INFO, "[fetch_remote_config_explicit] Fetching sequence initiated"); var request = { method: "rc" }; @@ -1820,9 +1820,9 @@ } if (self.check_consent(featureEnums.REMOTE_CONFIG)) { prepareRequest(request); - sendXmlHttpRequest("fetch_remote_config_explicit", self.url + readPath, request, function(err, params, responseText) { + sendXmlHttpRequest("[fetch_remote_config_explicit]", self.url + readPath, request, function(err, params, responseText) { if (err) { - log(logLevelEnums.ERROR, "fetch_remote_config_explicit, An error occurred: " + err); + log(logLevelEnums.ERROR, "[fetch_remote_config_explicit] An error occurred: " + err); return; } try { @@ -1840,17 +1840,17 @@ setValueInStorage("cly_remote_configs", remoteConfigs); } catch (ex) { - log(logLevelEnums.ERROR, "fetch_remote_config_explicit, Had an issue while parsing the response: " + ex); + log(logLevelEnums.ERROR, "[fetch_remote_config_explicit] Had an issue while parsing the response: " + ex); } if (providedCall) { - log(logLevelEnums.INFO, "fetch_remote_config_explicit, Callback function is provided"); + log(logLevelEnums.INFO, "[fetch_remote_config_explicit] Callback function is provided"); providedCall(err, remoteConfigs); } // JSON array can pass }, true); } else { - log(logLevelEnums.ERROR, "fetch_remote_config_explicit, Remote config requires explicit consent"); + log(logLevelEnums.ERROR, "[fetch_remote_config_explicit] Remote config requires explicit consent"); if (providedCall) { providedCall(new Error("Remote config requires explicit consent"), remoteConfigs); } @@ -1862,9 +1862,9 @@ * @param {array=} keys - Array of keys opt in FOR * */ this.enrollUserToAb = function(keys) { - log(logLevelEnums.INFO, "enrollUserToAb, Providing AB test keys to opt in for"); + log(logLevelEnums.INFO, "[enrollUserToAb] Providing AB test keys to opt in for"); if (!keys || !Array.isArray(keys) || keys.length === 0) { - log(logLevelEnums.ERROR, "enrollUserToAb, No keys provided"); + log(logLevelEnums.ERROR, "[enrollUserToAb] No keys provided"); return; } var request = { @@ -1872,17 +1872,17 @@ keys: JSON.stringify(keys) }; prepareRequest(request); - sendXmlHttpRequest("enrollUserToAb", this.url + readPath, request, function(err, params, responseText) { + sendXmlHttpRequest("[enrollUserToAb]", this.url + readPath, request, function(err, params, responseText) { if (err) { - log(logLevelEnums.ERROR, "enrollUserToAb, An error occurred: " + err); + log(logLevelEnums.ERROR, "[enrollUserToAb] An error occurred: " + err); return; } try { var resp = JSON.parse(responseText); - log(logLevelEnums.DEBUG, "enrollUserToAb, Parsed the response's result: [" + resp.result + "]"); + log(logLevelEnums.DEBUG, "[enrollUserToAb] Parsed the response's result: [" + resp.result + "]"); } catch (ex) { - log(logLevelEnums.ERROR, "enrollUserToAb, Had an issue while parsing the response: " + ex); + log(logLevelEnums.ERROR, "[enrollUserToAb] Had an issue while parsing the response: " + ex); } // JSON array can pass }, true); @@ -1894,7 +1894,7 @@ * @returns {object} remote configs * */ this.get_remote_config = function(key) { - log(logLevelEnums.INFO, "get_remote_config, Getting remote config from storage"); + log(logLevelEnums.INFO, "[get_remote_config] Getting remote config from storage"); if (typeof key !== "undefined") { return remoteConfigs[key]; } @@ -1905,7 +1905,7 @@ * Stop tracking duration time for this user * */ this.stop_time = function() { - log(logLevelEnums.INFO, "stop_time, Stopping tracking duration"); + log(logLevelEnums.INFO, "[stop_time] Stopping tracking duration"); if (trackTime) { trackTime = false; storedDuration = getTimestamp() - lastBeat; @@ -1917,7 +1917,7 @@ * Start tracking duration time for this user, by default it is automatically tracked if you are using internal session handling * */ this.start_time = function() { - log(logLevelEnums.INFO, "start_time, Starting tracking duration"); + log(logLevelEnums.INFO, "[start_time] Starting tracking duration"); if (!trackTime) { trackTime = true; lastBeat = getTimestamp() - storedDuration; @@ -1931,7 +1931,7 @@ * Track user sessions automatically, including time user spent on your website * */ this.track_sessions = function() { - log(logLevelEnums.INFO, "track_session, Starting tracking user session"); + log(logLevelEnums.INFO, "[track_session] Starting tracking user session"); // start session this.begin_session(); this.start_time(); @@ -2019,10 +2019,10 @@ * @param {object=} viewSegments - optional key value object with segments to report with the view * */ this.track_pageview = function(page, ignoreList, viewSegments) { - log(logLevelEnums.INFO, "track_pageview, Tracking page views"); - log(logLevelEnums.VERBOSE, "track_pageview, last view is:[" + lastView + "], current view ID is:[" + currentViewId + "], previous view ID is:[" + previousViewId + "]"); + log(logLevelEnums.INFO, "[track_pageview] Tracking page views"); + log(logLevelEnums.VERBOSE, "[track_pageview] last view is:[" + lastView + "], current view ID is:[" + currentViewId + "], previous view ID is:[" + previousViewId + "]"); if (lastView && trackingScrolls) { - log(logLevelEnums.DEBUG, "track_pageview, Scroll registry triggered"); + log(logLevelEnums.DEBUG, "[track_pageview] Scroll registry triggered"); processScrollView(); // for single page site's view change isScrollRegistryOpen = true; scrollRegistryTopPosition = 0; @@ -2042,11 +2042,11 @@ page = this.getViewName(); } if (page === undefined || page === "") { - log(logLevelEnums.ERROR, "track_pageview, No page name to track (it is either undefined or empty string). No page view can be tracked."); + log(logLevelEnums.ERROR, "[track_pageview] No page name to track (it is either undefined or empty string). No page view can be tracked."); return; } if (page === null) { - log(logLevelEnums.ERROR, "track_pageview, View name returned as null. Page view will be ignored."); + log(logLevelEnums.ERROR, "[track_pageview] View name returned as null. Page view will be ignored."); return; } @@ -2055,18 +2055,18 @@ try { var reg = new RegExp(ignoreList[i]); if (reg.test(page)) { - log(logLevelEnums.INFO, "track_pageview, Ignoring the page: " + page); + log(logLevelEnums.INFO, "[track_pageview] Ignoring the page: " + page); return; } } catch (ex) { - log(logLevelEnums.ERROR, "track_pageview, Problem with finding ignore list item: " + ignoreList[i] + ", error: " + ex); + log(logLevelEnums.ERROR, "[track_pageview] Problem with finding ignore list item: " + ignoreList[i] + ", error: " + ex); } } } lastView = page; lastViewTime = getTimestamp(); - log(logLevelEnums.VERBOSE, "track_pageview, last view is assigned:[" + lastView + "], current view ID is:[" + currentViewId + "], previous view ID is:[" + previousViewId + "]"); + log(logLevelEnums.VERBOSE, "[track_pageview] last view is assigned:[" + lastView + "], current view ID is:[" + currentViewId + "], previous view ID is:[" + previousViewId + "]"); var segments = { name: page, visit: 1, @@ -2132,7 +2132,7 @@ * @param {object=} segments - optional view segments to track with the view * */ this.track_view = function(page, ignoreList, segments) { - log(logLevelEnums.INFO, "track_view, Initiating tracking page views"); + log(logLevelEnums.INFO, "[track_view] Initiating tracking page views"); this.track_pageview(page, ignoreList, segments); }; @@ -2141,9 +2141,9 @@ * @param {Object=} parent - DOM object which children to track, by default it is document body * */ this.track_clicks = function(parent) { - log(logLevelEnums.INFO, "track_clicks, Starting to track clicks"); + log(logLevelEnums.INFO, "[track_clicks] Starting to track clicks"); if (parent) { - log(logLevelEnums.INFO, "track_clicks, Tracking the specified children:[" + parent + "]"); + log(logLevelEnums.INFO, "[track_clicks] Tracking the specified children:[" + parent + "]"); } parent = parent || document; var shouldProcess = true; @@ -2196,9 +2196,9 @@ * @param {Object=} parent - DOM object which children to track, by default it is document body * */ this.track_scrolls = function(parent) { - log(logLevelEnums.INFO, "track_scrolls, Starting to track scrolls"); + log(logLevelEnums.INFO, "[track_scrolls] Starting to track scrolls"); if (parent) { - log(logLevelEnums.INFO, "track_scrolls, Tracking the specified children"); + log(logLevelEnums.INFO, "[track_scrolls] Tracking the specified children"); } parent = parent || window; isScrollRegistryOpen = true; @@ -2213,9 +2213,9 @@ * @param {Object=} parent - DOM object which children to track, by default it is document body * */ this.track_links = function(parent) { - log(logLevelEnums.INFO, "track_links, Starting to track clicks to links"); + log(logLevelEnums.INFO, "[track_links] Starting to track clicks to links"); if (parent) { - log(logLevelEnums.INFO, "track_links, Tracking the specified children"); + log(logLevelEnums.INFO, "[track_links] Tracking the specified children"); } parent = parent || document; /** @@ -2255,7 +2255,7 @@ * @param {boolean=} trackHidden - provide true to also track hidden inputs, default false * */ this.track_forms = function(parent, trackHidden) { - log(logLevelEnums.INFO, "track_forms, Starting to track form submissions. DOM object provided:[" + (!!parent) + "] Tracking hidden inputs :[" + (!!trackHidden) + "]"); + log(logLevelEnums.INFO, "[track_forms] Starting to track form submissions. DOM object provided:[" + (!!parent) + "] Tracking hidden inputs :[" + (!!trackHidden) + "]"); parent = parent || document; /** * Get name of the input @@ -2345,7 +2345,7 @@ * @param {boolean} [useCustom=false] - submit collected data as custom user properties, by default collects as main user properties * */ this.collect_from_forms = function(parent, useCustom) { - log(logLevelEnums.INFO, "collect_from_forms, Starting to collect possible user data. DOM object provided:[" + (!!parent) + "] Submitting custom user property:[" + (!!useCustom) + "]"); + log(logLevelEnums.INFO, "[collect_from_forms] Starting to collect possible user data. DOM object provided:[" + (!!parent) + "] Submitting custom user property:[" + (!!useCustom) + "]"); parent = parent || document; /** * Process form data @@ -2467,7 +2467,7 @@ // record user info, if any if (hasUserInfo) { - log(logLevelEnums.INFO, "collect_from_forms, Gathered user data", userdata); + log(logLevelEnums.INFO, "[collect_from_forms] Gathered user data", userdata); if (useCustom) { self.user_details({ custom: userdata }); } @@ -2487,10 +2487,10 @@ * */ this.collect_from_facebook = function(custom) { if (typeof FB === "undefined" || !FB || !FB.api) { - log(logLevelEnums.ERROR, "collect_from_facebook, Facebook SDK is not available"); + log(logLevelEnums.ERROR, "[collect_from_facebook] Facebook SDK is not available"); return; } - log(logLevelEnums.INFO, "collect_from_facebook, Starting to collect possible user data"); + log(logLevelEnums.INFO, "[collect_from_facebook] Starting to collect possible user data"); /* globals FB */ FB.api("/me", function(resp) { var data = {}; @@ -2539,7 +2539,7 @@ * Opts out user of any metric tracking * */ this.opt_out = function() { - log(logLevelEnums.INFO, "opt_out, Opting out the user"); + log(logLevelEnums.INFO, "[opt_out] Opting out the user"); this.ignore_visitor = true; setValueInStorage("cly_ignore", true); }; @@ -2548,7 +2548,7 @@ * Opts in user for tracking, if complies with other user ignore rules like bot useragent and prefetch settings * */ this.opt_in = function() { - log(logLevelEnums.INFO, "opt_in, Opting in the user"); + log(logLevelEnums.INFO, "[opt_in] Opting in the user"); setValueInStorage("cly_ignore", false); this.ignore_visitor = false; checkIgnore(); @@ -2570,7 +2570,7 @@ * @deprecated use 'recordRatingWidgetWithID' in place of this call * */ this.report_feedback = function(ratingWidget) { - log(logLevelEnums.WARNING, "report_feedback, Deprecated function call! Use 'recordRatingWidgetWithID' or 'reportFeedbackWidgetManually' in place of this call. Call will be redirected to 'recordRatingWidgetWithID' now!"); + log(logLevelEnums.WARNING, "[report_feedback] Deprecated function call! Use 'recordRatingWidgetWithID' or 'reportFeedbackWidgetManually' in place of this call. Call will be redirected to 'recordRatingWidgetWithID' now!"); this.recordRatingWidgetWithID(ratingWidget); }; /** @@ -2585,16 +2585,16 @@ * @param {string=} ratingWidget.comment - user's comment * */ this.recordRatingWidgetWithID = function(ratingWidget) { - log(logLevelEnums.INFO, "recordRatingWidgetWithID, Providing information about user with ID: [ " + ratingWidget.widget_id + " ]"); + log(logLevelEnums.INFO, "[recordRatingWidgetWithID] Providing information about user with ID: [ " + ratingWidget.widget_id + " ]"); if (!this.check_consent(featureEnums.STAR_RATING)) { return; } if (!ratingWidget.widget_id) { - log(logLevelEnums.ERROR, "recordRatingWidgetWithID, Rating Widget must contain widget_id property"); + log(logLevelEnums.ERROR, "[recordRatingWidgetWithID] Rating Widget must contain widget_id property"); return; } if (!ratingWidget.rating) { - log(logLevelEnums.ERROR, "recordRatingWidgetWithID, Rating Widget must contain rating property"); + log(logLevelEnums.ERROR, "[recordRatingWidgetWithID] Rating Widget must contain rating property"); return; } var props = ["widget_id", "contactMe", "platform", "app_version", "rating", "email", "comment"]; @@ -2608,14 +2608,14 @@ event.segmentation.app_version = this.metrics._app_version || this.app_version; } if (event.segmentation.rating > 5) { - log(logLevelEnums.WARNING, "recordRatingWidgetWithID, You have entered a rating higher than 5. Changing it back to 5 now."); + log(logLevelEnums.WARNING, "[recordRatingWidgetWithID] You have entered a rating higher than 5. Changing it back to 5 now."); event.segmentation.rating = 5; } else if (event.segmentation.rating < 1) { - log(logLevelEnums.WARNING, "recordRatingWidgetWithID, You have entered a rating lower than 1. Changing it back to 1 now."); + log(logLevelEnums.WARNING, "[recordRatingWidgetWithID] You have entered a rating lower than 1. Changing it back to 1 now."); event.segmentation.rating = 1; } - log(logLevelEnums.INFO, "recordRatingWidgetWithID, Reporting Rating Widget: ", event); + log(logLevelEnums.INFO, "[recordRatingWidgetWithID] Reporting Rating Widget: ", event); add_cly_events(event); }; /** @@ -2650,19 +2650,19 @@ return; } if (!(CountlyFeedbackWidget && CountlyWidgetData)) { - log(logLevelEnums.ERROR, "reportFeedbackWidgetManually, Widget data and/or Widget object not provided. Aborting."); + log(logLevelEnums.ERROR, "[reportFeedbackWidgetManually] Widget data and/or Widget object not provided. Aborting."); return; } if (!CountlyFeedbackWidget._id) { - log(logLevelEnums.ERROR, "reportFeedbackWidgetManually, Feedback Widgets must contain _id property"); + log(logLevelEnums.ERROR, "[reportFeedbackWidgetManually] Feedback Widgets must contain _id property"); return; } if (offlineMode) { - log(logLevelEnums.ERROR, "reportFeedbackWidgetManually, Feedback Widgets can not be reported in offline mode"); + log(logLevelEnums.ERROR, "[reportFeedbackWidgetManually] Feedback Widgets can not be reported in offline mode"); return; } - log(logLevelEnums.INFO, "reportFeedbackWidgetManually, Providing information about user with, provided result of the widget with ID: [ " + CountlyFeedbackWidget._id + " ] and type: [" + CountlyFeedbackWidget.type + "]"); + log(logLevelEnums.INFO, "[reportFeedbackWidgetManually] Providing information about user with, provided result of the widget with ID: [ " + CountlyFeedbackWidget._id + " ] and type: [" + CountlyFeedbackWidget.type + "]"); // type specific checks to see if everything was provided var props = []; @@ -2671,16 +2671,16 @@ if (type === "nps") { if (widgetResult) { if (!widgetResult.rating) { - log(logLevelEnums.ERROR, "reportFeedbackWidgetManually, Widget must contain rating property"); + log(logLevelEnums.ERROR, "[reportFeedbackWidgetManually] Widget must contain rating property"); return; } widgetResult.rating = Math.round(widgetResult.rating); if (widgetResult.rating > 10) { - log(logLevelEnums.WARNING, "reportFeedbackWidgetManually, You have entered a rating higher than 10. Changing it back to 10 now."); + log(logLevelEnums.WARNING, "[reportFeedbackWidgetManually] You have entered a rating higher than 10. Changing it back to 10 now."); widgetResult.rating = 10; } else if (widgetResult.rating < 0) { - log(logLevelEnums.WARNING, "reportFeedbackWidgetManually, You have entered a rating lower than 0. Changing it back to 0 now."); + log(logLevelEnums.WARNING, "[reportFeedbackWidgetManually] You have entered a rating lower than 0. Changing it back to 0 now."); widgetResult.rating = 0; } props = ["rating", "comment"]; @@ -2690,7 +2690,7 @@ else if (type === "survey") { if (widgetResult) { if (Object.keys(widgetResult).length < 1) { - log(logLevelEnums.ERROR, "reportFeedbackWidgetManually, Widget should have answers to be reported"); + log(logLevelEnums.ERROR, "[reportFeedbackWidgetManually] Widget should have answers to be reported"); return; } props = Object.keys(widgetResult); @@ -2700,16 +2700,16 @@ else if (type === "rating") { if (widgetResult) { if (!widgetResult.rating) { - log(logLevelEnums.ERROR, "reportFeedbackWidgetManually, Widget must contain rating property"); + log(logLevelEnums.ERROR, "[reportFeedbackWidgetManually] Widget must contain rating property"); return; } widgetResult.rating = Math.round(widgetResult.rating); if (widgetResult.rating > 5) { - log(logLevelEnums.WARNING, "reportFeedbackWidgetManually, You have entered a rating higher than 5. Changing it back to 5 now."); + log(logLevelEnums.WARNING, "[reportFeedbackWidgetManually] You have entered a rating higher than 5. Changing it back to 5 now."); widgetResult.rating = 5; } else if (widgetResult.rating < 1) { - log(logLevelEnums.WARNING, "reportFeedbackWidgetManually, You have entered a rating lower than 1. Changing it back to 1 now."); + log(logLevelEnums.WARNING, "[reportFeedbackWidgetManually] You have entered a rating lower than 1. Changing it back to 1 now."); widgetResult.rating = 1; } props = ["rating", "comment", "email", "contactMe"]; @@ -2717,7 +2717,7 @@ eventKey = internalEventKeyEnums.STAR_RATING; } else { - log(logLevelEnums.ERROR, "reportFeedbackWidgetManually, Widget has an unacceptable type"); + log(logLevelEnums.ERROR, "[reportFeedbackWidgetManually] Widget has an unacceptable type"); return; } @@ -2741,7 +2741,7 @@ } // add event - log(logLevelEnums.INFO, "reportFeedbackWidgetManually, Reporting " + type + ": ", event); + log(logLevelEnums.INFO, "[reportFeedbackWidgetManually] Reporting " + type + ": ", event); add_cly_events(event); }; /** @@ -2751,7 +2751,7 @@ * @deprecated use 'presentRatingWidgetWithID' in place of this call */ this.show_feedback_popup = function(id) { - log(logLevelEnums.WARNING, "show_feedback_popup, Deprecated function call! Use 'presentRatingWidgetWithID' in place of this call. Call will be redirected now!"); + log(logLevelEnums.WARNING, "[show_feedback_popup] Deprecated function call! Use 'presentRatingWidgetWithID' in place of this call. Call will be redirected now!"); this.presentRatingWidgetWithID(id); }; /** @@ -2759,17 +2759,17 @@ * @param {string} id - id value of related rating widget, you can get this value by click "Copy ID" button in row menu at "Feedback widgets" screen */ this.presentRatingWidgetWithID = function(id) { - log(logLevelEnums.INFO, "presentRatingWidgetWithID, Showing rating widget popup for the widget with ID: [ " + id + " ]"); + log(logLevelEnums.INFO, "[presentRatingWidgetWithID] Showing rating widget popup for the widget with ID: [ " + id + " ]"); if (!this.check_consent(featureEnums.STAR_RATING)) { return; } if (offlineMode) { - log(logLevelEnums.ERROR, "presentRatingWidgetWithID, Cannot show ratingWidget popup in offline mode"); + log(logLevelEnums.ERROR, "[presentRatingWidgetWithID] Cannot show ratingWidget popup in offline mode"); } else { - sendXmlHttpRequest("presentRatingWidgetWithID", this.url + "/o/feedback/widget", { widget_id: id }, function(err, params, responseText) { + sendXmlHttpRequest("[presentRatingWidgetWithID]", this.url + "/o/feedback/widget", { widget_id: id }, function(err, params, responseText) { if (err) { - log(logLevelEnums.ERROR, "presentRatingWidgetWithID, An error occurred: " + err); + log(logLevelEnums.ERROR, "[presentRatingWidgetWithID] An error occurred: " + err); return; } try { @@ -2778,7 +2778,7 @@ processWidget(currentWidget, false); } catch (JSONParseError) { - log(logLevelEnums.ERROR, "presentRatingWidgetWithID, JSON parse failed: " + JSONParseError); + log(logLevelEnums.ERROR, "[presentRatingWidgetWithID] JSON parse failed: " + JSONParseError); } // JSON array can pass }, true); @@ -2792,7 +2792,7 @@ * @deprecated use 'initializeRatingWidgets' in place of this call */ this.initialize_feedback_popups = function(enableWidgets) { - log(logLevelEnums.WARNING, "initialize_feedback_popups, Deprecated function call! Use 'initializeRatingWidgets' in place of this call. Call will be redirected now!"); + log(logLevelEnums.WARNING, "[initialize_feedback_popups] Deprecated function call! Use 'initializeRatingWidgets' in place of this call. Call will be redirected now!"); this.initializeRatingWidgets(enableWidgets); }; /** @@ -2800,7 +2800,7 @@ * @param {array=} enableWidgets - widget ids array */ this.initializeRatingWidgets = function(enableWidgets) { - log(logLevelEnums.INFO, "initializeRatingWidgets, Initializing rating widget with provided widget IDs:[ " + enableWidgets + "]"); + log(logLevelEnums.INFO, "[initializeRatingWidgets] Initializing rating widget with provided widget IDs:[ " + enableWidgets + "]"); if (!this.check_consent(featureEnums.STAR_RATING)) { return; } @@ -2814,9 +2814,9 @@ stickers[0].remove(); } - sendXmlHttpRequest("initializeRatingWidgets", this.url + "/o/feedback/multiple-widgets-by-id", { widgets: JSON.stringify(enableWidgets) }, function(err, params, responseText) { + sendXmlHttpRequest("[initializeRatingWidgets]", this.url + "/o/feedback/multiple-widgets-by-id", { widgets: JSON.stringify(enableWidgets) }, function(err, params, responseText) { if (err) { - log(logLevelEnums.ERROR, "initializeRatingWidgets, An error occurred: " + err); + log(logLevelEnums.ERROR, "[initializeRatingWidgets] An error occurred: " + err); return; } try { @@ -2853,7 +2853,7 @@ } } catch (JSONParseError) { - log(logLevelEnums.ERROR, "initializeRatingWidgets, JSON parse error: " + JSONParseError); + log(logLevelEnums.ERROR, "[initializeRatingWidgets] JSON parse error: " + JSONParseError); } // JSON array can pass }, true); @@ -2867,7 +2867,7 @@ * @deprecated use 'enableRatingWidgets' in place of this call * */ this.enable_feedback = function(params) { - log(logLevelEnums.WARNING, "enable_feedback, Deprecated function call! Use 'enableRatingWidgets' in place of this call. Call will be redirected now!"); + log(logLevelEnums.WARNING, "[enable_feedback] Deprecated function call! Use 'enableRatingWidgets' in place of this call. Call will be redirected now!"); this.enableRatingWidgets(params); }; /** @@ -2876,12 +2876,12 @@ * example params: {"popups":["5b21581b967c4850a7818617"]} * */ this.enableRatingWidgets = function(params) { - log(logLevelEnums.INFO, "enableRatingWidgets, Enabling rating widget with params:", params); + log(logLevelEnums.INFO, "[enableRatingWidgets] Enabling rating widget with params:", params); if (!this.check_consent(featureEnums.STAR_RATING)) { return; } if (offlineMode) { - log(logLevelEnums.ERROR, "enableRatingWidgets, Cannot enable rating widgets in offline mode"); + log(logLevelEnums.ERROR, "[enableRatingWidgets] Cannot enable rating widgets in offline mode"); } else { setValueInStorage("cly_fb_widgets", params.popups || params.widgets); @@ -2896,7 +2896,7 @@ this.initializeRatingWidgets(enableWidgets); } else { - log(logLevelEnums.ERROR, "enableRatingWidgets, You should provide at least one widget id as param. Read documentation for more detail. https://resources.count.ly/plugins/feedback"); + log(logLevelEnums.ERROR, "[enableRatingWidgets] You should provide at least one widget id as param. Read documentation for more detail. https://resources.count.ly/plugins/feedback"); } } }; @@ -2906,7 +2906,7 @@ * @param {Function} callback - Callback function with two parameters, 1st for returned list, 2nd for error * */ this.get_available_feedback_widgets = function(callback) { - log(logLevelEnums.INFO, "get_available_feedback_widgets, Getting the feedback list, callback function is provided:[" + (!!callback) + "]"); + log(logLevelEnums.INFO, "[get_available_feedback_widgets] Getting the feedback list, callback function is provided:[" + (!!callback) + "]"); if (!this.check_consent(featureEnums.FEEDBACK)) { if (callback) { callback(null, new Error("Consent for feedback not provided.")); @@ -2915,7 +2915,7 @@ } if (offlineMode) { - log(logLevelEnums.ERROR, "get_available_feedback_widgets, Cannot enable feedback widgets in offline mode."); + log(logLevelEnums.ERROR, "[get_available_feedback_widgets] Cannot enable feedback widgets in offline mode."); return; } @@ -2926,9 +2926,9 @@ app_key: this.app_key }; - sendXmlHttpRequest("get_available_feedback_widgets", url, data, function(err, params, responseText) { + sendXmlHttpRequest("[get_available_feedback_widgets]", url, data, function(err, params, responseText) { if (err) { - log(logLevelEnums.ERROR, "get_available_feedback_widgets, Error occurred while fetching feedbacks: " + err); + log(logLevelEnums.ERROR, "[get_available_feedback_widgets] Error occurred while fetching feedbacks: " + err); if (callback) { callback(null, err); } @@ -2943,7 +2943,7 @@ } } catch (error) { - log(logLevelEnums.ERROR, "get_available_feedback_widgets, Error while parsing feedback widgets list: " + error); + log(logLevelEnums.ERROR, "[get_available_feedback_widgets] Error while parsing feedback widgets list: " + error); if (callback) { callback(null, error); } @@ -2959,10 +2959,10 @@ * */ this.getFeedbackWidgetData = function(CountlyFeedbackWidget, callback) { if (!CountlyFeedbackWidget.type) { - log(logLevelEnums.ERROR, "getFeedbackWidgetData, Expected the provided widget object to have a type but got: [" + JSON.stringify(CountlyFeedbackWidget) + "], aborting."); + log(logLevelEnums.ERROR, "[getFeedbackWidgetData] Expected the provided widget object to have a type but got: [" + JSON.stringify(CountlyFeedbackWidget) + "], aborting."); return; } - log(logLevelEnums.INFO, "getFeedbackWidgetData, Retrieving data for: [" + JSON.stringify(CountlyFeedbackWidget) + "], callback function is provided:[" + (!!callback) + "]"); + log(logLevelEnums.INFO, "[getFeedbackWidgetData] Retrieving data for: [" + JSON.stringify(CountlyFeedbackWidget) + "], callback function is provided:[" + (!!callback) + "]"); if (!this.check_consent(featureEnums.FEEDBACK)) { if (callback) { callback(null, new Error("Consent for feedback not provided.")); @@ -2971,7 +2971,7 @@ } if (offlineMode) { - log(logLevelEnums.ERROR, "getFeedbackWidgetData, Cannot enable feedback widgets in offline mode."); + log(logLevelEnums.ERROR, "[getFeedbackWidgetData] Cannot enable feedback widgets in offline mode."); return; } @@ -2996,11 +2996,11 @@ url += "/o/surveys/rating/widget"; } else { - log(logLevelEnums.ERROR, "getFeedbackWidgetData, Unknown type info: [" + CountlyFeedbackWidget.type + "]"); + log(logLevelEnums.ERROR, "[getFeedbackWidgetData] Unknown type info: [" + CountlyFeedbackWidget.type + "]"); return; } - sendXmlHttpRequest("getFeedbackWidgetData", url, data, responseCallback, true); + sendXmlHttpRequest("[getFeedbackWidgetData]", url, data, responseCallback, true); /** * Server response would be evaluated here @@ -3010,7 +3010,7 @@ */ function responseCallback(err, params, responseText) { if (err) { - log(logLevelEnums.ERROR, "getFeedbackWidgetData, Error occurred while fetching feedbacks: " + err); + log(logLevelEnums.ERROR, "[getFeedbackWidgetData] Error occurred while fetching feedbacks: " + err); if (callback) { callback(null, err); } @@ -3025,7 +3025,7 @@ } } catch (error) { - log(logLevelEnums.ERROR, "getFeedbackWidgetData, Error while parsing feedback widgets list: " + error); + log(logLevelEnums.ERROR, "[getFeedbackWidgetData] Error while parsing feedback widgets list: " + error); if (callback) { callback(null, error); } @@ -3040,7 +3040,7 @@ * @param {String} className - Class name to append the feedback widget * */ this.present_feedback_widget = function(presentableFeedback, id, className) { - log(logLevelEnums.INFO, "present_feedback_widget, Presenting the feedback widget by appending to the element with ID: [ " + id + " ] and className: [ " + className + " ]"); + log(logLevelEnums.INFO, "[present_feedback_widget] Presenting the feedback widget by appending to the element with ID: [ " + id + " ] and className: [ " + className + " ]"); if (!this.check_consent(featureEnums.FEEDBACK)) { return; } @@ -3049,7 +3049,7 @@ || (typeof presentableFeedback !== "object") || Array.isArray(presentableFeedback) ) { - log(logLevelEnums.ERROR, "present_feedback_widget, Please provide at least one feedback widget object."); + log(logLevelEnums.ERROR, "[present_feedback_widget] Please provide at least one feedback widget object."); return; } @@ -3057,19 +3057,19 @@ var url = this.url; if (presentableFeedback.type === "nps") { - log(logLevelEnums.DEBUG, "present_feedback_widget, Widget type: nps."); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Widget type: nps."); url += "/feedback/nps"; } else if (presentableFeedback.type === "survey") { - log(logLevelEnums.DEBUG, "present_feedback_widget, Widget type: survey."); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Widget type: survey."); url += "/feedback/survey"; } else if (presentableFeedback.type === "rating") { - log(logLevelEnums.DEBUG, "present_feedback_widget, Widget type: rating."); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Widget type: rating."); url += "/feedback/rating"; } else { - log(logLevelEnums.ERROR, "present_feedback_widget, Feedback widget only accepts nps, rating and survey types."); + log(logLevelEnums.ERROR, "[present_feedback_widget] Feedback widget only accepts nps, rating and survey types."); return; } @@ -3078,14 +3078,14 @@ // set feedback widget family as ratings and load related style file when type is ratings if (presentableFeedback.type === "rating") { - log(logLevelEnums.DEBUG, "present_feedback_widget, Loading css for rating widget."); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Loading css for rating widget."); feedbackWidgetFamily = "ratings"; loadCSS(this.url + "/star-rating/stylesheets/countly-feedback-web.css"); } // if it's not ratings, it means we need to name it as surveys and load related style file // (at least until we add new type in future) else { - log(logLevelEnums.DEBUG, "present_feedback_widget, Loading css for survey or nps."); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Loading css for survey or nps."); loadCSS(this.url + "/surveys/stylesheets/countly-surveys.css"); feedbackWidgetFamily = "surveys"; } @@ -3123,7 +3123,7 @@ // Any subsequent onload means that the survey is being refreshed or reset. // This time hide it as being done in the above check. initiated = true; - log(logLevelEnums.DEBUG, "present_feedback_widget, Loaded iframe."); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Loaded iframe."); }; var overlay = document.getElementById("csbg"); @@ -3131,14 +3131,14 @@ // Remove any existing overlays overlay.remove(); overlay = document.getElementById("csbg"); - log(logLevelEnums.DEBUG, "present_feedback_widget, Removing past overlay."); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Removing past overlay."); } var wrapper = document.getElementsByClassName("countly-" + feedbackWidgetFamily + "-wrapper"); for (var i = 0; i < wrapper.length; i++) { // Remove any existing feedback wrappers wrapper[i].remove(); - log(logLevelEnums.DEBUG, "present_feedback_widget, Removed a wrapper."); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Removed a wrapper."); } wrapper = document.createElement("div"); @@ -3159,7 +3159,7 @@ found = true; } else { - log(logLevelEnums.ERROR, "present_feedback_widget, Provided ID not found."); + log(logLevelEnums.ERROR, "[present_feedback_widget] Provided ID not found."); } } @@ -3170,7 +3170,7 @@ element = document.getElementsByClassName(className)[0]; } else { - log(logLevelEnums.ERROR, "present_feedback_widget, Provided class not found."); + log(logLevelEnums.ERROR, "[present_feedback_widget] Provided class not found."); } } } @@ -3183,7 +3183,7 @@ ratingsOverlay.className = "countly-ratings-overlay"; ratingsOverlay.id = "countly-ratings-overlay-" + presentableFeedback._id; wrapper.appendChild(ratingsOverlay); - log(logLevelEnums.DEBUG, "present_feedback_widget, appended the rating overlay to wrapper"); + log(logLevelEnums.DEBUG, "[present_feedback_widget] appended the rating overlay to wrapper"); // add an event listener for the overlay // so if someone clicked on the overlay, we can close popup @@ -3193,20 +3193,20 @@ } wrapper.appendChild(iframe); - log(logLevelEnums.DEBUG, "present_feedback_widget, Appended the iframe"); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Appended the iframe"); add_event(window, "message", function(e) { var data = {}; try { data = JSON.parse(e.data); - log(logLevelEnums.DEBUG, "present_feedback_widget, Parsed response message " + data); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Parsed response message " + data); } catch (ex) { - log(logLevelEnums.ERROR, "present_feedback_widget, Error while parsing message body " + ex); + log(logLevelEnums.ERROR, "[present_feedback_widget] Error while parsing message body " + ex); } if (!data.close) { - log(logLevelEnums.DEBUG, "present_feedback_widget, Closing signal not sent yet"); + log(logLevelEnums.DEBUG, "[present_feedback_widget] Closing signal not sent yet"); return; } @@ -3320,7 +3320,7 @@ } } catch (e) { - log(logLevelEnums.ERROR, "present_feedback_widget, Something went wrong while presenting the widget: " + e); + log(logLevelEnums.ERROR, "[present_feedback_widget] Something went wrong while presenting the widget: " + e); } /** @@ -3339,7 +3339,7 @@ function showRatingForFeedbackWidget(feedback) { // render sticker if hide sticker property isn't set if (!feedback.appearance.hideS) { - log(logLevelEnums.DEBUG, "present_feedback_widget, handling the sticker as it was not set to hidden"); + log(logLevelEnums.DEBUG, "[present_feedback_widget] handling the sticker as it was not set to hidden"); // create sticker wrapper element var sticker = document.createElement("div"); sticker.innerText = feedback.appearance.text; @@ -3371,7 +3371,7 @@ * @param {Object} segments - custom crash segments */ this.recordError = function(err, nonfatal, segments) { - log(logLevelEnums.INFO, "recordError, Recording error"); + log(logLevelEnums.INFO, "[recordError] Recording error"); if (this.check_consent(featureEnums.CRASHES) && err) { // crashSegments, if not null, was set while enabling error tracking segments = segments || crashSegments; @@ -3504,7 +3504,7 @@ // prevent widget create process if widget exist with same id var isDuplicate = !!document.getElementById("countly-feedback-sticker-" + currentWidget._id); if (isDuplicate) { - log(logLevelEnums.ERROR, "Widget with same ID exists"); + log(logLevelEnums.ERROR, "[FeedbackWidget] Widget with same ID exists"); return; } try { @@ -3575,7 +3575,7 @@ } } catch (e) { - log(logLevelEnums.ERROR, "Somethings went wrong while element injecting process: " + e); + log(logLevelEnums.ERROR, "[FeedbackWidget] Somethings went wrong while element injecting process: " + e); } } @@ -3695,12 +3695,12 @@ */ function toRequestQueue(request) { if (self.ignore_visitor) { - log(logLevelEnums.WARNING, "User is opt_out will ignore the request: " + request); + log(logLevelEnums.WARNING, "[RequestQueue] User is opt_out will ignore the request: " + request); return; } if (!self.app_key || !self.device_id) { - log(logLevelEnums.ERROR, "app_key or device_id is missing ", self.app_key, self.device_id); + log(logLevelEnums.ERROR, "[RequestQueue] app_key or device_id is missing ", self.app_key, self.device_id); return; } @@ -3725,7 +3725,7 @@ // ignore bots if (self.ignore_visitor) { hasPulse = false; - log(logLevelEnums.WARNING, "User opt_out, no heartbeat"); + log(logLevelEnums.WARNING, "[HeartBeat] User opt_out, no heartbeat"); return; } @@ -3738,7 +3738,7 @@ Countly.q = []; for (i = 0; i < q.length; i++) { req = q[i]; - log(logLevelEnums.DEBUG, "Processing queued call", req); + log(logLevelEnums.DEBUG, "[HeartBeat] Processing queued call", req); if (typeof req === "function") { req(); } @@ -3800,10 +3800,10 @@ readyToProcess = false; var params = requestQueue[0]; params.rr = requestQueue.length; // added at 23.2.3. It would give the current length of the queue. That includes the current request. - log(logLevelEnums.DEBUG, "Processing request", params); + log(logLevelEnums.DEBUG, "[HeartBeat] Processing request", params); setValueInStorage("cly_queue", requestQueue, true); if (!self.test_mode) { - sendXmlHttpRequest("send_request_queue", self.url + apiPath, params, function(err, parameters) { + sendXmlHttpRequest("[send_request_queue]", self.url + apiPath, params, function(err, parameters) { log(logLevelEnums.DEBUG, "Request Finished", parameters, err); if (err) { failTimeout = getTimestamp() + failTimeoutAmount; @@ -3913,13 +3913,13 @@ try { var reg = new RegExp(ignoreReferrers[k]); if (reg.test(document.referrer)) { - log(logLevelEnums.DEBUG, "Ignored: " + document.referrer); + log(logLevelEnums.DEBUG, "[Metrics] Ignored: " + document.referrer); ignoring = true; break; } } catch (ex) { - log(logLevelEnums.ERROR, "Problem with ignoring: " + ignoreReferrers[k], ", error: " + ex); + log(logLevelEnums.ERROR, "[Metrics] Problem with ignoring: " + ignoreReferrers[k], ", error: " + ex); } } } @@ -3929,7 +3929,7 @@ } } - log(logLevelEnums.DEBUG, "Got metrics", metrics); + log(logLevelEnums.DEBUG, "[Metrics] Got metrics", metrics); return metrics; } @@ -3959,7 +3959,7 @@ extraArguments += arguments[i]; } // eslint-disable-next-line no-shadow - var log = level + message + extraArguments; + var log = level + "[Countly] " + message + extraArguments; // decide on the console if (level === logLevelEnums.ERROR) { // eslint-disable-next-line no-console @@ -3999,7 +3999,7 @@ function sendXmlHttpRequest(functionName, url, params, callback, useBroadResponseValidator) { useBroadResponseValidator = useBroadResponseValidator || false; try { - log(logLevelEnums.DEBUG, "Sending XML HTTP request"); + log(logLevelEnums.DEBUG, "[sendXmlHttpRequest] Sending XML HTTP request"); var xhr = null; if (window.XMLHttpRequest) { xhr = new window.XMLHttpRequest(); @@ -4026,7 +4026,7 @@ // fallback on error xhr.onreadystatechange = function() { if (this.readyState === 4) { - log(logLevelEnums.DEBUG, functionName + " HTTP request completed [" + this.status + "][" + this.responseText + "]"); + log(logLevelEnums.DEBUG, functionName + " [sendXmlHttpRequest] HTTP request completed [" + this.status + "][" + this.responseText + "]"); // response validation function will be selected to also accept JSON arrays if useBroadResponseValidator is true var isResponseValidated; if (useBroadResponseValidator) { @@ -4044,7 +4044,7 @@ } else { log(logLevelEnums.ERROR, functionName + " Failed Server XML HTTP request, ", this.status); - if (functionName === "send_request_queue") { + if (functionName === "[send_request_queue]") { HealthCheck.saveRequestCounters(this.status, this.responseText); } if (typeof callback === "function") { @@ -4062,7 +4062,7 @@ } catch (e) { // fallback - log(logLevelEnums.ERROR, functionName + " Failed XML HTTP request: " + e); + log(logLevelEnums.ERROR, functionName + " [sendXmlHttpRequest] Failed XML HTTP request: " + e); if (typeof callback === "function") { callback(true, params); } @@ -4081,7 +4081,7 @@ function isResponseValid(statusCode, str) { // status code and response format check if (!(statusCode >= 200 && statusCode < 300)) { - log(logLevelEnums.ERROR, "Http response status code is not within the expected range:[" + statusCode + "]"); + log(logLevelEnums.ERROR, "[ResponseValidation] Http response status code is not within the expected range:[" + statusCode + "]"); return false; } @@ -4091,14 +4091,14 @@ // check if parsed response is a JSON object, if not the response is not valid if (Object.prototype.toString.call(parsedResponse) !== "[object Object]") { - log(logLevelEnums.ERROR, "Http response is not JSON Object"); + log(logLevelEnums.ERROR, "[ResponseValidation] Http response is not JSON Object"); return false; } return !!(parsedResponse.result); } catch (e) { - log(logLevelEnums.ERROR, "Http response is not JSON: " + e); + log(logLevelEnums.ERROR, "[ResponseValidation] Http response is not JSON: " + e); return false; } } @@ -4115,7 +4115,7 @@ function isResponseValidBroad(statusCode, str) { // status code and response format check if (!(statusCode >= 200 && statusCode < 300)) { - log(logLevelEnums.ERROR, "Http response status code is not within the expected range: " + statusCode); + log(logLevelEnums.ERROR, "[ResponseValidationBroad] Http response status code is not within the expected range: " + statusCode); return false; } @@ -4124,7 +4124,7 @@ var parsedResponse = JSON.parse(str); // check if parsed response is a JSON object or JSON array, if not it is not valid if ((Object.prototype.toString.call(parsedResponse) !== "[object Object]") && (!Array.isArray(parsedResponse))) { - log(logLevelEnums.ERROR, "Http response is not JSON Object nor JSON Array"); + log(logLevelEnums.ERROR, "[ResponseValidationBroad] Http response is not JSON Object nor JSON Array"); return false; } @@ -4132,7 +4132,7 @@ return true; } catch (e) { - log(logLevelEnums.ERROR, "Http response is not JSON: " + e); + log(logLevelEnums.ERROR, "[ResponseValidationBroad] Http response is not JSON: " + e); return false; } } @@ -4276,7 +4276,7 @@ function getValueFromStorage(key, useLocalStorage, useRawKey) { // check if we should use storage at all if (self.storage === "none") { - log(logLevelEnums.WARNING, "Storage is disabled. Value with key: " + key + " won't be retrieved"); + log(logLevelEnums.WARNING, "[Storage] Storage is disabled. Value with key: " + key + " won't be retrieved"); return; } @@ -4316,7 +4316,7 @@ function setValueInStorage(key, value, useLocalStorage, useRawKey) { // check if we should use storage options at all if (self.storage === "none") { - log(logLevelEnums.WARNING, "Storage is disabled. Value with key: " + key + " won't be stored"); + log(logLevelEnums.WARNING, "[Storage] Storage is disabled. Value with key: " + key + " won't be stored"); return; } @@ -4355,7 +4355,7 @@ function removeValueFromStorage(key, useLocalStorage, useRawKey) { // check if we should use storage options at all if (self.storage === "none") { - log(logLevelEnums.WARNING, "Storage is disabled. Value with key: " + key + " won't be removed"); + log(logLevelEnums.WARNING, "[Storage] Storage is disabled. Value with key: " + key + " won't be removed"); return; } @@ -4425,7 +4425,7 @@ * @param {Varies} newValue - new value for storage */ this.onStorageChange = function(key, newValue) { - log(logLevelEnums.INFO, "onStorageChange, Applying storage changes"); + log(logLevelEnums.INFO, "[Storage] onStorageChange, Applying storage changes"); switch (key) { // queue of requests case "cly_queue": @@ -4598,12 +4598,12 @@ // add common request params prepareRequest(request); // send request - sendXmlHttpRequest("healthCheck", self.url + apiPath, request, function(err, params, status, responseText) { + sendXmlHttpRequest("[healthCheck]", self.url + apiPath, request, function(err, params, status, responseText) { if (err) { - log(logLevelEnums.ERROR, "healthCheck, An error occurred. Status: [" + status + "], response: [" + responseText + "]"); + log(logLevelEnums.ERROR, "[healthCheck] An error occurred. Status: [" + status + "], response: [" + responseText + "]"); } else { - log(logLevelEnums.INFO, "healthCheck, Request was successful. Status: [" + status + "], response: [" + responseText + "]"); + log(logLevelEnums.INFO, "[healthCheck] Request was successful. Status: [" + status + "], response: [" + responseText + "]"); // reset and save health check counters if request was successful HealthCheck.resetAndSaveCounters(); }