| @@ 103-118 (lines=16) @@ | ||
| 100 | * |
|
| 101 | * @return void |
|
| 102 | */ |
|
| 103 | public function pageview() |
|
| 104 | { |
|
| 105 | // Only interact once per experiment. #reallyli update |
|
| 106 | if (config('ab.unique_pageview')) { |
|
| 107 | if ($this->session->get('pageview')) { |
|
| 108 | return; |
|
| 109 | } |
|
| 110 | } |
|
| 111 | ||
| 112 | $experiment = Experiment::firstOrNew(['name' => $this->experiment()]); |
|
| 113 | $experiment->visitors++; |
|
| 114 | $experiment->save(); |
|
| 115 | ||
| 116 | // Mark current experiment as interacted. |
|
| 117 | $this->session->set('pageview', 1); |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * Increment the engagement for the current experiment. |
|
| @@ 125-138 (lines=14) @@ | ||
| 122 | * |
|
| 123 | * @return void |
|
| 124 | */ |
|
| 125 | public function interact() |
|
| 126 | { |
|
| 127 | // Only interact once per experiment. |
|
| 128 | if ($this->session->get('interacted')) { |
|
| 129 | return; |
|
| 130 | } |
|
| 131 | ||
| 132 | $experiment = Experiment::firstOrNew(['name' => $this->experiment()]); |
|
| 133 | $experiment->engagement++; |
|
| 134 | $experiment->save(); |
|
| 135 | ||
| 136 | // Mark current experiment as interacted. |
|
| 137 | $this->session->set('interacted', 1); |
|
| 138 | } |
|
| 139 | ||
| 140 | /** |
|
| 141 | * Mark a goal as completed for the current experiment. |
|