Giter Site home page Giter Site logo

matomo-nodejs-tracker's People

Contributors

cherry avatar fhemberger avatar findus23 avatar frencil avatar gedankennebel avatar greenkeeperio-bot avatar michaelhidalgo avatar richie765 avatar strugee avatar tibianmod avatar toub avatar tsteur avatar yantze 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  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

matomo-nodejs-tracker's Issues

Support `send_image=0` and 204 response code

As per https://developer.matomo.org/api-reference/tracking-api:

send_image โ€” If set to 0 (send_image=0) Matomo will respond with a HTTP 204 response code instead of a GIF image. This improves performance and can fix errors if images are not allowed to be obtained directly (eg Chrome Apps). Available since Matomo 2.10.0

If this is currently set, the library treats the response as an error because it's not an explicit 200 response. 204s should probably also count as a success.

Add support for new Crash Analytics feature

To support Matomo's new Crash Analytics feature, we'd like to add crash tracking methods in all supported tracking SDKs.

The tracking methods should be similar to the PHP SDK's methods:

public function trackPhpThrowable(\Throwable $ex, $category = false); // deduces as much information as possible

public function trackCrash($message, $type, $category, $stack, $location, $line, $column); // user supplies all information

trackCrash() passes its parameters as the following HTTP API parameters:

  • $message: sent as cra, the crash message
  • $type: sent as cra_tp, the type of crash, for example "TypeError"
  • $category: sent as cra_ct (optional, it's like a custom dimension to categorise the crash, typically left empty)
  • $stack: sent as cra_st, a stack trace or similar
  • $location: (the originating source file) sent as cra_ru, the file name or source or something similar
  • $line: sent as cra_rl, the line number in the file
  • $column: sent as cra_rc, the column within the line of the file

IMPORTANT It must also pass ca=1 (stands for 'custom action') as a parameter so if the plugin is deactivated in Matomo, nothing will be tracked.

trackPhpThrowable (or the equivalent method for the language of this SDK) should accept an exception object and deduce set the crash tracking parameters based on it. The type should be set to the exception class name or something similar.

See also the implementation in the PHP tracker:

Please let me know if there are any questions.

Wrong Client IP

Hi,
It seems that the IP logged in Matomo is the IP of the server where the nodeJS app is running and not the client/visitor IP.
Is there any fix to this issue?

Thank you.

<!edit>
OK, I just read a comment of @Findus23 on another issue that say :

Technically the tracker is only intended for use in NodeJS

Does it means that matomo-nodejs-tracker is not intended to replace the javascript code?
</!edit>

Compatibility with Matomo 4

Hi there,

this issue refs matomo-org/matomo#16397 (comment)

in Matomo 4 we're changing the structure of the visitor cookie. I don't know if this SDK reads the cookie of a visitor if one is set?

In the PHP tracker we had to make this change because of it https://github.com/matomo-org/matomo-php-tracker/pull/79/files#diff-cd22a4ca6eb55e6a5ad813334624ed89L1370-L1840

The cookie was changed in https://github.com/matomo-org/matomo/pull/15774/files#diff-1279d666063b65e6d6777f902d11574fR3322-R3330

It used to contain 6 indexes (newVisitor, uuid, createTs, visitCount, currentVisitTs, lastVisitTs) but now contains only indexes:
Slot 0: newVisitor
Slot 1: uuid
Slot 2: createTs

Basically, if this tracker does read the cookie, then the tracker needs to be changed to only read the first to slots from the cookie (cookieVisitorId and createTs) see https://github.com/matomo-org/matomo-php-tracker/pull/79/files#diff-cd22a4ca6eb55e6a5ad813334624ed89L1370-L1840

All other information from the cookie list visit count, currentVisitTs, lastVisitTs is no longer needed in Matomo 4.

piwik-tracker can't support Protocol:https: not supported.

Error: Protocol:https: not supported.
at Object.exports.request (http.js:1840:11)
at Object.exports.get (http.js:1847:21)
at PiwikTracker.track (/Users/dxiao/Documents/Code/nodejs-cantas/node_modules/piwik-tracker/index.js:58:18)
at repl:1:7
at REPLServer.self.eval (repl.js:110:21)
at repl.js:249:20
at REPLServer.self.eval (repl.js:122:7)
at Interface. (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)

Cannot send search events

Hello,

I want to send "search" tracking events from a nodeJS backend.

Using trackBulk, I send events with _id, cdt, e_c, e_a, e_n, e_v successfully (and see them reported in the Matomo web app).

However when sending _id, cdt, search, search_cat, search_count, I see nothing in the "Site search" section of the Matomo web app, whereas site search is enabled for my site.

Am I missing something?

custom ip?

my own ip is the ip where all the requests come from. how can i change that?

Unable to determine the domain name

Issue: I'm getting the error.
Unable to determine the domain name -- TypeError [ERR_INVALID_DOMAIN_NAME]: Unable to determine the domain name\n at new ClientRequest (_http_client.js:71:13)\n at request (http.js:42:10)\n at Object.get (http.js:46:13)\n at MatomoTracker.track (/.../node_modules/matomo-tracker/index.js:72:24)\n at MatomoLinkService.track (/.../matomo-link.service.js:23:21)\n at new MatomoLinkService (/.../matomo-link.service.js:20:14)\n at Injector.instantiateClass (/.../node_modules/@nestjs/core/injector/injector.js:289:19)\n at callback (/.../node_modules/@nestjs/core/injector/injector.js:76:41)\n at process._tickCallback (internal/process/next_tick.js:68:7)\n at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)"}

