@reyaxyz/athena-logger 0.3.28 → 0.4.0
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/modules/error/index.js +5 -5
- package/dist/modules/error/index.js.map +1 -1
- package/dist/modules/user-journey/index.js +46 -34
- package/dist/modules/user-journey/index.js.map +1 -1
- package/dist/modules/user-journey/state.js +6 -6
- package/dist/modules/user-journey/state.js.map +1 -1
- package/dist/modules/user-journey/types.js.map +1 -1
- package/dist/shared.js +8 -6
- package/dist/shared.js.map +1 -1
- package/dist/types/modules/error/index.d.ts.map +1 -1
- package/dist/types/modules/user-journey/index.d.ts.map +1 -1
- package/dist/types/modules/user-journey/state.d.ts +9 -7
- package/dist/types/modules/user-journey/state.d.ts.map +1 -1
- package/dist/types/modules/user-journey/types.d.ts +1 -0
- package/dist/types/modules/user-journey/types.d.ts.map +1 -1
- package/dist/types/shared.d.ts +1 -2
- package/dist/types/shared.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/modules/error/index.ts +10 -7
- package/src/modules/user-journey/index.ts +68 -41
- package/src/modules/user-journey/state.ts +7 -10
- package/src/modules/user-journey/types.ts +1 -0
- package/src/shared.ts +4 -2
|
@@ -15,15 +15,15 @@ exports.error = void 0;
|
|
|
15
15
|
var browser_logs_1 = require("@datadog/browser-logs");
|
|
16
16
|
var shared_1 = require("../../shared");
|
|
17
17
|
var error = function (params) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
console.error("Athena.Error.error was called", params);
|
|
18
|
+
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
19
|
+
console.warn('Athena.Error.error was called. Logger not initialized', params);
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
|
-
if (!(0, shared_1.
|
|
24
|
-
console.
|
|
22
|
+
if (!(0, shared_1.isAllowLogging)()) {
|
|
23
|
+
console.error('Athena.Error.error was called', params);
|
|
25
24
|
return;
|
|
26
25
|
}
|
|
26
|
+
var context = params.context, message = params.message, metadata = params.metadata, walletAddress = params.walletAddress, error = params.error;
|
|
27
27
|
browser_logs_1.datadogLogs.logger.error("athena.error/".concat(context).concat(message ? ": ".concat(message) : ''), __assign(__assign({}, metadata), (walletAddress && { user: { walletAddress: walletAddress } })), error);
|
|
28
28
|
};
|
|
29
29
|
exports.error = error;
|
|
@@ -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,uCAAmE;AAG5D,IAAM,KAAK,GAAG,UAAC,MAAsB;IAC1C,IAAI,CAAC,IAAA,4BAAmB,GAAE,EAAE,CAAC;QAC3B,OAAO,CAAC,IAAI,CACV,uDAAuD,EACvD,MAAM,CACP,CAAC;QACF,OAAO;IACT,CAAC;IAED,IAAI,CAAC,IAAA,uBAAc,GAAE,EAAE,CAAC;QACtB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC;QACvD,OAAO;IACT,CAAC;IAEO,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,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;AArBW,QAAA,KAAK,SAqBhB","sourcesContent":["import { datadogLogs } from '@datadog/browser-logs';\nimport { isAllowLogging, isLoggerInitialized } from '../../shared';\nimport { LogErrorParams } from './types';\n\nexport const error = (params: LogErrorParams) => {\n if (!isLoggerInitialized()) {\n console.warn(\n 'Athena.Error.error was called. Logger not initialized',\n params,\n );\n return;\n }\n\n if (!isAllowLogging()) {\n console.error('Athena.Error.error was called', params);\n return;\n }\n\n const { context, message, metadata, walletAddress, error } = params;\n\n datadogLogs.logger.error(\n `athena.error/${context}${message ? `: ${message}` : ''}`,\n { ...metadata, ...(walletAddress && { user: { walletAddress } }) },\n error as Error,\n );\n};\n"]}
|
|
@@ -16,7 +16,16 @@ var browser_logs_1 = require("@datadog/browser-logs");
|
|
|
16
16
|
var shared_1 = require("../../shared");
|
|
17
17
|
var state_1 = require("./state");
|
|
18
18
|
var action = function (params) {
|
|
19
|
+
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
20
|
+
console.warn('Athena.UserJourney.action was called. Logger not initialized', params);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!(0, shared_1.isAllowLogging)()) {
|
|
24
|
+
console.warn("Athena.UserJourney.action was called", params);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
19
27
|
var action = params.action, message = params.message, payload = params.payload;
|
|
28
|
+
var walletId = (0, state_1.getWalletId)();
|
|
20
29
|
var walletAddress = (0, state_1.getWalletAddress)();
|
|
21
30
|
var walletName = (0, state_1.getWalletName)();
|
|
22
31
|
var chainId = (0, state_1.getChainId)();
|
|
@@ -24,6 +33,10 @@ var action = function (params) {
|
|
|
24
33
|
console.warn('Logger missing wallet address');
|
|
25
34
|
return;
|
|
26
35
|
}
|
|
36
|
+
if (!walletId) {
|
|
37
|
+
console.warn('Logger missing wallet id');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
27
40
|
if (!walletName) {
|
|
28
41
|
console.warn('Logger missing wallet name');
|
|
29
42
|
return;
|
|
@@ -32,29 +45,35 @@ var action = function (params) {
|
|
|
32
45
|
console.warn('Logger missing chainId');
|
|
33
46
|
return;
|
|
34
47
|
}
|
|
35
|
-
if (!shared_1.allowLogging) {
|
|
36
|
-
console.warn("Athena.UserJourney.action was called", params);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
40
|
-
console.warn('Logger not initialized');
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
48
|
browser_logs_1.datadogLogs.logger.info("athena.user_journey/".concat(action).concat(message ? ": ".concat(message) : ''), __assign(__assign({}, payload), { user: {
|
|
44
49
|
walletAddress: walletAddress,
|
|
45
50
|
walletName: walletName,
|
|
51
|
+
walletId: walletId,
|
|
46
52
|
chainId: chainId,
|
|
47
53
|
} }));
|
|
48
54
|
};
|
|
49
55
|
var error = function (params) {
|
|
56
|
+
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
57
|
+
console.warn('Athena.UserJourney.error was called. Logger not initialized', params);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!(0, shared_1.isAllowLogging)()) {
|
|
61
|
+
console.error('Athena.UserJourney.error was called', params);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
50
64
|
var action = params.action, error = params.error, message = params.message, payload = params.payload;
|
|
51
65
|
var walletAddress = (0, state_1.getWalletAddress)();
|
|
52
66
|
var walletName = (0, state_1.getWalletName)();
|
|
67
|
+
var walletId = (0, state_1.getWalletId)();
|
|
53
68
|
var chainId = (0, state_1.getChainId)();
|
|
54
69
|
if (!walletAddress) {
|
|
55
70
|
console.warn('Logger missing wallet address');
|
|
56
71
|
return;
|
|
57
72
|
}
|
|
73
|
+
if (!walletId) {
|
|
74
|
+
console.warn('Logger missing wallet id');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
58
77
|
if (!walletName) {
|
|
59
78
|
console.warn('Logger missing wallet name');
|
|
60
79
|
return;
|
|
@@ -63,47 +82,40 @@ var error = function (params) {
|
|
|
63
82
|
console.warn('Logger missing chainId');
|
|
64
83
|
return;
|
|
65
84
|
}
|
|
66
|
-
if (!shared_1.allowLogging) {
|
|
67
|
-
console.error("Athena.UserJourney.error was called", params);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
71
|
-
console.warn('Logger not initialized');
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
85
|
browser_logs_1.datadogLogs.logger.error("athena.user_journey/".concat(action).concat(message ? ": ".concat(message) : ''), __assign(__assign({}, payload), { user: {
|
|
75
86
|
walletAddress: walletAddress,
|
|
87
|
+
walletId: walletId,
|
|
76
88
|
walletName: walletName,
|
|
77
89
|
chainId: chainId,
|
|
78
90
|
} }), error);
|
|
79
91
|
};
|
|
80
92
|
var start = function (params) {
|
|
81
|
-
|
|
93
|
+
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
94
|
+
console.warn('Athena.UserJourney.start was called. Logger not initialized', params);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!(0, shared_1.isAllowLogging)()) {
|
|
98
|
+
console.warn('Athena.UserJourney.start was called', params);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var address = params.address, chainId = params.chainId, walletName = params.walletName, walletId = params.walletId;
|
|
82
102
|
(0, state_1.initialize)({
|
|
83
103
|
walletAddress: address,
|
|
84
104
|
chainId: chainId,
|
|
85
105
|
walletName: walletName,
|
|
106
|
+
walletId: walletId,
|
|
86
107
|
});
|
|
87
|
-
if (!shared_1.allowLogging) {
|
|
88
|
-
console.warn("Athena.UserJourney.start was called", params);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
92
|
-
console.warn('Logger not initialized');
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
108
|
action({
|
|
96
109
|
action: 'wallet_connected',
|
|
97
|
-
payload: { walletAddress: address, chainId: chainId, walletName: walletName },
|
|
98
110
|
});
|
|
99
111
|
};
|
|
100
112
|
var switchChain = function (chainId) {
|
|
101
|
-
if (!shared_1.
|
|
102
|
-
console.warn(
|
|
113
|
+
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
114
|
+
console.warn('Athena.UserJourney.switchChain was called. Logger not initialized', { chainId: chainId });
|
|
103
115
|
return;
|
|
104
116
|
}
|
|
105
|
-
if (!(0, shared_1.
|
|
106
|
-
console.warn('
|
|
117
|
+
if (!(0, shared_1.isAllowLogging)()) {
|
|
118
|
+
console.warn('Athena.UserJourney.switchChain was called', { chainId: chainId });
|
|
107
119
|
return;
|
|
108
120
|
}
|
|
109
121
|
(0, state_1.setChainId)(chainId);
|
|
@@ -112,12 +124,12 @@ var switchChain = function (chainId) {
|
|
|
112
124
|
});
|
|
113
125
|
};
|
|
114
126
|
var stop = function () {
|
|
115
|
-
if (!shared_1.
|
|
116
|
-
console.warn(
|
|
127
|
+
if (!(0, shared_1.isLoggerInitialized)()) {
|
|
128
|
+
console.warn('Athena.UserJourney.stop was called. Logger not initialized');
|
|
117
129
|
return;
|
|
118
130
|
}
|
|
119
|
-
if (!(0, shared_1.
|
|
120
|
-
console.warn(
|
|
131
|
+
if (!(0, shared_1.isAllowLogging)()) {
|
|
132
|
+
console.warn("Athena.UserJourney.stop was called");
|
|
121
133
|
return;
|
|
122
134
|
}
|
|
123
135
|
action({
|
|
@@ -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,uCAAmE;AACnE,iCAQiB;AAOjB,IAAM,MAAM,GAAG,UAAC,MAA+B;IAC7C,IAAI,CAAC,IAAA,4BAAmB,GAAE,EAAE,CAAC;QAC3B,OAAO,CAAC,IAAI,CACV,8DAA8D,EAC9D,MAAM,CACP,C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B,GAAE,EAAE,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;QAC3E,OAAO;IACT,CAAC;IAED,IAAI,CAAC,IAAA,uBAAc,GAAE,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;QACnD,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 { isAllowLogging, isLoggerInitialized } from '../../shared';\nimport {\n clear,\n getChainId,\n getWalletAddress,\n getWalletId,\n getWalletName,\n initialize,\n setChainId,\n} from './state';\nimport {\n UserJourneyActionParams,\n UserJourneyErrorParams,\n UserJourneyStartParams,\n} from './types';\n\nconst action = (params: UserJourneyActionParams) => {\n if (!isLoggerInitialized()) {\n console.warn(\n 'Athena.UserJourney.action was called. Logger not initialized',\n params,\n );\n return;\n }\n\n if (!isAllowLogging()) {\n console.warn(`Athena.UserJourney.action was called`, params);\n return;\n }\n\n const { action, message, payload } = params;\n const walletId = getWalletId();\n const walletAddress = getWalletAddress();\n const walletName = getWalletName();\n const chainId = getChainId();\n\n if (!walletAddress) {\n console.warn('Logger missing wallet address');\n return;\n }\n\n if (!walletId) {\n console.warn('Logger missing wallet id');\n return;\n }\n\n if (!walletName) {\n console.warn('Logger missing wallet name');\n return;\n }\n\n if (!chainId) {\n console.warn('Logger missing chainId');\n return;\n }\n\n datadogLogs.logger.info(\n `athena.user_journey/${action}${message ? `: ${message}` : ''}`,\n {\n ...payload,\n user: {\n walletAddress,\n walletName,\n walletId,\n chainId,\n },\n },\n );\n};\n\nconst error = (params: UserJourneyErrorParams) => {\n if (!isLoggerInitialized()) {\n console.warn(\n 'Athena.UserJourney.error was called. Logger not initialized',\n params,\n );\n return;\n }\n\n if (!isAllowLogging()) {\n console.error('Athena.UserJourney.error was called', params);\n return;\n }\n\n const { action, error, message, payload } = params;\n const walletAddress = getWalletAddress();\n const walletName = getWalletName();\n const walletId = getWalletId();\n const chainId = getChainId();\n\n if (!walletAddress) {\n console.warn('Logger missing wallet address');\n return;\n }\n\n if (!walletId) {\n console.warn('Logger missing wallet id');\n return;\n }\n\n if (!walletName) {\n console.warn('Logger missing wallet name');\n return;\n }\n\n if (!chainId) {\n console.warn('Logger missing chainId');\n return;\n }\n\n datadogLogs.logger.error(\n `athena.user_journey/${action}${message ? `: ${message}` : ''}`,\n {\n ...payload,\n user: {\n walletAddress,\n walletId,\n walletName,\n chainId,\n },\n },\n error as Error,\n );\n};\n\nconst start = (params: UserJourneyStartParams) => {\n if (!isLoggerInitialized()) {\n console.warn(\n 'Athena.UserJourney.start was called. Logger not initialized',\n params,\n );\n return;\n }\n\n if (!isAllowLogging()) {\n console.warn('Athena.UserJourney.start was called', params);\n return;\n }\n\n const { address, chainId, walletName, walletId } = params;\n initialize({\n walletAddress: address,\n chainId,\n walletName,\n walletId,\n });\n\n action({\n action: 'wallet_connected',\n });\n};\n\nconst switchChain = (chainId: number) => {\n if (!isLoggerInitialized()) {\n console.warn(\n 'Athena.UserJourney.switchChain was called. Logger not initialized',\n { chainId },\n );\n return;\n }\n\n if (!isAllowLogging()) {\n console.warn('Athena.UserJourney.switchChain was called', { chainId });\n return;\n }\n\n setChainId(chainId);\n action({\n action: `chain_changed`,\n });\n};\n\nconst stop = () => {\n if (!isLoggerInitialized()) {\n console.warn('Athena.UserJourney.stop was called. Logger not initialized');\n return;\n }\n\n if (!isAllowLogging()) {\n console.warn(`Athena.UserJourney.stop was called`);\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,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clear = exports.setChainId = exports.
|
|
3
|
+
exports.clear = exports.setChainId = exports.getWalletId = exports.getChainId = exports.getWalletName = exports.getWalletAddress = exports.initialize = void 0;
|
|
4
4
|
var state = {
|
|
5
|
+
walletId: null,
|
|
5
6
|
walletAddress: null,
|
|
6
7
|
walletName: null,
|
|
7
8
|
chainId: null,
|
|
8
9
|
};
|
|
9
10
|
var initialize = function (_a) {
|
|
10
|
-
var walletAddress = _a.walletAddress, walletName = _a.walletName, chainId = _a.chainId;
|
|
11
|
+
var walletId = _a.walletId, walletAddress = _a.walletAddress, walletName = _a.walletName, chainId = _a.chainId;
|
|
11
12
|
state.walletAddress = walletAddress;
|
|
12
13
|
state.chainId = chainId;
|
|
13
14
|
state.walletName = walletName;
|
|
15
|
+
state.walletId = walletId;
|
|
14
16
|
};
|
|
15
17
|
exports.initialize = initialize;
|
|
16
18
|
var getWalletAddress = function () { return state.walletAddress; };
|
|
17
19
|
exports.getWalletAddress = getWalletAddress;
|
|
18
20
|
var getWalletName = function () { return state.walletName; };
|
|
19
21
|
exports.getWalletName = getWalletName;
|
|
22
|
+
var getWalletId = function () { return state.walletId; };
|
|
23
|
+
exports.getWalletId = getWalletId;
|
|
20
24
|
var getChainId = function () { return state.chainId; };
|
|
21
25
|
exports.getChainId = getChainId;
|
|
22
|
-
var setWalletAddress = function (walletAddress) {
|
|
23
|
-
state.walletAddress = walletAddress;
|
|
24
|
-
};
|
|
25
|
-
exports.setWalletAddress = setWalletAddress;
|
|
26
26
|
var setChainId = function (chainId) {
|
|
27
27
|
state.chainId = chainId;
|
|
28
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"/","sources":["modules/user-journey/state.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"/","sources":["modules/user-journey/state.ts"],"names":[],"mappings":";;;AAOA,IAAM,KAAK,GAAqB;IAC9B,QAAQ,EAAE,IAAI;IACd,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;CACd,CAAC;AAEF,IAAM,UAAU,GAAG,UAAC,EAKD;QAJjB,QAAQ,cAAA,EACR,aAAa,mBAAA,EACb,UAAU,gBAAA,EACV,OAAO,aAAA;IAEP,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC;IACpC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC5B,CAAC,CAAC;AAiBA,gCAAU;AAfZ,IAAM,gBAAgB,GAAG,cAAM,OAAA,KAAK,CAAC,aAAa,EAAnB,CAAmB,CAAC;AAgBjD,4CAAgB;AAflB,IAAM,aAAa,GAAG,cAAM,OAAA,KAAK,CAAC,UAAU,EAAhB,CAAgB,CAAC;AAgB3C,sCAAa;AAff,IAAM,WAAW,GAAG,cAAM,OAAA,KAAK,CAAC,QAAQ,EAAd,CAAc,CAAC;AAiBvC,kCAAW;AAhBb,IAAM,UAAU,GAAG,cAAM,OAAA,KAAK,CAAC,OAAO,EAAb,CAAa,CAAC;AAerC,gCAAU;AAbZ,IAAM,UAAU,GAAG,UAAC,OAAe;IACjC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;AAC1B,CAAC,CAAC;AAaA,gCAAU;AAXZ,IAAM,KAAK,GAAG;IACZ,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;AACvB,CAAC,CAAC;AASA,sBAAK","sourcesContent":["type UserJourneyState = {\n walletAddress: string | null;\n walletId: string | null;\n walletName: string | null;\n chainId: number | null;\n};\n\nconst state: UserJourneyState = {\n walletId: null,\n walletAddress: null,\n walletName: null,\n chainId: null,\n};\n\nconst initialize = ({\n walletId,\n walletAddress,\n walletName,\n chainId,\n}: UserJourneyState) => {\n state.walletAddress = walletAddress;\n state.chainId = chainId;\n state.walletName = walletName;\n state.walletId = walletId;\n};\n\nconst getWalletAddress = () => state.walletAddress;\nconst getWalletName = () => state.walletName;\nconst getWalletId = () => state.walletId;\nconst getChainId = () => state.chainId;\n\nconst setChainId = (chainId: number) => {\n state.chainId = chainId;\n};\n\nconst clear = () => {\n state.walletAddress = null;\n state.chainId = null;\n};\n\nexport {\n initialize,\n getWalletAddress,\n getWalletName,\n getChainId,\n getWalletId,\n setChainId,\n clear,\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\nexport type UserJourneyStartParams = {\n address: string;\n walletName: string;\n chainId: number;\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 walletName: string;\n walletId: string;\n chainId: number;\n};\n"]}
|
package/dist/shared.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLoggerInitialized = exports.
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.isLoggerInitialized = exports.isAllowLogging = exports.setAllowLogging = exports.setInitialized = void 0;
|
|
4
|
+
var initialized = false;
|
|
5
|
+
var allowLogging = false;
|
|
6
6
|
var setInitialized = function (value) {
|
|
7
|
-
|
|
7
|
+
initialized = value;
|
|
8
8
|
};
|
|
9
9
|
exports.setInitialized = setInitialized;
|
|
10
10
|
var setAllowLogging = function (value) {
|
|
11
|
-
|
|
11
|
+
allowLogging = value;
|
|
12
12
|
};
|
|
13
13
|
exports.setAllowLogging = setAllowLogging;
|
|
14
|
-
var
|
|
14
|
+
var isAllowLogging = function () { return allowLogging; };
|
|
15
|
+
exports.isAllowLogging = isAllowLogging;
|
|
16
|
+
var isLoggerInitialized = function () { return initialized; };
|
|
15
17
|
exports.isLoggerInitialized = isLoggerInitialized;
|
|
16
18
|
//# sourceMappingURL=shared.js.map
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"/","sources":["shared.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"/","sources":["shared.ts"],"names":[],"mappings":";;;AAAA,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,YAAY,GAAG,KAAK,CAAC;AAElB,IAAM,cAAc,GAAG,UAAC,KAAc;IAC3C,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB;AAEK,IAAM,eAAe,GAAG,UAAC,KAAc;IAC5C,YAAY,GAAG,KAAK,CAAC;AACvB,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEK,IAAM,cAAc,GAAG,cAAM,OAAA,YAAY,EAAZ,CAAY,CAAC;AAApC,QAAA,cAAc,kBAAsB;AAE1C,IAAM,mBAAmB,GAAG,cAAM,OAAA,WAAW,EAAX,CAAW,CAAC;AAAxC,QAAA,mBAAmB,uBAAqB","sourcesContent":["let initialized = false;\nlet allowLogging = false;\n\nexport const setInitialized = (value: boolean) => {\n initialized = value;\n};\n\nexport const setAllowLogging = (value: boolean) => {\n allowLogging = value;\n};\n\nexport const isAllowLogging = () => allowLogging;\n\nexport const isLoggerInitialized = () => initialized;\n"]}
|
|
@@ -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,WAAY,cAAc,
|
|
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,SAqB3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/user-journey/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/user-journey/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AA+KjB,eAAO,MAAM,WAAW;qBA7KA,uBAAuB;oBAsDxB,sBAAsB;oBAuDtB,sBAAsB;2BA2Bf,MAAM;;CA2CnC,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
walletAddress: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
type UserJourneyState = {
|
|
2
|
+
walletAddress: string | null;
|
|
3
|
+
walletId: string | null;
|
|
4
|
+
walletName: string | null;
|
|
5
|
+
chainId: number | null;
|
|
6
|
+
};
|
|
7
|
+
declare const initialize: ({ walletId, walletAddress, walletName, chainId, }: UserJourneyState) => void;
|
|
6
8
|
declare const getWalletAddress: () => string | null;
|
|
7
9
|
declare const getWalletName: () => string | null;
|
|
10
|
+
declare const getWalletId: () => string | null;
|
|
8
11
|
declare const getChainId: () => number | null;
|
|
9
|
-
declare const setWalletAddress: (walletAddress: string) => void;
|
|
10
12
|
declare const setChainId: (chainId: number) => void;
|
|
11
13
|
declare const clear: () => void;
|
|
12
|
-
export { initialize, getWalletAddress, getWalletName, getChainId,
|
|
14
|
+
export { initialize, getWalletAddress, getWalletName, getChainId, getWalletId, setChainId, clear, };
|
|
13
15
|
//# sourceMappingURL=state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"/","sources":["modules/user-journey/state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"/","sources":["modules/user-journey/state.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AASF,QAAA,MAAM,UAAU,sDAKb,gBAAgB,SAKlB,CAAC;AAEF,QAAA,MAAM,gBAAgB,qBAA4B,CAAC;AACnD,QAAA,MAAM,aAAa,qBAAyB,CAAC;AAC7C,QAAA,MAAM,WAAW,qBAAuB,CAAC;AACzC,QAAA,MAAM,UAAU,qBAAsB,CAAC;AAEvC,QAAA,MAAM,UAAU,YAAa,MAAM,SAElC,CAAC;AAEF,QAAA,MAAM,KAAK,YAGV,CAAC;AAEF,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,WAAW,EACX,UAAU,EACV,KAAK,GACN,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;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,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,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
package/dist/types/shared.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export declare let initialized: boolean;
|
|
2
|
-
export declare let allowLogging: boolean;
|
|
3
1
|
export declare const setInitialized: (value: boolean) => void;
|
|
4
2
|
export declare const setAllowLogging: (value: boolean) => void;
|
|
3
|
+
export declare const isAllowLogging: () => boolean;
|
|
5
4
|
export declare const isLoggerInitialized: () => boolean;
|
|
6
5
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"/","sources":["shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"/","sources":["shared.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,UAAW,OAAO,SAE5C,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,OAAO,SAE7C,CAAC;AAEF,eAAO,MAAM,cAAc,eAAqB,CAAC;AAEjD,eAAO,MAAM,mBAAmB,eAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/athena-logger",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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": "2e1d8f3fcf2ae4b64b3ccb4670ff930e59145bbc"
|
|
47
47
|
}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { datadogLogs } from '@datadog/browser-logs';
|
|
2
|
-
import {
|
|
2
|
+
import { isAllowLogging, isLoggerInitialized } from '../../shared';
|
|
3
3
|
import { LogErrorParams } from './types';
|
|
4
4
|
|
|
5
5
|
export const error = (params: LogErrorParams) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
if (!isLoggerInitialized()) {
|
|
7
|
+
console.warn(
|
|
8
|
+
'Athena.Error.error was called. Logger not initialized',
|
|
9
|
+
params,
|
|
10
|
+
);
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
if (!
|
|
14
|
-
console.
|
|
14
|
+
if (!isAllowLogging()) {
|
|
15
|
+
console.error('Athena.Error.error was called', params);
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
const { context, message, metadata, walletAddress, error } = params;
|
|
20
|
+
|
|
18
21
|
datadogLogs.logger.error(
|
|
19
22
|
`athena.error/${context}${message ? `: ${message}` : ''}`,
|
|
20
23
|
{ ...metadata, ...(walletAddress && { user: { walletAddress } }) },
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { datadogLogs } from '@datadog/browser-logs';
|
|
2
|
-
import {
|
|
2
|
+
import { isAllowLogging, isLoggerInitialized } from '../../shared';
|
|
3
3
|
import {
|
|
4
4
|
clear,
|
|
5
5
|
getChainId,
|
|
6
6
|
getWalletAddress,
|
|
7
|
+
getWalletId,
|
|
7
8
|
getWalletName,
|
|
8
9
|
initialize,
|
|
9
10
|
setChainId,
|
|
@@ -15,7 +16,21 @@ import {
|
|
|
15
16
|
} from './types';
|
|
16
17
|
|
|
17
18
|
const action = (params: UserJourneyActionParams) => {
|
|
19
|
+
if (!isLoggerInitialized()) {
|
|
20
|
+
console.warn(
|
|
21
|
+
'Athena.UserJourney.action was called. Logger not initialized',
|
|
22
|
+
params,
|
|
23
|
+
);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!isAllowLogging()) {
|
|
28
|
+
console.warn(`Athena.UserJourney.action was called`, params);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
18
32
|
const { action, message, payload } = params;
|
|
33
|
+
const walletId = getWalletId();
|
|
19
34
|
const walletAddress = getWalletAddress();
|
|
20
35
|
const walletName = getWalletName();
|
|
21
36
|
const chainId = getChainId();
|
|
@@ -25,6 +40,11 @@ const action = (params: UserJourneyActionParams) => {
|
|
|
25
40
|
return;
|
|
26
41
|
}
|
|
27
42
|
|
|
43
|
+
if (!walletId) {
|
|
44
|
+
console.warn('Logger missing wallet id');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
28
48
|
if (!walletName) {
|
|
29
49
|
console.warn('Logger missing wallet name');
|
|
30
50
|
return;
|
|
@@ -35,16 +55,6 @@ const action = (params: UserJourneyActionParams) => {
|
|
|
35
55
|
return;
|
|
36
56
|
}
|
|
37
57
|
|
|
38
|
-
if (!allowLogging) {
|
|
39
|
-
console.warn(`Athena.UserJourney.action was called`, params);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!isLoggerInitialized()) {
|
|
44
|
-
console.warn('Logger not initialized');
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
58
|
datadogLogs.logger.info(
|
|
49
59
|
`athena.user_journey/${action}${message ? `: ${message}` : ''}`,
|
|
50
60
|
{
|
|
@@ -52,6 +62,7 @@ const action = (params: UserJourneyActionParams) => {
|
|
|
52
62
|
user: {
|
|
53
63
|
walletAddress,
|
|
54
64
|
walletName,
|
|
65
|
+
walletId,
|
|
55
66
|
chainId,
|
|
56
67
|
},
|
|
57
68
|
},
|
|
@@ -59,9 +70,23 @@ const action = (params: UserJourneyActionParams) => {
|
|
|
59
70
|
};
|
|
60
71
|
|
|
61
72
|
const error = (params: UserJourneyErrorParams) => {
|
|
73
|
+
if (!isLoggerInitialized()) {
|
|
74
|
+
console.warn(
|
|
75
|
+
'Athena.UserJourney.error was called. Logger not initialized',
|
|
76
|
+
params,
|
|
77
|
+
);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!isAllowLogging()) {
|
|
82
|
+
console.error('Athena.UserJourney.error was called', params);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
62
86
|
const { action, error, message, payload } = params;
|
|
63
87
|
const walletAddress = getWalletAddress();
|
|
64
88
|
const walletName = getWalletName();
|
|
89
|
+
const walletId = getWalletId();
|
|
65
90
|
const chainId = getChainId();
|
|
66
91
|
|
|
67
92
|
if (!walletAddress) {
|
|
@@ -69,6 +94,11 @@ const error = (params: UserJourneyErrorParams) => {
|
|
|
69
94
|
return;
|
|
70
95
|
}
|
|
71
96
|
|
|
97
|
+
if (!walletId) {
|
|
98
|
+
console.warn('Logger missing wallet id');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
72
102
|
if (!walletName) {
|
|
73
103
|
console.warn('Logger missing wallet name');
|
|
74
104
|
return;
|
|
@@ -79,22 +109,13 @@ const error = (params: UserJourneyErrorParams) => {
|
|
|
79
109
|
return;
|
|
80
110
|
}
|
|
81
111
|
|
|
82
|
-
if (!allowLogging) {
|
|
83
|
-
console.error(`Athena.UserJourney.error was called`, params);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!isLoggerInitialized()) {
|
|
88
|
-
console.warn('Logger not initialized');
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
112
|
datadogLogs.logger.error(
|
|
93
113
|
`athena.user_journey/${action}${message ? `: ${message}` : ''}`,
|
|
94
114
|
{
|
|
95
115
|
...payload,
|
|
96
116
|
user: {
|
|
97
117
|
walletAddress,
|
|
118
|
+
walletId,
|
|
98
119
|
walletName,
|
|
99
120
|
chainId,
|
|
100
121
|
},
|
|
@@ -104,37 +125,43 @@ const error = (params: UserJourneyErrorParams) => {
|
|
|
104
125
|
};
|
|
105
126
|
|
|
106
127
|
const start = (params: UserJourneyStartParams) => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
if (!allowLogging) {
|
|
115
|
-
console.warn(`Athena.UserJourney.start was called`, params);
|
|
128
|
+
if (!isLoggerInitialized()) {
|
|
129
|
+
console.warn(
|
|
130
|
+
'Athena.UserJourney.start was called. Logger not initialized',
|
|
131
|
+
params,
|
|
132
|
+
);
|
|
116
133
|
return;
|
|
117
134
|
}
|
|
118
135
|
|
|
119
|
-
if (!
|
|
120
|
-
console.warn('
|
|
136
|
+
if (!isAllowLogging()) {
|
|
137
|
+
console.warn('Athena.UserJourney.start was called', params);
|
|
121
138
|
return;
|
|
122
139
|
}
|
|
123
140
|
|
|
141
|
+
const { address, chainId, walletName, walletId } = params;
|
|
142
|
+
initialize({
|
|
143
|
+
walletAddress: address,
|
|
144
|
+
chainId,
|
|
145
|
+
walletName,
|
|
146
|
+
walletId,
|
|
147
|
+
});
|
|
148
|
+
|
|
124
149
|
action({
|
|
125
150
|
action: 'wallet_connected',
|
|
126
|
-
payload: { walletAddress: address, chainId, walletName },
|
|
127
151
|
});
|
|
128
152
|
};
|
|
129
153
|
|
|
130
154
|
const switchChain = (chainId: number) => {
|
|
131
|
-
if (!
|
|
132
|
-
console.warn(
|
|
155
|
+
if (!isLoggerInitialized()) {
|
|
156
|
+
console.warn(
|
|
157
|
+
'Athena.UserJourney.switchChain was called. Logger not initialized',
|
|
158
|
+
{ chainId },
|
|
159
|
+
);
|
|
133
160
|
return;
|
|
134
161
|
}
|
|
135
162
|
|
|
136
|
-
if (!
|
|
137
|
-
console.warn('
|
|
163
|
+
if (!isAllowLogging()) {
|
|
164
|
+
console.warn('Athena.UserJourney.switchChain was called', { chainId });
|
|
138
165
|
return;
|
|
139
166
|
}
|
|
140
167
|
|
|
@@ -145,13 +172,13 @@ const switchChain = (chainId: number) => {
|
|
|
145
172
|
};
|
|
146
173
|
|
|
147
174
|
const stop = () => {
|
|
148
|
-
if (!
|
|
149
|
-
console.warn(
|
|
175
|
+
if (!isLoggerInitialized()) {
|
|
176
|
+
console.warn('Athena.UserJourney.stop was called. Logger not initialized');
|
|
150
177
|
return;
|
|
151
178
|
}
|
|
152
179
|
|
|
153
|
-
if (!
|
|
154
|
-
console.warn(
|
|
180
|
+
if (!isAllowLogging()) {
|
|
181
|
+
console.warn(`Athena.UserJourney.stop was called`);
|
|
155
182
|
return;
|
|
156
183
|
}
|
|
157
184
|
|
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
type UserJourneyState = {
|
|
2
2
|
walletAddress: string | null;
|
|
3
|
+
walletId: string | null;
|
|
3
4
|
walletName: string | null;
|
|
4
5
|
chainId: number | null;
|
|
5
6
|
};
|
|
6
7
|
|
|
7
8
|
const state: UserJourneyState = {
|
|
9
|
+
walletId: null,
|
|
8
10
|
walletAddress: null,
|
|
9
11
|
walletName: null,
|
|
10
12
|
chainId: null,
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
const initialize = ({
|
|
16
|
+
walletId,
|
|
14
17
|
walletAddress,
|
|
15
18
|
walletName,
|
|
16
19
|
chainId,
|
|
17
|
-
}: {
|
|
18
|
-
walletAddress: string;
|
|
19
|
-
walletName: string;
|
|
20
|
-
chainId: number;
|
|
21
|
-
}) => {
|
|
20
|
+
}: UserJourneyState) => {
|
|
22
21
|
state.walletAddress = walletAddress;
|
|
23
22
|
state.chainId = chainId;
|
|
24
23
|
state.walletName = walletName;
|
|
24
|
+
state.walletId = walletId;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const getWalletAddress = () => state.walletAddress;
|
|
28
28
|
const getWalletName = () => state.walletName;
|
|
29
|
+
const getWalletId = () => state.walletId;
|
|
29
30
|
const getChainId = () => state.chainId;
|
|
30
31
|
|
|
31
|
-
const setWalletAddress = (walletAddress: string) => {
|
|
32
|
-
state.walletAddress = walletAddress;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
32
|
const setChainId = (chainId: number) => {
|
|
36
33
|
state.chainId = chainId;
|
|
37
34
|
};
|
|
@@ -46,7 +43,7 @@ export {
|
|
|
46
43
|
getWalletAddress,
|
|
47
44
|
getWalletName,
|
|
48
45
|
getChainId,
|
|
49
|
-
|
|
46
|
+
getWalletId,
|
|
50
47
|
setChainId,
|
|
51
48
|
clear,
|
|
52
49
|
};
|
package/src/shared.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
let initialized = false;
|
|
2
|
+
let allowLogging = false;
|
|
3
3
|
|
|
4
4
|
export const setInitialized = (value: boolean) => {
|
|
5
5
|
initialized = value;
|
|
@@ -9,4 +9,6 @@ export const setAllowLogging = (value: boolean) => {
|
|
|
9
9
|
allowLogging = value;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
export const isAllowLogging = () => allowLogging;
|
|
13
|
+
|
|
12
14
|
export const isLoggerInitialized = () => initialized;
|