Skip to content

Commit

Permalink
Update defaultSource slightly (functioning runEveryHour)
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Jun 17, 2021
1 parent ee3f16e commit 73f98c1
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions frontend/src/scenes/plugins/edit/PluginSource.tsx
Expand Up @@ -12,29 +12,30 @@ import SCAFFOLD_errors from '!raw-loader!@posthog/plugin-scaffold/dist/errors.d.
// @ts-ignore
import SCAFFOLD_types from '!raw-loader!@posthog/plugin-scaffold/dist/types.d.ts'

const defaultSource = `
// Learn more about plugins at: https://posthog.com/docs/plugins/build/overview
const defaultSource = `// Learn more about plugins at: https://posthog.com/docs/plugins/build/overview
/* Runs on every event */
// Processes each event, optionally transforming it
export function processEvent(event, { config }) {
// Some events (like $identify) don't have properties
// Some events (such as $identify) don't have properties
if (event.properties) {
event.properties['hello'] = \`Hello \${config.name}\`
}
// Return the event to ingest, return nothing to discard
// Return the event to be ingested, or return null to discard
return event
}
/* Runs once on plugin installation */
// Runs when the plugin is loaded, allows for preparing it as needed
export function setupPlugin (meta) {
console.log(\`The date is \${new Date().toDateString()}\`)
}
/* Runs once every full hour */
// function runEveryHour(meta) {
// const weather = await (await fetch('https://weather.example.api/?city=New+York')).json()
// posthog.capture('weather', { degrees: weather.deg, fahrenheit: weather.us })
// }`
// Runs every hour on the hour
async function runEveryHour(meta) {
const response = await fetch('https://palabras-aleatorias-public-api.herokuapp.com/random')
const data = await response.json()
const randomSpanishWord = data.body.Word
console.log(\`隆\${randomSpanishWord.toUpperCase()}!\`)
}`

const defaultConfig = [
{
Expand Down

0 comments on commit 73f98c1

Please sign in to comment.