定制 multek/laravel-customer-engagement 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

multek/laravel-customer-engagement

最新稳定版本:v1.0.0

Composer 安装命令:

composer require multek/laravel-customer-engagement

包简介

A unified customer engagement platform for Laravel — contracts, DTOs, and manager for push notifications, user sync, and event tracking across multiple providers.

README 文档

README

A unified customer engagement platform for Laravel. Provides contracts, DTOs, and a driver-based manager for push notifications, user sync, and event tracking across multiple providers.

Features

  • Driver-Based Architecture - Swap providers (OneSignal, Braze, Firebase, etc.) without changing application code
  • Capability Contracts - SyncsUsers, SendsNotifications, TracksEvents interfaces for fine-grained driver capabilities
  • Laravel Notification Channel - EngagementChannel works with Laravel's native notification system
  • DTOs - Customer, Notification, and CustomerEvent data transfer objects for type-safe interactions
  • Model Trait - HasCustomerEngagement for syncing Eloquent models
  • Async Jobs - Queue-based customer sync with SyncCustomer
  • Events - NotificationSent and NotificationFailed events for observability
  • Null Driver - Built-in null driver for testing and environments without a provider

Requirements

  • PHP 8.2+
  • Laravel 11.0+

Installation

composer require multek/laravel-customer-engagement

Publish the config file:

php artisan vendor:publish --tag=customer-engagement-config

Available Drivers

Driver Package Capabilities
OneSignal multek/laravel-onesignal Notifications, User Sync, Event Tracking
Null Built-in None (testing/fallback)

Usage

Configuration

// config/customer-engagement.php
'default' => env('ENGAGEMENT_DRIVER', 'onesignal'),

Sending Notifications

use Multek\CustomerEngagement\Facades\Engagement;
use Multek\CustomerEngagement\DTOs\Notification;

$notification = new Notification(
    title: 'Order Shipped',
    body: 'Your order #456 has been shipped.',
    data: ['order_id' => 456],
);

// Send to a single user
Engagement::sendToUser('user_123', $notification);

// Send to multiple users
Engagement::sendToUsers(['user_1', 'user_2'], $notification);

// Send to a segment
Engagement::sendToSegment('Active Users', $notification);

User Sync

use Multek\CustomerEngagement\DTOs\Customer;

$customer = new Customer(
    externalId: 'user_123',
    tags: ['plan' => 'pro', 'role' => 'admin'],
);

Engagement::createUser($customer);
Engagement::updateUser($customer);
Engagement::deleteUser('user_123');

Event Tracking

use Multek\CustomerEngagement\DTOs\CustomerEvent;

$event = new CustomerEvent(
    externalId: 'user_123',
    name: 'purchase',
    payload: ['amount' => 99.90, 'product' => 'Pro Plan'],
);

Engagement::trackEvent($event);

Capability Checks

// Check what the current driver supports
Engagement::syncsUsers();          // bool
Engagement::sendsNotifications();  // bool
Engagement::tracksEvents();        // bool

// Check a specific driver
Engagement::syncsUsers('onesignal'); // bool

Using a Specific Driver

// Override the default driver for a single call
Engagement::sendToUser('user_123', $notification, driver: 'onesignal');

Creating a Custom Driver

Implement the contracts your provider supports:

use Multek\CustomerEngagement\Contracts\EngagementDriver;
use Multek\CustomerEngagement\Contracts\SendsNotifications;
use Multek\CustomerEngagement\Contracts\SyncsUsers;

class BrazeDriver implements EngagementDriver, SendsNotifications, SyncsUsers
{
    public function getName(): string
    {
        return 'braze';
    }

    // Implement SendsNotifications methods...
    // Implement SyncsUsers methods...
}

Register it in your service provider:

use Multek\CustomerEngagement\EngagementManager;

public function boot(): void
{
    $this->app->make(EngagementManager::class)->extend('braze', function () {
        return new BrazeDriver(config('services.braze'));
    });
}

Testing

composer test

License

MIT

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固