Skip to content

Is it possible to use the plugin on the Server Side (NodeJS)? #5

Description

@jmaferreira

Declaring as:

const Analytics = require("analytics").default;
const plausiblePlugin = require("analytics-plugin-plausible").default;


const analytics = Analytics({
  app: "RODA Marketplace",
  plugins: [
    plausiblePlugin({
      domain: "...", 
      hashMode: false,
      trackLocalhost: false, 
      apiHost: "...", 
    }),
  ],
});

Tracking access as:

  analytics.page();

I get the following error when using on the server side:

(node:35700) UnhandledPromiseRejectionWarning: ReferenceError: location is not defined
    at getConfig (/Users/mferreira/git/roda-market/01-code/images/marketplace/node_modules/plausible-tracker/build/main/lib/tracker.js:42:91)
    at trackEvent (/Users/mferreira/git/roda-market/01-code/images/marketplace/node_modules/plausible-tracker/build/main/lib/tracker.js:44:72)
    at Object.trackPageview (/Users/mferreira/git/roda-market/01-code/images/marketplace/node_modules/plausible-tracker/build/main/lib/tracker.js:47:9)
    at Object.page (/Users/mferreira/git/roda-market/01-code/images/marketplace/node_modules/analytics-plugin-plausible/dist/plausible.js:53:31)
    at /Users/mferreira/git/roda-market/01-code/images/marketplace/node_modules/@analytics/core/dist/server/analytics-core.js:1:7850
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:35700) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions