JSPM

@tinloof/sanity-amplitude-experiment

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 161
  • Score
    100M100P100Q98717F
  • License MIT

A plugin to easily connect your Amplitude experiments with your Sanity documents.

Package Exports

  • @tinloof/sanity-amplitude-experiment
  • @tinloof/sanity-amplitude-experiment/package.json

Readme

@tinloof/sanity-amplitude-experiment

A plugin to easily connect your Amplitude experiments with your Sanity documents.

Installation

npm install @tinloof/sanity-amplitude-experiment

Requirements

Basic usage

1. Configure the plugin in sanity.config.ts

import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {amplitudeExperiment} from '@tinloof/sanity-amplitude-experiment'
import schemas from './schemas'

const projectId = process.env.SANITY_STUDIO_PROJECT_ID || ''
const dataset = process.env.SANITY_STUDIO_DATASET || ''

export default defineConfig({
  projectId,
  dataset,
  plugins: [structureTool(), amplitudeExperiment()],
  schema: {
    types: schemas,
  },
})

2. Add the amplitude-experiment field to your document

import {defineField, defineType} from 'sanity'

export default defineType({
  type: 'document',
  name: 'page',
  fields: [
    defineField({
      type: 'string',
      name: 'title',
      group: 'content',
    }),
    defineField({
      name: 'experiment',
      type: 'amplitude-experiment',
    }),
  ],
})

3. Configure your Management API key