@discordanalytics/core 2.6.1 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +6 -25
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -10,35 +10,16 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
15
  };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
38
19
  Object.defineProperty(exports, "__esModule", { value: true });
39
20
  exports.CustomEvent = exports.AnalyticsBase = void 0;
40
21
  const types_1 = require("./types");
41
- const node_fetch_1 = __importStar(require("node-fetch"));
22
+ const node_fetch_1 = __importDefault(require("node-fetch"));
42
23
  /**
43
24
  * DiscordAnalytics Base Class
44
25
  * @class AnalyticsBase
@@ -250,11 +231,11 @@ class CustomEvent {
250
231
  this.ensure();
251
232
  }
252
233
  async ensure() {
253
- if (typeof this._analytics.stats_data.custom_events[this._event_key] !== 'number') {
234
+ if (typeof this._analytics.stats_data.custom_events[this._event_key] !== 'number' && process.env.NODE_ENV === 'production') {
254
235
  this._analytics.debug(`[DISCORDANALYTICS] Fetching value for event ${this._event_key}`);
255
236
  const url = types_1.ApiEndpoints.EVENT_URL.replace(':id', this._analytics.client_id).replace(':event', this._event_key);
256
237
  const res = await this._analytics.api_call_with_retries('GET', url);
257
- if (res instanceof node_fetch_1.Response && this._last_action !== 'set') {
238
+ if (res instanceof Response && this._last_action !== 'set') {
258
239
  const data = await res.json();
259
240
  this._analytics.stats_data.custom_events[this._event_key] = (this._analytics.stats_data.custom_events[this._event_key] || 0) + (data.today_value || 0);
260
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discordanalytics/core",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "description": "Core package to work with Discord Analytics",
5
5
  "main": "dist/index.js",
6
6
  "author": "Discord Analytics",
@@ -14,7 +14,8 @@
14
14
  "url": "https://github.com/DiscordAnalytics/node-package/issues"
15
15
  },
16
16
  "dependencies": {
17
- "node-fetch": "^3.0.0"
17
+ "@types/node-fetch": "^2.6.13",
18
+ "node-fetch": "^2.7.0"
18
19
  },
19
20
  "devDependencies": {
20
21
  "@types/node": "*",