@tonconnect/sdk 3.4.0-beta.5 → 3.4.0-beta.7
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/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +61 -23
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +61 -23
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +15 -1
- package/package.json +3 -3
package/lib/cjs/index.cjs
CHANGED
|
@@ -3880,7 +3880,7 @@ class TonConnectTracker {
|
|
|
3880
3880
|
}
|
|
3881
3881
|
}
|
|
3882
3882
|
|
|
3883
|
-
const tonConnectSdkVersion = "3.4.0-beta.
|
|
3883
|
+
const tonConnectSdkVersion = "3.4.0-beta.7";
|
|
3884
3884
|
|
|
3885
3885
|
const bounceableTag = 0x11;
|
|
3886
3886
|
const noBounceableTag = 0x51;
|
|
@@ -4455,7 +4455,7 @@ class AnalyticsManager {
|
|
|
4455
4455
|
this.currentBatchTimeoutMs = this.batchTimeoutMs;
|
|
4456
4456
|
this.maxBatchSize = (_b = options.maxBatchSize) !== null && _b !== void 0 ? _b : 100;
|
|
4457
4457
|
this.analyticsUrl = (_c = options.analyticsUrl) !== null && _c !== void 0 ? _c : 'https://analytics.ton.org/events';
|
|
4458
|
-
this.
|
|
4458
|
+
this.mode = (_d = options.mode) !== null && _d !== void 0 ? _d : 'telemetry';
|
|
4459
4459
|
this.baseEvent = Object.assign({ subsystem: 'dapp-sdk', version: tonConnectSdkVersion, client_environment: (_f = (_e = options.environment) === null || _e === void 0 ? void 0 : _e.getClientEnvironment) === null || _f === void 0 ? void 0 : _f.call(_e) }, getStaticConnectionMetrics());
|
|
4460
4460
|
this.addWindowFocusAndBlurSubscriptions();
|
|
4461
4461
|
}
|
|
@@ -4481,16 +4481,17 @@ class AnalyticsManager {
|
|
|
4481
4481
|
}
|
|
4482
4482
|
emit(event) {
|
|
4483
4483
|
var _a;
|
|
4484
|
-
if (
|
|
4484
|
+
if (this.mode === 'off') {
|
|
4485
4485
|
return;
|
|
4486
4486
|
}
|
|
4487
4487
|
const traceId = (_a = event.trace_id) !== null && _a !== void 0 ? _a : UUIDv7();
|
|
4488
4488
|
const dynamicMetrics = getDynamicConnectionMetrics();
|
|
4489
4489
|
const enhancedEvent = Object.assign(Object.assign(Object.assign(Object.assign({}, this.baseEvent), dynamicMetrics), event), { event_id: UUIDv7(), client_timestamp: Math.floor(Date.now() / 1000), trace_id: traceId });
|
|
4490
|
+
const filteredEvent = this.mode === 'telemetry' ? this.filterFullModeFields(enhancedEvent) : enhancedEvent;
|
|
4490
4491
|
if (isQaModeEnabled()) {
|
|
4491
|
-
logDebug(
|
|
4492
|
+
logDebug(filteredEvent);
|
|
4492
4493
|
}
|
|
4493
|
-
this.events.push(
|
|
4494
|
+
this.events.push(filteredEvent);
|
|
4494
4495
|
if (this.events.length >= this.maxBatchSize) {
|
|
4495
4496
|
void this.flush();
|
|
4496
4497
|
return;
|
|
@@ -4632,15 +4633,30 @@ class AnalyticsManager {
|
|
|
4632
4633
|
logError('Cannot subscribe to the document.visibilitychange: ', e);
|
|
4633
4634
|
}
|
|
4634
4635
|
}
|
|
4635
|
-
|
|
4636
|
-
this.
|
|
4637
|
-
}
|
|
4638
|
-
isEnabled() {
|
|
4639
|
-
return this.enabled;
|
|
4636
|
+
getMode() {
|
|
4637
|
+
return this.mode;
|
|
4640
4638
|
}
|
|
4641
4639
|
getPendingEventsCount() {
|
|
4642
4640
|
return this.events.length;
|
|
4643
4641
|
}
|
|
4642
|
+
filterFullModeFields(event) {
|
|
4643
|
+
const filtered = Object.assign({}, event);
|
|
4644
|
+
for (const field of AnalyticsManager.FULL_MODE_FIELDS) {
|
|
4645
|
+
delete filtered[field];
|
|
4646
|
+
}
|
|
4647
|
+
// wallet_address is kept for error events, removed for non-error events
|
|
4648
|
+
const eventName = 'event_name' in event ? String(event.event_name) : '';
|
|
4649
|
+
const isErrorEvent = 'error_code' in event ||
|
|
4650
|
+
'error_message' in event ||
|
|
4651
|
+
eventName.includes('error') ||
|
|
4652
|
+
eventName === 'connection-error' ||
|
|
4653
|
+
eventName === 'transaction-signing-failed' ||
|
|
4654
|
+
eventName === 'sign-data-request-failed';
|
|
4655
|
+
if (!isErrorEvent && 'wallet_address' in filtered) {
|
|
4656
|
+
delete filtered.wallet_address;
|
|
4657
|
+
}
|
|
4658
|
+
return filtered;
|
|
4659
|
+
}
|
|
4644
4660
|
setWalletListDownloadDuration(duration) {
|
|
4645
4661
|
this.baseEvent = Object.assign(Object.assign({}, this.baseEvent), { wallet_list_download_duration: duration });
|
|
4646
4662
|
}
|
|
@@ -4652,6 +4668,12 @@ AnalyticsManager.HTTP_STATUS = {
|
|
|
4652
4668
|
};
|
|
4653
4669
|
AnalyticsManager.MAX_BACKOFF_ATTEMPTS = 5;
|
|
4654
4670
|
AnalyticsManager.BACKOFF_MULTIPLIER = 2;
|
|
4671
|
+
AnalyticsManager.FULL_MODE_FIELDS = [
|
|
4672
|
+
'user_id',
|
|
4673
|
+
'tg_id',
|
|
4674
|
+
'locale',
|
|
4675
|
+
'tma_is_premium'
|
|
4676
|
+
];
|
|
4655
4677
|
|
|
4656
4678
|
/**
|
|
4657
4679
|
* A concrete implementation of EventDispatcher that dispatches events to the browser window.
|
|
@@ -5369,7 +5391,7 @@ class TonConnect {
|
|
|
5369
5391
|
this.statusChangeSubscriptions.forEach(callback => callback(this._wallet));
|
|
5370
5392
|
}
|
|
5371
5393
|
constructor(options) {
|
|
5372
|
-
var _a, _b;
|
|
5394
|
+
var _a, _b, _c;
|
|
5373
5395
|
this._wallet = null;
|
|
5374
5396
|
this.provider = null;
|
|
5375
5397
|
this.statusChangeSubscriptions = [];
|
|
@@ -5381,8 +5403,6 @@ class TonConnect {
|
|
|
5381
5403
|
};
|
|
5382
5404
|
this.walletsRequiredFeatures = options === null || options === void 0 ? void 0 : options.walletsRequiredFeatures;
|
|
5383
5405
|
this.environment = (_a = options === null || options === void 0 ? void 0 : options.environment) !== null && _a !== void 0 ? _a : new DefaultEnvironment();
|
|
5384
|
-
// TODO: in production ready make flag to enable them?
|
|
5385
|
-
this.analytics = new AnalyticsManager({ environment: this.environment });
|
|
5386
5406
|
this.walletsList = new WalletsListManager({
|
|
5387
5407
|
walletsListSource: options === null || options === void 0 ? void 0 : options.walletsListSource,
|
|
5388
5408
|
cacheTTLMs: options === null || options === void 0 ? void 0 : options.walletsListCacheTTLMs,
|
|
@@ -5396,16 +5416,8 @@ class TonConnect {
|
|
|
5396
5416
|
eventDispatcher,
|
|
5397
5417
|
tonConnectSdkVersion: tonConnectSdkVersion
|
|
5398
5418
|
});
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
locale: this.environment.getLocale(),
|
|
5402
|
-
browser: this.environment.getBrowser(),
|
|
5403
|
-
platform: this.environment.getPlatform(),
|
|
5404
|
-
tg_id: telegramUser === null || telegramUser === void 0 ? void 0 : telegramUser.id,
|
|
5405
|
-
tma_is_premium: telegramUser === null || telegramUser === void 0 ? void 0 : telegramUser.isPremium,
|
|
5406
|
-
manifest_json_url: manifestUrl,
|
|
5407
|
-
origin_url: getOriginWithPath
|
|
5408
|
-
}));
|
|
5419
|
+
this.environment = (_c = options === null || options === void 0 ? void 0 : options.environment) !== null && _c !== void 0 ? _c : new DefaultEnvironment();
|
|
5420
|
+
this.initAnalytics(manifestUrl, eventDispatcher, options);
|
|
5409
5421
|
if (!this.dappSettings.manifestUrl) {
|
|
5410
5422
|
throw new DappMetadataError('Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest');
|
|
5411
5423
|
}
|
|
@@ -5837,6 +5849,32 @@ class TonConnect {
|
|
|
5837
5849
|
logError('Cannot subscribe to the document.visibilitychange: ', e);
|
|
5838
5850
|
}
|
|
5839
5851
|
}
|
|
5852
|
+
initAnalytics(manifestUrl, eventDispatcher, options) {
|
|
5853
|
+
var _a;
|
|
5854
|
+
const analyticsSettings = options === null || options === void 0 ? void 0 : options.analytics;
|
|
5855
|
+
const mode = (_a = analyticsSettings === null || analyticsSettings === void 0 ? void 0 : analyticsSettings.mode) !== null && _a !== void 0 ? _a : 'telemetry';
|
|
5856
|
+
if (mode === 'off') {
|
|
5857
|
+
return;
|
|
5858
|
+
}
|
|
5859
|
+
const analytics = new AnalyticsManager({
|
|
5860
|
+
environment: this.environment,
|
|
5861
|
+
mode
|
|
5862
|
+
});
|
|
5863
|
+
this.analytics = analytics;
|
|
5864
|
+
const telegramUser = this.environment.getTelegramUser();
|
|
5865
|
+
const sharedAnalyticsData = {
|
|
5866
|
+
browser: this.environment.getBrowser(),
|
|
5867
|
+
platform: this.environment.getPlatform(),
|
|
5868
|
+
manifest_json_url: manifestUrl,
|
|
5869
|
+
origin_url: getOriginWithPath,
|
|
5870
|
+
locale: this.environment.getLocale()
|
|
5871
|
+
};
|
|
5872
|
+
if (telegramUser) {
|
|
5873
|
+
sharedAnalyticsData.tg_id = telegramUser.id;
|
|
5874
|
+
sharedAnalyticsData.tma_is_premium = telegramUser.isPremium;
|
|
5875
|
+
}
|
|
5876
|
+
bindEventsTo(eventDispatcher, analytics.scoped(sharedAnalyticsData));
|
|
5877
|
+
}
|
|
5840
5878
|
createProvider(wallet) {
|
|
5841
5879
|
let provider;
|
|
5842
5880
|
if (!Array.isArray(wallet) && isWalletConnectionSourceJS(wallet)) {
|