Exemplo n.º 1
0
 /**
  * Renders the library method.
  *
  * @param MethodInterface $method
  *
  * @return string
  */
 public function renderMethod(MethodInterface $method)
 {
     if (!$method->supports(MethodInterface::BROWSER_PLATFORM)) {
         throw new \InvalidArgumentException('Renderer only accepts browser methods.');
     }
     return 'window.analytics.' . $method->getName() . '(' . $this->renderArguments($method) . ');';
 }
Exemplo n.º 2
0
 /**
  * Get the method data for the given user id.
  *
  * @param MethodInterface $method
  * @param string          $userId
  *
  * @return array
  */
 private function getMethodData(MethodInterface $method, $userId)
 {
     $data = $method->getArguments();
     $data['action'] = $method->getName();
     $data['secret'] = $this->getWriteKey();
     // Don't overwrite the userId if it it is present.
     if (!isset($data['userId']) && !isset($data['from'])) {
         $data['userId'] = $userId;
     }
     return $data;
 }