@reyaxyz/athena-logger 0.3.0 → 0.3.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.
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/modules/error/index.js +6 -2
- package/dist/modules/error/index.js.map +1 -1
- package/dist/modules/user-journey/index.js +27 -7
- package/dist/modules/user-journey/index.js.map +1 -1
- package/dist/modules/user-journey/types.js.map +1 -1
- package/dist/types/index.d.ts +6 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts +1 -7
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/modules/error/index.d.ts +1 -1
- package/dist/types/modules/error/index.d.ts.map +1 -1
- package/dist/types/modules/user-journey/index.d.ts +4 -7
- package/dist/types/modules/user-journey/index.d.ts.map +1 -1
- package/dist/types/modules/user-journey/types.d.ts +4 -0
- package/dist/types/modules/user-journey/types.d.ts.map +1 -1
- package/dist/types/types.d.ts +8 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +1 -5
- package/src/logger.ts +1 -7
- package/src/modules/error/index.ts +9 -8
- package/src/modules/user-journey/index.ts +39 -6
- package/src/modules/user-journey/types.ts +5 -0
- package/src/types.ts +13 -0
package/dist/index.js
CHANGED
|
@@ -10,11 +10,26 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
+
};
|
|
13
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
28
|
exports.Athena = void 0;
|
|
15
29
|
var user_journey_1 = require("./modules/user-journey");
|
|
16
30
|
var error_1 = require("./modules/error");
|
|
17
31
|
var logger_1 = require("./logger");
|
|
32
|
+
__exportStar(require("./types"), exports);
|
|
18
33
|
exports.Athena = {
|
|
19
34
|
initialize: logger_1.initialize,
|
|
20
35
|
UserJourney: __assign({}, user_journey_1.userJourney),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAqD;AACrD,yCAAwC;AACxC,mCAAsC;AACtC,0CAAwB;AAEX,QAAA,MAAM,GAAG;IACpB,UAAU,qBAAA;IACV,WAAW,eACN,0BAAW,CACf;IACD,KAAK,EAAE;QACL,KAAK,eAAA;KACN;CACF,CAAC","sourcesContent":["import { userJourney } from './modules/user-journey';\nimport { error } from './modules/error';\nimport { initialize } from './logger';\nexport * from './types';\n\nexport const Athena = {\n initialize,\n UserJourney: {\n ...userJourney,\n },\n Error: {\n error,\n },\n};\n"]}
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"/","sources":["logger.ts"],"names":[],"mappings":";;;AAAA,sDAAoD;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EH,gFAAgF;QAChF,MAAM,CAAC,gBAAgB,CACrB,kBAAkB,EAClB,UAAC,KAAK;YACJ,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,IAAM,OAAO,GAAG,oDAA6C,KAAK,CAAC,MAAM,CAAE,CAAC;YAC5E,IAAA,aAAK,EAAC;gBACJ,OAAO,EAAE,2BAA2B;gBACpC,KAAK,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC;gBACzB,OAAO,SAAA;aACR,CAAC,CAAC;QACL,CAAC,EACD,KAAK,CACN,CAAC;QAEF,IAAA,uBAAc,EAAC,IAAI,CAAC,CAAC;QACrB,IAAA,wBAAe,EAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAA,uBAAc,EAAC,KAAK,CAAC,CAAC;QACtB,IAAA,wBAAe,EAAC,KAAK,CAAC,CAAC;IACzB,CAAC;AACH,CAAC,CAAC;AA/DW,QAAA,UAAU,cA+DrB","sourcesContent":["import { datadogLogs } from '@datadog/browser-logs';\nimport { setInitialized, setAllowLogging } from './shared';\nimport { error } from './modules/error';\nimport { InitializeParams } from './types';\n\nexport const initialize = ({\n clientToken,\n environment,\n service,\n version,\n}: InitializeParams) => {\n const isLocalhost = environment === 'localhost';\n if (!environment || !clientToken || !service || !version) {\n setInitialized(false);\n setAllowLogging(false);\n return;\n }\n\n if (isLocalhost) {\n setInitialized(true);\n setAllowLogging(false);\n return;\n }\n\n try {\n datadogLogs.init({\n clientToken,\n env: environment,\n service,\n sessionSampleRate: 100,\n site: 'datadoghq.eu',\n forwardConsoleLogs: ['error'],\n forwardErrorsToLogs: true,\n version,\n });\n\n // Log rejected Promises without a .catch() handler\n window.addEventListener('unhandledrejection', (event) => {\n event.preventDefault();\n const message = `Promise rejected and uncaught; reason: ${event.reason}`;\n error({\n context: 'window/onunhandledrejection',\n error: new Error(message),\n message,\n });\n });\n\n // Log rejected Promises that are caught late (handler attached at a later time)\n window.addEventListener(\n 'rejectionhandled',\n (event) => {\n event.preventDefault();\n const message = `Promise rejected and caught late; reason: ${event.reason}`;\n error({\n context: 'window/onrejectionhandled',\n error: new Error(message),\n message,\n });\n },\n false,\n );\n\n setInitialized(true);\n setAllowLogging(true);\n } catch (err) {\n setInitialized(false);\n setAllowLogging(false);\n }\n};\n"]}
|
|
@@ -14,8 +14,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.error = void 0;
|
|
15
15
|
var browser_logs_1 = require("@datadog/browser-logs");
|
|
16
16
|
var shared_1 = require("../../shared");
|
|
17
|
-
var error = function (
|
|
18
|
-
var context =
|
|
17
|
+
var error = function (params) {
|
|
18
|
+
var context = params.context, message = params.message, metadata = params.metadata, walletAddress = params.walletAddress, error = params.error;
|
|
19
|
+
if (!shared_1.allowLogging) {
|
|
20
|
+
console.error("Athena.Error.error was called", params);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
19
23
|
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
20
24
|
console.warn('Logger not initialized');
|
|
21
25
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAAoD;AACpD,uCAAiE;AAG1D,IAAM,KAAK,GAAG,UAAC,MAAsB;IAClC,IAAA,OAAO,GAA8C,MAAM,QAApD,EAAE,OAAO,GAAqC,MAAM,QAA3C,EAAE,QAAQ,GAA2B,MAAM,SAAjC,EAAE,aAAa,GAAY,MAAM,cAAlB,EAAE,KAAK,GAAK,MAAM,MAAX,CAAY;IAEpE,IAAI,CAAC,qBAAY,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC;QACvD,OAAO;IACT,CAAC;IAED,IAAI,CAAC,IAAA,4BAAmB,GAAE,EAAE,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACvC,OAAO;IACT,CAAC;IAED,0BAAW,CAAC,MAAM,CAAC,KAAK,CACtB,uBAAgB,OAAO,SAAG,OAAO,CAAC,CAAC,CAAC,YAAK,OAAO,CAAE,CAAC,CAAC,CAAC,EAAE,CAAE,wBACpD,QAAQ,GAAK,CAAC,aAAa,IAAI,EAAE,IAAI,EAAE,EAAE,aAAa,eAAA,EAAE,EAAE,CAAC,GAChE,KAAc,CACf,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,KAAK,SAkBhB","sourcesContent":["import { datadogLogs } from '@datadog/browser-logs';\nimport { allowLogging, isLoggerInitialized } from '../../shared';\nimport { LogErrorParams } from './types';\n\nexport const error = (params: LogErrorParams) => {\n const { context, message, metadata, walletAddress, error } = params;\n\n if (!allowLogging) {\n console.error(`Athena.Error.error was called`, params);\n return;\n }\n\n if (!isLoggerInitialized()) {\n console.warn('Logger not initialized');\n return;\n }\n\n datadogLogs.logger.error(\n `athena.error/${context}${message ? `: ${message}` : ''}`,\n { ...metadata, ...(walletAddress && { user: { walletAddress } }) },\n error as Error,\n );\n};\n"]}
|
|
@@ -15,8 +15,8 @@ exports.userJourney = void 0;
|
|
|
15
15
|
var browser_logs_1 = require("@datadog/browser-logs");
|
|
16
16
|
var shared_1 = require("../../shared");
|
|
17
17
|
var state_1 = require("./state");
|
|
18
|
-
var action = function (
|
|
19
|
-
var action =
|
|
18
|
+
var action = function (params) {
|
|
19
|
+
var action = params.action, message = params.message, payload = params.payload;
|
|
20
20
|
var walletAddress = (0, state_1.getWalletAddress)();
|
|
21
21
|
var chainId = (0, state_1.getChainId)();
|
|
22
22
|
if (!walletAddress) {
|
|
@@ -27,6 +27,10 @@ var action = function (_a) {
|
|
|
27
27
|
console.warn('Logger missing chainId');
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
+
if (!shared_1.allowLogging) {
|
|
31
|
+
console.warn("Athena.UserJourney.action was called", params);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
30
34
|
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
31
35
|
console.warn('Logger not initialized');
|
|
32
36
|
return;
|
|
@@ -36,8 +40,8 @@ var action = function (_a) {
|
|
|
36
40
|
chainId: chainId,
|
|
37
41
|
} }));
|
|
38
42
|
};
|
|
39
|
-
var error = function (
|
|
40
|
-
var action =
|
|
43
|
+
var error = function (params) {
|
|
44
|
+
var action = params.action, error = params.error, message = params.message, payload = params.payload;
|
|
41
45
|
var walletAddress = (0, state_1.getWalletAddress)();
|
|
42
46
|
var chainId = (0, state_1.getChainId)();
|
|
43
47
|
if (!walletAddress) {
|
|
@@ -48,6 +52,10 @@ var error = function (_a) {
|
|
|
48
52
|
console.warn('Logger missing chainId');
|
|
49
53
|
return;
|
|
50
54
|
}
|
|
55
|
+
if (!shared_1.allowLogging) {
|
|
56
|
+
console.error("Athena.UserJourney.error was called", params);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
51
59
|
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
52
60
|
console.warn('Logger not initialized');
|
|
53
61
|
return;
|
|
@@ -57,18 +65,26 @@ var error = function (_a) {
|
|
|
57
65
|
chainId: chainId,
|
|
58
66
|
} }), error);
|
|
59
67
|
};
|
|
60
|
-
var start = function (
|
|
61
|
-
var address =
|
|
68
|
+
var start = function (params) {
|
|
69
|
+
var address = params.address, chainId = params.chainId;
|
|
70
|
+
(0, state_1.initialize)(address, chainId);
|
|
71
|
+
if (!shared_1.allowLogging) {
|
|
72
|
+
console.warn("Athena.UserJourney.start was called", params);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
62
75
|
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
63
76
|
console.warn('Logger not initialized');
|
|
64
77
|
return;
|
|
65
78
|
}
|
|
66
|
-
(0, state_1.initialize)(address, chainId);
|
|
67
79
|
action({
|
|
68
80
|
action: 'wallet_connected',
|
|
69
81
|
});
|
|
70
82
|
};
|
|
71
83
|
var switchChain = function (chainId) {
|
|
84
|
+
if (!shared_1.allowLogging) {
|
|
85
|
+
console.warn("Athena.UserJourney.switchChain was called", { chainId: chainId });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
72
88
|
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
73
89
|
console.warn('Logger not initialized');
|
|
74
90
|
return;
|
|
@@ -79,6 +95,10 @@ var switchChain = function (chainId) {
|
|
|
79
95
|
});
|
|
80
96
|
};
|
|
81
97
|
var stop = function () {
|
|
98
|
+
if (!shared_1.allowLogging) {
|
|
99
|
+
console.warn("Athena.UserJourney.stop was called");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
82
102
|
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
83
103
|
console.warn('Logger not initialized');
|
|
84
104
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/user-journey/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/user-journey/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAAoD;AACpD,uCAAiE;AACjE,iCAMiB;AAOjB,IAAM,MAAM,GAAG,UAAC,MAA+B;IACrC,IAAA,MAAM,GAAuB,MAAM,OAA7B,EAAE,OAAO,GAAc,MAAM,QAApB,EAAE,OAAO,GAAK,MAAM,QAAX,CAAY;IAC5C,IAAM,aAAa,GAAG,IAAA,wBAAgB,GAAE,CAAC;IACzC,IAAM,OAAO,GAAG,IAAA,kBAAU,GAAE,CAAC;IAE7B,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,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;IACX,IAAI,CAAC,qBAAY,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;QACnD,OAAO;IACT,CAAC;IAED,IAAI,CAAC,IAAA,4BAAmB,GAAE,EAAE,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACvC,OAAO;IACT,CAAC;IAED,MAAM,CAAC;QACL,MAAM,EAAE,qBAAqB;KAC9B,CAAC,CAAC;IACH,IAAA,aAAK,GAAE,CAAC;AACV,CAAC,CAAC;AAEW,QAAA,WAAW,GAAG;IACzB,MAAM,QAAA;IACN,KAAK,OAAA;IACL,KAAK,OAAA;IACL,WAAW,aAAA;IACX,IAAI,MAAA;CACL,CAAC","sourcesContent":["import { datadogLogs } from '@datadog/browser-logs';\nimport { allowLogging, isLoggerInitialized } from '../../shared';\nimport {\n clear,\n getChainId,\n getWalletAddress,\n initialize,\n setChainId,\n} from './state';\nimport {\n UserJourneyActionParams,\n UserJourneyErrorParams,\n UserJourneyStartParams,\n} from './types';\n\nconst action = (params: UserJourneyActionParams) => {\n const { action, message, payload } = params;\n const walletAddress = getWalletAddress();\n const chainId = getChainId();\n\n if (!walletAddress) {\n console.warn('Logger missing wallet address');\n return;\n }\n\n if (!chainId) {\n console.warn('Logger missing chainId');\n return;\n }\n\n if (!allowLogging) {\n console.warn(`Athena.UserJourney.action was called`, params);\n return;\n }\n\n if (!isLoggerInitialized()) {\n console.warn('Logger not initialized');\n return;\n }\n\n datadogLogs.logger.info(\n `athena.user_journey/${action}${message ? `: ${message}` : ''}`,\n {\n ...payload,\n user: {\n walletAddress,\n chainId,\n },\n },\n );\n};\n\nconst error = (params: UserJourneyErrorParams) => {\n const { action, error, message, payload } = params;\n const walletAddress = getWalletAddress();\n const chainId = getChainId();\n\n if (!walletAddress) {\n console.warn('Logger missing wallet address');\n return;\n }\n\n if (!chainId) {\n console.warn('Logger missing chainId');\n return;\n }\n\n if (!allowLogging) {\n console.error(`Athena.UserJourney.error was called`, params);\n return;\n }\n\n if (!isLoggerInitialized()) {\n console.warn('Logger not initialized');\n return;\n }\n\n datadogLogs.logger.error(\n `athena.user_journey/${action}${message ? `: ${message}` : ''}`,\n {\n ...payload,\n user: {\n walletAddress,\n chainId,\n },\n },\n error as Error,\n );\n};\n\nconst start = (params: UserJourneyStartParams) => {\n const { address, chainId } = params;\n initialize(address, chainId);\n\n if (!allowLogging) {\n console.warn(`Athena.UserJourney.start was called`, params);\n return;\n }\n\n if (!isLoggerInitialized()) {\n console.warn('Logger not initialized');\n return;\n }\n\n action({\n action: 'wallet_connected',\n });\n};\n\nconst switchChain = (chainId: number) => {\n if (!allowLogging) {\n console.warn(`Athena.UserJourney.switchChain was called`, { chainId });\n return;\n }\n\n if (!isLoggerInitialized()) {\n console.warn('Logger not initialized');\n return;\n }\n\n setChainId(chainId);\n action({\n action: `chain_changed`,\n });\n};\n\nconst stop = () => {\n if (!allowLogging) {\n console.warn(`Athena.UserJourney.stop was called`);\n return;\n }\n\n if (!isLoggerInitialized()) {\n console.warn('Logger not initialized');\n return;\n }\n\n action({\n action: 'wallet_disconnected',\n });\n clear();\n};\n\nexport const userJourney = {\n action,\n error,\n start,\n switchChain,\n stop,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["modules/user-journey/types.ts"],"names":[],"mappings":"","sourcesContent":["export type UserJourneyActionParams = {\n action: string;\n message?: string;\n payload?: Record<string, unknown>;\n};\n\nexport type UserJourneyErrorParams = {\n action: string;\n error: Error | unknown;\n message?: string;\n payload?: Record<string, unknown>;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["modules/user-journey/types.ts"],"names":[],"mappings":"","sourcesContent":["export type UserJourneyActionParams = {\n action: string;\n message?: string;\n payload?: Record<string, unknown>;\n};\n\nexport type UserJourneyErrorParams = {\n action: string;\n error: Error | unknown;\n message?: string;\n payload?: Record<string, unknown>;\n};\n\nexport type UserJourneyStartParams = {\n address: string;\n chainId: number;\n};\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
|
+
export * from './types';
|
|
1
2
|
export declare const Athena: {
|
|
2
|
-
initialize: ({ clientToken, environment, service, version, }:
|
|
3
|
-
clientToken: string;
|
|
4
|
-
environment: string;
|
|
5
|
-
service: string;
|
|
6
|
-
version: string;
|
|
7
|
-
}) => void;
|
|
3
|
+
initialize: ({ clientToken, environment, service, version, }: import("./types").InitializeParams) => void;
|
|
8
4
|
UserJourney: {
|
|
9
|
-
action: (
|
|
10
|
-
error: (
|
|
11
|
-
start: (
|
|
12
|
-
address: string;
|
|
13
|
-
chainId: number;
|
|
14
|
-
}) => void;
|
|
5
|
+
action: (params: import("./types").UserJourneyActionParams) => void;
|
|
6
|
+
error: (params: import("./types").UserJourneyErrorParams) => void;
|
|
7
|
+
start: (params: import("./types").UserJourneyStartParams) => void;
|
|
15
8
|
switchChain: (chainId: number) => void;
|
|
16
9
|
stop: () => void;
|
|
17
10
|
};
|
|
18
11
|
Error: {
|
|
19
|
-
error: (
|
|
12
|
+
error: (params: import("./types").LogErrorParams) => void;
|
|
20
13
|
};
|
|
21
14
|
};
|
|
22
|
-
export type { UserJourneyActionParams, UserJourneyErrorParams, } from './modules/types';
|
|
23
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,MAAM;;;;;;;;;;;;CAQlB,CAAC"}
|
package/dist/types/logger.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
clientToken: string;
|
|
3
|
-
environment: string;
|
|
4
|
-
service: string;
|
|
5
|
-
version: string;
|
|
6
|
-
};
|
|
1
|
+
import { InitializeParams } from './types';
|
|
7
2
|
export declare const initialize: ({ clientToken, environment, service, version, }: InitializeParams) => void;
|
|
8
|
-
export {};
|
|
9
3
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"/","sources":["logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"/","sources":["logger.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,UAAU,oDAKpB,gBAAgB,SA0DlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/error/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/error/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,KAAK,WAAY,cAAc,SAkB3C,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { UserJourneyActionParams, UserJourneyErrorParams } from './types';
|
|
1
|
+
import { UserJourneyActionParams, UserJourneyErrorParams, UserJourneyStartParams } from './types';
|
|
2
2
|
export declare const userJourney: {
|
|
3
|
-
action: (
|
|
4
|
-
error: (
|
|
5
|
-
start: (
|
|
6
|
-
address: string;
|
|
7
|
-
chainId: number;
|
|
8
|
-
}) => void;
|
|
3
|
+
action: (params: UserJourneyActionParams) => void;
|
|
4
|
+
error: (params: UserJourneyErrorParams) => void;
|
|
5
|
+
start: (params: UserJourneyStartParams) => void;
|
|
9
6
|
switchChain: (chainId: number) => void;
|
|
10
7
|
stop: () => void;
|
|
11
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/user-journey/index.ts"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/user-journey/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAkIjB,eAAO,MAAM,WAAW;qBAhIA,uBAAuB;oBAqCxB,sBAAsB;oBAsCtB,sBAAsB;2BAmBf,MAAM;;CAwCnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["modules/user-journey/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["modules/user-journey/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { UserJourneyActionParams, UserJourneyErrorParams, UserJourneyStartParams, LogErrorParams, } from './modules/types';
|
|
2
|
+
export type InitializeParams = {
|
|
3
|
+
clientToken: string;
|
|
4
|
+
environment: string;
|
|
5
|
+
service: string;
|
|
6
|
+
version: string;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n UserJourneyActionParams,\n UserJourneyErrorParams,\n UserJourneyStartParams,\n LogErrorParams,\n} from './modules/types';\n\nexport type InitializeParams = {\n clientToken: string;\n environment: string;\n service: string;\n version: string;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/athena-logger",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"@datadog/browser-logs": "5.17.1"
|
|
44
44
|
},
|
|
45
45
|
"packageManager": "pnpm@8.3.1",
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "45e15291d0a0b96ded23d17ac4e03d36999b4902"
|
|
47
47
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { userJourney } from './modules/user-journey';
|
|
2
2
|
import { error } from './modules/error';
|
|
3
3
|
import { initialize } from './logger';
|
|
4
|
+
export * from './types';
|
|
4
5
|
|
|
5
6
|
export const Athena = {
|
|
6
7
|
initialize,
|
|
@@ -11,8 +12,3 @@ export const Athena = {
|
|
|
11
12
|
error,
|
|
12
13
|
},
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
export type {
|
|
16
|
-
UserJourneyActionParams,
|
|
17
|
-
UserJourneyErrorParams,
|
|
18
|
-
} from './modules/types';
|
package/src/logger.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { datadogLogs } from '@datadog/browser-logs';
|
|
2
2
|
import { setInitialized, setAllowLogging } from './shared';
|
|
3
3
|
import { error } from './modules/error';
|
|
4
|
-
|
|
5
|
-
type InitializeParams = {
|
|
6
|
-
clientToken: string;
|
|
7
|
-
environment: string;
|
|
8
|
-
service: string;
|
|
9
|
-
version: string;
|
|
10
|
-
};
|
|
4
|
+
import { InitializeParams } from './types';
|
|
11
5
|
|
|
12
6
|
export const initialize = ({
|
|
13
7
|
clientToken,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { datadogLogs } from '@datadog/browser-logs';
|
|
2
|
-
import { isLoggerInitialized } from '../../shared';
|
|
2
|
+
import { allowLogging, isLoggerInitialized } from '../../shared';
|
|
3
3
|
import { LogErrorParams } from './types';
|
|
4
4
|
|
|
5
|
-
export const error = ({
|
|
6
|
-
context,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
5
|
+
export const error = (params: LogErrorParams) => {
|
|
6
|
+
const { context, message, metadata, walletAddress, error } = params;
|
|
7
|
+
|
|
8
|
+
if (!allowLogging) {
|
|
9
|
+
console.error(`Athena.Error.error was called`, params);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
12
13
|
if (!isLoggerInitialized()) {
|
|
13
14
|
console.warn('Logger not initialized');
|
|
14
15
|
return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { datadogLogs } from '@datadog/browser-logs';
|
|
2
|
-
import { isLoggerInitialized } from '../../shared';
|
|
2
|
+
import { allowLogging, isLoggerInitialized } from '../../shared';
|
|
3
3
|
import {
|
|
4
4
|
clear,
|
|
5
5
|
getChainId,
|
|
@@ -7,9 +7,14 @@ import {
|
|
|
7
7
|
initialize,
|
|
8
8
|
setChainId,
|
|
9
9
|
} from './state';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
UserJourneyActionParams,
|
|
12
|
+
UserJourneyErrorParams,
|
|
13
|
+
UserJourneyStartParams,
|
|
14
|
+
} from './types';
|
|
11
15
|
|
|
12
|
-
const action = (
|
|
16
|
+
const action = (params: UserJourneyActionParams) => {
|
|
17
|
+
const { action, message, payload } = params;
|
|
13
18
|
const walletAddress = getWalletAddress();
|
|
14
19
|
const chainId = getChainId();
|
|
15
20
|
|
|
@@ -23,6 +28,11 @@ const action = ({ action, message, payload }: UserJourneyActionParams) => {
|
|
|
23
28
|
return;
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
if (!allowLogging) {
|
|
32
|
+
console.warn(`Athena.UserJourney.action was called`, params);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
if (!isLoggerInitialized()) {
|
|
27
37
|
console.warn('Logger not initialized');
|
|
28
38
|
return;
|
|
@@ -40,7 +50,8 @@ const action = ({ action, message, payload }: UserJourneyActionParams) => {
|
|
|
40
50
|
);
|
|
41
51
|
};
|
|
42
52
|
|
|
43
|
-
const error = (
|
|
53
|
+
const error = (params: UserJourneyErrorParams) => {
|
|
54
|
+
const { action, error, message, payload } = params;
|
|
44
55
|
const walletAddress = getWalletAddress();
|
|
45
56
|
const chainId = getChainId();
|
|
46
57
|
|
|
@@ -54,6 +65,11 @@ const error = ({ action, error, message, payload }: UserJourneyErrorParams) => {
|
|
|
54
65
|
return;
|
|
55
66
|
}
|
|
56
67
|
|
|
68
|
+
if (!allowLogging) {
|
|
69
|
+
console.error(`Athena.UserJourney.error was called`, params);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
57
73
|
if (!isLoggerInitialized()) {
|
|
58
74
|
console.warn('Logger not initialized');
|
|
59
75
|
return;
|
|
@@ -72,19 +88,31 @@ const error = ({ action, error, message, payload }: UserJourneyErrorParams) => {
|
|
|
72
88
|
);
|
|
73
89
|
};
|
|
74
90
|
|
|
75
|
-
const start = (
|
|
91
|
+
const start = (params: UserJourneyStartParams) => {
|
|
92
|
+
const { address, chainId } = params;
|
|
93
|
+
initialize(address, chainId);
|
|
94
|
+
|
|
95
|
+
if (!allowLogging) {
|
|
96
|
+
console.warn(`Athena.UserJourney.start was called`, params);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
76
100
|
if (!isLoggerInitialized()) {
|
|
77
101
|
console.warn('Logger not initialized');
|
|
78
102
|
return;
|
|
79
103
|
}
|
|
80
104
|
|
|
81
|
-
initialize(address, chainId);
|
|
82
105
|
action({
|
|
83
106
|
action: 'wallet_connected',
|
|
84
107
|
});
|
|
85
108
|
};
|
|
86
109
|
|
|
87
110
|
const switchChain = (chainId: number) => {
|
|
111
|
+
if (!allowLogging) {
|
|
112
|
+
console.warn(`Athena.UserJourney.switchChain was called`, { chainId });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
88
116
|
if (!isLoggerInitialized()) {
|
|
89
117
|
console.warn('Logger not initialized');
|
|
90
118
|
return;
|
|
@@ -97,6 +125,11 @@ const switchChain = (chainId: number) => {
|
|
|
97
125
|
};
|
|
98
126
|
|
|
99
127
|
const stop = () => {
|
|
128
|
+
if (!allowLogging) {
|
|
129
|
+
console.warn(`Athena.UserJourney.stop was called`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
100
133
|
if (!isLoggerInitialized()) {
|
|
101
134
|
console.warn('Logger not initialized');
|
|
102
135
|
return;
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
UserJourneyActionParams,
|
|
3
|
+
UserJourneyErrorParams,
|
|
4
|
+
UserJourneyStartParams,
|
|
5
|
+
LogErrorParams,
|
|
6
|
+
} from './modules/types';
|
|
7
|
+
|
|
8
|
+
export type InitializeParams = {
|
|
9
|
+
clientToken: string;
|
|
10
|
+
environment: string;
|
|
11
|
+
service: string;
|
|
12
|
+
version: string;
|
|
13
|
+
};
|