public static void sendPulseTimingEvent ( RaygunPulseEventType eventType , String name , long milliseconds ) { if ( RaygunClient . sessionId == null ) { sendPulseEvent ( RaygunSettings . RUM_EVENT_SESSION_START ) ; } if ( eventType == RaygunPulseEventType . ACTIVITY_LOADED ) { if ( RaygunClient . shouldIgnoreView ( name ) ) { return ; } } RaygunPulseMessage message = new RaygunPulseMessage ( ) ; RaygunPulseDataMessage dataMessage = new RaygunPulseDataMessage ( ) ; SimpleDateFormat df = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss" ) ; df . setTimeZone ( TimeZone . getTimeZone ( "UTC" ) ) ; Calendar c = Calendar . getInstance ( ) ; c . add ( Calendar . MILLISECOND , - ( int ) milliseconds ) ; String timestamp = df . format ( c . getTime ( ) ) ; dataMessage . setTimestamp ( timestamp ) ; dataMessage . setSessionId ( RaygunClient . sessionId ) ; dataMessage . setVersion ( RaygunClient . version ) ; dataMessage . setOS ( "Android" ) ; dataMessage . setOSVersion ( Build . VERSION . RELEASE ) ; dataMessage . setPlatform ( String . format ( "%s %s" , Build . MANUFACTURER , Build . MODEL ) ) ; dataMessage . setType ( "mobile_event_timing" ) ; RaygunUserContext userContext ; if ( RaygunClient . userInfo == null ) { userContext = new RaygunUserContext ( new RaygunUserInfo ( null , null , null , null , null , true ) , RaygunClient . context ) ; } else { userContext = new RaygunUserContext ( RaygunClient . userInfo , RaygunClient . context ) ; } dataMessage . setUser ( userContext ) ; RaygunPulseData data = new RaygunPulseData ( ) ; RaygunPulseTimingMessage timingMessage = new RaygunPulseTimingMessage ( ) ; timingMessage . setType ( eventType == RaygunPulseEventType . ACTIVITY_LOADED ? "p" : "n" ) ; timingMessage . setDuration ( milliseconds ) ; data . setName ( name ) ; data . setTiming ( timingMessage ) ; RaygunPulseData [ ] dataArray = new RaygunPulseData [ ] { data } ; String dataStr = new Gson ( ) . toJson ( dataArray ) ; dataMessage . setData ( dataStr ) ; message . setEventData ( new RaygunPulseDataMessage [ ] { dataMessage } ) ; enqueueWorkForRUMService ( RaygunClient . apiKey , new Gson ( ) . toJson ( message ) ) ; }
Sends a pulse timing event to Raygun . The message is sent on a background thread .