Skip to content

Commit b415191

Browse files
author
Alex Westergaard
committed
Option to auto-post when event limit is reached
1 parent f99d601 commit b415191

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Analytics.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Analytics extends Model\ToArray implements Facade\Analytics, Facade\Export
1919
private $debug;
2020
private $measurement_id;
2121
private $api_secret;
22+
private $postOnEventLimit = false;
2223

2324
protected $non_personalized_ads;
2425
protected $timestamp_micros;
@@ -100,6 +101,12 @@ public function setTimestamp($microOrUnix)
100101
return $this;
101102
}
102103

104+
public function postOnEventLimit(bool $push = true)
105+
{
106+
$this->postOnEventLimit = $push;
107+
return $this;
108+
}
109+
103110
/**
104111
* Add user property to your analytics request \
105112
* Maximum is 25 per request
@@ -141,6 +148,10 @@ public function addEvent(Model\Event $event)
141148
}
142149

143150
$this->events[] = $event->toArray();
151+
152+
if (count($this->events) >= 25 && $this->postOnEventLimit === true) {
153+
$this->post();
154+
}
144155
return $this;
145156
}
146157

0 commit comments

Comments
 (0)