react-code-dataset / wp-calypso /client /lib /analytics /utils /should-report-omit-blog-id.js
Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
861 Bytes
import { getSiteFragment } from 'calypso/lib/route';
const SITE_FRAGMENT_REGEX = /\/(:site|:site_id|:siteid|:blogid|:blog_id|:siteslug)(\/|$|\?)/i;
/**
* Check if a path should report the currently selected site ID.
*
* Some paths should never report it because it's used
* to tell general admin and site-specific activities apart.
* @param {string} path The tracked path.
* @returns {boolean} If the report should null `blog_id`.
*/
export default ( path ) => {
// Path could be a number but it should not. See Sentry issue with ID 4645035069
if ( typeof path !== 'string' ) {
return true;
}
if ( SITE_FRAGMENT_REGEX.test( path ) ) {
return false;
}
// Stepper routes start with /setup/, and might contain site slug or ID via URL parameters.
if ( path.startsWith( '/setup/' ) ) {
return false;
}
return ! getSiteFragment( path );
};