Expect: I send track event to matomo dashboard

My code:

import { Injectable } from '@nestjs/common';
import * as MatomoTracker from 'matomo-tracker';

@Injectable()
export class MatomoLinkService {
    private matomoUrl = process.env.MATOMO_URL || 'example.de';
    private matomoId = process.env.MATOMO_ID || '1';
    private matomoTracker: MatomoTracker;
    matomo;
    constructor() {
        this.matomo = new MatomoTracker(this.matomoId, this.matomoUrl, true);
        console.log('this.matomo ==== ', this.matomo);
        this.track({});
    }

    track(event: object): void {
        this.matomo.track('Test 2');
    }
}
`

Console.log info:

this.matomo ====  MatomoTracker {
  domain: null,
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  siteId: '1',
  trackerUrl: 'example.de',
  agent:
   { _connectionListener: [Function: connectionListener],
     METHODS:
      [ 'ACL',
        'BIND',
        'CHECKOUT',
        'CONNECT',
        'COPY',
        'DELETE',
        'GET',
        'HEAD',
        'LINK',
        'LOCK',
        'M-SEARCH',
        'MERGE',
        'MKACTIVITY',
        'MKCALENDAR',
        'MKCOL',
        'MOVE',
        'NOTIFY',
        'OPTIONS',
        'PATCH',
        'POST',
        'PROPFIND',
        'PROPPATCH',
        'PURGE',
        'PUT',
        'REBIND',
        'REPORT',
        'SEARCH',
        'SOURCE',
        'SUBSCRIBE',
        'TRACE',
        'UNBIND',
        'UNLINK',
        'UNLOCK',
        'UNSUBSCRIBE' ],
     STATUS_CODES:
      { '100': 'Continue',
        '101': 'Switching Protocols',
        '102': 'Processing',
        '103': 'Early Hints',
        '200': 'OK',
        '201': 'Created',
        '202': 'Accepted',
        '203': 'Non-Authoritative Information',
        '204': 'No Content',
        '205': 'Reset Content',
        '206': 'Partial Content',
        '207': 'Multi-Status',
        '208': 'Already Reported',
        '226': 'IM Used',
        '300': 'Multiple Choices',
        '301': 'Moved Permanently',
        '302': 'Found',
        '303': 'See Other',
        '304': 'Not Modified',
        '305': 'Use Proxy',
        '307': 'Temporary Redirect',
        '308': 'Permanent Redirect',
        '400': 'Bad Request',
        '401': 'Unauthorized',
        '402': 'Payment Required',
        '403': 'Forbidden',
        '404': 'Not Found',
        '405': 'Method Not Allowed',
        '406': 'Not Acceptable',
        '407': 'Proxy Authentication Required',
        '408': 'Request Timeout',
        '409': 'Conflict',
        '410': 'Gone',
        '411': 'Length Required',
        '412': 'Precondition Failed',
        '413': 'Payload Too Large',
        '414': 'URI Too Long',
        '415': 'Unsupported Media Type',
        '416': 'Range Not Satisfiable',
        '417': 'Expectation Failed',
        '418': 'I\'m a Teapot',
        '421': 'Misdirected Request',
        '422': 'Unprocessable Entity',
        '423': 'Locked',
        '424': 'Failed Dependency',
        '425': 'Unordered Collection',
        '426': 'Upgrade Required',
        '428': 'Precondition Required',
        '429': 'Too Many Requests',
        '431': 'Request Header Fields Too Large',
        '451': 'Unavailable For Legal Reasons',
        '500': 'Internal Server Error',
        '501': 'Not Implemented',
        '502': 'Bad Gateway',
        '503': 'Service Unavailable',
        '504': 'Gateway Timeout',
        '505': 'HTTP Version Not Supported',
        '506': 'Variant Also Negotiates',
        '507': 'Insufficient Storage',
        '508': 'Loop Detected',
        '509': 'Bandwidth Limit Exceeded',
        '510': 'Not Extended',
        '511': 'Network Authentication Required' },
     Agent:
      { [Function: Agent] super_: [Function], defaultMaxSockets: Infinity },
     ClientRequest: { [Function: ClientRequest] super_: [Function] },
     IncomingMessage: { [Function: IncomingMessage] super_: [Function] },
     OutgoingMessage: { [Function: OutgoingMessage] super_: [Function] },
     Server: { [Function: Server] super_: [Function] },
     ServerResponse: { [Function: ServerResponse] super_: [Function] },
     createServer: [Function: createServer],
     get: [Function: get],
     request: [Function: request],
     maxHeaderSize: [Getter],
     globalAgent: [Getter/Setter] } }

`

