From 5973fb9146036153b43fcaa57706209b105d1fdc Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Thu, 25 Jan 2024 16:21:20 +0300 Subject: [PATCH 1/2] feat: add warning for defaults --- examples/apm_example.js | 11 +++++++++-- examples/bulk_import_example.js | 11 +++++++++-- examples/example.js | 12 +++++++++--- examples/multi-process.js | 11 +++++++++-- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/examples/apm_example.js b/examples/apm_example.js index be2da01..ccb3ca8 100644 --- a/examples/apm_example.js +++ b/examples/apm_example.js @@ -1,10 +1,17 @@ //since we need to test crashing the app /*global app*/ +const COUNTLY_SERVER_KEY = "https://your.server.ly"; +const COUNTLY_APP_KEY = "YOUR_APP_KEY"; + +if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly"){ + throw new Error("Please do not use default set of app key and server url") +} + var Countly = require("../lib/countly.js"); Countly.init({ - app_key: "YOUR_APP_KEY", - url: "https://try.count.ly", //your server goes here + app_key: COUNTLY_APP_KEY, + url: COUNTLY_SERVER_KEY, //your server goes here debug: true }); diff --git a/examples/bulk_import_example.js b/examples/bulk_import_example.js index 83da019..2ace9d2 100644 --- a/examples/bulk_import_example.js +++ b/examples/bulk_import_example.js @@ -1,8 +1,15 @@ +const COUNTLY_SERVER_KEY = "https://your.server.ly"; +const COUNTLY_APP_KEY = "YOUR_APP_KEY"; + +if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly"){ + throw new Error("Please do not use default set of app key and server url") +} + var CountlyBulk = require("../lib/countly").Bulk; var server = new CountlyBulk({ - app_key: "YOUR_APP_KEY", - url: "https://try.count.ly", //your server goes here + app_key: COUNTLY_APP_KEY, + url: COUNTLY_SERVER_KEY, //your server goes here debug: true }); diff --git a/examples/example.js b/examples/example.js index 65fdd35..9912668 100644 --- a/examples/example.js +++ b/examples/example.js @@ -1,14 +1,20 @@ //since we need to test crashing the app /*global runthis, crashDaApp*/ +const COUNTLY_SERVER_KEY = "https://your.server.ly"; +const COUNTLY_APP_KEY = "YOUR_APP_KEY"; + +if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly"){ + throw new Error("Please do not use default set of app key and server url") +} + var Countly = require("../lib/countly.js"); Countly.init({ - app_key: "YOUR_APP_KEY", - url: "https://try.count.ly", //your server goes here + app_key: COUNTLY_APP_KEY, + url: COUNTLY_SERVER_KEY, //your server goes here debug: true }); - Countly.begin_session(); Countly.track_errors(); diff --git a/examples/multi-process.js b/examples/multi-process.js index 5e1e711..f7cf7e3 100644 --- a/examples/multi-process.js +++ b/examples/multi-process.js @@ -13,11 +13,18 @@ else if (cluster.isWorker) { console.log("I am worker " + cluster.worker.id); } +const COUNTLY_SERVER_KEY = "https://your.server.ly"; +const COUNTLY_APP_KEY = "YOUR_APP_KEY"; + +if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly"){ + throw new Error("Please do not use default set of app key and server url") +} + var Countly = require("../lib/countly.js"); Countly.init({ - app_key: "YOUR_APP_KEY", - url: "https://try.count.ly", //your server goes here + app_key: COUNTLY_APP_KEY, + url: COUNTLY_SERVER_KEY, //your server goes here debug: true }); From 7c5e92b0656c77f8d6e4c69947735ccb296cb32f Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Fri, 26 Jan 2024 09:06:49 +0300 Subject: [PATCH 2/2] feat: warn --- examples/apm_example.js | 2 +- examples/bulk_import_example.js | 2 +- examples/example.js | 2 +- examples/multi-process.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/apm_example.js b/examples/apm_example.js index ccb3ca8..93d9163 100644 --- a/examples/apm_example.js +++ b/examples/apm_example.js @@ -4,7 +4,7 @@ const COUNTLY_SERVER_KEY = "https://your.server.ly"; const COUNTLY_APP_KEY = "YOUR_APP_KEY"; if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly"){ - throw new Error("Please do not use default set of app key and server url") + console.warn("Please do not use default set of app key and server url") } var Countly = require("../lib/countly.js"); diff --git a/examples/bulk_import_example.js b/examples/bulk_import_example.js index 2ace9d2..65a9d76 100644 --- a/examples/bulk_import_example.js +++ b/examples/bulk_import_example.js @@ -2,7 +2,7 @@ const COUNTLY_SERVER_KEY = "https://your.server.ly"; const COUNTLY_APP_KEY = "YOUR_APP_KEY"; if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly"){ - throw new Error("Please do not use default set of app key and server url") + console.warn("Please do not use default set of app key and server url") } var CountlyBulk = require("../lib/countly").Bulk; diff --git a/examples/example.js b/examples/example.js index 9912668..635f7e7 100644 --- a/examples/example.js +++ b/examples/example.js @@ -4,7 +4,7 @@ const COUNTLY_SERVER_KEY = "https://your.server.ly"; const COUNTLY_APP_KEY = "YOUR_APP_KEY"; if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly"){ - throw new Error("Please do not use default set of app key and server url") + console.warn("Please do not use default set of app key and server url") } var Countly = require("../lib/countly.js"); diff --git a/examples/multi-process.js b/examples/multi-process.js index f7cf7e3..59086fe 100644 --- a/examples/multi-process.js +++ b/examples/multi-process.js @@ -17,7 +17,7 @@ const COUNTLY_SERVER_KEY = "https://your.server.ly"; const COUNTLY_APP_KEY = "YOUR_APP_KEY"; if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly"){ - throw new Error("Please do not use default set of app key and server url") + console.warn("Please do not use default set of app key and server url") } var Countly = require("../lib/countly.js");