Indent JavaScript SDK

The Indent JavaScript SDK provides your JavaScript and TypeScript applications access to Indent.

You can install the SDK with Yarn or NPM:

yarn add @indent/audit

npm i -S @indent/audit

Or using our script tag:

<script
  src="https://cdn.indent.com/v1/js/audit.js"
  data-input-dsn="https://write.indentapis.com/v1/ZG9jcy1leGFtcGxl"
></script>

Looking to add Indent to your website? Follow this guide.

View the source code on GitHub.

After you've installed the SDK, you can include it in your JS application with your Input's DSN. You can put your INPUT_DSN in an environment variable or copy the code from that page:

import { audit } from '@indent/audit'

audit.init({ dsn: 'https://write.indentapis.com/v1/ZG9jcy1leGFtcGxl' })

Once you've initalized your client, you can start writing audit events:

const pageview = url =>
  audit.write({
    event: 'page_viewed',
    actor: { id: window.appUserId || 'anonymous' },
    resources: [{ kind: 'http/url', id: url || window.location.href }]
  })

pageview()
audit.init({
  dsn: 'https://write.indentapis.com/v1/ZG9jcy1leGFtcGxl',
  debug: false
})
audit.write(
  {
    event: 'page_viewed',
    actor: { id: 'anonymous', altIds: ['ip-addr/127.0.0.1'] },
    resources: [
      {
        kind: 'http/url',
        id: 'https://indent.com/docs/sdk/js'
      }
    ]
  },
  // Optional object for passing options like `flushImmediately`
  // to immediately flush queued events to the Indent Audit API.
  {
    flushImmediately: true
  }
)

Chat with an engineer or let us know if you’d like to work with Indent in a different language or with a specific framework.