@augustdigital/sdk 4.17.0-alpha.3 → 4.17.0-alpha.4
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/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.js.map +1 -0
- package/lib/abis/index.d.ts +1 -0
- package/lib/abis/index.js +1 -0
- package/lib/abis/index.js.map +1 -1
- package/lib/adapters/evm/index.d.ts +2 -1
- package/lib/adapters/evm/index.js +4 -0
- package/lib/adapters/evm/index.js.map +1 -1
- package/lib/core/base.class.d.ts +1 -3
- package/lib/core/base.class.js +1 -5
- package/lib/core/base.class.js.map +1 -1
- package/lib/core/constants.adapters.d.ts +117 -0
- package/lib/core/constants.adapters.js +160 -0
- package/lib/core/constants.adapters.js.map +1 -0
- package/lib/core/constants.core.d.ts +78 -0
- package/lib/core/constants.core.js +75 -0
- package/lib/core/constants.core.js.map +1 -0
- package/lib/core/constants.d.ts +96 -0
- package/lib/core/constants.js +148 -0
- package/lib/core/constants.js.map +1 -0
- package/lib/core/constants.vaults.d.ts +64 -0
- package/lib/core/constants.vaults.js +155 -0
- package/lib/core/constants.vaults.js.map +1 -0
- package/lib/core/constants.web3.d.ts +31 -0
- package/lib/core/constants.web3.js +112 -0
- package/lib/core/constants.web3.js.map +1 -0
- package/lib/core/core.helpers.d.ts +48 -0
- package/lib/core/core.helpers.js +210 -0
- package/lib/core/core.helpers.js.map +1 -0
- package/lib/core/fetcher.js +2 -20
- package/lib/core/fetcher.js.map +1 -1
- package/lib/core/helpers.adapters.d.ts +9 -0
- package/lib/core/helpers.adapters.js +28 -0
- package/lib/core/helpers.adapters.js.map +1 -0
- package/lib/core/helpers.core.d.ts +48 -0
- package/lib/core/helpers.core.js +210 -0
- package/lib/core/helpers.core.js.map +1 -0
- package/lib/core/helpers.signer.d.ts +9 -0
- package/lib/core/helpers.signer.js +54 -0
- package/lib/core/helpers.signer.js.map +1 -0
- package/lib/core/helpers.vaults.d.ts +36 -0
- package/lib/core/helpers.vaults.js +145 -0
- package/lib/core/helpers.vaults.js.map +1 -0
- package/lib/core/helpers.web3.d.ts +95 -0
- package/lib/core/helpers.web3.js +376 -0
- package/lib/core/helpers.web3.js.map +1 -0
- package/lib/core/index.d.ts +0 -1
- package/lib/core/index.js +0 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/read.actions.d.ts +6 -0
- package/lib/core/read.actions.js +39 -0
- package/lib/core/read.actions.js.map +1 -0
- package/lib/core/web3.helpers.d.ts +95 -0
- package/lib/core/web3.helpers.js +356 -0
- package/lib/core/web3.helpers.js.map +1 -0
- package/lib/core/write.actions.d.ts +12 -0
- package/lib/core/write.actions.js +51 -0
- package/lib/core/write.actions.js.map +1 -0
- package/lib/main.js +0 -3
- package/lib/main.js.map +1 -1
- package/lib/modules/vaults/constants.d.ts +109 -0
- package/lib/modules/vaults/constants.js +194 -0
- package/lib/modules/vaults/constants.js.map +1 -0
- package/lib/modules/vaults/main.d.ts +2 -1
- package/lib/modules/vaults/main.js +3 -0
- package/lib/modules/vaults/main.js.map +1 -1
- package/lib/modules/vaults/vault.actions.d.ts +19 -0
- package/lib/modules/vaults/vault.actions.js +95 -0
- package/lib/modules/vaults/vault.actions.js.map +1 -0
- package/lib/modules/vaults/write.actions.d.ts +7 -0
- package/lib/modules/vaults/write.actions.js +45 -0
- package/lib/modules/vaults/write.actions.js.map +1 -1
- package/lib/verify.d.ts +2 -0
- package/lib/verify.js +33 -0
- package/lib/verify.js.map +1 -0
- package/package.json +13 -16
- package/lib/core/analytics/constants.d.ts +0 -12
- package/lib/core/analytics/constants.js +0 -49
- package/lib/core/analytics/constants.js.map +0 -1
- package/lib/core/analytics/index.d.ts +0 -6
- package/lib/core/analytics/index.js +0 -31
- package/lib/core/analytics/index.js.map +0 -1
- package/lib/core/analytics/instrumentation.d.ts +0 -2
- package/lib/core/analytics/instrumentation.js +0 -150
- package/lib/core/analytics/instrumentation.js.map +0 -1
- package/lib/core/analytics/metrics.d.ts +0 -12
- package/lib/core/analytics/metrics.js +0 -133
- package/lib/core/analytics/metrics.js.map +0 -1
- package/lib/core/analytics/sentry.d.ts +0 -9
- package/lib/core/analytics/sentry.js +0 -167
- package/lib/core/analytics/sentry.js.map +0 -1
- package/lib/core/analytics/types.d.ts +0 -21
- package/lib/core/analytics/types.js +0 -3
- package/lib/core/analytics/types.js.map +0 -1
- package/lib/core/analytics/user-identity.d.ts +0 -8
- package/lib/core/analytics/user-identity.js +0 -82
- package/lib/core/analytics/user-identity.js.map +0 -1
- package/lib/core/analytics/version.d.ts +0 -1
- package/lib/core/analytics/version.js +0 -5
- package/lib/core/analytics/version.js.map +0 -1
package/lib/verify.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.verifyInfuraKey = verifyInfuraKey;
|
|
13
|
+
exports.verifyAugustKey = verifyAugustKey;
|
|
14
|
+
const utils_1 = require("@augustdigital/utils");
|
|
15
|
+
function verifyInfuraKey(key) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
if (key.length !== 32)
|
|
18
|
+
return false;
|
|
19
|
+
const regex = /[a-z0-9]+/i;
|
|
20
|
+
if (!regex.test(key))
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function verifyAugustKey(key) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const verify = yield (0, utils_1.fetchAugustWithKey)(key, utils_1.WEBSERVER_ENDPOINTS.auth.verify);
|
|
28
|
+
if (verify.status === 200)
|
|
29
|
+
return true;
|
|
30
|
+
return false;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../src.ts/verify.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,0CAKC;AAED,0CAIC;AAbD,gDAA+E;AAE/E,SAAsB,eAAe,CAAC,GAAW;;QAC/C,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE;YAAE,OAAO,KAAK,CAAC;QACpC,MAAM,KAAK,GAAG,YAAY,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAED,SAAsB,eAAe,CAAC,GAAW;;QAC/C,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAkB,EAAC,GAAG,EAAE,2BAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9E,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augustdigital/sdk",
|
|
3
|
-
"version": "4.17.0-alpha.
|
|
3
|
+
"version": "4.17.0-alpha.4",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"augustdigital",
|
|
@@ -12,17 +12,6 @@
|
|
|
12
12
|
"author": "August Digital",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"description": "JS SDK powering the August Digital ecosystem.",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "tsc",
|
|
17
|
-
"prepublishOnly": "node scripts/update-version.js && pnpm build",
|
|
18
|
-
"test": "pnpm build && cross-env node dist/test",
|
|
19
|
-
"test:jest": "jest",
|
|
20
|
-
"test:jest:watch": "jest --watch",
|
|
21
|
-
"test:jest:coverage": "jest --coverage",
|
|
22
|
-
"clean": "rm -rf ./lib",
|
|
23
|
-
"format": "pnpm prettier '**/*.{json,yaml,ts,md}' --write",
|
|
24
|
-
"lint-sdk": "lint-staged"
|
|
25
|
-
},
|
|
26
15
|
"lint-staged": {
|
|
27
16
|
"*.{json,md,html,js,jsx,ts,tsx}": [
|
|
28
17
|
"pnpm format"
|
|
@@ -36,15 +25,13 @@
|
|
|
36
25
|
},
|
|
37
26
|
"dependencies": {
|
|
38
27
|
"@coral-xyz/anchor": "^0.31.1",
|
|
39
|
-
"@sentry/browser": "^8.0.0",
|
|
40
28
|
"@solana/spl-token": "^0.4.14",
|
|
41
29
|
"@solana/wallet-adapter-base": "^0.9.27",
|
|
42
30
|
"@solana/web3.js": "^1.98.4",
|
|
43
31
|
"buffer": "^6.0.3",
|
|
44
32
|
"ethereum-block-by-date": "^1.5.0",
|
|
45
33
|
"ethers": "^6.13.1",
|
|
46
|
-
"lru-cache": "^11.2.2"
|
|
47
|
-
"uuid": "^9.0.0"
|
|
34
|
+
"lru-cache": "^11.2.2"
|
|
48
35
|
},
|
|
49
36
|
"devDependencies": {
|
|
50
37
|
"@types/jest": "^29.5.0",
|
|
@@ -60,5 +47,15 @@
|
|
|
60
47
|
"viem": {
|
|
61
48
|
"optional": true
|
|
62
49
|
}
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc",
|
|
53
|
+
"test": "pnpm build && cross-env node dist/test",
|
|
54
|
+
"test:jest": "jest",
|
|
55
|
+
"test:jest:watch": "jest --watch",
|
|
56
|
+
"test:jest:coverage": "jest --coverage",
|
|
57
|
+
"clean": "rm -rf ./lib",
|
|
58
|
+
"format": "pnpm prettier '**/*.{json,yaml,ts,md}' --write",
|
|
59
|
+
"lint-sdk": "lint-staged"
|
|
63
60
|
}
|
|
64
|
-
}
|
|
61
|
+
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const SENTRY_DSN = "https://d73b6a85fe14960b8dac8ac61a743a94@o4507215496609792.ingest.de.sentry.io/4510699327389776";
|
|
2
|
-
export declare const SENTRY_CONFIG: {
|
|
3
|
-
readonly tracesSampleRate: 0.1;
|
|
4
|
-
readonly enableTracing: true;
|
|
5
|
-
readonly environment: "production";
|
|
6
|
-
};
|
|
7
|
-
export declare const METHOD_CATEGORIES: {
|
|
8
|
-
readonly read: readonly ["getVaults", "getVault", "getVaultLoans", "getVaultAllocations", "getVaultApy", "getVaultTvl", "getVaultHistoricalTimeseries", "getVaultPositions", "getVaultUserHistory", "getVaultUserTransfers", "getVaultUserLifetimePnl", "getVaultPnl", "getVaultStakingPositions", "getUserPoints", "getPrice", "getVaultAvailableRedemptions", "getVaultBorrowerHealthFactor", "fetchPointsLeaderboard", "getVaultAnnualizedApy", "getVaultSummary", "getVaultWithdrawals", "previewRedemption", "getTotalDeposited", "getYieldLastRealizedOn"];
|
|
9
|
-
readonly write: readonly ["vaultDeposit", "registerUserForPoints"];
|
|
10
|
-
readonly state: readonly ["switchNetwork", "updateWallet", "clearWallet"];
|
|
11
|
-
};
|
|
12
|
-
export declare function getMethodCategory(methodName: string): string;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.METHOD_CATEGORIES = exports.SENTRY_CONFIG = exports.SENTRY_DSN = void 0;
|
|
4
|
-
exports.getMethodCategory = getMethodCategory;
|
|
5
|
-
exports.SENTRY_DSN = 'https://d73b6a85fe14960b8dac8ac61a743a94@o4507215496609792.ingest.de.sentry.io/4510699327389776';
|
|
6
|
-
exports.SENTRY_CONFIG = {
|
|
7
|
-
tracesSampleRate: 0.1,
|
|
8
|
-
enableTracing: true,
|
|
9
|
-
environment: 'production',
|
|
10
|
-
};
|
|
11
|
-
exports.METHOD_CATEGORIES = {
|
|
12
|
-
read: [
|
|
13
|
-
'getVaults',
|
|
14
|
-
'getVault',
|
|
15
|
-
'getVaultLoans',
|
|
16
|
-
'getVaultAllocations',
|
|
17
|
-
'getVaultApy',
|
|
18
|
-
'getVaultTvl',
|
|
19
|
-
'getVaultHistoricalTimeseries',
|
|
20
|
-
'getVaultPositions',
|
|
21
|
-
'getVaultUserHistory',
|
|
22
|
-
'getVaultUserTransfers',
|
|
23
|
-
'getVaultUserLifetimePnl',
|
|
24
|
-
'getVaultPnl',
|
|
25
|
-
'getVaultStakingPositions',
|
|
26
|
-
'getUserPoints',
|
|
27
|
-
'getPrice',
|
|
28
|
-
'getVaultAvailableRedemptions',
|
|
29
|
-
'getVaultBorrowerHealthFactor',
|
|
30
|
-
'fetchPointsLeaderboard',
|
|
31
|
-
'getVaultAnnualizedApy',
|
|
32
|
-
'getVaultSummary',
|
|
33
|
-
'getVaultWithdrawals',
|
|
34
|
-
'previewRedemption',
|
|
35
|
-
'getTotalDeposited',
|
|
36
|
-
'getYieldLastRealizedOn',
|
|
37
|
-
],
|
|
38
|
-
write: ['vaultDeposit', 'registerUserForPoints'],
|
|
39
|
-
state: ['switchNetwork', 'updateWallet', 'clearWallet'],
|
|
40
|
-
};
|
|
41
|
-
function getMethodCategory(methodName) {
|
|
42
|
-
for (const [category, methods] of Object.entries(exports.METHOD_CATEGORIES)) {
|
|
43
|
-
if (methods.includes(methodName)) {
|
|
44
|
-
return category;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return 'other';
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src.ts/core/analytics/constants.ts"],"names":[],"mappings":";;;AA2DA,8CAOC;AA9DY,QAAA,UAAU,GACrB,iGAAiG,CAAC;AAKvF,QAAA,aAAa,GAAG;IAE3B,gBAAgB,EAAE,GAAG;IAErB,aAAa,EAAE,IAAI;IAEnB,WAAW,EAAE,YAAY;CACjB,CAAC;AAKE,QAAA,iBAAiB,GAAG;IAE/B,IAAI,EAAE;QACJ,WAAW;QACX,UAAU;QACV,eAAe;QACf,qBAAqB;QACrB,aAAa;QACb,aAAa;QACb,8BAA8B;QAC9B,mBAAmB;QACnB,qBAAqB;QACrB,uBAAuB;QACvB,yBAAyB;QACzB,aAAa;QACb,0BAA0B;QAC1B,eAAe;QACf,UAAU;QACV,8BAA8B;QAC9B,8BAA8B;QAC9B,wBAAwB;QACxB,uBAAuB;QACvB,iBAAiB;QACjB,qBAAqB;QACrB,mBAAmB;QACnB,mBAAmB;QACnB,wBAAwB;KACzB;IAED,KAAK,EAAE,CAAC,cAAc,EAAE,uBAAuB,CAAC;IAEhD,KAAK,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,aAAa,CAAC;CAC/C,CAAC;AAKX,SAAgB,iBAAiB,CAAC,UAAkB;IAClD,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,yBAAiB,CAAC,EAAE,CAAC;QACpE,IAAK,OAA6B,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACxD,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type { IAnalyticsConfig, IUserIdentity, IMethodCallMetrics, } from './types';
|
|
2
|
-
export { SENTRY_CONFIG, METHOD_CATEGORIES, getMethodCategory, } from './constants';
|
|
3
|
-
export { hashApiKey, getSessionId, generateFingerprint, createUserIdentity, getUserId, resetSession, } from './user-identity';
|
|
4
|
-
export { initializeSentry, updateUser, clearUser, isAnalyticsEnabled, getSentry, resetAnalytics, } from './sentry';
|
|
5
|
-
export { trackCacheOperation, trackApiCall, trackNetworkSwitch, getCacheStats, resetCacheStats, } from './metrics';
|
|
6
|
-
export { withMethodTracking, instrumentClass } from './instrumentation';
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.instrumentClass = exports.withMethodTracking = exports.resetCacheStats = exports.getCacheStats = exports.trackNetworkSwitch = exports.trackApiCall = exports.trackCacheOperation = exports.resetAnalytics = exports.getSentry = exports.isAnalyticsEnabled = exports.clearUser = exports.updateUser = exports.initializeSentry = exports.resetSession = exports.getUserId = exports.createUserIdentity = exports.generateFingerprint = exports.getSessionId = exports.hashApiKey = exports.getMethodCategory = exports.METHOD_CATEGORIES = exports.SENTRY_CONFIG = void 0;
|
|
4
|
-
var constants_1 = require("./constants");
|
|
5
|
-
Object.defineProperty(exports, "SENTRY_CONFIG", { enumerable: true, get: function () { return constants_1.SENTRY_CONFIG; } });
|
|
6
|
-
Object.defineProperty(exports, "METHOD_CATEGORIES", { enumerable: true, get: function () { return constants_1.METHOD_CATEGORIES; } });
|
|
7
|
-
Object.defineProperty(exports, "getMethodCategory", { enumerable: true, get: function () { return constants_1.getMethodCategory; } });
|
|
8
|
-
var user_identity_1 = require("./user-identity");
|
|
9
|
-
Object.defineProperty(exports, "hashApiKey", { enumerable: true, get: function () { return user_identity_1.hashApiKey; } });
|
|
10
|
-
Object.defineProperty(exports, "getSessionId", { enumerable: true, get: function () { return user_identity_1.getSessionId; } });
|
|
11
|
-
Object.defineProperty(exports, "generateFingerprint", { enumerable: true, get: function () { return user_identity_1.generateFingerprint; } });
|
|
12
|
-
Object.defineProperty(exports, "createUserIdentity", { enumerable: true, get: function () { return user_identity_1.createUserIdentity; } });
|
|
13
|
-
Object.defineProperty(exports, "getUserId", { enumerable: true, get: function () { return user_identity_1.getUserId; } });
|
|
14
|
-
Object.defineProperty(exports, "resetSession", { enumerable: true, get: function () { return user_identity_1.resetSession; } });
|
|
15
|
-
var sentry_1 = require("./sentry");
|
|
16
|
-
Object.defineProperty(exports, "initializeSentry", { enumerable: true, get: function () { return sentry_1.initializeSentry; } });
|
|
17
|
-
Object.defineProperty(exports, "updateUser", { enumerable: true, get: function () { return sentry_1.updateUser; } });
|
|
18
|
-
Object.defineProperty(exports, "clearUser", { enumerable: true, get: function () { return sentry_1.clearUser; } });
|
|
19
|
-
Object.defineProperty(exports, "isAnalyticsEnabled", { enumerable: true, get: function () { return sentry_1.isAnalyticsEnabled; } });
|
|
20
|
-
Object.defineProperty(exports, "getSentry", { enumerable: true, get: function () { return sentry_1.getSentry; } });
|
|
21
|
-
Object.defineProperty(exports, "resetAnalytics", { enumerable: true, get: function () { return sentry_1.resetAnalytics; } });
|
|
22
|
-
var metrics_1 = require("./metrics");
|
|
23
|
-
Object.defineProperty(exports, "trackCacheOperation", { enumerable: true, get: function () { return metrics_1.trackCacheOperation; } });
|
|
24
|
-
Object.defineProperty(exports, "trackApiCall", { enumerable: true, get: function () { return metrics_1.trackApiCall; } });
|
|
25
|
-
Object.defineProperty(exports, "trackNetworkSwitch", { enumerable: true, get: function () { return metrics_1.trackNetworkSwitch; } });
|
|
26
|
-
Object.defineProperty(exports, "getCacheStats", { enumerable: true, get: function () { return metrics_1.getCacheStats; } });
|
|
27
|
-
Object.defineProperty(exports, "resetCacheStats", { enumerable: true, get: function () { return metrics_1.resetCacheStats; } });
|
|
28
|
-
var instrumentation_1 = require("./instrumentation");
|
|
29
|
-
Object.defineProperty(exports, "withMethodTracking", { enumerable: true, get: function () { return instrumentation_1.withMethodTracking; } });
|
|
30
|
-
Object.defineProperty(exports, "instrumentClass", { enumerable: true, get: function () { return instrumentation_1.instrumentClass; } });
|
|
31
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src.ts/core/analytics/index.ts"],"names":[],"mappings":";;;AAmCA,yCAIqB;AAHnB,0GAAA,aAAa,OAAA;AACb,8GAAA,iBAAiB,OAAA;AACjB,8GAAA,iBAAiB,OAAA;AAInB,iDAOyB;AANvB,2GAAA,UAAU,OAAA;AACV,6GAAA,YAAY,OAAA;AACZ,oHAAA,mBAAmB,OAAA;AACnB,mHAAA,kBAAkB,OAAA;AAClB,0GAAA,SAAS,OAAA;AACT,6GAAA,YAAY,OAAA;AAId,mCAOkB;AANhB,0GAAA,gBAAgB,OAAA;AAChB,oGAAA,UAAU,OAAA;AACV,mGAAA,SAAS,OAAA;AACT,4GAAA,kBAAkB,OAAA;AAClB,mGAAA,SAAS,OAAA;AACT,wGAAA,cAAc,OAAA;AAIhB,qCAMmB;AALjB,8GAAA,mBAAmB,OAAA;AACnB,uGAAA,YAAY,OAAA;AACZ,6GAAA,kBAAkB,OAAA;AAClB,wGAAA,aAAa,OAAA;AACb,0GAAA,eAAe,OAAA;AAIjB,qDAAwE;AAA/D,qHAAA,kBAAkB,OAAA;AAAE,kHAAA,eAAe,OAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare function withMethodTracking<T extends (...args: unknown[]) => Promise<unknown>>(methodName: string, method: T, getChainId?: () => number | undefined): T;
|
|
2
|
-
export declare function instrumentClass<T extends object>(instance: T, getChainId: () => number | undefined): T;
|
|
@@ -1,150 +0,0 @@
|
|
|
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.withMethodTracking = withMethodTracking;
|
|
37
|
-
exports.instrumentClass = instrumentClass;
|
|
38
|
-
const Sentry = __importStar(require("@sentry/browser"));
|
|
39
|
-
const constants_1 = require("./constants");
|
|
40
|
-
const sentry_1 = require("./sentry");
|
|
41
|
-
function withMethodTracking(methodName, method, getChainId) {
|
|
42
|
-
return async function trackedMethod(...args) {
|
|
43
|
-
if (!(0, sentry_1.isAnalyticsEnabled)()) {
|
|
44
|
-
return method(...args);
|
|
45
|
-
}
|
|
46
|
-
const startTime = performance.now();
|
|
47
|
-
const chainId = getChainId?.();
|
|
48
|
-
const category = (0, constants_1.getMethodCategory)(methodName);
|
|
49
|
-
try {
|
|
50
|
-
return await Sentry.startSpan({
|
|
51
|
-
op: 'sdk.method',
|
|
52
|
-
name: methodName,
|
|
53
|
-
attributes: {
|
|
54
|
-
category,
|
|
55
|
-
chainId: chainId?.toString() || 'unknown',
|
|
56
|
-
},
|
|
57
|
-
}, async (span) => {
|
|
58
|
-
try {
|
|
59
|
-
const result = await method(...args);
|
|
60
|
-
const duration = performance.now() - startTime;
|
|
61
|
-
span?.setAttribute('duration', Math.round(duration));
|
|
62
|
-
span?.setAttribute('success', true);
|
|
63
|
-
trackMethodCall(methodName, {
|
|
64
|
-
method: methodName,
|
|
65
|
-
chainId,
|
|
66
|
-
duration,
|
|
67
|
-
success: true,
|
|
68
|
-
category,
|
|
69
|
-
});
|
|
70
|
-
span?.setStatus({ code: 1 });
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
const duration = performance.now() - startTime;
|
|
75
|
-
const errorType = error instanceof Error ? error.name : 'UnknownError';
|
|
76
|
-
span?.setAttribute('duration', Math.round(duration));
|
|
77
|
-
span?.setAttribute('success', false);
|
|
78
|
-
span?.setAttribute('error', error instanceof Error ? error.message : String(error));
|
|
79
|
-
trackMethodCall(methodName, {
|
|
80
|
-
method: methodName,
|
|
81
|
-
chainId,
|
|
82
|
-
duration,
|
|
83
|
-
success: false,
|
|
84
|
-
category,
|
|
85
|
-
errorType,
|
|
86
|
-
});
|
|
87
|
-
span?.setStatus({ code: 2, message: errorType });
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
if (error instanceof Error && error.message?.includes('Sentry')) {
|
|
94
|
-
return method(...args);
|
|
95
|
-
}
|
|
96
|
-
throw error;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function trackMethodCall(methodName, metrics) {
|
|
101
|
-
try {
|
|
102
|
-
Sentry.addBreadcrumb({
|
|
103
|
-
category: 'sdk.method',
|
|
104
|
-
message: methodName,
|
|
105
|
-
level: metrics.success ? 'info' : 'error',
|
|
106
|
-
data: {
|
|
107
|
-
chainId: metrics.chainId,
|
|
108
|
-
duration: Math.round(metrics.duration),
|
|
109
|
-
category: metrics.category,
|
|
110
|
-
errorType: metrics.errorType,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
Sentry.setMeasurement('sdk.method.duration', metrics.duration, 'millisecond');
|
|
114
|
-
Sentry.setTag('sdk.last_method', methodName);
|
|
115
|
-
Sentry.setTag('sdk.last_category', metrics.category);
|
|
116
|
-
if (metrics.chainId) {
|
|
117
|
-
Sentry.setTag('sdk.last_chainId', metrics.chainId.toString());
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function isAsyncMethod(fn) {
|
|
124
|
-
if (fn.constructor.name === 'AsyncFunction') {
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
const fnString = fn.toString();
|
|
128
|
-
return fnString.includes('__awaiter') || fnString.startsWith('async');
|
|
129
|
-
}
|
|
130
|
-
function instrumentClass(instance, getChainId) {
|
|
131
|
-
try {
|
|
132
|
-
const proto = Object.getPrototypeOf(instance);
|
|
133
|
-
const methodNames = Object.getOwnPropertyNames(proto).filter((name) => {
|
|
134
|
-
if (name === 'constructor' || name.startsWith('_'))
|
|
135
|
-
return false;
|
|
136
|
-
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
137
|
-
return typeof descriptor?.value === 'function';
|
|
138
|
-
});
|
|
139
|
-
for (const methodName of methodNames) {
|
|
140
|
-
const original = instance[methodName];
|
|
141
|
-
if (typeof original === 'function' && isAsyncMethod(original)) {
|
|
142
|
-
instance[methodName] = withMethodTracking(methodName, original.bind(instance), getChainId);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
}
|
|
148
|
-
return instance;
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../src.ts/core/analytics/instrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,gDAoFC;AA8DD,0CA6BC;AA7LD,wDAA0C;AAC1C,2CAAgD;AAChD,qCAA8C;AAY9C,SAAgB,kBAAkB,CAEhC,UAAkB,EAAE,MAAS,EAAE,UAAqC;IACpE,OAAO,KAAK,UAAU,aAAa,CACjC,GAAG,IAAmB;QAGtB,IAAI,CAAC,IAAA,2BAAkB,GAAE,EAAE,CAAC;YAC1B,OAAO,MAAM,CAAC,GAAG,IAAI,CAA2B,CAAC;QACnD,CAAC;QAED,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,UAAU,EAAE,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,IAAA,6BAAiB,EAAC,UAAU,CAAC,CAAC;QAE/C,IAAI,CAAC;YAEH,OAAO,MAAM,MAAM,CAAC,SAAS,CAC3B;gBACE,EAAE,EAAE,YAAY;gBAChB,IAAI,EAAE,UAAU;gBAChB,UAAU,EAAE;oBACV,QAAQ;oBACR,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,SAAS;iBAC1C;aACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;gBACb,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;oBACrC,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;oBAG/C,IAAI,EAAE,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACrD,IAAI,EAAE,YAAY,CA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CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACxE,CAAC;AAUD,SAAgB,eAAe,CAC7B,QAAW,EACX,UAAoC;IAEpC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC9C,MAAM,WAAW,GAAG,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YAEpE,IAAI,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,OAAO,KAAK,CAAC;YAEjE,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAChE,OAAO,OAAO,UAAU,EAAE,KAAK,KAAK,UAAU,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,MAAM,QAAQ,GAAI,QAAoC,CAAC,UAAU,CAAC,CAAC;YACnE,IAAI,OAAO,QAAQ,KAAK,UAAU,IAAI,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC7D,QAAoC,CAAC,UAAU,CAAC,GAAG,kBAAkB,CACpE,UAAU,EACV,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAA6C,EACnE,UAAU,CACX,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ICacheOperation, ICacheType } from './types';
|
|
2
|
-
declare let cacheStats: {
|
|
3
|
-
hits: number;
|
|
4
|
-
misses: number;
|
|
5
|
-
sets: number;
|
|
6
|
-
};
|
|
7
|
-
export declare function trackCacheOperation(operation: ICacheOperation, cacheType: ICacheType): void;
|
|
8
|
-
export declare function trackApiCall(endpoint: string, method: string, startTime: number, status: number, server: string): void;
|
|
9
|
-
export declare function trackNetworkSwitch(chainId: number): void;
|
|
10
|
-
export declare function getCacheStats(): typeof cacheStats;
|
|
11
|
-
export declare function resetCacheStats(): void;
|
|
12
|
-
export {};
|
|
@@ -1,133 +0,0 @@
|
|
|
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.trackCacheOperation = trackCacheOperation;
|
|
37
|
-
exports.trackApiCall = trackApiCall;
|
|
38
|
-
exports.trackNetworkSwitch = trackNetworkSwitch;
|
|
39
|
-
exports.getCacheStats = getCacheStats;
|
|
40
|
-
exports.resetCacheStats = resetCacheStats;
|
|
41
|
-
const Sentry = __importStar(require("@sentry/browser"));
|
|
42
|
-
const sentry_1 = require("./sentry");
|
|
43
|
-
let cacheStats = {
|
|
44
|
-
hits: 0,
|
|
45
|
-
misses: 0,
|
|
46
|
-
sets: 0,
|
|
47
|
-
};
|
|
48
|
-
function trackCacheOperation(operation, cacheType) {
|
|
49
|
-
if (!(0, sentry_1.isAnalyticsEnabled)())
|
|
50
|
-
return;
|
|
51
|
-
try {
|
|
52
|
-
switch (operation) {
|
|
53
|
-
case 'hit':
|
|
54
|
-
cacheStats.hits++;
|
|
55
|
-
break;
|
|
56
|
-
case 'miss':
|
|
57
|
-
cacheStats.misses++;
|
|
58
|
-
break;
|
|
59
|
-
case 'set':
|
|
60
|
-
cacheStats.sets++;
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
const totalLookups = cacheStats.hits + cacheStats.misses;
|
|
64
|
-
const hitRate = totalLookups > 0 ? cacheStats.hits / totalLookups : 0;
|
|
65
|
-
Sentry.addBreadcrumb({
|
|
66
|
-
category: 'cache',
|
|
67
|
-
message: `${cacheType}:${operation}`,
|
|
68
|
-
level: 'debug',
|
|
69
|
-
data: {
|
|
70
|
-
cacheType,
|
|
71
|
-
operation,
|
|
72
|
-
hitRate: hitRate.toFixed(3),
|
|
73
|
-
totalOperations: cacheStats.hits + cacheStats.misses + cacheStats.sets,
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function trackApiCall(endpoint, method, startTime, status, server) {
|
|
81
|
-
if (!(0, sentry_1.isAnalyticsEnabled)())
|
|
82
|
-
return;
|
|
83
|
-
try {
|
|
84
|
-
const duration = performance.now() - startTime;
|
|
85
|
-
const normalizedEndpoint = normalizeEndpoint(endpoint);
|
|
86
|
-
Sentry.addBreadcrumb({
|
|
87
|
-
category: 'api',
|
|
88
|
-
message: `${method} ${normalizedEndpoint}`,
|
|
89
|
-
level: status >= 400 || status === 0 ? 'error' : 'info',
|
|
90
|
-
data: {
|
|
91
|
-
endpoint: normalizedEndpoint,
|
|
92
|
-
method,
|
|
93
|
-
duration: Math.round(duration),
|
|
94
|
-
status,
|
|
95
|
-
server,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
Sentry.setMeasurement('api.duration', duration, 'millisecond');
|
|
99
|
-
Sentry.setTag('api.last_endpoint', normalizedEndpoint);
|
|
100
|
-
Sentry.setTag('api.server', server);
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function trackNetworkSwitch(chainId) {
|
|
106
|
-
if (!(0, sentry_1.isAnalyticsEnabled)())
|
|
107
|
-
return;
|
|
108
|
-
try {
|
|
109
|
-
Sentry.addBreadcrumb({
|
|
110
|
-
category: 'network',
|
|
111
|
-
message: `Switched to chain ${chainId}`,
|
|
112
|
-
level: 'info',
|
|
113
|
-
data: { chainId },
|
|
114
|
-
});
|
|
115
|
-
Sentry.setTag('active.chainId', chainId.toString());
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function normalizeEndpoint(endpoint) {
|
|
121
|
-
return (endpoint
|
|
122
|
-
.replace(/0x[a-fA-F0-9]{40}/g, ':address')
|
|
123
|
-
.replace(/\/\d{5,}/g, '/:chainId')
|
|
124
|
-
.replace(/[a-f0-9-]{36}/gi, ':uuid')
|
|
125
|
-
.replace(/\/\d+(?=\/|$)/g, '/:id'));
|
|
126
|
-
}
|
|
127
|
-
function getCacheStats() {
|
|
128
|
-
return { ...cacheStats };
|
|
129
|
-
}
|
|
130
|
-
function resetCacheStats() {
|
|
131
|
-
cacheStats = { hits: 0, misses: 0, sets: 0 };
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=metrics.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src.ts/core/analytics/metrics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,kDAuCC;AAWD,oCAsCC;AAOD,gDAeC;AA0BD,sCAEC;AAKD,0CAEC;AApKD,wDAA0C;AAC1C,qCAA8C;AAM9C,IAAI,UAAU,GAAG;IACf,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;CACR,CAAC;AAQF,SAAgB,mBAAmB,CACjC,SAA0B,EAC1B,SAAqB;IAErB,IAAI,CAAC,IAAA,2BAAkB,GAAE;QAAE,OAAO;IAElC,IAAI,CAAC;QAEH,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,KAAK;gBACR,UAAU,CAAC,IAAI,EAAE,CAAC;gBAClB,MAAM;YACR,KAAK,MAAM;gBACT,UAAU,CAAC,MAAM,EAAE,CAAC;gBACpB,MAAM;YACR,KAAK,KAAK;gBACR,UAAU,CAAC,IAAI,EAAE,CAAC;gBAClB,MAAM;QACV,CAAC;QAGD,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC;QACzD,MAAM,OAAO,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAGtE,MAAM,CAAC,aAAa,CAAC;YACnB,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,GAAG,SAAS,IAAI,SAAS,EAAE;YACpC,KAAK,EAAE,OAAO;YACd,IAAI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E,OAAO;IAElC,IAAI,CAAC;QACH,MAAM,CAAC,aAAa,CAAC;YACnB,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,qBAAqB,OAAO,EAAE;YACvC,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,EAAE,OAAO,EAAE;SAClB,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;AACH,CAAC;AASD,SAAS,iBAAiB,CAAC,QAAgB;IACzC,OAAO,CACL,QAAQ;SAEL,OAAO,CAAC,oBAAoB,EAAE,UAAU,CAAC;SAEzC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC;SAEjC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SAEnC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CACrC,CAAC;AACJ,CAAC;AAKD,SAAgB,aAAa;IAC3B,OAAO,EAAE,GAAG,UAAU,EAAE,CAAC;AAC3B,CAAC;AAKD,SAAgB,eAAe;IAC7B,UAAU,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as Sentry from '@sentry/browser';
|
|
2
|
-
import { IEnv } from '../../types';
|
|
3
|
-
import { IAnalyticsConfig } from './types';
|
|
4
|
-
export declare function initializeSentry(config: IAnalyticsConfig, environment: IEnv, walletAddress?: string, apiKey?: string): void;
|
|
5
|
-
export declare function updateUser(walletAddress?: string, environment?: IEnv): void;
|
|
6
|
-
export declare function clearUser(): void;
|
|
7
|
-
export declare function isAnalyticsEnabled(): boolean;
|
|
8
|
-
export declare function getSentry(): typeof Sentry | null;
|
|
9
|
-
export declare function resetAnalytics(): void;
|