@tonconnect/sdk 3.4.0-beta.5 → 3.4.0-beta.6
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 -21
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +61 -21
- 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.6";
|
|
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 = [];
|
|
@@ -5396,16 +5418,8 @@ class TonConnect {
|
|
|
5396
5418
|
eventDispatcher,
|
|
5397
5419
|
tonConnectSdkVersion: tonConnectSdkVersion
|
|
5398
5420
|
});
|
|
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
|
-
}));
|
|
5421
|
+
this.environment = (_c = options === null || options === void 0 ? void 0 : options.environment) !== null && _c !== void 0 ? _c : new DefaultEnvironment();
|
|
5422
|
+
this.initAnalytics(manifestUrl, eventDispatcher, options);
|
|
5409
5423
|
if (!this.dappSettings.manifestUrl) {
|
|
5410
5424
|
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
5425
|
}
|
|
@@ -5837,6 +5851,32 @@ class TonConnect {
|
|
|
5837
5851
|
logError('Cannot subscribe to the document.visibilitychange: ', e);
|
|
5838
5852
|
}
|
|
5839
5853
|
}
|
|
5854
|
+
initAnalytics(manifestUrl, eventDispatcher, options) {
|
|
5855
|
+
var _a;
|
|
5856
|
+
const analyticsSettings = options === null || options === void 0 ? void 0 : options.analytics;
|
|
5857
|
+
const mode = (_a = analyticsSettings === null || analyticsSettings === void 0 ? void 0 : analyticsSettings.mode) !== null && _a !== void 0 ? _a : 'telemetry';
|
|
5858
|
+
if (mode === 'off') {
|
|
5859
|
+
return;
|
|
5860
|
+
}
|
|
5861
|
+
const analytics = new AnalyticsManager({
|
|
5862
|
+
environment: this.environment,
|
|
5863
|
+
mode
|
|
5864
|
+
});
|
|
5865
|
+
this.analytics = analytics;
|
|
5866
|
+
const telegramUser = this.environment.getTelegramUser();
|
|
5867
|
+
const sharedAnalyticsData = {
|
|
5868
|
+
browser: this.environment.getBrowser(),
|
|
5869
|
+
platform: this.environment.getPlatform(),
|
|
5870
|
+
manifest_json_url: manifestUrl,
|
|
5871
|
+
origin_url: getOriginWithPath,
|
|
5872
|
+
locale: this.environment.getLocale()
|
|
5873
|
+
};
|
|
5874
|
+
if (telegramUser) {
|
|
5875
|
+
sharedAnalyticsData.tg_id = telegramUser.id;
|
|
5876
|
+
sharedAnalyticsData.tma_is_premium = telegramUser.isPremium;
|
|
5877
|
+
}
|
|
5878
|
+
bindEventsTo(eventDispatcher, analytics.scoped(sharedAnalyticsData));
|
|
5879
|
+
}
|
|
5840
5880
|
createProvider(wallet) {
|
|
5841
5881
|
let provider;
|
|
5842
5882
|
if (!Array.isArray(wallet) && isWalletConnectionSourceJS(wallet)) {
|