Daandelange / kirby3-simplestats

All your data are belong to us. -- Track pageviews, referrers and devices on your Kirby 3 website.
MIT License
60 stars 7 forks source link

Page section blueprint : broken and js error thrown #38

Closed boguscode closed 8 months ago

boguscode commented 1 year ago

Hi,

got simplestats up and running to some extend, but when I try to implement the statistics in one of my blueprints, it throws this error, when I enter that particular blueprint in the panel

Cannot read properties of undefined (reading 'length')

My Blueprint uses tabs and goes like this:

title: MySite

tabs:
  stats:
    label: Stats
    icon: globe
    sections:
      pagestats:
        type: pagestats
        label: TestHeadline
        size: small
        showTotals: true
        showTimeline: true
        showLanguages: true
        showFullInfo: true

  content:
    label: Content
    icon: text
    columns:
      - width: 1/3
        fields:
          titlebar:
            label: Website Title
            type: text
          line1:
            type: line

I also enabled the panel view in my config php like this:

require_once(__DIR__ . '/../plugins/simplestats/src/models/SimpleStatsTimeFrameUtility.php');
return [
  // [...] your options ...

  // Simplestats
  'daandelange.simplestats.panel.enable' => true, // Disable the panel view completely
  'daandelange.simplestats.tracking.enableReferers' => true, // Disable referer tracking
  'daandelange.simplestats.tracking.timeFrameUtility' => new \daandelange\SimpleStats\SimpleStatsTimeFrameUtilityWeekly(), // Here you can put your custom inherited class from SimpleStatsTimeFrameUtility
  'daandelange.simplestats.tracking.timeFrameUtility' => 'weekly', // Alternative
  'daandelange.simplestats.tracking.method' => \daandelange\SimpleStats\SimpleStatsTrackingMode::OnImage,
];

can somebody give me a hint on what's wrong there?

Daandelange commented 1 year ago

Hi, this is not a configuration mistake but a bug, I think it has been fixed in https://github.com/Daandelange/kirby3-simplestats/commit/4bae997ac62d2aa0258d399b9530973ca95799fb, are you using master ?

My page blueprint stats tab is identical to yours, it looks correct.

boguscode commented 1 year ago

yes, 0.6.2-beta from the release page. Are the code changes already in there?

Daandelange commented 1 year ago

There have quite some changes since 0.6.2, while no release recently (gotta make one), you could try the master zip meanwhile.

boguscode commented 1 year ago

I tried master to no avail. the error keeps popping up :(

Daandelange commented 1 year ago

Sorry, I'm unable to reproduce the error, even with an empty database... could you show me the line from which the error is thrown from ? (the corresponding somevar.length and parts around it)

boguscode commented 1 year ago

I also tried deleting the db and starting anew. No luck.

from where do I get the somevar.length information you'll need? I'm not a programmer unfortunately. The eroor pops up in my panel.

Bildschirmfoto 2023-05-04 um 10 42 19

Daandelange commented 1 year ago

If you want to try :

  1. Open the developer tools of your browser.
  2. In the console area, locate the error that is shown on your screenshot, it will have a link to a file and a line. Click on it.
  3. Try to prettify that minimised code so it's easier to read using the {} button below the code viewer.
  4. Take screenshot of the code area. (you might need to click once again on the file link to highlight the correct line)
boguscode commented 1 year ago

there's a hole bunch of files involved

Bildschirmfoto 2023-05-04 um 12 29 19

Daandelange commented 1 year ago

Sorry, I didn't specify : you need the first one ;)

boguscode commented 1 year ago

It points me to this:

}, [t._v(t._s(t.$t("simplestats.visits.languagesovertime")))]), t.visitsOverTime.length > 0 ? s("area-chart", { attrs: { data: t.visitsOverTime, download: !0, download: "PageVisitsOverTime.png", xtitle: t.$t("simplestats.charts.time"), ytitle: t.$t("simplestats.charts.visits"), height: this.sectionSize == "small" ? "240px" : this.sectionSize == "large" ? "280px" : this.sectionSize == "tiny" ? "120px" : "260px", library: t.chartOptions }

Daandelange commented 1 year ago

Ok, I see, I have a local fix for it, but I just came to realise that the page stats section is not working anymore, I need to add timeline features to it and move the old charts to the new common one. It's probably been broken for a while :s I'll let you know when I have some progress on this.

boguscode commented 1 year ago

Thanks so much for your support!

CHE1RON commented 1 year ago

Bumping this, as it would be greatly increase its usefulness 😉

jonasholfeld commented 11 months ago

Hi! Is there a hot fix or a commit for this? Would love to try the plugin but can't get it to work because of the JS error... Thanks a lot!

Daandelange commented 11 months ago

Hello, sorry, no (hot)fix yet. I hope to address this somewhen soon. This said, without using the page section, the plugin should work, so you can test it partially. ;)

assbach commented 10 months ago

looking forward to the fix as well, :) Thank you!

Daandelange commented 9 months ago

Hi, I just pushed a new version with some improvements on this side. It should work on multi-language websites, I didn't really have the time to test anything in depth. Feel free to try. ;)

Daandelange commented 9 months ago

As of v0.6.5 it also works correctly in mono language setups, but the layout is still a draft.

Here's how it looks using 2 different blueprint setups :

It could be of great use to me if you could post a screenshot of how it looks with your custom blueprints, to compare different use cases.