Skip to content

Commit

Permalink
fix: code review addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Oct 24, 2024
1 parent da92522 commit c23e83a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ describe('Init tests', () => {
secure_cookie: false,
persistence: 'localStorage',
persistence_name: 'test',
record_block_class: 'block-class',
record_collect_fonts: true,
loaded: expect.any(Function),
});
});
Expand Down Expand Up @@ -286,7 +284,6 @@ describe('Init tests', () => {
loaded: expect.any(Function),
});
});

});

describe('isLoaded and isReady tests', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,32 @@ class Mixpanel {
}

const mixpanelIntgConfig = getDestinationOptions(this.analytics.loadOnlyIntegrations);
// ref : https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#session-replay
if (mixpanelIntgConfig) {
const sessionReplayConfig = {
record_block_class: mixpanelIntgConfig.recordBlockClass,
record_collect_fonts: mixpanelIntgConfig.recordCollectFonts,
record_idle_timeout_ms: mixpanelIntgConfig.recordIdleTimeout,
record_mask_text_class: mixpanelIntgConfig.recordMaskTextClass,
record_mask_text_selector: mixpanelIntgConfig.recordMaskTextSelector,
record_max_ms: mixpanelIntgConfig.recordMaxMs,
record_min_ms: mixpanelIntgConfig.recordMinMs,
};
options = { ...options, ...removeUndefinedAndNullValues(sessionReplayConfig) };
}

// ref : https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#session-replay
if (isDefinedAndNotNull(this.sessionReplayPercentage)) {
const percentageInt = parseInt(this.sessionReplayPercentage, 10);
if (percentageInt >= 0 && percentageInt <= 100) {
options.record_sessions_percent = percentageInt;

if (mixpanelIntgConfig) {
const sessionReplayConfig = removeUndefinedAndNullValues({
record_block_class: mixpanelIntgConfig.recordBlockClass,
record_collect_fonts: mixpanelIntgConfig.recordCollectFonts,
record_idle_timeout_ms: mixpanelIntgConfig.recordIdleTimeout,
record_mask_text_class: mixpanelIntgConfig.recordMaskTextClass,
record_mask_text_selector: mixpanelIntgConfig.recordMaskTextSelector,
record_max_ms: mixpanelIntgConfig.recordMaxMs,
record_min_ms: mixpanelIntgConfig.recordMinMs,
});
options = { ...options, ...sessionReplayConfig };
}
} else {
logger.warn(
`Invalid sessionReplayPercentage: ${this.sessionReplayPercentage}. It should be a string matching the pattern "^(100|[1-9]?[0-9])$"`,
);
}
}

options.loaded = () => {
this.isNativeSDKLoaded = true;
};
Expand Down

0 comments on commit c23e83a

Please sign in to comment.