| | import { recordTracksEvent } from '@automattic/calypso-analytics'; |
| | import config from '@automattic/calypso-config'; |
| | import page from '@automattic/calypso-router'; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | export function redirectTo( url ) { |
| | if ( window && window.history && window.history.pushState ) { |
| | |
| | |
| | |
| | |
| | |
| | |
| | window.history.pushState( null, null, url ); |
| | } |
| |
|
| | return page.redirect( url ); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export function getImportSectionLocation( siteSlug, isJetpack = false ) { |
| | return isJetpack && ! config.isEnabled( 'importer/unified' ) |
| | ? `https://${ siteSlug }/wp-admin/import.php` |
| | : `/import/${ siteSlug }/?engine=wordpress`; |
| | } |
| |
|
| | export const WEEK_IN_MILLISECONDS = 7 * 1000 * 3600 * 24; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | export const isUserNewerThan = ( age ) => ( user ) => { |
| | const registrationDate = user && Date.parse( user.date ); |
| | if ( ! registrationDate ) { |
| | return false; |
| | } |
| | const userAge = Date.now() - registrationDate; |
| | return userAge <= age; |
| | }; |
| |
|
| | export const isNewUser = isUserNewerThan( WEEK_IN_MILLISECONDS ); |
| |
|
| | function formatMigrationEventProps( user, from = '' ) { |
| | const migrationFlow = from ? from : 'onboarding-flow'; |
| | return { |
| | is_new_user: isNewUser( user ), |
| | migration_flow: migrationFlow, |
| | }; |
| | } |
| |
|
| | export function triggerMigrationStartingEvent( user, from = '' ) { |
| | return recordTracksEvent( |
| | 'calypso_migration_starting_point', |
| | formatMigrationEventProps( user, from ) |
| | ); |
| | } |
| |
|