From b37da7b1d8373ede1c7c0921ba1fc393b2882169 Mon Sep 17 00:00:00 2001 From: Michael Leaney Date: Thu, 15 May 2014 14:42:50 +1000 Subject: [PATCH] DP-77 Add defaultContext for Fornax consumer Will merge context with defaultContext in that order. --- lib/Analytics/Consumer/Fornax.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Analytics/Consumer/Fornax.php b/lib/Analytics/Consumer/Fornax.php index e93ea1b..96e088c 100644 --- a/lib/Analytics/Consumer/Fornax.php +++ b/lib/Analytics/Consumer/Fornax.php @@ -140,6 +140,10 @@ private function write($body) { $body['anonymousId'] = $this->options['anonymousId']; } + if (isset($this->options['defaultContext']) && is_array($this->options['defaultContext'])) { + $body['context'] = array_merge($this->options['defaultContext'], $body['context']); + } + $content = json_encode($body); $content.= "\n";