array(), 'events' => array(), ); } if ( $data->key == 'snapshot' ) { $existing_data[ $data->key ] = $data; } else { $existing_data['events'][] = $data; } update_option( 'gf_telemetry_data', $existing_data, false ); } /** * Take a snapshot of the current site data. * * @since 2.8 * * @return void */ public static function take_snapshot() { $snapshot = new GF_Telemetry_Snapshot_Data(); self::save_data( $snapshot ); } /** * Send data to the telemetry endpoint. * * @since 2.8 * * @param array $entries The data to send. * * @return array|WP_Error */ public static function send_data( $entries ) { // allow overriding the endpoint to use the local or staging environment for testing purposes. $endpoint = defined( 'GF_TELEMETRY_ENDPOINT' ) ? GF_TELEMETRY_ENDPOINT : self::TELEMETRY_ENDPOINT; $site_url = get_site_url(); $data = array( 'license_key_md5' => md5( get_option( 'rg_gforms_key', '' ) ), 'site_url' => $site_url, 'product' => 'gravityforms', 'tag' => 'system_report', 'data' => $entries, ); return wp_remote_post( $endpoint . 'api/telemetry_data_bulk', array( 'headers' => array( 'Content-Type' => 'application/json', 'Authorization' => sha1( $site_url ), ), 'method' => 'POST', 'data_format' => 'body', 'body' => json_encode( $data ), ) ); } }