posthog-node 5.9.3 → 5.9.5
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.
- package/dist/client.d.ts +0 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -7
- package/dist/client.mjs +5 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +2 -2
- package/src/client.ts +5 -13
- package/src/version.ts +1 -1
- package/dist/utils/logger.d.ts +0 -3
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -63
- package/dist/utils/logger.mjs +0 -29
- package/src/utils/logger.ts +0 -39
package/dist/client.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
8
8
|
private featureFlagsPoller?;
|
|
9
9
|
protected errorTracking: ErrorTracking;
|
|
10
10
|
private maxCacheSize;
|
|
11
|
-
private logger;
|
|
12
11
|
readonly options: PostHogOptions;
|
|
13
12
|
distinctIdHasSentFlagCalls: Record<string, string[]>;
|
|
14
13
|
/**
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,oBAAoB,EAEpB,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAC/B,wBAAwB,EAExB,qBAAqB,EAEtB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,cAAc,EAEf,MAAM,SAAS,CAAA;AAChB,OAAO,EAAqB,gBAAgB,EAAuB,MAAM,eAAe,CAAA;AAExF,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAkB,sBAAsB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","source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E,GAAG,CAAC,GAClD,OAAO,CAAC,IAAI,CAAC;IASH,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAC7D,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,EAAE,sBAAsB,CAAA;QAClC,OAAO,EAAE,qBAAqB,CAAA;KAC/B,CAAC;IA8EF,OAAO,CAAC,cAAc;CAuBvB"}
|
package/dist/client.js
CHANGED
|
@@ -41,7 +41,6 @@ const feature_flags_js_namespaceObject = require("./extensions/feature-flags/fea
|
|
|
41
41
|
const index_js_namespaceObject = require("./extensions/error-tracking/index.js");
|
|
42
42
|
var index_js_default = /*#__PURE__*/ __webpack_require__.n(index_js_namespaceObject);
|
|
43
43
|
const external_storage_memory_js_namespaceObject = require("./storage-memory.js");
|
|
44
|
-
const logger_js_namespaceObject = require("./utils/logger.js");
|
|
45
44
|
const MINIMUM_POLLING_INTERVAL = 100;
|
|
46
45
|
const THIRTY_SECONDS = 30000;
|
|
47
46
|
const MAX_CACHE_SIZE = 50000;
|
|
@@ -49,7 +48,6 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
49
48
|
constructor(apiKey, options = {}){
|
|
50
49
|
super(apiKey, options), this._memoryStorage = new external_storage_memory_js_namespaceObject.PostHogMemoryStorage();
|
|
51
50
|
this.options = options;
|
|
52
|
-
this.logger = (0, logger_js_namespaceObject.createLogger)(this.logMsgIfDebug.bind(this));
|
|
53
51
|
this.options.featureFlagsPollingInterval = 'number' == typeof options.featureFlagsPollingInterval ? Math.max(options.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
|
|
54
52
|
if (options.personalApiKey) {
|
|
55
53
|
if (options.personalApiKey.includes('phc_')) throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');
|
|
@@ -70,7 +68,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
70
68
|
customHeaders: this.getCustomHeaders()
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
|
-
this.errorTracking = new (index_js_default())(this, options, this.
|
|
71
|
+
this.errorTracking = new (index_js_default())(this, options, this._logger);
|
|
74
72
|
this.distinctIdHasSentFlagCalls = {};
|
|
75
73
|
this.maxCacheSize = options.maxCacheSize || MAX_CACHE_SIZE;
|
|
76
74
|
}
|
|
@@ -100,7 +98,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
100
98
|
this.featureFlagsPoller?.debug(enabled);
|
|
101
99
|
}
|
|
102
100
|
capture(props) {
|
|
103
|
-
if ('string' == typeof props) this.
|
|
101
|
+
if ('string' == typeof props) this._logger.warn('Called capture() with a string as the first argument when an object was expected.');
|
|
104
102
|
this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options })=>super.captureStateless(distinctId, event, properties, {
|
|
105
103
|
timestamp: options.timestamp,
|
|
106
104
|
disableGeoip: options.disableGeoip,
|
|
@@ -110,7 +108,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
110
108
|
}));
|
|
111
109
|
}
|
|
112
110
|
async captureImmediate(props) {
|
|
113
|
-
if ('string' == typeof props) this.
|
|
111
|
+
if ('string' == typeof props) this._logger.warn('Called captureImmediate() with a string as the first argument when an object was expected.');
|
|
114
112
|
return this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options })=>super.captureStatelessImmediate(distinctId, event, properties, {
|
|
115
113
|
timestamp: options.timestamp,
|
|
116
114
|
disableGeoip: options.disableGeoip,
|
|
@@ -460,12 +458,12 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
460
458
|
for (const fn of fns){
|
|
461
459
|
result = fn(result);
|
|
462
460
|
if (!result) {
|
|
463
|
-
this.
|
|
461
|
+
this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
|
|
464
462
|
return null;
|
|
465
463
|
}
|
|
466
464
|
if (!result.properties || 0 === Object.keys(result.properties).length) {
|
|
467
465
|
const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
|
|
468
|
-
this.
|
|
466
|
+
this._logger.warn(message);
|
|
469
467
|
}
|
|
470
468
|
}
|
|
471
469
|
return result;
|
package/dist/client.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import { PostHogCoreStateless, getFeatureFlagValue, isPlainObject, safeSetTimeou
|
|
|
3
3
|
import { FeatureFlagsPoller } from "./extensions/feature-flags/feature-flags.mjs";
|
|
4
4
|
import error_tracking from "./extensions/error-tracking/index.mjs";
|
|
5
5
|
import { PostHogMemoryStorage } from "./storage-memory.mjs";
|
|
6
|
-
import { createLogger } from "./utils/logger.mjs";
|
|
7
6
|
const MINIMUM_POLLING_INTERVAL = 100;
|
|
8
7
|
const THIRTY_SECONDS = 30000;
|
|
9
8
|
const MAX_CACHE_SIZE = 50000;
|
|
@@ -11,7 +10,6 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
11
10
|
constructor(apiKey, options = {}){
|
|
12
11
|
super(apiKey, options), this._memoryStorage = new PostHogMemoryStorage();
|
|
13
12
|
this.options = options;
|
|
14
|
-
this.logger = createLogger(this.logMsgIfDebug.bind(this));
|
|
15
13
|
this.options.featureFlagsPollingInterval = 'number' == typeof options.featureFlagsPollingInterval ? Math.max(options.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
|
|
16
14
|
if (options.personalApiKey) {
|
|
17
15
|
if (options.personalApiKey.includes('phc_')) throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');
|
|
@@ -32,7 +30,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
32
30
|
customHeaders: this.getCustomHeaders()
|
|
33
31
|
});
|
|
34
32
|
}
|
|
35
|
-
this.errorTracking = new error_tracking(this, options, this.
|
|
33
|
+
this.errorTracking = new error_tracking(this, options, this._logger);
|
|
36
34
|
this.distinctIdHasSentFlagCalls = {};
|
|
37
35
|
this.maxCacheSize = options.maxCacheSize || MAX_CACHE_SIZE;
|
|
38
36
|
}
|
|
@@ -62,7 +60,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
62
60
|
this.featureFlagsPoller?.debug(enabled);
|
|
63
61
|
}
|
|
64
62
|
capture(props) {
|
|
65
|
-
if ('string' == typeof props) this.
|
|
63
|
+
if ('string' == typeof props) this._logger.warn('Called capture() with a string as the first argument when an object was expected.');
|
|
66
64
|
this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options })=>super.captureStateless(distinctId, event, properties, {
|
|
67
65
|
timestamp: options.timestamp,
|
|
68
66
|
disableGeoip: options.disableGeoip,
|
|
@@ -72,7 +70,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
72
70
|
}));
|
|
73
71
|
}
|
|
74
72
|
async captureImmediate(props) {
|
|
75
|
-
if ('string' == typeof props) this.
|
|
73
|
+
if ('string' == typeof props) this._logger.warn('Called captureImmediate() with a string as the first argument when an object was expected.');
|
|
76
74
|
return this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options })=>super.captureStatelessImmediate(distinctId, event, properties, {
|
|
77
75
|
timestamp: options.timestamp,
|
|
78
76
|
disableGeoip: options.disableGeoip,
|
|
@@ -422,12 +420,12 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
422
420
|
for (const fn of fns){
|
|
423
421
|
result = fn(result);
|
|
424
422
|
if (!result) {
|
|
425
|
-
this.
|
|
423
|
+
this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`);
|
|
426
424
|
return null;
|
|
427
425
|
}
|
|
428
426
|
if (!result.properties || 0 === Object.keys(result.properties).length) {
|
|
429
427
|
const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`;
|
|
430
|
-
this.
|
|
428
|
+
this._logger.warn(message);
|
|
431
429
|
}
|
|
432
430
|
}
|
|
433
431
|
return result;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.9.
|
|
1
|
+
export declare const version = "5.9.5";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
version: ()=>version
|
|
28
28
|
});
|
|
29
|
-
const version = '5.9.
|
|
29
|
+
const version = '5.9.5';
|
|
30
30
|
exports.version = __webpack_exports__.version;
|
|
31
31
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
32
32
|
"version"
|
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '5.9.
|
|
1
|
+
const version = '5.9.5';
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-node",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.5",
|
|
4
4
|
"description": "PostHog Node.js integration",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"module": "dist/entrypoints/index.node.mjs",
|
|
26
26
|
"types": "dist/entrypoints/index.node.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@posthog/core": "1.2.
|
|
28
|
+
"@posthog/core": "1.2.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.0.0",
|
package/src/client.ts
CHANGED
|
@@ -25,7 +25,6 @@ import { FeatureFlagsPoller } from './extensions/feature-flags/feature-flags'
|
|
|
25
25
|
import ErrorTracking from './extensions/error-tracking'
|
|
26
26
|
import { safeSetTimeout, PostHogEventProperties } from '@posthog/core'
|
|
27
27
|
import { PostHogMemoryStorage } from './storage-memory'
|
|
28
|
-
import { createLogger } from './utils/logger'
|
|
29
28
|
|
|
30
29
|
// Standard local evaluation rate limit is 600 per minute (10 per second),
|
|
31
30
|
// so the fastest a poller should ever be set is 100ms.
|
|
@@ -40,7 +39,6 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
40
39
|
private featureFlagsPoller?: FeatureFlagsPoller
|
|
41
40
|
protected errorTracking: ErrorTracking
|
|
42
41
|
private maxCacheSize: number
|
|
43
|
-
private logger: Logger
|
|
44
42
|
public readonly options: PostHogOptions
|
|
45
43
|
|
|
46
44
|
distinctIdHasSentFlagCalls: Record<string, string[]>
|
|
@@ -79,8 +77,6 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
79
77
|
|
|
80
78
|
this.options = options
|
|
81
79
|
|
|
82
|
-
this.logger = createLogger(this.logMsgIfDebug.bind(this))
|
|
83
|
-
|
|
84
80
|
this.options.featureFlagsPollingInterval =
|
|
85
81
|
typeof options.featureFlagsPollingInterval === 'number'
|
|
86
82
|
? Math.max(options.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL)
|
|
@@ -115,7 +111,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
115
111
|
}
|
|
116
112
|
}
|
|
117
113
|
|
|
118
|
-
this.errorTracking = new ErrorTracking(this, options, this.
|
|
114
|
+
this.errorTracking = new ErrorTracking(this, options, this._logger)
|
|
119
115
|
this.distinctIdHasSentFlagCalls = {}
|
|
120
116
|
this.maxCacheSize = options.maxCacheSize || MAX_CACHE_SIZE
|
|
121
117
|
}
|
|
@@ -309,9 +305,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
309
305
|
*/
|
|
310
306
|
capture(props: EventMessage): void {
|
|
311
307
|
if (typeof props === 'string') {
|
|
312
|
-
this.
|
|
313
|
-
console.warn('Called capture() with a string as the first argument when an object was expected.')
|
|
314
|
-
)
|
|
308
|
+
this._logger.warn('Called capture() with a string as the first argument when an object was expected.')
|
|
315
309
|
}
|
|
316
310
|
this.addPendingPromise(
|
|
317
311
|
this.prepareEventMessage(props)
|
|
@@ -375,9 +369,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
375
369
|
*/
|
|
376
370
|
async captureImmediate(props: EventMessage): Promise<void> {
|
|
377
371
|
if (typeof props === 'string') {
|
|
378
|
-
this.
|
|
379
|
-
console.warn('Called captureImmediate() with a string as the first argument when an object was expected.')
|
|
380
|
-
)
|
|
372
|
+
this._logger.warn('Called captureImmediate() with a string as the first argument when an object was expected.')
|
|
381
373
|
}
|
|
382
374
|
return this.addPendingPromise(
|
|
383
375
|
this.prepareEventMessage(props)
|
|
@@ -1518,12 +1510,12 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
1518
1510
|
for (const fn of fns) {
|
|
1519
1511
|
result = fn(result)
|
|
1520
1512
|
if (!result) {
|
|
1521
|
-
this.
|
|
1513
|
+
this._logger.info(`Event '${eventMessage.event}' was rejected in beforeSend function`)
|
|
1522
1514
|
return null
|
|
1523
1515
|
}
|
|
1524
1516
|
if (!result.properties || Object.keys(result.properties).length === 0) {
|
|
1525
1517
|
const message = `Event '${result.event}' has no properties after beforeSend function, this is likely an error.`
|
|
1526
|
-
this.
|
|
1518
|
+
this._logger.warn(message)
|
|
1527
1519
|
}
|
|
1528
1520
|
}
|
|
1529
1521
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.9.
|
|
1
|
+
export const version = '5.9.5'
|
package/dist/utils/logger.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAsCtC,eAAO,MAAM,YAAY,GAAI,eAAe,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,WAAiD,CAAA"}
|
package/dist/utils/logger.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
createLogger: ()=>createLogger
|
|
28
|
-
});
|
|
29
|
-
const _createLogger = (prefix, logMsgIfDebug)=>{
|
|
30
|
-
const logger = {
|
|
31
|
-
_log: (level, ...args)=>{
|
|
32
|
-
logMsgIfDebug(()=>{
|
|
33
|
-
const consoleLog = console[level];
|
|
34
|
-
consoleLog(prefix, ...args);
|
|
35
|
-
});
|
|
36
|
-
},
|
|
37
|
-
info: (...args)=>{
|
|
38
|
-
logger._log('log', ...args);
|
|
39
|
-
},
|
|
40
|
-
warn: (...args)=>{
|
|
41
|
-
logger._log('warn', ...args);
|
|
42
|
-
},
|
|
43
|
-
error: (...args)=>{
|
|
44
|
-
logger._log('error', ...args);
|
|
45
|
-
},
|
|
46
|
-
critical: (...args)=>{
|
|
47
|
-
console.error(prefix, ...args);
|
|
48
|
-
},
|
|
49
|
-
uninitializedWarning: (methodName)=>{
|
|
50
|
-
logger.error(`You must initialize PostHog before calling ${methodName}`);
|
|
51
|
-
},
|
|
52
|
-
createLogger: (additionalPrefix)=>_createLogger(`${prefix} ${additionalPrefix}`, logMsgIfDebug)
|
|
53
|
-
};
|
|
54
|
-
return logger;
|
|
55
|
-
};
|
|
56
|
-
const createLogger = (logMsgIfDebug)=>_createLogger('[PostHog.js]', logMsgIfDebug);
|
|
57
|
-
exports.createLogger = __webpack_exports__.createLogger;
|
|
58
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
59
|
-
"createLogger"
|
|
60
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
61
|
-
Object.defineProperty(exports, '__esModule', {
|
|
62
|
-
value: true
|
|
63
|
-
});
|
package/dist/utils/logger.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const _createLogger = (prefix, logMsgIfDebug)=>{
|
|
2
|
-
const logger = {
|
|
3
|
-
_log: (level, ...args)=>{
|
|
4
|
-
logMsgIfDebug(()=>{
|
|
5
|
-
const consoleLog = console[level];
|
|
6
|
-
consoleLog(prefix, ...args);
|
|
7
|
-
});
|
|
8
|
-
},
|
|
9
|
-
info: (...args)=>{
|
|
10
|
-
logger._log('log', ...args);
|
|
11
|
-
},
|
|
12
|
-
warn: (...args)=>{
|
|
13
|
-
logger._log('warn', ...args);
|
|
14
|
-
},
|
|
15
|
-
error: (...args)=>{
|
|
16
|
-
logger._log('error', ...args);
|
|
17
|
-
},
|
|
18
|
-
critical: (...args)=>{
|
|
19
|
-
console.error(prefix, ...args);
|
|
20
|
-
},
|
|
21
|
-
uninitializedWarning: (methodName)=>{
|
|
22
|
-
logger.error(`You must initialize PostHog before calling ${methodName}`);
|
|
23
|
-
},
|
|
24
|
-
createLogger: (additionalPrefix)=>_createLogger(`${prefix} ${additionalPrefix}`, logMsgIfDebug)
|
|
25
|
-
};
|
|
26
|
-
return logger;
|
|
27
|
-
};
|
|
28
|
-
const createLogger = (logMsgIfDebug)=>_createLogger('[PostHog.js]', logMsgIfDebug);
|
|
29
|
-
export { createLogger };
|
package/src/utils/logger.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@posthog/core'
|
|
2
|
-
|
|
3
|
-
const _createLogger = (prefix: string, logMsgIfDebug: (fn: () => void) => void): Logger => {
|
|
4
|
-
const logger: Logger = {
|
|
5
|
-
_log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {
|
|
6
|
-
logMsgIfDebug(() => {
|
|
7
|
-
const consoleLog = console[level]
|
|
8
|
-
consoleLog(prefix, ...args)
|
|
9
|
-
})
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
info: (...args: any[]) => {
|
|
13
|
-
logger._log('log', ...args)
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
warn: (...args: any[]) => {
|
|
17
|
-
logger._log('warn', ...args)
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
error: (...args: any[]) => {
|
|
21
|
-
logger._log('error', ...args)
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
critical: (...args: any[]) => {
|
|
25
|
-
// Critical errors are always logged to the console
|
|
26
|
-
// eslint-disable-next-line no-console
|
|
27
|
-
console.error(prefix, ...args)
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
uninitializedWarning: (methodName: string) => {
|
|
31
|
-
logger.error(`You must initialize PostHog before calling ${methodName}`)
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
createLogger: (additionalPrefix: string) => _createLogger(`${prefix} ${additionalPrefix}`, logMsgIfDebug),
|
|
35
|
-
}
|
|
36
|
-
return logger
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const createLogger = (logMsgIfDebug: (fn: () => void) => void) => _createLogger('[PostHog.js]', logMsgIfDebug)
|