Skip to content

Commit 67b8e51

Browse files
committed
refactor(payment_link): replace console log with postLog for pushing SDK logs
1 parent 325e784 commit 67b8e51

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

crates/router/src/core/payment_link/payment_link_initiate/payment_link.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,10 @@
325325
</svg>
326326
</div>
327327
<script>
328+
{{logging_template}}
328329
{{locale_template}}
329330
{{rendered_js}}
330331
{{payment_link_initiator}}
331-
{{logging_template}}
332332
</script>
333333
{{ hyperloader_sdk_link }}
334334
</body>

crates/router/src/core/payment_link/payment_link_initiate/secure_payment_link_initiator.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if (!isFramed) {
5757
});
5858
var type =
5959
paymentDetails.sdk_layout === "spaced_accordion" ||
60-
paymentDetails.sdk_layout === "accordion"
60+
paymentDetails.sdk_layout === "accordion"
6161
? "accordion"
6262
: paymentDetails.sdk_layout;
6363

@@ -111,13 +111,26 @@ if (!isFramed) {
111111
paymentDetails.locale;
112112
try {
113113
window.top.location.href = returnUrl;
114+
115+
// Push logs to logs endpoint
114116
} catch (error) {
115-
console.error(
116-
"CRITICAL ERROR",
117-
"Failed to redirect top document. Error - ",
118-
error
119-
);
120-
console.info("Redirecting in current document");
117+
var url = window.location.href;
118+
var { paymentId, merchantId, attemptId, connector } = parseRoute(url);
119+
var urlToPost = getEnvRoute(url);
120+
var message = {
121+
message: "CRITICAL ERROR - Failed to redirect top document. Falling back to redirecting using window.location",
122+
reason: error.message,
123+
}
124+
var log = {
125+
message,
126+
url,
127+
paymentId,
128+
merchantId,
129+
attemptId,
130+
connector,
131+
};
132+
postLog(log, urlToPost);
133+
121134
window.location.href = returnUrl;
122135
}
123136
}

crates/router/src/core/payment_link/payment_link_status/status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800"
1212
/>
1313
<script>
14+
{{logging_template}}
1415
{{locale_template}}
1516
{{ rendered_js }}
16-
{{logging_template}}
1717
</script>
1818
</head>
1919
<body onload="boot()">

0 commit comments

Comments
 (0)