@tinloof/sanity-amplitude-experiment
v0.0.3
Published
A plugin to easily connect your Amplitude experiments with your Sanity documents.
Downloads
9
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
- A Sanity project
- An Amplitude account (Growth plan)
- An Amplitude Management API key
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',
}),
],
})