PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.14.2
Independent Analytics – WordPress Analytics Plugin v2.14.2
2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / IAWP / Models / Journey.php
independent-analytics / IAWP / Models Last commit date
Campaign.php 10 months ago Campaign_Landing_Page.php 9 months ago Campaign_UTM_Campaign.php 9 months ago Campaign_UTM_Medium.php 9 months ago Campaign_UTM_Source.php 9 months ago ClickWhale_Link_Page.php 1 year ago Current_Traffic.php 2 years ago Device.php 10 months ago Form.php 1 year ago Geo.php 10 months ago Journey.php 5 months ago Link.php 8 months ago Link_Pattern.php 10 months ago Model.php 6 months ago Page.php 10 months ago Page_Author_Archive.php 2 years ago Page_Date_Archive.php 2 years ago Page_Home.php 2 years ago Page_Not_Found.php 1 year ago Page_Post_Type_Archive.php 1 year ago Page_Search.php 2 years ago Page_Singular.php 1 year ago Page_Term_Archive.php 2 years ago Page_Virtual.php 1 year ago Referrer.php 6 months ago Referrer_Type.php 9 months ago Universal_Model_Columns.php 1 year ago Visitor.php 9 months ago
Journey.php
190 lines
1 <?php
2
3 namespace IAWP\Models;
4
5 use IAWPSCOPED\Carbon\CarbonImmutable;
6 use IAWPSCOPED\Carbon\CarbonInterval;
7 use IAWP\Favicon\Favicon;
8 use IAWP\Icon_Directory_Factory;
9 use IAWP\Journey\EngagementScore;
10 use IAWP\Utils\Currency;
11 use IAWP\Utils\Timezone;
12 /** @internal */
13 class Journey extends \IAWP\Models\Model
14 {
15 protected $row;
16 private $created_at;
17 public function __construct($row)
18 {
19 $this->row = $row;
20 $this->created_at = $row->created_at;
21 if (\is_string($row->duration)) {
22 $row->duration = (int) $row->duration;
23 }
24 }
25 public function id() : int
26 {
27 return $this->row->session_id;
28 }
29 public function table_type() : string
30 {
31 return 'journeys';
32 }
33 /**
34 * @return string Time ago the session was started
35 */
36 public function session_started_at() : string
37 {
38 $created_at = CarbonImmutable::parse($this->created_at, 'utc')->timezone(Timezone::site_timezone());
39 return $created_at->diffForHumans();
40 }
41 public function landing_page() : string
42 {
43 return $this->row->cached_title;
44 }
45 public function referrer()
46 {
47 return $this->row->referrer;
48 }
49 public function domain()
50 {
51 return \esc_url($this->row->domain);
52 }
53 public function is_direct() : bool
54 {
55 return $this->row->referrer_type === 'Direct';
56 }
57 public function referrer_favicon_url() : ?string
58 {
59 return Favicon::for($this->row->domain)->url();
60 }
61 public function fallback_favicon_color_id() : int
62 {
63 $options = [1, 2, 3, 4, 5];
64 return $options[\abs(\crc32($this->row->domain ?? '')) % \count($options)];
65 }
66 public function has_domain()
67 {
68 $url = $this->domain();
69 return \is_string($url) && \strlen($url) > 0;
70 }
71 public function views()
72 {
73 return $this->row->views;
74 }
75 public function views_engagement_score() : int
76 {
77 return EngagementScore::for_session_total_views($this->row->views);
78 }
79 public function duration() : ?string
80 {
81 if (!\is_int($this->row->duration)) {
82 return null;
83 }
84 $interval = CarbonInterval::seconds($this->row->duration);
85 return $interval->cascade()->forHumans(['short' => \true]);
86 }
87 public function duration_engagement_score() : int
88 {
89 return EngagementScore::for_session_duration($this->row->duration);
90 }
91 public function duration_in_seconds() : ?int
92 {
93 if (!\is_int($this->row->duration)) {
94 return null;
95 }
96 return $this->row->duration;
97 }
98 public function has_link()
99 {
100 if ($this->referrer_url() === '') {
101 return \false;
102 }
103 if ($this->row->referrer_type === 'Ad') {
104 return \false;
105 }
106 return \true;
107 }
108 public function referrer_url()
109 {
110 return $this->row->referrer_url;
111 }
112 public function has_conversion() : bool
113 {
114 return $this->has_order() || $this->has_click() || $this->has_form_submission();
115 }
116 public function has_order() : bool
117 {
118 return $this->row->orders > 0;
119 }
120 public function has_click() : bool
121 {
122 return $this->row->clicks > 0;
123 }
124 public function has_form_submission() : bool
125 {
126 return $this->row->form_submissions > 0;
127 }
128 public function gross_sales() : string
129 {
130 $gross_sales = $this->row->wc_gross_sales ?? 0;
131 return Currency::format($gross_sales, \false);
132 }
133 public function refunded_amount() : ?string
134 {
135 $refunded_amount = $this->row->wc_refunded_amount ?? null;
136 if ($refunded_amount === 0) {
137 return null;
138 }
139 return Currency::format($refunded_amount, \false);
140 }
141 public function country()
142 {
143 return $this->row->country ?? \__('Unknown country', 'independent-analytics');
144 }
145 public function country_code()
146 {
147 return $this->row->country_code;
148 }
149 public function country_flag_url()
150 {
151 $country_code = $this->row->country_code ?? '';
152 return Icon_Directory_Factory::flags()->find_icon_url($country_code);
153 }
154 public function device_type()
155 {
156 return $this->row->device_type ?? \__('Unknown device type', 'independent-analytics');
157 }
158 public function device_type_icon_url()
159 {
160 $device_type = $this->row->device_type ?? '';
161 return Icon_Directory_Factory::device_types()->find_icon_url($device_type);
162 }
163 public function device_browser()
164 {
165 return $this->row->device_browser ?? \__('Unknown browser', 'independent-analytics');
166 }
167 public function device_browser_icon_url()
168 {
169 $device_browser = $this->row->device_browser ?? '';
170 return Icon_Directory_Factory::browsers()->find_icon_url($device_browser);
171 }
172 public function utm_source() : ?string
173 {
174 return $this->row->utm_source ?? null;
175 }
176 public function examiner_title() : ?string
177 {
178 return '';
179 // return $this->title();
180 }
181 public function examiner_url() : string
182 {
183 return '';
184 // return iawp_dashboard_url([
185 // 'tab' => 'campaigns',
186 // 'examiner' => $this->id(),
187 // ]);
188 }
189 }
190