Skip to content

Commit 10be04e

Browse files
authored
refactor(sdk): always send RPC requests via network and deeplink (#1181)
* feat: set rpc id even without network * refactor: streamline RPC method tracking in write function - Moved RPC method tracking logic to ensure it is executed before sending analytics. - Enhanced logging for the RPC method tracker to include detailed information about the tracked methods and data. - Removed redundant console warnings to clean up the code and improve readability. * refactor(write): simplify message sending logic • Remove conditional analytics sending • Always send RPC requests via network • Add debug logging for triggeredInstaller state • Remove redundant RPC method tracking * feat: cleanup
1 parent f9a9921 commit 10be04e

File tree

1 file changed

+5
-24
lines changed
  • packages/sdk/src/services/RemoteCommunicationPostMessageStream

1 file changed

+5
-24
lines changed

packages/sdk/src/services/RemoteCommunicationPostMessageStream/write.ts

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import {
2-
TrackingEvents,
3-
SendAnalytics,
4-
DEFAULT_SERVER_URL,
5-
} from '@metamask/sdk-communication-layer';
61
import { RemoteCommunicationPostMessageStream } from '../../PostMessageStream/RemoteCommunicationPostMessageStream';
72
import { METHODS_TO_REDIRECT, RPC_METHODS } from '../../config';
83
import {
@@ -62,7 +57,11 @@ export async function write(
6257
deeplinkProtocolAvailable && mobileWeb && authorized;
6358

6459
try {
65-
if (!activeDeeplinkProtocol || triggeredInstaller) {
60+
console.warn(
61+
`[RCPMS: _write()] triggeredInstaller=${triggeredInstaller} activeDeeplinkProtocol=${activeDeeplinkProtocol}`,
62+
);
63+
64+
if (!triggeredInstaller) {
6665
// The only reason not to send via network is because the rpc call will be sent in the deeplink
6766
instance.state.remote
6867
?.sendMessage(data?.data)
@@ -72,24 +71,6 @@ export async function write(
7271
.catch((err: unknown) => {
7372
logger(`[RCPMS: _write()] error sending message`, err);
7473
});
75-
} else {
76-
try {
77-
// Only send analytics if we are not sending via network.
78-
await SendAnalytics(
79-
{
80-
id: channelId,
81-
event: TrackingEvents.SDK_RPC_REQUEST,
82-
params: {
83-
method: targetMethod,
84-
from: 'mobile',
85-
},
86-
},
87-
instance.state.remote?.state.communicationServerUrl ??
88-
DEFAULT_SERVER_URL,
89-
);
90-
} catch (error) {
91-
logger(`[RCPMS: _write()] error sending analytics`, error);
92-
}
9374
}
9475

9576
if (!isSecure) {

0 commit comments

Comments
 (0)