Code Monkey home page Code Monkey logo

plausible's People

Contributors

atinux avatar barbapapazes avatar danielroe avatar hymair avatar johannschopplich avatar maximepvrt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

plausible's Issues

Waiting for first pageview

Hi there,
I have the module installed, but Im getting this on the dashboard,

Do I need to add the snippet as well? Or is it something that the module should handle?

<script defer data-domain="alvarosaburido.dev" src="https://plausible.io/js/script.js"></script>

Thanks

Screenshot 2022-11-30 at 20 06 48

Vercel proxy counts every click as unique user

When using this module and proxy the requests like advised in the documentation of plausible, it counts users x times as unique.

my configs:

plausible: {
    apiHost: "",
    trackLocalhost: false,
    autoOutboundTracking: false,
},
"rewrites": [
    {
      "source": "/js/script.js",
      "destination": "https://analytics.mydomain.de/js/plausible.js"
    },
    {
      "source": "/api/event",
      "destination": "https://analytics.mydomain.de/api/event"
    }
]

Could be initiated on demand

Due to the GDPR in Europe, it would be nice to have a way to no auto initiate the plugin until the user accepts the GDPR/Cookie Consent.

Is there a possibility to do it?

Should/Could I try to do a PR?

Thanks in advance

Remove `utm` tracking query on page load

Hello,

I'm not sure if this feature must be here of within the plausible analytics but could be nice to remove utm query in order to avoid users to share links with a wrong query.

useTrackEvent not found

Hello,

I'm trying to use useTrackEvent in my Nuxt package (which is based on Nuxt Module, inside my turborepo monorepo to be shared between my differents Nuxt3 apps).

I got this error: Cannot find name 'useTrackEvent'. in vscode but also in CLI.

How can i import this composable to fix the typing? From where?

Thank's in advance.

Encountered Issue with Plausible Analytics Integration in Nuxt 3 during Testing

We've encountered an issue integrating Plausible Analytics in a Nuxt 3 application, specifically during testing with vitest. Despite following documentation and trying various mocking strategies, we're unable to successfully mock useTrackPageview and related functionalities for our unit tests. This results in tests failing due to Nuxt instance availability errors or incorrect mock implementations.

Steps to Reproduce

  • Integrate Plausible Analytics in a Nuxt 3 application.
  • Implement unit testing for components or functionalities utilizing Plausible's useTrackPageview or useTrackEvent.
  • Attempt to mock Plausible's functionalities using Vitest.

Expected Behavior

Mocks for Plausible's useTrackPageview and useTrackEvent should correctly simulate their functionalities, allowing for successful execution of unit tests without encountering Nuxt instance availability errors.

Actual Behavior

Tests fail with errors related to Nuxt instance availability or incorrect mock implementations. Specifically, we encountered errors like [nuxt] instance unavailable when trying to mock useTrackPageview.
Tried Solutions

Mocking @nuxtjs/plausible and #app (for useNuxtApp) globally in our Vitest setup file.
Adjusting mock implementations to closely match the signatures and behaviors of Plausible's functions.
Ensuring mocks for $plausible are included as part of the object returned by useNuxtApp.

Despite these efforts, the issue persists, indicating a potential gap in documentation or support for this specific use case.
Additional Context

Nuxt 3 version: 3.4.14
Vitest version: 1.2.2
@nuxtjs/plausible version: 0.2.4

Relevant configuration snippets and code samples:
// @vitest-environment happy-dom
import { describe, it, expect, vi } from "vitest";
import { mount } from "@vue/test-utils";
import { useHead } from "@unhead/vue";
import NewMessage from "@/pages/m/new.vue";
import type { PlausibleOptions, EventOptions } from "plausible-tracker";

// Mock Nuxt 3 app
vi.mock("#app", () => ({
  useNuxtApp: vi.fn(() => ({
    $config: {},
    $plausible: {
      trackLocalhost: false,
      autoPageviews: false,
      autoOutboundTracking: true,
      trackPageview: vi.fn(
        (eventData?: PlausibleOptions, options?: EventOptions) => {}
      ),
      trackEvent: vi.fn(
        (
          eventName: string,
          options?: EventOptions,
          eventData?: PlausibleOptions
        ) => {}
      ),
    },
  })),
}));

