Plugin Directory

Changeset 2133590


Ignore:
Timestamp:
08/04/2019 11:26:15 AM (7 years ago)
Author:
clickervolt
Message:

1.126

  • Added new "suspicious" related segments in reporting tab
Location:
clickervolt/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • clickervolt/trunk/admin/js/stats.js

    r2129157 r2133590  
    933933        var suspiciousScoreSum = row['suspiciousScoreSum'];
    934934        var suspiciousTrafficRate = clicks > 0
    935             ? parseInt(suspiciousScoreSum / clicks)
     935            ? Math.min(100, parseInt(suspiciousScoreSum / clicks))
    936936            : null;
    937937
  • clickervolt/trunk/admin/reporting/handlers/handlerBase.php

    r2080903 r2133590  
    55require_once __DIR__ . '/handler.php';
    66
    7 class HandlerBase extends Handler {
    8 
     7class HandlerBase extends Handler
     8{
    99    /**
    1010     *
    1111     * @return [] (first element is for 'select from', others are for joins - the ones for joins must include the join clause)
    1212     */
    13     protected function getTableNames( $request ) {
    14 
     13    protected function getTableNames($request)
     14    {
    1515        $table = new \ClickerVolt\TableStatsBase();
    16         return [ $table->getName() ];
     16        return [$table->getName()];
    1717    }
    1818
     
    2121     * @return []
    2222     */
    23     protected function getMapper( $request ) {
    24 
     23    protected function getMapper($request)
     24    {
    2525        $timestampCol = $this->getTimestampColumn();
    2626
     
    4141                self::MAP_SELECT => "concat(date_format(from_unixtime({$timestampCol}), '%H'), ':00-', date_format(from_unixtime(3600 + {$timestampCol}), '%H'), ':00')"
    4242            ],
     43
     44            Segment::TYPE_SUSPICIOUS_VS_CLEAN => [
     45                self::MAP_SELECT => "if( suspiciousScoreSum = 0, 'All Clean', 'Suspicious' )"
     46            ],
     47
     48            Segment::TYPE_SUSPICIOUS_BUCKETS => [
     49                self::MAP_SELECT => "case
     50                    when suspiciousScoreSum = 0 then 'All Clean'
     51                    when (suspiciousScoreSum / clicks) <= 25 then '1 to 25%'
     52                    when (suspiciousScoreSum / clicks) <= 50 then '26 to 50%'
     53                    when (suspiciousScoreSum / clicks) <= 75 then '51 to 75%'
     54                    when (suspiciousScoreSum / clicks) <= 99 then '76 to 99%'
     55                    when (suspiciousScoreSum / clicks) >= 100 then '100% Suspicious'
     56                    else null
     57                end"
     58            ],
    4359        ];
    4460
     
    4965     *
    5066     */
    51     protected function formatValue( $value, $segmentType ) {
    52 
    53         switch( $segmentType ) {
     67    protected function formatValue($value, $segmentType)
     68    {
     69        switch ($segmentType) {
    5470
    5571            case Segment::TYPE_TIME_DAY_OF_WEEK: {
    5672
    57                 $dayToString = [
    58                     1 => 'Sunday',
    59                     2 => 'Monday',
    60                     3 => 'Tuesday',
    61                     4 => 'Wednesday',
    62                     5 => 'Thursday',
    63                     6 => 'Friday',
    64                     7 => 'Saturday',
    65                 ];
     73                    $dayToString = [
     74                        1 => 'Sunday',
     75                        2 => 'Monday',
     76                        3 => 'Tuesday',
     77                        4 => 'Wednesday',
     78                        5 => 'Thursday',
     79                        6 => 'Friday',
     80                        7 => 'Saturday',
     81                    ];
    6682
    67                 if( !empty($dayToString[$value]) ) {
    68                     $value = $dayToString[$value];
     83                    if (!empty($dayToString[$value])) {
     84                        $value = $dayToString[$value];
     85                    }
    6986                }
    70             }
    71             break;
     87                break;
    7288
    7389            default:
    74                 $value = parent::formatValue( $value, $segmentType );
     90                $value = parent::formatValue($value, $segmentType);
    7591                break;
    7692        }
  • clickervolt/trunk/admin/reporting/handlers/handlerClicks.php

    r2080903 r2133590  
    77use ClickerVolt\TableURLsPaths;
    88
    9 class HandlerClicks extends HandlerWholePath {
    10 
     9class HandlerClicks extends HandlerWholePath
     10{
    1111    /**
    1212     *
    1313     * @return [] (first element is for 'select from', others are for joins - the ones for joins must include the join clause)
    1414     */
    15     protected function getTableNames( $request ) {
    16 
     15    protected function getTableNames($request)
     16    {
    1717        $tableClicksName = (new \ClickerVolt\TableClicks())->getName();
    1818        $tableAIDsName = (new \ClickerVolt\TableAIDs())->getName();
     
    2727        ];
    2828
    29         $mapper = $this->getMapper( $request );
     29        $mapper = $this->getMapper($request);
    3030        $devicesTableNeeded = false;
    3131        $geosTableNeeded = false;
    3232        $referrersTableNeeded = false;
    3333
    34         foreach( $request->segments as $segment ) {
    35             if( strpos($mapper[$segment->getType()][self::MAP_SELECT], 'devices.') !== false ) {
     34        foreach ($request->segments as $segment) {
     35            if (strpos($mapper[$segment->getType()][self::MAP_SELECT], 'devices.') !== false) {
    3636                $devicesTableNeeded = true;
    3737            }
    38             if( strpos($mapper[$segment->getType()][self::MAP_SELECT], 'geos.') !== false ) {
     38            if (strpos($mapper[$segment->getType()][self::MAP_SELECT], 'geos.') !== false) {
    3939                $geosTableNeeded = true;
    4040            }
    41             if( strpos($mapper[$segment->getType()][self::MAP_SELECT], 'ref.') !== false ) {
     41            if (strpos($mapper[$segment->getType()][self::MAP_SELECT], 'ref.') !== false) {
    4242                $referrersTableNeeded = true;
    4343            }
    4444        }
    4545
    46         if( $devicesTableNeeded ) {
     46        if ($devicesTableNeeded) {
    4747            $tableDevices = new \ClickerVolt\TableDevices();
    4848            $tables[] = $tableDevices->getName() . " as devices on devices.deviceHash = {$tableClicksName}.deviceHash";
    4949        }
    5050
    51         if( $geosTableNeeded ) {
     51        if ($geosTableNeeded) {
    5252            $tableGeos = new \ClickerVolt\TableGeos();
    5353            $tables[] = $tableGeos->getName() . " as geos on geos.geoHash = {$tableClicksName}.geoHash";
    5454        }
    5555
    56         if( $referrersTableNeeded ) {
     56        if ($referrersTableNeeded) {
    5757            $tableReferrers = new \ClickerVolt\TableReferrers();
    5858            $tables[] = $tableReferrers->getName() . " as ref on ref.referrerHash = {$tableClicksName}.referrerHash";
    5959        }
    6060
    61         if( $request->isSegmentPresent( Segment::TYPE_FUNNEL_LINK ) ) {
     61        if ($request->isSegmentPresent(Segment::TYPE_FUNNEL_LINK)) {
    6262
    6363            $tableURLsPaths = new TableURLsPaths();
     
    7272     *
    7373     */
    74     protected function formatValue( $value, $segmentType ) {
    75 
    76         $value = parent::formatValue( $value, $segmentType );
     74    protected function formatValue($value, $segmentType)
     75    {
     76        $value = parent::formatValue($value, $segmentType);
    7777
    7878        $otherHandlers = [];
     
    8080        $otherHandlers[] = new HandlerWholePathGeos();
    8181        $otherHandlers[] = new HandlerWholePathReferrers();
    82         foreach( $otherHandlers as $handler ) {
    83             $value = $handler->formatValue( $value, $segmentType );
     82        foreach ($otherHandlers as $handler) {
     83            $value = $handler->formatValue($value, $segmentType);
    8484        }
    8585
     
    9090     *
    9191     */
    92     protected function getTimestampColumn() {
     92    protected function getTimestampColumn()
     93    {
    9394        return "timestamp";
    9495    }
     
    9798     *
    9899     */
    99     protected function getSQLMetrics( $request ) {
    100 
     100    protected function getSQLMetrics($request)
     101    {
    101102        $table = new \ClickerVolt\TableClicks();
    102103        $tname = $table->getName();
     
    117118     * @return []
    118119     */
    119     protected function getMapper( $request ) {
     120    protected function getMapper($request)
     121    {
     122        $mapper = [
     123            Segment::TYPE_SUSPICIOUS_VS_CLEAN => [
     124                self::MAP_SELECT => "n/a"    // too slow - return unknown
     125            ],
    120126
    121         $mapper = [
     127            Segment::TYPE_SUSPICIOUS_BUCKETS => [
     128                self::MAP_SELECT => "n/a"    // too slow - return unknown
     129            ],
    122130
    123131            Segment::TYPE_IP_RANGE_C => [
     
    178186        $handleReferrers = new HandlerWholePathReferrers();
    179187
    180         return array_merge(
    181             $handleDevices->getMapper($request),
    182             $handleGeos->getMapper($request),
    183             $handleReferrers->getMapper($request),
    184             parent::getMapper($request),
    185             $mapper );
     188        return array_merge(
     189            $handleDevices->getMapper($request),
     190            $handleGeos->getMapper($request),
     191            $handleReferrers->getMapper($request),
     192            parent::getMapper($request),
     193            $mapper
     194        );
    186195    }
    187196}
  • clickervolt/trunk/admin/reporting/segment.php

    r2080903 r2133590  
    33namespace ClickerVolt\Reporting;
    44
    5 class Segment {
    6 
     5class Segment
     6{
    77    const TYPE_EMPTY = 'Empty';
    88    const TYPE_CLICK_ID = 'Click ID';
     
    1010    const TYPE_FUNNEL_LINK = 'Funnel Links';
    1111    const TYPE_SOURCE = 'Source';
     12    const TYPE_SUSPICIOUS_VS_CLEAN = 'Suspicious VS Clean';
     13    const TYPE_SUSPICIOUS_BUCKETS = 'Suspicious Buckets';
    1214    const TYPE_URL = 'URL';
    1315    const TYPE_DEVICE_TYPE = 'Device Type';
     
    5961    ];
    6062
    61     function __construct( $type, $filter = null ) {
     63    function __construct($type, $filter = null)
     64    {
    6265        $this->type = $type;
    6366        $this->filter = $filter !== '' ? $filter : null;
    6467    }
    6568
    66     function getType() {
     69    function getType()
     70    {
    6771        return $this->type;
    6872    }
    6973
    70     function getFilter() {
     74    function getFilter()
     75    {
    7176        return $this->filter;
    7277    }
    7378
    74     function isVar() {
    75         return in_array( $this->getType(), self::VAR_TYPES );
     79    function isVar()
     80    {
     81        return in_array($this->getType(), self::VAR_TYPES);
    7682    }
    7783
  • clickervolt/trunk/admin/views/dashboard.php

    r2129157 r2133590  
    581581                break;
    582582
     583            case "Source > Suspicious VS Clean":
     584                jQuery("#segment1").val(clickerVoltVars.const.ReportingSegments.TYPE_SOURCE);
     585                jQuery("#segment2").val(clickerVoltVars.const.ReportingSegments.TYPE_SUSPICIOUS_VS_CLEAN);
     586                break;
     587
     588            case "Source > Suspicious Buckets":
     589                jQuery("#segment1").val(clickerVoltVars.const.ReportingSegments.TYPE_SOURCE);
     590                jQuery("#segment2").val(clickerVoltVars.const.ReportingSegments.TYPE_SUSPICIOUS_BUCKETS);
     591                break;
     592
    583593            case "Source > V1":
    584594                jQuery("#segment1").val(clickerVoltVars.const.ReportingSegments.TYPE_SOURCE);
     
    697707                jQuery("#segment2").val(clickerVoltVars.const.ReportingSegments.TYPE_URL);
    698708                jQuery("#segment3").val(clickerVoltVars.const.ReportingSegments.TYPE_FUNNEL_LINK);
     709                break;
     710
     711            case "Source > Suspicious VS Clean > Funnel Links":
     712                jQuery("#segment1").val(clickerVoltVars.const.ReportingSegments.TYPE_SOURCE);
     713                jQuery("#segment2").val(clickerVoltVars.const.ReportingSegments.TYPE_SUSPICIOUS_VS_CLEAN);
     714                jQuery("#segment3").val(clickerVoltVars.const.ReportingSegments.TYPE_FUNNEL_LINK);
     715                break;
     716
     717            case "Suspicious VS Clean":
     718                jQuery("#segment1").val(clickerVoltVars.const.ReportingSegments.TYPE_SUSPICIOUS_VS_CLEAN);
     719                break;
     720
     721            case "Suspicious Buckets":
     722                jQuery("#segment1").val(clickerVoltVars.const.ReportingSegments.TYPE_SUSPICIOUS_BUCKETS);
    699723                break;
    700724
     
    817841            clickerVoltVars.const.ReportingSegments.TYPE_FUNNEL_LINK,
    818842            clickerVoltVars.const.ReportingSegments.TYPE_SOURCE,
     843            clickerVoltVars.const.ReportingSegments.TYPE_SUSPICIOUS_VS_CLEAN,
     844            clickerVoltVars.const.ReportingSegments.TYPE_SUSPICIOUS_BUCKETS,
    819845            clickerVoltVars.const.ReportingSegments.TYPE_URL,
    820846            clickerVoltVars.const.ReportingSegments.TYPE_DEVICE_TYPE,
  • clickervolt/trunk/admin/views/dashboardTabReports.php

    r2129157 r2133590  
    44
    55        <div class="stat-buttons-shortcuts">
    6             <button class="button stat-button" list="Funnel Links|Funnel Links > URL|Source > Funnel Links|Source > URL > Funnel Links">Funnel Links</button>
    7             <button class="button stat-button" list="Source|Source > URL|Source > V1|Source > V2|Source > V3|Source > V4|Source > V5|Source > V6|Source > V7|Source > V8|Source > V9|Source > V10">Source</button>
     6            <button class="button stat-button" list="Funnel Links|Funnel Links > URL|Source > Funnel Links|Source > URL > Funnel Links|Source > Suspicious VS Clean > Funnel Links">Funnel Links</button>
     7            <button class="button stat-button" list="Source|Source > Suspicious VS Clean|Source > Suspicious Buckets|Source > URL|Source > V1|Source > V2|Source > V3|Source > V4|Source > V5|Source > V6|Source > V7|Source > V8|Source > V9|Source > V10">Source</button>
    88            <button class="button stat-button" list="V1|V2|V3|V4|V5|V6|V7|V8|V9|V10">Source Vars</button>
     9            <button class="button stat-button" list="Suspicious VS Clean|Suspicious Buckets">Suspicious Traffic</button>
    910            <button class="button stat-button">URL</button>
    1011            <button class="button stat-button" list="Device Type|Device Brand|Device Name">Device</button>
  • clickervolt/trunk/clickervolt.php

    r2133010 r2133590  
    55 * Plugin URI:  https://clickervolt.com/
    66 * Description: Advanced click tracking, link cloaking and affiliate campaigns management made easy.
    7  * Version:     1.125
     7 * Version:     1.126
    88 * Author:      ClickerVolt.com
    99 * License:     GPLv3
  • clickervolt/trunk/db/db.php

    r2133010 r2133590  
    1111class DB
    1212{
    13     const VERSION = 1.125;
     13    const VERSION = 1.126;
    1414
    1515    const OPTION_VERSION = 'clickervolt-version';
  • clickervolt/trunk/readme.txt

    r2133010 r2133590  
    11=== ClickerVolt - Advanced Click + Link Tracking for Affiliates ===
    2 Contributors: clickervolt
     2Contributors: clickervolt, freemius
    33Tags: affiliate, tracker, link, tracking, click, shortlink, url, page cloaker, link cloaker, cloaker, cloaking, redirect, redirection, drilldown, stats, statistics, marketing, aida
    44Requires at least: 4.9
     
    263263
    264264== Changelog ==
     265= 1.126 =
     266* Added new "suspicious" related segments in reporting tab
     267
    265268= 1.125 =
    266269* Removed Peerfly affiliate network template (they stopped business)
  • clickervolt/trunk/redirect/jsTracking/js/cvTrack.js

    r2133010 r2133590  
    2525                referrer: CVTrack.getReferrer(),
    2626            };
     27
     28            window.addEventListener("beforeunload", function () {
     29                // We force that the page must be seen at least 3 seconds to
     30                // be sure the remote tracking has a chance to be triggered...
     31                var minTimeOnPage = 3;
     32                do {
     33                    var curTime = Date.now() / 1000;
     34                } while (curTime < (window.clickerVolt.timeOnPageStart + minTimeOnPage));
     35            });
    2736        }
    2837
     
    168177        if (callback) {
    169178            request.onreadystatechange = function () {
    170                 if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
     179                // We don't use XMLHttpRequest.DONE anymore because
     180                // some libs override the XMLHttpRequest object.
     181                var DONE = 4;
     182                if (this.readyState === DONE && this.status === 200) {
    171183                    callback(this.response);
    172184                }
Note: See TracChangeset for help on using the changeset viewer.