|
47 | 47 |
|
48 | 48 | // register event function |
49 | 49 | const endpoint = script.getAttribute("data-endpoint") || "/pirsch/event"; |
| 50 | + const disableQueryParams = script.hasAttribute("data-disable-query"); |
| 51 | + const disableReferrer = script.hasAttribute("data-disable-referrer"); |
| 52 | + const disableResolution = script.hasAttribute("data-disable-resolution"); |
| 53 | + |
50 | 54 | window.pirsch = function (name, options) { |
51 | 55 | if (typeof name !== "string" || !name) { |
52 | 56 | return Promise.reject("The event name for Pirsch is invalid (must be a non-empty string)! Usage: pirsch('event name', {duration: 42, meta: {key: 'value'}})"); |
|
62 | 66 | } |
63 | 67 |
|
64 | 68 | if (navigator.sendBeacon(endpoint, JSON.stringify({ |
65 | | - url: location.href.substring(0, 1800), |
| 69 | + url: disableQueryParams ? (location.href.includes('?') ? location.href.split('?')[0] : location.href).substring(0, 1800) : location.href.substring(0, 1800), |
66 | 70 | title: document.title, |
67 | | - referrer: document.referrer, |
68 | | - screen_width: screen.width, |
69 | | - screen_height: screen.height, |
| 71 | + referrer: (disableReferrer ? '' : document.referrer), |
| 72 | + screen_width: (disableResolution ? 0 : screen.width), |
| 73 | + screen_height: (disableResolution ? 0 : screen.height), |
70 | 74 | event_name: name, |
71 | 75 | event_duration: options && options.duration && typeof options.duration === "number" ? options.duration : 0, |
72 | 76 | event_meta: meta |
|
0 commit comments