symfonylab / customerio-bundle
将 customer.io 集成到 Symfony
dev-master
2019-11-15 15:58 UTC
Requires
- php: ^7.3
- ext-json: *
- symfony-bundles/json-request-bundle: ^2.0
- symfony/framework-bundle: 4.3.*
- symfony/monolog-bundle: ^3.4
- symfony/yaml: 4.3.*
- userscape/customerio: ^2.1
Requires (Dev)
- doctrine/doctrine-fixtures-bundle: ^3.2
- symfony/browser-kit: ^4.3
- symfony/maker-bundle: ^1.13
- symfony/phpunit-bridge: ^4.3
- symfony/profiler-pack: ^1.0
- symfony/routing: ^4.3
This package is not auto-updated.
Last update: 2024-09-29 06:02:40 UTC
README
Symfony 集成 http://customer.io。
配置
使用 composer 安装该包,并在您的 Kernel 中注册它。
然后配置您的 site_id 和 api_key
# app/config/config.yml symfonylab_customer_io: site_id: <YOUR-SITE-ID> api_key: <YOUR-API-KEY>
使用方法
客户模型
在您的客户域类上实现 SymfonyLab\CustomerIOBundle\Model\CustomerInterface。
事件跟踪/客户识别
use SymfonyLab\CustomerIOBundle\Event\TrackingEvent; use SymfonyLab\CustomerIOBundle\Event\ActionEvent; /** @var \Symfony\Component\EventDispatcher\EventDispatcher $tracker */ $dispatcher = $this->getContainer()->get('event_dispatcher'); $customer = $repo->getCustomer(); // retrieve your customer domain object // send the customer over to customer.io for identification $dispatcher->dispatch(new TrackingEvent($customer)); // now track a `click` event $dispatcher->dispatch(new ActionEvent($customer, 'click'));
Webhooks
该包附带一个控制器,可以消费 customer.io webhooks。
要使用它们,注册 routing.xml
# app/config/routing.yml customerio_hooks: resource: "@SymfonyLabCustomerIOBundle/Resources/config/routing.yaml"
现在您的钩子 URL 将是 http://your.project.com/webhook,您需要在 customer.io 中配置。
完成后,您可以监听 webhook 事件
<service id="acme.webhooklistener" class="Acme\DemoBundle\Listener\WebhookListener"> <tag name="kernel.event_listener" event="customer_io.email_clicked" method="onClick" /> </service>
use SymfonyLab\CustomerIOBundle\Event\WebHookEvent; class WebhookListener { public function onClick(WebHookEvent $event) { $this->logger->info('Customer clicked on email with address: ' . $event->getEmail()); } }