Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] enable compress api in 1ds-post-channel #2451

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

siyuniu-ms
Copy link
Contributor

No description provided.

@siyuniu-ms siyuniu-ms requested a review from a team as a code owner January 15, 2025 01:24
@siyuniu-ms siyuniu-ms requested a review from a team as a code owner January 15, 2025 01:33
@siyuniu-ms siyuniu-ms changed the title [main] enable compress api in sender [main] enable compress api in 1ds-post-channel Jan 15, 2025
@siyuniu-ms siyuniu-ms requested a review from MSNev January 17, 2025 20:38
_doOnComplete(onComplete, 0, {});
const CompressionStream = (window as any).CompressionStream;
// If CompressionStream is available, use it
if (!_disableZip && !isSync && CompressionStream && typeof CompressionStream !== "undefined") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this if test to another function (to avoid duplicating 1000-1009 and 987 - 997

So something like

function _preparePayload(cb: (payload: ...) => void, payload, <any other args we need)) {
    if (_disableZip || isSync || has preprocessor || !hasCompression) {
        cb(payload);
    }
... // Your compression code
    cb(payload); // <- gets called from within the Compression handling on success and failure
}

And then you just call it like this and it will either be the compressed code (called after it's compressed) or called immediately with the same payload

_preparePayload((payload) => {
    try {
         sendInterface.sendPOST(payload, onComplete, isSync);
         if (_sendListener) {
             // Send the original payload to the listener
             _sendListener(orgPayloadData, payload, isSync, thePayload.isBeacon);
        }
    } catch (ex) {
        _warnToConsole(_logger, "Unexpected exception sending payload. Ex:" + dumpObj(ex));
    }
|});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants