Skip to content

hallewood/logsnag-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogSnag PHP

A PHP SDK for the LogSnag API – logsnag.com

Installation

composer require hallewood/logsnag-php

Usage

Initialize Client

use Hallewood\LogSnag\Client;

$logsnag = new Client('7f568d735724351757637b1dbf108e5', 'my-project');

The project name will be auto-injected in all requests.

Log

//
// The channel and the event name are the only required parameters.
$logsnag->log('subscriptions', 'User subscribed!');

//
// Other parameters can be added when needed.
$logsnag->log(
    channel: 'subscriptions',
    event: 'User subscribed!',
    userId: '123-456',
    description: 'A new user subscribed to the **premium plan**.',
    icon: '👍🏼',
    notify: true,
    tags: [
        'payment-method': 'card',
        'plan': 'monthly',
    ],
    parser: 'markdown',
    timestamp: 1709842921,
);

Identify

//
// Both the user id and the properties are required.
$logsnag->identify(
    userId: '123-456',
    properties: [
        'active': 'yes',
        'signed-in': 'no',
    ],
);

Insight

//
// The title and the value are the only required parameters.
$logsnag->insight('Subscribed Users', 12);

//
// Other parameters can be added when needed.
$logsnag->log(
    title: 'Status',
    value: 'watered',
    icon: '🪴',
);

Insight Mutate

//
// The title and at least one mutation is required.
$logsnag->insight('Subscribed Users', inc: 3);

//
// Other parameters can be added when needed.
$logsnag->log(
    title: 'Subscribed Users',
    inc: -2,
    icon: '👍🏼',
);

About

A PHP SDK for the LogSnag API – logsnag.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages