@augustdigital/sdk 4.18.0 → 4.19.0-alpha.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/lib/core/analytics/constants.d.ts +6 -0
- package/lib/core/analytics/constants.js +10 -0
- package/lib/core/analytics/constants.js.map +1 -0
- package/lib/core/analytics/index.d.ts +7 -0
- package/lib/core/analytics/index.js +31 -0
- package/lib/core/analytics/index.js.map +1 -0
- package/lib/core/analytics/instrumentation.d.ts +3 -0
- package/lib/core/analytics/instrumentation.js +209 -0
- package/lib/core/analytics/instrumentation.js.map +1 -0
- package/lib/core/analytics/metrics.d.ts +10 -0
- package/lib/core/analytics/metrics.js +100 -0
- package/lib/core/analytics/metrics.js.map +1 -0
- package/lib/core/analytics/sanitize.d.ts +2 -0
- package/lib/core/analytics/sanitize.js +90 -0
- package/lib/core/analytics/sanitize.js.map +1 -0
- package/lib/core/analytics/sentry.d.ts +9 -0
- package/lib/core/analytics/sentry.js +175 -0
- package/lib/core/analytics/sentry.js.map +1 -0
- package/lib/core/analytics/types.d.ts +19 -0
- package/lib/core/analytics/types.js +3 -0
- package/lib/core/analytics/types.js.map +1 -0
- package/lib/core/analytics/user-identity.d.ts +7 -0
- package/lib/core/analytics/user-identity.js +92 -0
- package/lib/core/analytics/user-identity.js.map +1 -0
- package/lib/core/analytics/version.d.ts +1 -0
- package/lib/core/analytics/version.js +5 -0
- package/lib/core/analytics/version.js.map +1 -0
- package/lib/core/base.class.d.ts +3 -1
- package/lib/core/base.class.js +5 -1
- package/lib/core/base.class.js.map +1 -1
- package/lib/core/constants/vaults.d.ts +10 -2
- package/lib/core/constants/vaults.js +11 -3
- package/lib/core/constants/vaults.js.map +1 -1
- package/lib/core/fetcher.js +14 -2
- package/lib/core/fetcher.js.map +1 -1
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js +1 -0
- package/lib/core/index.js.map +1 -1
- package/lib/main.js +3 -0
- package/lib/main.js.map +1 -1
- package/lib/modules/vaults/getters.js +5 -4
- package/lib/modules/vaults/getters.js.map +1 -1
- package/package.json +13 -12
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.initializeSentry = initializeSentry;
|
|
37
|
+
exports.updateUser = updateUser;
|
|
38
|
+
exports.clearUser = clearUser;
|
|
39
|
+
exports.isAnalyticsEnabled = isAnalyticsEnabled;
|
|
40
|
+
exports.getSentry = getSentry;
|
|
41
|
+
exports.resetAnalytics = resetAnalytics;
|
|
42
|
+
const Sentry = __importStar(require("@sentry/browser"));
|
|
43
|
+
const constants_1 = require("./constants");
|
|
44
|
+
const user_identity_1 = require("./user-identity");
|
|
45
|
+
let isInitialized = false;
|
|
46
|
+
let isEnabled = true;
|
|
47
|
+
let currentIdentity = null;
|
|
48
|
+
let cachedApiKey;
|
|
49
|
+
function getSDKVersion() {
|
|
50
|
+
try {
|
|
51
|
+
return require('./version').SDK_VERSION || 'development';
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return 'development';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function safeSetTag(key, value) {
|
|
58
|
+
try {
|
|
59
|
+
Sentry.setTag(key, value);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function safeSetUser(user) {
|
|
65
|
+
try {
|
|
66
|
+
Sentry.setUser(user);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function initializeSentry(config, environment, walletAddress, apiKey) {
|
|
72
|
+
if (config.enabled === false) {
|
|
73
|
+
isEnabled = false;
|
|
74
|
+
console.log('August SDK: Analytics disabled');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
cachedApiKey = apiKey;
|
|
78
|
+
if (isInitialized) {
|
|
79
|
+
if (walletAddress !== currentIdentity?.walletAddress ||
|
|
80
|
+
environment !== currentIdentity?.environment) {
|
|
81
|
+
updateUser(walletAddress, environment);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
Sentry.init({
|
|
87
|
+
dsn: constants_1.SENTRY_DSN,
|
|
88
|
+
tracesSampleRate: constants_1.SENTRY_CONFIG.tracesSampleRate,
|
|
89
|
+
environment: environment.toLowerCase(),
|
|
90
|
+
release: `august-sdk@${getSDKVersion()}`,
|
|
91
|
+
sendDefaultPii: true,
|
|
92
|
+
integrations: [Sentry.captureConsoleIntegration({ levels: ['error'] })],
|
|
93
|
+
beforeSend(event) {
|
|
94
|
+
if (event.tags?.sdk !== 'august-digital') {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return event;
|
|
98
|
+
},
|
|
99
|
+
beforeSendTransaction(transaction) {
|
|
100
|
+
return transaction;
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
updateUser(walletAddress, environment);
|
|
104
|
+
safeSetTag('sdk', 'august-digital');
|
|
105
|
+
safeSetTag('sdk.version', getSDKVersion());
|
|
106
|
+
isInitialized = true;
|
|
107
|
+
console.log('August SDK: Analytics initialized. Disable with { analytics: { enabled: false } }');
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
isEnabled = false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function updateUser(walletAddress, environment = 'PROD') {
|
|
114
|
+
if (!isEnabled)
|
|
115
|
+
return;
|
|
116
|
+
try {
|
|
117
|
+
currentIdentity = (0, user_identity_1.createUserIdentity)(cachedApiKey, walletAddress, environment);
|
|
118
|
+
const userId = (0, user_identity_1.getUserId)(currentIdentity);
|
|
119
|
+
safeSetUser({
|
|
120
|
+
id: userId,
|
|
121
|
+
username: userId,
|
|
122
|
+
ip_address: '{{auto}}',
|
|
123
|
+
data: {
|
|
124
|
+
userId,
|
|
125
|
+
sessionId: currentIdentity.sessionId,
|
|
126
|
+
fingerprint: currentIdentity.fingerprint,
|
|
127
|
+
hasWallet: !!walletAddress,
|
|
128
|
+
hasApiKey: !!currentIdentity.apiKeyHash,
|
|
129
|
+
environment: currentIdentity.environment,
|
|
130
|
+
walletAddress: walletAddress || undefined,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function clearUser() {
|
|
138
|
+
if (!isEnabled)
|
|
139
|
+
return;
|
|
140
|
+
try {
|
|
141
|
+
const environment = currentIdentity?.environment || 'PROD';
|
|
142
|
+
currentIdentity = (0, user_identity_1.createUserIdentity)(cachedApiKey, undefined, environment);
|
|
143
|
+
const userId = (0, user_identity_1.getUserId)(currentIdentity);
|
|
144
|
+
safeSetUser({
|
|
145
|
+
id: userId,
|
|
146
|
+
username: userId,
|
|
147
|
+
ip_address: '{{auto}}',
|
|
148
|
+
data: {
|
|
149
|
+
userId,
|
|
150
|
+
sessionId: currentIdentity.sessionId,
|
|
151
|
+
fingerprint: currentIdentity.fingerprint,
|
|
152
|
+
hasWallet: false,
|
|
153
|
+
hasApiKey: !!currentIdentity.apiKeyHash,
|
|
154
|
+
environment: currentIdentity.environment,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function isAnalyticsEnabled() {
|
|
162
|
+
return isEnabled && isInitialized;
|
|
163
|
+
}
|
|
164
|
+
function getSentry() {
|
|
165
|
+
if (!isAnalyticsEnabled())
|
|
166
|
+
return null;
|
|
167
|
+
return Sentry;
|
|
168
|
+
}
|
|
169
|
+
function resetAnalytics() {
|
|
170
|
+
isInitialized = false;
|
|
171
|
+
isEnabled = true;
|
|
172
|
+
currentIdentity = null;
|
|
173
|
+
cachedApiKey = undefined;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=sentry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry.js","sourceRoot":"","sources":["../../../src.ts/core/analytics/sentry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,4CA+DC;AASD,gCA+BC;AAMD,8BAwBC;AAKD,gDAEC;AAMD,8BA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AAY,GAAG,SAAS,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IEnv } from '../../types';
|
|
2
|
+
export interface IAnalyticsConfig {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface IUserIdentity {
|
|
6
|
+
apiKeyHash?: string;
|
|
7
|
+
walletAddress?: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
fingerprint?: string;
|
|
10
|
+
environment: IEnv;
|
|
11
|
+
domain?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface IMethodCallMetrics {
|
|
14
|
+
method: string;
|
|
15
|
+
chainId?: number;
|
|
16
|
+
duration: number;
|
|
17
|
+
success: boolean;
|
|
18
|
+
errorType?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src.ts/core/analytics/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IEnv } from '../../types';
|
|
2
|
+
import { IUserIdentity } from './types';
|
|
3
|
+
export declare function hashApiKey(apiKey: string): string;
|
|
4
|
+
export declare function getSessionId(): string;
|
|
5
|
+
export declare function generateFingerprint(): string | undefined;
|
|
6
|
+
export declare function createUserIdentity(apiKey?: string, walletAddress?: string, environment?: IEnv): IUserIdentity;
|
|
7
|
+
export declare function getUserId(identity: IUserIdentity): string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashApiKey = hashApiKey;
|
|
4
|
+
exports.getSessionId = getSessionId;
|
|
5
|
+
exports.generateFingerprint = generateFingerprint;
|
|
6
|
+
exports.createUserIdentity = createUserIdentity;
|
|
7
|
+
exports.getUserId = getUserId;
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
let sessionId = null;
|
|
11
|
+
let cachedApiKeyHash = null;
|
|
12
|
+
function hashApiKey(apiKey) {
|
|
13
|
+
if (!apiKey)
|
|
14
|
+
return '';
|
|
15
|
+
if (cachedApiKeyHash)
|
|
16
|
+
return cachedApiKeyHash;
|
|
17
|
+
const hash = (0, crypto_1.createHash)('sha256').update(apiKey).digest('hex');
|
|
18
|
+
cachedApiKeyHash = hash.substring(0, 16);
|
|
19
|
+
return cachedApiKeyHash;
|
|
20
|
+
}
|
|
21
|
+
function getSessionId() {
|
|
22
|
+
if (!sessionId) {
|
|
23
|
+
sessionId = (0, uuid_1.v4)();
|
|
24
|
+
}
|
|
25
|
+
return sessionId;
|
|
26
|
+
}
|
|
27
|
+
function generateFingerprint() {
|
|
28
|
+
try {
|
|
29
|
+
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
|
|
30
|
+
const components = [
|
|
31
|
+
navigator.userAgent,
|
|
32
|
+
navigator.language,
|
|
33
|
+
new Date().getTimezoneOffset().toString(),
|
|
34
|
+
typeof screen !== 'undefined' ? screen.width?.toString() : '',
|
|
35
|
+
typeof screen !== 'undefined' ? screen.height?.toString() : '',
|
|
36
|
+
typeof screen !== 'undefined' ? screen.colorDepth?.toString() : '',
|
|
37
|
+
].filter(Boolean);
|
|
38
|
+
const hash = (0, crypto_1.createHash)('sha256')
|
|
39
|
+
.update(components.join('|'))
|
|
40
|
+
.digest('hex');
|
|
41
|
+
return hash.substring(0, 32);
|
|
42
|
+
}
|
|
43
|
+
if (typeof process !== 'undefined' && process.platform) {
|
|
44
|
+
const components = [process.platform, process.arch, process.version];
|
|
45
|
+
const hash = (0, crypto_1.createHash)('sha256')
|
|
46
|
+
.update(components.join('|'))
|
|
47
|
+
.digest('hex');
|
|
48
|
+
return hash.substring(0, 32);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
function createUserIdentity(apiKey, walletAddress, environment = 'PROD') {
|
|
57
|
+
let domain = undefined;
|
|
58
|
+
try {
|
|
59
|
+
if (typeof window !== 'undefined' && window.location) {
|
|
60
|
+
domain = window.location.hostname;
|
|
61
|
+
}
|
|
62
|
+
else if (typeof process !== 'undefined' && process.env) {
|
|
63
|
+
domain = process.env.VERCEL_PROJECT_PRODUCTION_URL || undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
apiKeyHash: apiKey ? hashApiKey(apiKey) : undefined,
|
|
70
|
+
walletAddress: walletAddress?.toLowerCase(),
|
|
71
|
+
sessionId: getSessionId(),
|
|
72
|
+
fingerprint: generateFingerprint(),
|
|
73
|
+
environment,
|
|
74
|
+
domain,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function getUserId(identity) {
|
|
78
|
+
if (identity.domain) {
|
|
79
|
+
return `domain:${identity.domain}`;
|
|
80
|
+
}
|
|
81
|
+
if (identity.apiKeyHash) {
|
|
82
|
+
return `apikey:${identity.apiKeyHash}`;
|
|
83
|
+
}
|
|
84
|
+
if (identity.walletAddress) {
|
|
85
|
+
return `wallet:${identity.walletAddress}`;
|
|
86
|
+
}
|
|
87
|
+
if (identity.fingerprint) {
|
|
88
|
+
return `fp:${identity.fingerprint}`;
|
|
89
|
+
}
|
|
90
|
+
return `session:${identity.sessionId}`;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=user-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-identity.js","sourceRoot":"","sources":["../../../src.ts/core/analytics/user-identity.ts"],"names":[],"mappings":";;AAkBA,gCASC;AAQD,oCAKC;AAQD,kDAiCC;AAUD,gDAyBC;AASD,8BAiBC;AA9ID,mCAAoC;AACpC,+BAAoC;AAKpC,IAAI,SAAS,GAAkB,IAAI,CAAC;AAGpC,IAAI,gBAAgB,GAAkB,IAAI,CAAC;AAS3C,SAAg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AE,aAAa,EAAE,WAAW,EAAE;QAC3C,SAAS,EAAE,YAAY,EAAE;QACzB,WAAW,EAAE,mBAAmB,EAAE;QAClC,WAAW;QACX,MAAM;KACP,CAAC;AACJ,CAAC;AASD,SAAgB,SAAS,CAAC,QAAuB;IAC/C,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO,UAAU,QAAQ,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;IAED,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxB,OAAO,UAAU,QAAQ,CAAC,UAAU,EAAE,CAAC;IACzC,CAAC;IACD,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC3B,OAAO,UAAU,QAAQ,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;IAED,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;QACzB,OAAO,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAED,OAAO,WAAW,QAAQ,CAAC,SAAS,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION = '4.17.0-alpha.3';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src.ts/core/analytics/version.ts"],"names":[],"mappings":";;;AAKa,QAAA,WAAW,GAAG,gBAAgB,CAAC"}
|
package/lib/core/base.class.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ISolanaConfig, IAddress, IChainId, IEnv, IProvidersConfig, IWSMonitorHeaders } from '../types';
|
|
2
|
+
import { IAnalyticsConfig } from './analytics';
|
|
2
3
|
interface IKeys {
|
|
3
4
|
august?: string;
|
|
4
5
|
graph?: string;
|
|
@@ -14,6 +15,7 @@ export interface IAugustBase {
|
|
|
14
15
|
solana?: ISolanaConfig;
|
|
15
16
|
keys: IKeys;
|
|
16
17
|
monitoring?: IMonitoring;
|
|
18
|
+
analytics?: IAnalyticsConfig;
|
|
17
19
|
}
|
|
18
20
|
interface IActiveNetwork {
|
|
19
21
|
chainId: IChainId;
|
|
@@ -25,7 +27,7 @@ export declare class AugustBase {
|
|
|
25
27
|
authorized: boolean;
|
|
26
28
|
activeNetwork: IActiveNetwork;
|
|
27
29
|
providers: IProvidersConfig;
|
|
28
|
-
constructor({ providers, keys, monitoring }: IAugustBase);
|
|
30
|
+
constructor({ providers, keys, monitoring, analytics }: IAugustBase);
|
|
29
31
|
init(): Promise<void>;
|
|
30
32
|
switchNetwork(chainId: IChainId): void;
|
|
31
33
|
updateWallet(address: IAddress): void;
|
package/lib/core/base.class.js
CHANGED
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AugustBase = void 0;
|
|
4
4
|
const auth_1 = require("./auth");
|
|
5
5
|
const logger_1 = require("./logger");
|
|
6
|
+
const analytics_1 = require("./analytics");
|
|
6
7
|
class AugustBase {
|
|
7
|
-
constructor({ providers, keys, monitoring }) {
|
|
8
|
+
constructor({ providers, keys, monitoring, analytics }) {
|
|
8
9
|
this.monitoring = {
|
|
9
10
|
'x-user-id': undefined,
|
|
10
11
|
'x-environment': undefined,
|
|
@@ -24,6 +25,7 @@ class AugustBase {
|
|
|
24
25
|
'x-environment': environment,
|
|
25
26
|
};
|
|
26
27
|
logger_1.Logger.setDevMode(environment === 'DEV');
|
|
28
|
+
(0, analytics_1.initializeSentry)(analytics ?? { enabled: true }, environment, monitoring?.['x-user-id'], keys?.august);
|
|
27
29
|
}
|
|
28
30
|
async init() {
|
|
29
31
|
const [augustCheck] = await Promise.all([
|
|
@@ -52,6 +54,7 @@ class AugustBase {
|
|
|
52
54
|
...this.monitoring,
|
|
53
55
|
'x-user-id': lowercasedAddress,
|
|
54
56
|
};
|
|
57
|
+
(0, analytics_1.updateUser)(lowercasedAddress, this.monitoring['x-environment']);
|
|
55
58
|
}
|
|
56
59
|
clearWallet() {
|
|
57
60
|
if (this.monitoring) {
|
|
@@ -60,6 +63,7 @@ class AugustBase {
|
|
|
60
63
|
'x-user-id': undefined,
|
|
61
64
|
};
|
|
62
65
|
}
|
|
66
|
+
(0, analytics_1.clearUser)();
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
exports.AugustBase = AugustBase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.class.js","sourceRoot":"","sources":["../../src.ts/core/base.class.ts"],"names":[],"mappings":";;;AAQA,iCAAyC;AACzC,qCAAkC;
|
|
1
|
+
{"version":3,"file":"base.class.js","sourceRoot":"","sources":["../../src.ts/core/base.class.ts"],"names":[],"mappings":";;;AAQA,iCAAyC;AACzC,qCAAkC;AAClC,2CAKqB;AAgCrB,MAAa,UAAU;IAcrB,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAe;QAZ5D,eAAU,GAAgB;YAC/B,WAAW,EAAE,SAAS;YACtB,eAAe,EAAE,SAAS;SAC3B,CAAC;QAWA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAEvB,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QAEpD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAG3B,IAAI,CAAC,aAAa,GAAG;YACnB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAa;YACtD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;SACpC,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAGjB,MAAM,WAAW,GACf,UAAU,EAAE,GAAG,IAAI,UAAU,EAAE,CAAC,eAAe,CAAC,IAAI,MAAM,CAAC;QAC7D,IAAI,CAAC,UAAU,GAAG;YAChB,GAAG,UAAU;YACb,eAAe,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AiB,EAAE,IAAI,CAAC,UAAU,CAAC,eAAe,CAAS,CAAC,CAAC;IAC1E,CAAC;IAKD,WAAW;QACT,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,GAAG;gBAChB,GAAG,IAAI,CAAC,UAAU;gBAClB,WAAW,EAAE,SAAS;aACvB,CAAC;QACJ,CAAC;QAGD,IAAA,qBAAS,GAAE,CAAC;IACd,CAAC;CACF;AAjHD,gCAiHC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { IAddress, IPoolFunctions } from '../../types';
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
2
|
+
export declare const VAULT_ALLOCATION_SUBACCOUNTS: {
|
|
3
|
+
AgoraAUSD: {
|
|
4
|
+
address: IAddress;
|
|
5
|
+
subaccount: IAddress;
|
|
6
|
+
};
|
|
7
|
+
earnAUSD: {
|
|
8
|
+
address: IAddress;
|
|
9
|
+
subaccount: IAddress;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
4
12
|
export declare const MULTI_ASSET_VAULTS: `0x${string}`[];
|
|
5
13
|
export declare const WRAPPER_ADAPTOR: {
|
|
6
14
|
43114: IAddress;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VAULT_SYMBOLS_REVERSE = exports.VAULT_SYMBOLS = exports.SUBGRAPH_VAULT_URLS = exports.GOLDSKY_BASE_URL = exports.VAULT_FUNCTIONS_V2_WHITELISTED_ASSETS = exports.VAULT_FUNCTIONS_V2_RECEIPT = exports.VAULT_FUNCTIONS_V2 = exports.VAULT_FUNCTIONS_V1 = exports.IDLE_CAPITAL_BORROWER_ADDRESS = exports.OLD_LENDING_POOLS = exports.WRAPPER_ADAPTOR = exports.MULTI_ASSET_VAULTS = exports.
|
|
3
|
+
exports.VAULT_SYMBOLS_REVERSE = exports.VAULT_SYMBOLS = exports.SUBGRAPH_VAULT_URLS = exports.GOLDSKY_BASE_URL = exports.VAULT_FUNCTIONS_V2_WHITELISTED_ASSETS = exports.VAULT_FUNCTIONS_V2_RECEIPT = exports.VAULT_FUNCTIONS_V2 = exports.VAULT_FUNCTIONS_V1 = exports.IDLE_CAPITAL_BORROWER_ADDRESS = exports.OLD_LENDING_POOLS = exports.WRAPPER_ADAPTOR = exports.MULTI_ASSET_VAULTS = exports.VAULT_ALLOCATION_SUBACCOUNTS = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
|
-
exports.
|
|
6
|
-
|
|
5
|
+
exports.VAULT_ALLOCATION_SUBACCOUNTS = {
|
|
6
|
+
AgoraAUSD: {
|
|
7
|
+
address: (0, ethers_1.getAddress)('0x828BC5895b78b2fb591018Ca5bDC2064742D6D0f'),
|
|
8
|
+
subaccount: (0, ethers_1.getAddress)('0xFff71B0b66f076C60Fa2f176a34a6EA709ccF21B'),
|
|
9
|
+
},
|
|
10
|
+
earnAUSD: {
|
|
11
|
+
address: (0, ethers_1.getAddress)('0x36eDbF0C834591BFdfCaC0Ef9605528c75c406aA'),
|
|
12
|
+
subaccount: (0, ethers_1.getAddress)('0xB0B929571985D6bB8d0CF6d18FAf14F0c6f0E276'),
|
|
13
|
+
},
|
|
14
|
+
};
|
|
7
15
|
exports.MULTI_ASSET_VAULTS = [
|
|
8
16
|
(0, ethers_1.getAddress)('0x18EE038C114a07f4B08b420fb1E4149a4F357249'),
|
|
9
17
|
(0, ethers_1.getAddress)('0x517677A19D8ae6FF600FB86C3C7bFCCD651e3eec'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vaults.js","sourceRoot":"","sources":["../../../src.ts/core/constants/vaults.ts"],"names":[],"mappings":";;;AACA,mCAAoC;AAavB,QAAA,
|
|
1
|
+
{"version":3,"file":"vaults.js","sourceRoot":"","sources":["../../../src.ts/core/constants/vaults.ts"],"names":[],"mappings":";;;AACA,mCAAoC;AAavB,QAAA,4BAA4B,GAAG;IAE1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AAS;IACvD,4CAA4C,EAAE,aAAa;IAC3D,4CAA4C,EAAE,QAAQ;IACtD,4CAA4C,EAAE,QAAQ;IACtD,4CAA4C,EAAE,UAAU;IACxD,4CAA4C,EAAE,MAAM;IACpD,4CAA4C,EAAE,UAAU;IACxD,4CAA4C,EAAE,oBAAoB;IAClE,4CAA4C,EAAE,qBAAqB;IACnE,4CAA4C,EAAE,OAAO;IACrD,4CAA4C,EAAE,UAAU;IACxD,4CAA4C,EAAE,SAAS;IACvD,4CAA4C,EAAE,aAAa;IAC3D,4CAA4C,EAAE,OAAO;IACrD,4CAA4C,EAAE,SAAS;IACvD,4CAA4C,EAAE,WAAW;IACzD,4CAA4C,EAAE,SAAS;IACvD,4CAA4C,EAAE,MAAM;IACpD,4CAA4C,EAAE,QAAQ;IACtD,4CAA4C,EAAE,QAAQ;IACtD,4CAA4C,EAAE,UAAU;IACxD,4CAA4C,EAAE,SAAS;IACvD,4CAA4C,EAAE,QAAQ;IACtD,4CAA4C,EAAE,SAAS;IACvD,4CAA4C,EAAE,UAAU;IACxD,4CAA4C,EAAE,UAAU;CACzD,CAAC;AAMW,QAAA,qBAAqB,GAChC,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,qBAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAChC,CAAC"}
|
package/lib/core/fetcher.js
CHANGED
|
@@ -23,6 +23,7 @@ const logger_1 = require("./logger");
|
|
|
23
23
|
const web3_1 = require("./helpers/web3");
|
|
24
24
|
const core_2 = require("./constants/core");
|
|
25
25
|
const vaults_1 = require("./helpers/vaults");
|
|
26
|
+
const analytics_1 = require("./analytics");
|
|
26
27
|
exports.CACHE = new lru_cache_1.LRUCache({
|
|
27
28
|
max: 1000,
|
|
28
29
|
ttl: 1000 * 60 * 60 * 24,
|
|
@@ -65,8 +66,10 @@ async function fetchAugustWithKey(apiKey, relativeUrl, options) {
|
|
|
65
66
|
};
|
|
66
67
|
const controller = new AbortController();
|
|
67
68
|
const timeoutId = setTimeout(() => controller.abort(), core_2.REQUEST_TIMEOUT_MS);
|
|
69
|
+
const startTime = performance.now();
|
|
70
|
+
const server = options?.server || 'production';
|
|
68
71
|
try {
|
|
69
|
-
const res = await fetch(`${core_2.WEBSERVER_URL[
|
|
72
|
+
const res = await fetch(`${core_2.WEBSERVER_URL[server]}${relativeUrl}`, {
|
|
70
73
|
headers: {
|
|
71
74
|
...defaultHeaders,
|
|
72
75
|
...options?.headers,
|
|
@@ -76,6 +79,7 @@ async function fetchAugustWithKey(apiKey, relativeUrl, options) {
|
|
|
76
79
|
signal: controller.signal,
|
|
77
80
|
});
|
|
78
81
|
clearTimeout(timeoutId);
|
|
82
|
+
(0, analytics_1.trackApiCall)(relativeUrl, options?.method ?? 'GET', startTime, res.status, server);
|
|
79
83
|
const correlationId = res.headers['x-correlation-id'];
|
|
80
84
|
const logger = logger_1.Logger.getLogger();
|
|
81
85
|
if (!res.ok || res.status !== 200) {
|
|
@@ -90,6 +94,7 @@ async function fetchAugustWithKey(apiKey, relativeUrl, options) {
|
|
|
90
94
|
}
|
|
91
95
|
catch (error) {
|
|
92
96
|
clearTimeout(timeoutId);
|
|
97
|
+
(0, analytics_1.trackApiCall)(relativeUrl, options?.method ?? 'GET', startTime, 0, server);
|
|
93
98
|
if (error.name === 'AbortError') {
|
|
94
99
|
const timeoutError = new Error(`Request timeout after ${core_2.REQUEST_TIMEOUT_MS / 1000}s: ${relativeUrl}`);
|
|
95
100
|
logger_1.Logger.log.error('fetchAugustWithKey', timeoutError, { relativeUrl });
|
|
@@ -105,6 +110,7 @@ async function fetchAugustPublic(relativeUrl, options) {
|
|
|
105
110
|
};
|
|
106
111
|
const controller = new AbortController();
|
|
107
112
|
const timeoutId = setTimeout(() => controller.abort(), core_2.REQUEST_TIMEOUT_MS);
|
|
113
|
+
const startTime = performance.now();
|
|
108
114
|
try {
|
|
109
115
|
const res = await fetch(`${core_2.WEBSERVER_URL['public']}${relativeUrl}`, {
|
|
110
116
|
headers: {
|
|
@@ -116,6 +122,7 @@ async function fetchAugustPublic(relativeUrl, options) {
|
|
|
116
122
|
signal: controller.signal,
|
|
117
123
|
});
|
|
118
124
|
clearTimeout(timeoutId);
|
|
125
|
+
(0, analytics_1.trackApiCall)(relativeUrl, options?.method ?? 'GET', startTime, res.status, 'public');
|
|
119
126
|
const correlationId = res.headers['x-correlation-id'];
|
|
120
127
|
const logger = logger_1.Logger.getLogger();
|
|
121
128
|
if (!res.ok || res.status !== 200) {
|
|
@@ -130,6 +137,7 @@ async function fetchAugustPublic(relativeUrl, options) {
|
|
|
130
137
|
}
|
|
131
138
|
catch (error) {
|
|
132
139
|
clearTimeout(timeoutId);
|
|
140
|
+
(0, analytics_1.trackApiCall)(relativeUrl, options?.method ?? 'GET', startTime, 0, 'public');
|
|
133
141
|
if (error.name === 'AbortError') {
|
|
134
142
|
const timeoutError = new Error(`Request timeout after ${core_2.REQUEST_TIMEOUT_MS / 1000}s: ${relativeUrl}`);
|
|
135
143
|
logger_1.Logger.log.error('fetchAugustPublic', timeoutError, { relativeUrl });
|
|
@@ -146,8 +154,10 @@ async function fetchAugustWithBearer(bearerToken, relativeUrl, options) {
|
|
|
146
154
|
};
|
|
147
155
|
const controller = new AbortController();
|
|
148
156
|
const timeoutId = setTimeout(() => controller.abort(), core_2.REQUEST_TIMEOUT_MS);
|
|
157
|
+
const startTime = performance.now();
|
|
158
|
+
const server = options?.server ?? 'production';
|
|
149
159
|
try {
|
|
150
|
-
const res = await fetch(`${core_2.WEBSERVER_URL[
|
|
160
|
+
const res = await fetch(`${core_2.WEBSERVER_URL[server]}${relativeUrl}`, {
|
|
151
161
|
headers: {
|
|
152
162
|
...defaultHeaders,
|
|
153
163
|
...options.headers,
|
|
@@ -157,6 +167,7 @@ async function fetchAugustWithBearer(bearerToken, relativeUrl, options) {
|
|
|
157
167
|
signal: controller.signal,
|
|
158
168
|
});
|
|
159
169
|
clearTimeout(timeoutId);
|
|
170
|
+
(0, analytics_1.trackApiCall)(relativeUrl, options?.method ?? 'GET', startTime, res.status, server);
|
|
160
171
|
const correlationId = res.headers['x-correlation-id'];
|
|
161
172
|
const logger = logger_1.Logger.getLogger();
|
|
162
173
|
if (!res.ok || res.status !== 200) {
|
|
@@ -171,6 +182,7 @@ async function fetchAugustWithBearer(bearerToken, relativeUrl, options) {
|
|
|
171
182
|
}
|
|
172
183
|
catch (error) {
|
|
173
184
|
clearTimeout(timeoutId);
|
|
185
|
+
(0, analytics_1.trackApiCall)(relativeUrl, options?.method ?? 'GET', startTime, 0, server);
|
|
174
186
|
if (error.name === 'AbortError') {
|
|
175
187
|
const timeoutError = new Error(`Request timeout after ${core_2.REQUEST_TIMEOUT_MS / 1000}s: ${relativeUrl}`);
|
|
176
188
|
logger_1.Logger.log.error('fetchAugustWithBearer', timeoutError, { relativeUrl });
|