// Mock for @nuxtjs/plausible
vi.mock("@nuxtjs/plausible", () => ({
  useTrackPageview: vi.fn(
    (eventData?: PlausibleOptions, options?: EventOptions) => {}
  ),
  useTrackEvent: vi.fn(
    (
      eventName: string,
      options?: EventOptions,
      eventData?: PlausibleOptions
    ) => {}
  ),
}));

// Mock for useHead
vi.mock("@unhead/vue");
vi.mocked(useHead).mockImplementation(vi.fn());

describe("Creating NewMessage", () => {
  const wrapper = mount(NewMessage);

  it("renders without crashing", () => {
    expect(wrapper.exists()).toBe(true);
  });

  it("displays warning message when the textarea max limits reach", async () => {
    const textarea = wrapper.find("textarea");
    await textarea.setValue("0".repeat(256));
    expect(wrapper.find(".warning").exists()).toBe(true);
    expect(wrapper.find(".warning").text()).toBe("0 characters left.");
  });
});

Test Result:

 FAIL  tests/pages/m/new.spec.ts [ tests/pages/m/new.spec.ts ]
Error: [nuxt] instance unavailable
 โฏ Module.useNuxtApp node_modules/nuxt/dist/app/nuxt.js:218:13
    216|   Object.defineProperty(obj, key, { get: () => val });
    217| }
    218| export function defineAppConfig(config) {
       |             ^
    219|   return config;
    220| }
 โฏ Module.useTrackPageview node_modules/@nuxtjs/plausible/dist/runtime/composables/useTrackPageview.mjs:6:27

Request

Guidance on correctly mocking Plausible Analytics for unit tests in a Nuxt 3 application, or any updates to the documentation or package that could help address this issue.

Thank you

Question: Usage without `autoPageviews: true`

Hi there! I wanted to use Plausible in a Nuxt project and exclude some of my routes from being automatically tracked as pageview.

Since this is currently not possible with the plausible-tracker, I thought of setting autoPageviews: false and manually tracking them, excluding the paths I don't want to manually.

But where would be the best option to do that? In a Nuxt client middleware? Or in a route watcher in app.vue? Or maybe the page:finish hook? From the implementation of this nuxt module, it wasn't super clear for me on how to do it.

Appreciate your input!

Issues with `.env` in Docker image build

Hej Plausible Team,

I'm curious that I am totally missunderstanding your doc's but I'm currently running into issues with my .env setup.

Currently following is the base:

.env
NUXT_PUBLIC_PLAUSIBLE_DOMAIN="webpage.com" NUXT_PUBLIC_PLAUSIBLE_API_HOST="https://plausible.webpage.com" //just examples
.env is placed in project's root. Other variables in .env file are working well like

NUXT_PUBLIC_SUPABASE_URL="" NUXT_PUBLIC_SUPABASE_KEY=""

in nuxt.config.ts (also root of the project)

modules: [
[...],
"@nuxtjs/plausible",
],

I tried different approaches like:

plausible: { domain: process.env.NUXT_PLAUSIBLE_DOMAIN, apiHost: process.env.NUXT_PLAUSIBLE_API_HOST, },

or accessing via runtimeConfig:

runtimeConfig: { public: { PLAUSIBLE_DOMAIN: process.env.NUXT_PUBLIC_PLAUSIBLE_DOMAIN, PLAUSIBLE_API_HOST: process.env.NUXT_PUBLIC_PLAUSIBLE_API_HOST, }, },

or even both combined.

If I place the URL and apiHost hardcoded in the plausible section it works fine. If I run my application with

yarn run start

Also fine (will be set in nuxt.public plausible section) ain't tracking because of settings to ignore localhost.

Building the docker image on server, it runs. Going trough a Gitlab Pipleline, these values are setted to default.

Please Can you help me?

Best Regards,

Chris

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.