How to use the analytics.logEvent function in analytics

To help you get started, we’ve selected a few analytics examples, based on popular ways it is used in public projects.

github hyperstart / hyperstart.io / src / editor / runProject.ts View on Github external
actions._setState({
          compilationOutput: {
            success: false,
            loading: false,
            compiledModules
          }
        })
        throw "Compilation error(s)!"
      }
      const indexHtml = getFile(state, "/index.html")

      if (!indexHtml) {
        throw new Error("No index.html found in files")
      }

      logEvent(debug ? "debug" : "run", {
        event_category: "project",
        event_label: debug ? "DebugProject" : "RunProject"
      })

      const iframeSource = indexHtml.content
        .replace(
          `<script src="/bundle.js"></script>`,
          `<script>${output.code}</script>`
        )
        .replace(
          `</head>`,
          `<style>body { background-color: white; }</style></head>`
        ) // <script>if (window.history) { window.history.replaceState(null, null, "/") }</script>

      actions._setState({
        compilationOutput: {
github hyperstart / hyperstart.io / src / editor / module.ts View on Github external
saveProject: () => (state, actions): Promise<void> => {
      checkOpen(state)
      if (state.status === "read-only") {
        throw new Error(`Status should not be read-only.`)
      }
      if (state.status === "editing") {
        let toSave = state.project
        if (toSave.details !== state.original.details) {
          logEvent("rename_project", {
            event_category: "project",
            event_label: "Rename"
          })
          const name = normalize(toSave.details.name)
          toSave = {
            details: {
              ...toSave.details,
              name,
              hidden: name === "",
              searches: getSearches(name)
            },
            files: toSave.files
          }
        }
        return actions._projects.save(toSave).then(project => {
          // TODO recompute searches and stuff
github hyperstart / hyperstart.io / src / lib / search / module.ts View on Github external
.then(results => {
            logEvent("search", {
              event_category: "project",
              event_label: "Search"
            })
            const hasNext = results.length > search.resultsPerPage
            actions.update({ name, status: "success", results, hasNext })
            return actions.getState()[name]
          })
          .catch(e => {
github hyperstart / hyperstart.io / src / users / module.ts View on Github external
.then(() => {
                logEvent("login", {
                  event_category: "users",
                  event_label: eventLabel
                })

                onUserChanged(auth.currentUser, null)
                resolve()
              })
              .catch(e => {
github hyperstart / hyperstart.io / src / editor / ui / module.ts View on Github external
openEmbedModal: () => {
      logEvent("screen_view", { screen_name: "Embed modal" })
      return { embedModal: true }
    },
    closeEmbedModal: () => {
github hyperstart / hyperstart.io / src / forkProject.ts View on Github external
actions.users.getCurrentUser().then(user => {
      const owner = getProjectOwner(user)
      const newProject = copyProject(project, owner)
      actions.editor.open(newProject)
      replace("/projects/" + newProject.details.id)

      logEvent("fork_project", {
        event_category: "project",
        event_label: "Fork"
      })
    })
  )
github hyperstart / hyperstart.io / src / users / module.ts View on Github external
.then(() => {
              actions.hideSignUpModal()
              logEvent("signup", {
                event_category: "users",
                event_label: "SignupEmail"
              })

              onUserChanged(auth.currentUser, null)
              resolve()
            })
            .catch(e => {
github hyperstart / hyperstart.io / src / createProject.ts View on Github external
.then(project => {
        actions.editor.open(project)
        replace("/projects/" + project.details.id)
        logEvent("create_project", {
          event_category: "project",
          event_label: "Create" + template + "ProjectFromIndex"
        })
      })
  )
github hyperstart / hyperstart.io / src / editor / module.ts View on Github external
.then(project => {
          actions._setState({
            project,
            original: project,
            status: "editing"
          })
          replace(`/projects/${project.details.id}`)

          logEvent("fork_project", {
            event_category: "project",
            event_label: "Fork"
          })
        })
    },
github hyperstart / hyperstart.io / src / editor / debug / module.ts View on Github external
showPane: (paneShown: boolean) => {
      if (paneShown == true) {
        logEvent("debug", {
          event_category: "project",
          event_label: "ToggleDebug"
        })
      }
      return { paneShown }
    },
    setValueDisplay: (valueDisplay: api.ValueDisplay) => {

analytics

Lightweight analytics library for tracking events, page views, & identifying users. Works with any third party analytics provider via an extendable plugin system.

MIT
Latest version published 6 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages