open-index/open-npm huggingface dataset:
npm package: @fluidity-money/snitch-client
Description: Client side utilities for reporting to the Superposition Snitch graph.
Latest version: 0.4.0

# Snitch Client

A tiny browser oriented client for interacting with the Superposition Snitch graph.

## Usage

```javascript
import { tagUser, hitUser } from '@superposition/snitch-client'

await tagUser(
  {
    tag: null,
    source: 'x',
    property: '9lives',
    address: '0x...',
    facts: [ { key: 'languages', value: ['en'] } ]
  },
  { endpoint: 'https://example.com/snitch' }
)
```

If `endpoint` is omitted, `process.env.NEXT_PUBLIC_SNITCH_ENDPOINT` is used.

The function resolves with the tag identifier returned by the graph.

Calls with the same input are memoised locally. The resolved tag is cached in
`localStorage` so repeated invocations with identical parameters will return the
stored value without hitting the network.

The optional `tag` field lets you pass an existing tag identifier. Use `null` or
omit the property to have the graph generate a new tag for the user.

```javascript
// Track a page visit
await hitUser(
  {
    tag: 'uuid',
    property: '9lives',
    page: 'home',
    referrer: 'landing'
  },
  { endpoint: 'https://example.com/snitch' }
)
```

`hitUser` resolves with `true` on success and allows you to record a visit to a specific page.