@customerlog/svelte
v0.2.2
Published
Svelte bindings for customer.log — console.log for your startup
Readme
@customerlog/svelte
The official Svelte bindings for customer.log.
Wraps the core @customerlog/sdk with a store, a createCustomerLog() helper, and automatic browser session tracking.
<script>
import { initCustomerLog } from "@customerlog/svelte";
const customer = initCustomerLog({ apiKey: "cl_xxx" });
</script>
<button on:click={() => customer.log({
channel: "signups",
title: "User signed up",
level: "success",
notify: true,
})}>Track</button>Install
npm install @customerlog/svelte @customerlog/sdkUsage
App-wide via the store
// lib/customer-log.ts
import { initCustomerLog } from "@customerlog/svelte";
export const customer = initCustomerLog({ apiKey: import.meta.env.VITE_CUSTOMER_LOG_API_KEY });<script>
import { customerLog } from "@customerlog/svelte";
$: client = $customerLog;
</script>
{#if client}
<button on:click={() => client.log({ channel: "clicks", title: "Clicked CTA", notify: true })}>Go</button>
{/if}Local instance
const { log, pageView } = createCustomerLog({ apiKey: "cl_xxx" });API
| Export | Description |
|--------|-------------|
| initCustomerLog(config) | Creates a client, sets it in the customerLog store, returns it |
| customerLog | Writable<CustomerLog \| null> store |
| createCustomerLog(config) | Returns { client, log(options), pageView(path?, metadata?) } |
| CustomerLog | The core client (for advanced use) |
| CustomerLogError | Error class with .status |
See the core SDK docs for the full log() options table.
License
MIT
