透過 100+ 個技巧學習 Nuxt!

logrocket
nuxt-logrocket

LogRocket 模組適用於 Nuxt,可協助您修正錯誤並了解使用者行為。

nuxt-logrocket

nuxt-logrocket

npm (scoped with tag)npmCircleCICodecovjs-standard-style

LogRocket 模組適用於 Nuxt.js

📖 發行說明

功能

  • Nuxt 3 & Nuxt Bridge
  • 支援 Pinia 整合
  • 能夠在開發模式下執行

設定

  • 使用 yarn 或 npm 將 nuxt-logrocket 依賴套件新增至您的專案
yarn add nuxt-logrocket

npm install nuxt-logrocket --save
  • nuxt-logrocket 新增至您的 nuxt.config.ts 檔案的 modules 區段
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: ['nuxt-logrocket'],

  logRocket: {
    id: '',
    dev: false,
    config: {
      //
    }
  }
})

選項

可以使用 執行階段設定nuxt.config.ts 中的 logRocket 區段傳遞選項。在大多數情況下,設定必要的 id 選項值就已足夠。

以下是完整的選項列表

選項類型預設必填
id字串''
dev布林值true
enablePinia布林值true
release字串null
consoleEnabled布林值true
networkEnabled布林值true
networkRequestSanitizer函式-
networkResponseSanitizer函式-
domEnabled布林值true
inputSanitizer布林值false
textSanitizer布林值false
baseHref字串null
shouldCaptureIP布林值true
rootHostname字串null
shouldDebugLog布林值true
mergeIframes布林值false

這是一個包含選項預設值的範例

{
  id: '',
  dev: true,
  enablePinia: true,
  config: {
    release: null,
    console: {
      isEnabled: true
    },
    network: {
      isEnabled: true,
      networkRequestSanitizer: () => {},
      networkResponseSanitizer: () => {}
    },
    dom: {
      isEnabled: true,
      inputSanitizer: false,
      textSanitizer: false,
      baseHref: null
    },
    shouldCaptureIP: true,
    rootHostname: null,
    shouldDebugLog: true,
    mergeIframes: false
  }
}

用法

LogRocket 在正確設定後會自動注入到您的應用程式中。預設情況下,此模組僅在 production 環境和客戶端事件中運作。

為了在您的應用程式中使用 LogRocket 注入的功能,您可以使用

const { $logRocket } = useNuxtApp()

請訪問 LogRocket 網站以獲取完整的功能列表:文件

Pinia

此模組會自動偵測 Pinia store 變動,並將它們附加到 LogRocket 會議。

此功能預設為啟用,可以將 enablePinia 選項設定為 false 來停用。

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: ['nuxt-logrocket'],

  logRocket: {
    id: '',
    enablePinia: false
  }
})

開發

  • 克隆此儲存庫
  • 使用 yarn install 安裝依賴套件
  • 使用 yarn run dev 啟動開發伺服器
  • 將瀏覽器指向 https://127.0.0.1:3000

授權條款

MIT 授權條款 - Alibaba Travels Co