WordPress.org

Plugin Directory

Changeset 704704


Ignore:
Timestamp:
04/27/13 15:32:05 (12 months ago)
Author:
eskapism
Message:

version 0.2

Location:
wp-javascript-error-logger
Files:
2 added
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • wp-javascript-error-logger/tags/0.2/index.php

    r704694 r704704  
    2020 
    2121        add_action("init", array( $this, "setup") ); 
     22        add_action("admin_init", array( $this, "setup_post_columns") ); 
     23 
     24 
     25    } 
     26 
     27    function setup_post_columns() { 
     28         
     29        add_filter( "manage_edit-" . self::slug . "_columns", array($this, 'edit_post_overview_columns')); 
     30        add_filter( "manage_" . self::slug . "_posts_custom_column", array($this, 'edit_post_overview_column'), 10, 2); 
     31 
     32    } 
     33 
     34    function edit_post_overview_columns( $columns ) { 
     35        $columns["url"] = "URL"; 
     36        $columns["message"] = "Message"; 
     37        $columns["line"] = "Line"; 
     38        return $columns; 
     39    } 
     40 
     41    function edit_post_overview_column( $column, $post_id ) { 
     42         
     43        switch ( $column ) { 
     44             
     45            case "url"; 
     46                $out = get_post_meta($post_id, "url", true); 
     47                break; 
     48             
     49            case "message"; 
     50                $out = get_post_meta($post_id, "message", true); 
     51                break; 
     52 
     53            case "line"; 
     54                $out = get_post_meta($post_id, "line", true); 
     55                break; 
     56 
     57        } 
     58 
     59        esc_html_e( $out ); 
    2260 
    2361    } 
     
    5290<script> 
    5391window.onerror = function(m, u, l) { 
    54     // console.log('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber); 
     92    // console.log('Error message: '+m+'\nURL: '+u+'\nLine Number: '+l); 
    5593    if (encodeURIComponent) { 
    5694        var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', 
    57             img = new Image(); 
     95            img = new Image(1,1); 
    5896        img.src = ajaxurl + "?action=log_js_error&m=" + encodeURIComponent(m) + "&u=" + encodeURIComponent(u) + "&l=" + encodeURIComponent(l); 
    5997    } 
    6098    return true; 
    6199} 
    62 // trigger test error 
    63 runFunctionThatDoesNotExist(); 
    64100</script> 
    65101<?php 
     102    // examples of JS code to test the logging: 
     103    // alert( non_defined_variable ); 
     104    // function_that_does_not_exist(); 
     105 
    66106    } // add js 
    67107 
     
    86126        $post_arr = array( 
    87127            "post_type" => self::slug, 
    88             "post_title" => $m 
     128            "post_title" => $m, 
     129            "post_status" => "publish" 
    89130        ); 
    90131        $new_post_id = wp_insert_post( $post_arr ); 
    91132         
     133        // Save things we get from onerror 
    92134        update_post_meta( $new_post_id, "message", $m ); 
    93135        update_post_meta( $new_post_id, "url", $u ); 
    94136        update_post_meta( $new_post_id, "line", $l ); 
     137 
     138        // Store some extra things 
     139        update_post_meta( $new_post_id, "HTTP_USER_AGENT", $_SERVER["HTTP_USER_AGENT"] ); 
     140        // update_post_meta( $new_post_id, "HTTP_REFERER", $_SERVER["HTTP_REFERER"] ); 
    95141 
    96142        exit; 
  • wp-javascript-error-logger/tags/0.2/readme.txt

    r704694 r704704  
    55Requires at least: 3.5.1 
    66Tested up to: 3.5.1 
    7 Stable tag: 0.1 
     7Stable tag: 0.2 
    88 
    9 A plugin that will log JavaScript-errors that occur your public website. Errors are logged to a non-public custom post type inside WordPress. 
     9A plugin that will log JavaScript-errors that occurs on the front-end of your website. Errors are logged to a non-public custom post type inside WordPress. 
    1010 
    1111== Description == 
    1212 
    13 A plugin that will log JavaScript-errors that occur your public website. Errors are logged to a non-public custom post type inside WordPress. 
     13WP JS Error Logger is a small plugin that I very quickly put together after wathcing [Diogo Antunes'](https://twitter.com/dicode) presentation ["Know your errors"](https://speakerdeck.com/dicode/know-your-errors) at [Front Trends 2013](http://2013.front-trends.com/) in Warsaw, Poland. 
     14 
     15It's a plugin that will log the JavaScript-errors that occur on the front-end of your public website. Errors are logged to a non-public custom post type inside WordPress. 
     16 
     17The errors that are logged are the errors that call window.onerror. Please note that not all errors end up there. But... some do, and now you can catch them! ;) 
    1418 
    1519== Screenshots == 
    1620 
    17 1. Coming soon 
     211. The overview screen inside WordPress. Each error is it's own post. 
     22 
     232. Details about an error: URL, line, type. 
    1824 
    1925== Changelog == 
    2026 
     27= 0.2 = 
     28- Second version. Slightly different than first version! 
     29 
    2130= 0.1 = 
    2231- First version 
  • wp-javascript-error-logger/trunk/index.php

    r704694 r704704  
    2020 
    2121        add_action("init", array( $this, "setup") ); 
     22        add_action("admin_init", array( $this, "setup_post_columns") ); 
     23 
     24 
     25    } 
     26 
     27    function setup_post_columns() { 
     28         
     29        add_filter( "manage_edit-" . self::slug . "_columns", array($this, 'edit_post_overview_columns')); 
     30        add_filter( "manage_" . self::slug . "_posts_custom_column", array($this, 'edit_post_overview_column'), 10, 2); 
     31 
     32    } 
     33 
     34    function edit_post_overview_columns( $columns ) { 
     35        $columns["url"] = "URL"; 
     36        $columns["message"] = "Message"; 
     37        $columns["line"] = "Line"; 
     38        return $columns; 
     39    } 
     40 
     41    function edit_post_overview_column( $column, $post_id ) { 
     42         
     43        switch ( $column ) { 
     44             
     45            case "url"; 
     46                $out = get_post_meta($post_id, "url", true); 
     47                break; 
     48             
     49            case "message"; 
     50                $out = get_post_meta($post_id, "message", true); 
     51                break; 
     52 
     53            case "line"; 
     54                $out = get_post_meta($post_id, "line", true); 
     55                break; 
     56 
     57        } 
     58 
     59        esc_html_e( $out ); 
    2260 
    2361    } 
     
    5290<script> 
    5391window.onerror = function(m, u, l) { 
    54     // console.log('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber); 
     92    // console.log('Error message: '+m+'\nURL: '+u+'\nLine Number: '+l); 
    5593    if (encodeURIComponent) { 
    5694        var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', 
    57             img = new Image(); 
     95            img = new Image(1,1); 
    5896        img.src = ajaxurl + "?action=log_js_error&m=" + encodeURIComponent(m) + "&u=" + encodeURIComponent(u) + "&l=" + encodeURIComponent(l); 
    5997    } 
    6098    return true; 
    6199} 
    62 // trigger test error 
    63 runFunctionThatDoesNotExist(); 
    64100</script> 
    65101<?php 
     102    // examples of JS code to test the logging: 
     103    // alert( non_defined_variable ); 
     104    // function_that_does_not_exist(); 
     105 
    66106    } // add js 
    67107 
     
    86126        $post_arr = array( 
    87127            "post_type" => self::slug, 
    88             "post_title" => $m 
     128            "post_title" => $m, 
     129            "post_status" => "publish" 
    89130        ); 
    90131        $new_post_id = wp_insert_post( $post_arr ); 
    91132         
     133        // Save things we get from onerror 
    92134        update_post_meta( $new_post_id, "message", $m ); 
    93135        update_post_meta( $new_post_id, "url", $u ); 
    94136        update_post_meta( $new_post_id, "line", $l ); 
     137 
     138        // Store some extra things 
     139        update_post_meta( $new_post_id, "HTTP_USER_AGENT", $_SERVER["HTTP_USER_AGENT"] ); 
     140        // update_post_meta( $new_post_id, "HTTP_REFERER", $_SERVER["HTTP_REFERER"] ); 
    95141 
    96142        exit; 
  • wp-javascript-error-logger/trunk/readme.txt

    r704694 r704704  
    55Requires at least: 3.5.1 
    66Tested up to: 3.5.1 
    7 Stable tag: 0.1 
     7Stable tag: 0.2 
    88 
    9 A plugin that will log JavaScript-errors that occur your public website. Errors are logged to a non-public custom post type inside WordPress. 
     9A plugin that will log JavaScript-errors that occurs on the front-end of your website. Errors are logged to a non-public custom post type inside WordPress. 
    1010 
    1111== Description == 
    1212 
    13 A plugin that will log JavaScript-errors that occur your public website. Errors are logged to a non-public custom post type inside WordPress. 
     13WP JS Error Logger is a small plugin that I very quickly put together after wathcing [Diogo Antunes'](https://twitter.com/dicode) presentation ["Know your errors"](https://speakerdeck.com/dicode/know-your-errors) at [Front Trends 2013](http://2013.front-trends.com/) in Warsaw, Poland. 
     14 
     15It's a plugin that will log the JavaScript-errors that occur on the front-end of your public website. Errors are logged to a non-public custom post type inside WordPress. 
     16 
     17The errors that are logged are the errors that call window.onerror. Please note that not all errors end up there. But... some do, and now you can catch them! ;) 
    1418 
    1519== Screenshots == 
    1620 
    17 1. Coming soon 
     211. The overview screen inside WordPress. Each error is it's own post. 
     22 
     232. Details about an error: URL, line, type. 
    1824 
    1925== Changelog == 
    2026 
     27= 0.2 = 
     28- Second version. Slightly different than first version! 
     29 
    2130= 0.1 = 
    2231- First version 
Note: See TracChangeset for help on using the changeset viewer.