Skip to content

Commit d8e9bf3

Browse files
steveseguinactions-user
authored andcommitted
fix(viewer): Prevent overwriting tab ID and refine event logging
- **background.js**: Modify the `processIncomingMessage` function to conditionally assign `message.tid`. The originating tab ID will now only be set if `message.tid` is currently `undefined` or `null`. This prevents an existing tab ID from being inadvertently overwritten, ensuring more accurate tracking and attribution of messages to their source tabs. This is crucial for reliable viewer count metrics and event processing. - **events.html**: Adjust logging within the event overlay to specifically output `e.data.dataReceived.overlayNinja`. This change streamlines debugging efforts by focusing the log output on relevant event data impacting the overlay display, aiding in the validation of viewer-related information. [auto-enhanced]
1 parent 9ca0aec commit d8e9bf3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

background.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3579,11 +3579,11 @@ const checkDuplicateSources = new CheckDuplicateSources();
35793579

35803580
async function processIncomingMessage(message, sender=null){
35813581

3582-
try {
3583-
if (sender?.tab){
3584-
message.tid = sender.tab.id; // including the source (tab id) of the social media site the data was pulled from
3585-
}
3586-
} catch (e) {}
3582+
try {
3583+
if (sender?.tab && (message.tid === undefined || message.tid === null)){
3584+
message.tid = sender.tab.id; // including the source (tab id) of the social media site the data was pulled from
3585+
}
3586+
} catch (e) {}
35873587

35883588
if (isExtensionOn && message?.type) {
35893589
if (!checkIfAllowed(message.type)) {

events.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,6 @@ <h1>Stream Events & Donations Dashboard</h1>
15031503

15041504
window.addEventListener("message", function (e) {
15051505
if (e.source != iframe.contentWindow) return;
1506-
log(e.data);
15071506
// Logic to populate iframe.connectedPeers, similar to dock.html
15081507
if ("action" in e.data && e.data.UUID && "value" in e.data) {
15091508
const peerUUID = e.data.UUID;
@@ -1530,6 +1529,7 @@ <h1>Stream Events & Donations Dashboard</h1>
15301529
}
15311530

15321531
if (e.data.dataReceived && e.data.dataReceived.overlayNinja) {
1532+
log(e.data.dataReceived.overlayNinja);
15331533
addMessageToOverlay(e.data.dataReceived.overlayNinja);
15341534
}
15351535
});

0 commit comments

Comments
 (0)