Basic Query

Hi,

Sorry for posting this here but couldn't find a place to ask this question.

I am running a Node js express service where I want to report a certain action under a route.

  1. I installed the package.
  2. initialised the site ID. (I basically copied the site and ID from the javascript tracking code which gets displayed on the front page of the matomo home page).
  3. Now, inside the route, where a certain action successfully performed, I entered the matomo.track('URL to Track');

When I run the express service and called the route, nothing happened and also no errors. But I cannot see the tracking info coming after the trigger.

Is it possible to just report to matomo that a particular action inside a route is successfully executed? I don't want to track the route but from the route, i want to talk to matomo that a certain action is completed. Is is possible to do this with this package?

It will be great if you could help me with this. I am very new to matomo.

Import error: TypeError: Vn is not a constructor

Due to our build-pipeline we can't use require to include the module. Using require it would't get bundled into the final build.

If we try to use import (import * as MatomoTracker from "matomo-tracker"; ) we can bundle it correctly but it throws an error on runtime: TypeError: Vn is not a constructor

Is there anything we can do?

Thanks a lot

Fails to build when imported in Create React App

I ran into this build error deploying to heroku once I added this tracker:

Failed to minify the code from this file: 
 	./node_modules/matomo-tracker/index.js:96 
Read more here: http://bit.ly/2tRViJ9

I just copied the code into my src directory for now, but would be nice if this package was published pre-compiled.

self signed certificate

Currently I get the error self signed certificate. My matomo uses a self-signed cert and I've had trouble setting up letsencrypt on it. Is this the library complaining or Matomo itself?

Support new `ca` tracking parameter for tracking requests that aren't page views

See matomo-org/matomo#16569 to learn more about the problem it fixes and visit https://developer.matomo.org/api-reference/tracking-api for more documentation about the new ca parameter.
Basically, we should be sending &ca=1 along any tracking request that isn't a page view. Practically, we should for now only send &ca=1 along any event and content tracking requests.

The parameter isn't required but it helps for more accurate tracking for edge cases where a user suddenly disables eg an event, goal or ecommerce plugin but still keeps sending these requests. If the parameter is not sent, Matomo would turn the tracking request into a page view and track a page view even though the tracking request should be ignored.

Let me know if there are any questions about this.

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.