diff --git a/.gitignore b/.gitignore index 2564286..759bce6 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ lib-cov coverage # Compiled binary addons (https://nodejs.org/api/addons.html) -dist/ artifacts/ work/ ci/ diff --git a/dist/LICENSE b/dist/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/dist/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/dist/MANIFEST.txt b/dist/MANIFEST.txt new file mode 100644 index 0000000..d21dec8 --- /dev/null +++ b/dist/MANIFEST.txt @@ -0,0 +1,33 @@ + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA512 + +{ + "manifestVersion": "2.0.0", + "signatureType": "community", + "signedByOrg": "macropower", + "signedByOrgName": "macropower", + "plugin": "macropower-analytics-panel", + "version": "2.0.0", + "time": 1618977662447, + "keyId": "7e4d0c6a708866e7", + "files": { + "img/logo.svg": "c82a984188d30c5d543c14465adf52601332db4579dd7fcf966d2bd8be933549", + "LICENSE": "189b1af95d661151e054cea10c91b3d754e4de4d3fecfb074c1fb29476f7167b", + "module.js": "a44815fc041ed1b5d263b58c22d37582da8d2204b90647a643289cbab2b14959", + "module.js.LICENSE.txt": "0d8f66cd4afb566cb5b7e1540c68f43b939d3eba12ace290f18abc4f4cb53ed0", + "module.js.map": "2c15bedfcb520025f178aa4e3073b33e5420765288048d8dccd052733ca06651", + "plugin.json": "b495cb51268e84649c0922b3158866eeac053c0b0111548e3d9bd075f2697351", + "README.md": "510152e8c4b00ca40f7a66441d57acd978285d23e3e2a00bc06f91a2a3c5d49f" + } +} +-----BEGIN PGP SIGNATURE----- +Version: OpenPGP.js v4.10.1 +Comment: https://openpgpjs.org + +wqEEARMKAAYFAmB/o34ACgkQfk0ManCIZuf9ZQIGNmIgY9htjiwPhKMzfwpb +hxBW79nJPMs2CuyJng2vlM64ouKKzNdp85/58jH6JlxgS/Xe3D93VOzbOLB1 +2goOstICCQEh4Klgr0MP3toFAE22ImmdK60PAjoTCzwa4Yd7GBCiLQOnTcaV +jNjL63jkQEo9jMIEg1MB95YQCg1tMc29o/+ylw== +=qQjv +-----END PGP SIGNATURE----- diff --git a/dist/README.md b/dist/README.md new file mode 100644 index 0000000..ec81431 --- /dev/null +++ b/dist/README.md @@ -0,0 +1,105 @@ +# macropower-analytics-panel + +[![Downloads](https://img.shields.io/badge/dynamic/json?color=green&label=downloads&query=%24.downloads&url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins%2Fmacropower-analytics-panel)](https://grafana.com/grafana/plugins/macropower-analytics-panel) +![Grafana Dependency](https://img.shields.io/badge/dynamic/json?color=orange&label=grafana%20dependency&query=%24.json.dependencies.grafanaDependency&url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins%2Fmacropower-analytics-panel) +![Version](https://img.shields.io/badge/dynamic/json?color=blue&label=version&query=%24.version&url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins%2Fmacropower-analytics-panel) +![Updated](https://img.shields.io/badge/dynamic/json?color=lightgray&label=updated&query=%24.json.info.updated&url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins%2Fmacropower-analytics-panel) + +Grafana panel that lets you measure dashboard utilization. It's like Google Analytics, but for Grafana dashboards! + +## Features + +Have you ever found yourself wanting to know who is using your dashboards, or how much they are being used? + +Have you ever asked yourself questions like, "Who should I be catering to" or "What data should I be focusing on"? + +Analytics panel extends your dashboards by giving you full control of your user's session data, letting you gather details such as: + +- Timestamps +- Session duration +- Tab focused state +- Selected variables +- Username +- User roles +- Dashboard Name/ID +- Instance info + +## Getting Started + +You'll need to complete a few tasks to get up and running. + +1. [Install the plugin](https://grafana.com/grafana/plugins/macropower-analytics-panel/?src=tw&tab=installation) +2. [Select, configure, and run a server](#running-a-server) +3. [Configure the panel](#configuring-the-panel) +4. [Hide the panel](#hiding-the-panel) (optional) + +### Running a Server + +This plugin works by harvesting information about a user's session and the current environment, and forwarding that data as JSON to an endpoint of your choice. + +**To use this plugin, you must run a server to receive and store/emit data.** There are a few different options to choose from, and they may each require different panel settings. Please refer to each of the linked servers' repos for more information. + +This plugin's [example](https://github.com/MacroPower/macropower-analytics-panel/tree/master/example) directory has a few docker-compose files that should help you get started, however we do not have them for every server (contributions welcome). + +#### Default + +Included in this plugin's repo is a simple [Go server](https://github.com/MacroPower/macropower-analytics-panel/tree/master/server) that requires no external dependencies. It can expose data to systems supporting the OpenMetrics standard (e.g. Prometheus, InfluxDB 2.0) and/or your logging system of choice via stdout (e.g. Loki). + +Get started or test this option with `docker-compose -f example/server/docker-compose.yaml up` + +#### analytics-panel-listener + +[@jtommi](https://github.com/jtommi) maintains [analytics-panel-listener](https://github.com/jtommi/analytics-panel-listener), a service that listens for this plugin's payloads and stores them in MongoDB. + +#### Telegraf + +You can use Telegraf's `http_listener_v2` input to accept data from this plugin. An example configuration for this input can be found in the [example](https://github.com/MacroPower/macropower-analytics-panel/tree/master/example) directory. This example requires you to enable "flatten" in the plugin's settings. You can tweak this configuration to send data to any of Telegraf's many outputs. + +Get started or test this option with `docker-compose -f example/telegraf/docker-compose.yaml up` + +#### Logstash / Fluentd / etc + +Most modern logging pipelines (e.g. [Fluentd](https://docs.fluentd.org/input/http), [Logstash](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http.html)) should support ingesting data from this plugin. You can either use the [default server](#default) and ship logs from its output, or create an http listener to accept this plugin's JSON payloads. If you use either of these or some other system, please consider making a contribution by including your config in this plugin's [examples](https://github.com/MacroPower/macropower-analytics-panel/tree/master/example) directory. + +#### Custom + +You can design a your own service to accept payloads provided by the plugin, and transform / store data as you see fit. If you do this, please consider open sourcing your work and telling me about it in an issue, so that I can include a link to your work here. + +### Configuring the Panel + +Once you have a server running, you must place its endpoint in the plugin's settings. For example, if you use the default server, the endpoint would be `http://your-server-name:your-port/write`. + +There are several other options which all provide descriptions in the Grafana UI. Please read them, and take note of any requirements in your server's documentation (for instance, using Telegraf is much more simple if you enable flatten, but most other servers will require flatten to be disabled). + +This plugin works by using the session data provided to every panel in your dashboard. As such, you will need to ensure that analytics-panel is being loaded every time a dashboard you wish to monitor is being loaded. This means that you should place this panel in part of the dashboard that is guaranteed to be loaded by the user when they visit your dashboard. As of right now, **the only place that you absolutely _cannot_ place analytics-panel is inside a row**, as expanding and collapsing the row is essentially the same as loading and unloading the entire dashboard, from any panel's perspective. + +### Hiding the Panel + +While you cannot place the panel inside a row, you can take several steps to make the panel very difficult to notice, and this will not have any negative effects on the plugin's behavior. + +- In Visualization, set Hidden to True. +- In General Settings, set Transparent to True. +- In General Settings, set Title/Description to nothing. Alternatively, you can set a Title/Description and use this panel as a title, separator, or footer. +- Save and make the panel as small as you want. I found that 0 height, 100% width works well. + +## Default Settings + +If you are planning on including this panel on many or all of your dashboards, you may want to consider changing the default settings for analytics-panel. This can save you time, since you will not need to input the same endpoint and/or toggle some setting every time you add a new panel. + +You can edit defaults by doing the following: + +- Edit the `src/defaults.json` file. +- Run `npm run build` to generate an updated dist. +- Sign with a [private signature](https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/#sign-a-private-plugin) (optional). +- Copy the updated plugin to your plugins directory. +- Restart Grafana. + +Note that changing defaults will not change existing panels. Defaults are _copied_ to the dashboard when the panel is added. + +## Troubleshooting + +If something is not working properly, the first thing you should do is look at your browser's console and network inspector. After opening the inspector, load a dashboard with an analytics-panel and take a look at the console, the request, and the response. In most cases, problems should be evident here. + +In the event that you have many panels scattered across many dashboards, and suspect that some panels may be experiencing issues, you can sort your dashboards by "Errors Total - Most", or one of its variants. Note that errors are not thrown if JSON data is visible. + +If you run into an issue you cannot solve, please post an [issue](https://github.com/MacroPower/macropower-analytics-panel/issues) and I will do my best to look into your inquiry. diff --git a/dist/img/logo.svg b/dist/img/logo.svg new file mode 100644 index 0000000..ec11f53 --- /dev/null +++ b/dist/img/logo.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/dist/module.js b/dist/module.js new file mode 100644 index 0000000..de61752 --- /dev/null +++ b/dist/module.js @@ -0,0 +1,3 @@ +/*! For license information please see module.js.LICENSE.txt */ +define(["react","@grafana/runtime","@grafana/ui","@grafana/data"],(function(t,e,n,a){return function(t){var e={};function n(a){if(e[a])return e[a].exports;var o=e[a]={i:a,l:!1,exports:{}};return t[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,a){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(a,o,function(e){return t[e]}.bind(null,o));return a},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=6)}([function(t){t.exports=JSON.parse('{"endpoint":"http://localhost:8080/write","dashboard":"$__dashboard","showDetails":true,"postStart":true,"postHeartbeat":false,"heartbeatInterval":60,"heartbeatAlways":false,"postEnd":false,"flatten":false}')},function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e){t.exports=a},function(t,e){function n(t){return t&&t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function a(t){return t}function o(t,e){const o=(e=e||{}).delimiter||".",r=e.maxDepth,i=e.transformKey||a,s={};return function t(a,l,u){u=u||1,Object.keys(a).forEach((function(d){const c=a[d],p=e.safe&&Array.isArray(c),f=Object.prototype.toString.call(c),h=n(c),y="[object Object]"===f||"[object Array]"===f,v=l?l+o+i(d):i(d);if(!p&&!h&&y&&Object.keys(c).length&&(!e.maxDepth||u0&&(o=d(a.shift()),c=d(a[0]))}p[o]=t(e[n],r)})),u}},function(t,e,n){"use strict";n.r(e);var a=n(4),o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var r=function(){return(r=Object.assign||function(t){for(var e,n=1,a=arguments.length;n1&&void 0!==arguments[1]?arguments[1]:0,n=(y[t[e+0]]+y[t[e+1]]+y[t[e+2]]+y[t[e+3]]+"-"+y[t[e+4]]+y[t[e+5]]+"-"+y[t[e+6]]+y[t[e+7]]+"-"+y[t[e+8]]+y[t[e+9]]+"-"+y[t[e+10]]+y[t[e+11]]+y[t[e+12]]+y[t[e+13]]+y[t[e+14]]+y[t[e+15]]).toLowerCase();if(!h(n))throw TypeError("Stringified UUID is invalid");return n};var m=function(t,e,n){var a=(t=t||{}).random||(t.rng||p)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,e){n=n||0;for(var o=0;o<16;++o)e[n+o]=a[o];return e}return b(a)},g=n(2);function w(t){return"/dashboard/new"===t}function O(t){if(!w(t)){var e=t.split("/");if(e&&e.length>2)return e[2]}return""}function S(t){return Math.floor(t/1e3)}function j(t){try{new URL(t)}catch(t){return!1}return!0}function I(t){var e=t.status.toString();if(!/^(0)|(20[0-4])$/.test(e))throw new Error("Returned status "+e);return t}function P(t){var e=Object(g.getTemplateSrv)();return{server:e.replace(t.server),dashboardName:e.replace(t.dashboard),variables:e.getVariables().map((function(t){var e,n,a=t,o=!1,r=null===(e=null==a?void 0:a.current)||void 0===e?void 0:e.value;return"string"==typeof r&&""!==r?r=[r]:Array.isArray(r)?o=!0:r=[],{name:t.name,label:null!==(n=t.label)&&void 0!==n?n:"",type:t.type,multi:o,values:r}}))}}function x(t,e,n,a,o,r,i,s){var l,u,d,c,p,f,h,y,v,b,m,w,j,I,P,x,E,_,N,A,T,V=S((new Date).getTime()),D=g.config.buildInfo,F={version:null!==(l=D.version)&&void 0!==l?l:"",commit:null!==(u=D.commit)&&void 0!==u?u:"",env:null!==(d=D.env)&&void 0!==d?d:"",edition:null!==(c=D.edition)&&void 0!==c?c:""},H=g.config.licenseInfo,k={hasLicense:null!==(p=H.hasLicense)&&void 0!==p&&p,expiry:null!==(f=H.expiry)&&void 0!==f?f:0,stateInfo:null!==(h=H.stateInfo)&&void 0!==h?h:""},R={hostname:i.hostname,port:i.port,protocol:i.protocol,buildInfo:F,licenseInfo:k},C={name:r,uid:O(i.pathname)},B=S(window.performance.timeOrigin),J=g.config.bootData.user,U={isSignedIn:null!==(y=J.isSignedIn)&&void 0!==y&&y,id:null!==(v=J.id)&&void 0!==v?v:0,login:null!==(b=J.login)&&void 0!==b?b:"",email:null!==(m=J.email)&&void 0!==m?m:"",name:null!==(w=J.name)&&void 0!==w?w:"",lightTheme:null!==(j=J.lightTheme)&&void 0!==j&&j,orgCount:null!==(I=J.orgCount)&&void 0!==I?I:0,orgId:null!==(P=J.orgId)&&void 0!==P?P:0,orgName:null!==(x=J.orgName)&&void 0!==x?x:"",orgRole:null!==(E=J.orgRole)&&void 0!==E?E:"",isGrafanaAdmin:null!==(_=J.isGrafanaAdmin)&&void 0!==_&&_,timezone:null!==(N=J.timezone)&&void 0!==N?N:"",locale:null!==(A=J.locale)&&void 0!==A?A:"",hasEditPermissionInFolders:null!==(T=J.hasEditPermissionInFolders)&&void 0!==T&&T};return{uuid:t,type:e,hasFocus:window.document.hasFocus(),options:n,host:R,dashboard:C,user:U,variables:s,timeRange:a,timeZone:o,timeOrigin:B,time:V}}var E=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.state=r({uuid:"",location:JSON.parse(JSON.stringify(window.location))},P(e.props.options.analyticsOptions)),e.getPayloadOrFlatPayload=function(t,n){var a=e.props.options.analyticsOptions,o=e.props.timeRange,r=x(t,n,a,{from:o.from.unix(),to:o.to.unix(),raw:o.raw},e.props.timeZone,e.state.dashboardName,e.state.location,e.state.variables);return a.flatten?Object(d.flatten)(r):r},e.sendPayload=function(t){e.setState({error:void 0});var n="";"start"===t?(n=m(),e.setState({uuid:n})):n=e.state.uuid;var a=e.state,o=a.server;if(w(a.location.pathname)){var r=new Error("Dashboard is new and unsaved, and thus no ID was found.");e.setState({error:r})}else if(j(o))fetch(o,{method:"POST",mode:"no-cors",body:JSON.stringify(e.getPayloadOrFlatPayload(n,t)),headers:{"Content-Type":"application/json"},keepalive:!0}).then((function(t){return I(t)})).catch((function(t){e.setState({error:t})}));else{r=new Error('"'+o+'" is not a valid URL.');e.setState({error:r})}},e.sendHeartbeat=function(){(e.props.options.analyticsOptions.heartbeatAlways||window.document.hasFocus())&&e.sendPayload("heartbeat")},e.shouldSetVars=function(t,n,a){return t!==e.state.server||n!==e.state.dashboardName||JSON.stringify(a)!==JSON.stringify(e.state.variables)},e.setHeartbeat=function(){var t=e.state.interval,n=e.props.options.analyticsOptions,a=n.postHeartbeat,o=n.heartbeatInterval,r=1e3*o,i=e.state.intervalFrequency;if(a||void 0===t){if(a&&void 0===t){var s=setInterval(e.sendHeartbeat,r);e.setState({interval:s,intervalFrequency:o})}else if(i&&i!==o){void 0!==t&&clearInterval(t);s=setInterval(e.sendHeartbeat,r);e.setState({interval:s,intervalFrequency:o})}}else clearInterval(t),e.setState({interval:void 0,intervalFrequency:void 0})},e}return function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.componentDidMount=function(){this.props.options.analyticsOptions.postStart&&this.sendPayload("start"),this.setHeartbeat()},e.prototype.componentDidUpdate=function(){var t=P(this.props.options.analyticsOptions);this.shouldSetVars(t.server,t.dashboardName,t.variables)&&this.setState(r({},t)),this.setHeartbeat()},e.prototype.componentWillUnmount=function(){this.props.options.analyticsOptions.postEnd&&this.sendPayload("end");var t=this.state.interval;void 0!==t&&clearInterval(t)},e.prototype.render=function(){var t=this,e=this.props,n=e.width,a=e.height,o=this.props.options.analyticsOptions.showDetails,r=this.state,i=r.error,s=r.uuid;if(i&&!o)throw i;return l.a.createElement("div",{style:{position:"relative",overflow:"auto",width:n,height:a}},i&&l.a.createElement("div",{style:{display:"inline-block",textAlign:"center",width:"100%"}},l.a.createElement(u.ErrorWithStack,{title:"analytics-panel error",error:i,errorInfo:null}),l.a.createElement(u.Button,{onClick:function(){return t.sendPayload("start")}},"Retry")),o&&l.a.createElement(u.JSONFormatter,{json:this.getPayloadOrFlatPayload(s,"start")}))},e}(s.PureComponent),_=n(0);n.d(e,"plugin",(function(){return N}));var N=new a.PanelPlugin(E).setPanelOptions((function(t){t.addTextInput({path:"analyticsOptions.server",name:"Endpoint",defaultValue:_.endpoint,description:"The endpoint to which to payloads will be sent."}).addTextInput({path:"analyticsOptions.dashboard",name:"Dashboard",defaultValue:_.dashboard,description:'The name of the dashboard.\n Use "$__dashboard" to reference the name of the current dashboard.'}).addBooleanSwitch({path:"analyticsOptions.showDetails",name:"Show Details",description:"Shows the printed JSON object on the panel.\n Displays any errors as full error with a retry button.\n Enabling this option will not allow Grafana to count errors in meta-analytics.\n Note that this option may require you to save the dashboard and reload the page to take effect.",defaultValue:_.showDetails}).addBooleanSwitch({path:"analyticsOptions.postStart",name:"Post Start",description:'Sends a payload with {"type": "start"} when the dashboard is loaded.',defaultValue:_.postStart}).addBooleanSwitch({path:"analyticsOptions.postEnd",name:"Post End",description:'Sends a payload with {"type": "end"} when the dashboard is exited.\n Note that this payload will not be sent if the browser or tab is closed.',defaultValue:_.postEnd}).addBooleanSwitch({path:"analyticsOptions.postHeartbeat",name:"Post Heartbeat",description:'Sends a payload with {"type": "heartbeat"} at regular intervals.',defaultValue:_.postHeartbeat}).addNumberInput({path:"analyticsOptions.heartbeatInterval",name:"Heartbeat Interval",description:"Frequency (in seconds) of heartbeat payloads.",defaultValue:_.heartbeatInterval,showIf:function(t){return t.analyticsOptions.postHeartbeat}}).addBooleanSwitch({path:"analyticsOptions.heartbeatAlways",name:"Heartbeat Always",description:"Send heartbeat payloads even when the dashboard is not in focus.\n This will continue messages when the dashboard is not visible or when another window has focus.\n Leave this option disabled unless you know what you're doing.",defaultValue:_.heartbeatAlways,showIf:function(t){return t.analyticsOptions.postHeartbeat}}).addBooleanSwitch({path:"analyticsOptions.flatten",name:"Flatten",description:"Flattens the payload JSON.\n This may make ingestion easier if you use a simple HTTP listener like Telegraf.",defaultValue:_.flatten})}))}])})); +//# sourceMappingURL=module.js.map \ No newline at end of file diff --git a/dist/module.js.LICENSE.txt b/dist/module.js.LICENSE.txt new file mode 100644 index 0000000..c18ab1d --- /dev/null +++ b/dist/module.js.LICENSE.txt @@ -0,0 +1,14 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ diff --git a/dist/module.js.map b/dist/module.js.map new file mode 100644 index 0000000..9b4785c --- /dev/null +++ b/dist/module.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"react\"","webpack:///external \"@grafana/runtime\"","webpack:///external \"@grafana/ui\"","webpack:///external \"@grafana/data\"","webpack:///../node_modules/flat/index.js","webpack:///../node_modules/tslib/tslib.es6.js","webpack:///../node_modules/uuid/dist/esm-browser/rng.js","webpack:///../node_modules/uuid/dist/esm-browser/regex.js","webpack:///../node_modules/uuid/dist/esm-browser/stringify.js","webpack:///../node_modules/uuid/dist/esm-browser/validate.js","webpack:///../node_modules/uuid/dist/esm-browser/v4.js","webpack:///./utils.ts","webpack:///./payload.ts","webpack:///./AnalyticsPanel.tsx","webpack:///./module.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","__WEBPACK_EXTERNAL_MODULE__1__","__WEBPACK_EXTERNAL_MODULE__2__","__WEBPACK_EXTERNAL_MODULE__3__","__WEBPACK_EXTERNAL_MODULE__4__","isBuffer","obj","constructor","keyIdentity","flatten","target","opts","delimiter","maxDepth","transformKey","output","step","prev","currentDepth","keys","forEach","isarray","safe","Array","isArray","type","toString","isbuffer","isobject","newKey","length","unflatten","overwrite","result","getkey","parsedKey","Number","isNaN","indexOf","reduce","val","isObject","isEmpty","keyPrefix","recipient","addKeys","split","map","key1","shift","key2","undefined","extendStatics","b","setPrototypeOf","__proto__","__assign","assign","arguments","apply","this","getRandomValues","rnds8","Uint8Array","rng","crypto","msCrypto","Error","uuid","test","byteToHex","push","substr","arr","offset","toLowerCase","TypeError","options","buf","rnds","random","isNew","pathname","getUidFromPath","path","unixFromMs","ms","Math","floor","isValidUrl","str","URL","_","throwOnBadResponse","status","getVars","templateSrv","server","replace","dashboardName","dashboard","variables","getVariables","v","untypedVariableModel","multi","current","label","values","getPayload","EventType","timeRange","timeZone","location","time","Date","getTime","configBuildInfo","buildInfo","version","commit","env","edition","configLicenseInfo","licenseInfo","hasLicense","expiry","stateInfo","host","hostname","port","protocol","uid","timeOrigin","window","performance","configUser","bootData","user","isSignedIn","id","login","email","lightTheme","orgCount","orgId","orgName","orgRole","isGrafanaAdmin","timezone","locale","hasEditPermissionInFolders","hasFocus","document","state","JSON","parse","stringify","props","analyticsOptions","getPayloadOrFlatPayload","eventType","tr","payload","from","unix","to","raw","flat","sendPayload","setState","error","fetch","method","body","headers","keepalive","then","e","sendHeartbeat","shouldSetVars","setHeartbeat","prevInterval","interval","postHeartbeat","heartbeatInterval","intervalFrequencyMs","prevIntervalFrequency","intervalFrequency","setInterval","clearInterval","__","componentDidMount","componentDidUpdate","vars","componentWillUnmount","render","width","height","showDetails","style","position","overflow","display","textAlign","title","PLUGIN_NAME","errorInfo","onClick","json","setPanelOptions","builder","addTextInput","defaultValue","defaults","endpoint","description","addBooleanSwitch","postStart","postEnd","addNumberInput","showIf","config","heartbeatAlways"],"mappings":";wGACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAA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,iBAAiB,CAChBrI,KAAM,2BACN5G,KAAM,WACNgP,YAAa,qKAEbH,aAAcC,EAASK,UAExBF,iBAAiB,CAChBrI,KAAM,iCACN5G,KAAM,iBACNgP,YAAa,mEACbH,aAAcC,EAAS9B,gBAExBoC,eAAe,CACdxI,KAAM,qCACN5G,KAAM,qBACNgP,YAAa,gDACbH,aAAcC,EAAS7B,kBACvBoC,OAAQ,SAACC,GAAoB,OAAAA,EAAO/D,iBAAP,iBAE9B0D,iBAAiB,CAChBrI,KAAM,mCACN5G,KAAM,mBACNgP,YAAa,+QAGbH,aAAcC,EAASS,gBACvBF,OAAQ,SAACC,GAAoB,OAAAA,EAAO/D,iBAAP,iBAE9B0D,iBAAiB,CAChBrI,KAAM,2BACN5G,KAAM,UACNgP,YAAa,oIAEbH,aAAcC,EAAS7M","file":"module.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__1__;","module.exports = __WEBPACK_EXTERNAL_MODULE__2__;","module.exports = __WEBPACK_EXTERNAL_MODULE__3__;","module.exports = __WEBPACK_EXTERNAL_MODULE__4__;","module.exports = flatten\nflatten.flatten = flatten\nflatten.unflatten = unflatten\n\nfunction isBuffer (obj) {\n return obj &&\n obj.constructor &&\n (typeof obj.constructor.isBuffer === 'function') &&\n obj.constructor.isBuffer(obj)\n}\n\nfunction keyIdentity (key) {\n return key\n}\n\nfunction flatten (target, opts) {\n opts = opts || {}\n\n const delimiter = opts.delimiter || '.'\n const maxDepth = opts.maxDepth\n const transformKey = opts.transformKey || keyIdentity\n const output = {}\n\n function step (object, prev, currentDepth) {\n currentDepth = currentDepth || 1\n Object.keys(object).forEach(function (key) {\n const value = object[key]\n const isarray = opts.safe && Array.isArray(value)\n const type = Object.prototype.toString.call(value)\n const isbuffer = isBuffer(value)\n const isobject = (\n type === '[object Object]' ||\n type === '[object Array]'\n )\n\n const newKey = prev\n ? prev + delimiter + transformKey(key)\n : transformKey(key)\n\n if (!isarray && !isbuffer && isobject && Object.keys(value).length &&\n (!opts.maxDepth || currentDepth < maxDepth)) {\n return step(value, newKey, currentDepth + 1)\n }\n\n output[newKey] = value\n })\n }\n\n step(target)\n\n return output\n}\n\nfunction unflatten (target, opts) {\n opts = opts || {}\n\n const delimiter = opts.delimiter || '.'\n const overwrite = opts.overwrite || false\n const transformKey = opts.transformKey || keyIdentity\n const result = {}\n\n const isbuffer = isBuffer(target)\n if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {\n return target\n }\n\n // safely ensure that the key is\n // an integer.\n function getkey (key) {\n const parsedKey = Number(key)\n\n return (\n isNaN(parsedKey) ||\n key.indexOf('.') !== -1 ||\n opts.object\n ) ? key\n : parsedKey\n }\n\n function addKeys (keyPrefix, recipient, target) {\n return Object.keys(target).reduce(function (result, key) {\n result[keyPrefix + delimiter + key] = target[key]\n\n return result\n }, recipient)\n }\n\n function isEmpty (val) {\n const type = Object.prototype.toString.call(val)\n const isArray = type === '[object Array]'\n const isObject = type === '[object Object]'\n\n if (!val) {\n return true\n } else if (isArray) {\n return !val.length\n } else if (isObject) {\n return !Object.keys(val).length\n }\n }\n\n target = Object.keys(target).reduce(function (result, key) {\n const type = Object.prototype.toString.call(target[key])\n const isObject = (type === '[object Object]' || type === '[object Array]')\n if (!isObject || isEmpty(target[key])) {\n result[key] = target[key]\n return result\n } else {\n return addKeys(\n key,\n result,\n flatten(target[key], opts)\n )\n }\n }, {})\n\n Object.keys(target).forEach(function (key) {\n const split = key.split(delimiter).map(transformKey)\n let key1 = getkey(split.shift())\n let key2 = getkey(split[0])\n let recipient = result\n\n while (key2 !== undefined) {\n if (key1 === '__proto__') {\n return\n }\n\n const type = Object.prototype.toString.call(recipient[key1])\n const isobject = (\n type === '[object Object]' ||\n type === '[object Array]'\n )\n\n // do not write over falsey, non-undefined values if overwrite is false\n if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {\n return\n }\n\n if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {\n recipient[key1] = (\n typeof key2 === 'number' &&\n !opts.object ? [] : {}\n )\n }\n\n recipient = recipient[key1]\n if (split.length > 0) {\n key1 = getkey(split.shift())\n key2 = getkey(split[0])\n }\n }\n\n // unflatten again for 'messy objects'\n recipient[key1] = unflatten(target[key], opts)\n })\n\n return result\n}\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nvar getRandomValues;\nvar rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation. Also,\n // find the complete implementation of crypto (msCrypto) on IE11.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nvar byteToHex = [];\n\nfor (var i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).substr(1));\n}\n\nfunction stringify(arr) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import rng from './rng.js';\nimport stringify from './stringify.js';\n\nfunction v4(options, buf, offset) {\n options = options || {};\n var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (var i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return stringify(rnds);\n}\n\nexport default v4;","import { VariableModel } from '@grafana/data';\r\nimport { getTemplateSrv } from '@grafana/runtime';\r\nimport { AnalyticsOptions } from './module';\r\nimport { TemplateVariable } from 'payload';\r\n\r\nexport function isNew(pathname: string) {\r\n const isNew = pathname === '/dashboard/new';\r\n console.log(pathname + ' is new: ' + isNew);\r\n return isNew;\r\n}\r\n\r\nexport function getUidFromPath(pathname: string) {\r\n if (!isNew(pathname)) {\r\n const path = pathname.split('/');\r\n if (path && path.length > 2) {\r\n return path[2];\r\n }\r\n }\r\n return '';\r\n}\r\n\r\nexport function unixFromMs(ms: number) {\r\n return Math.floor(ms / 1000);\r\n}\r\n\r\nexport function getTimestamp() {\r\n return unixFromMs(new Date().getTime());\r\n}\r\n\r\nexport function isValidUrl(str: string) {\r\n try {\r\n new URL(str);\r\n } catch (_) {\r\n return false;\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport function throwOnBadResponse(r: Response) {\r\n const status = r.status.toString();\r\n const regExp = /^(0)|(20[0-4])$/;\r\n\r\n if (!regExp.test(status)) {\r\n throw new Error(`Returned status ${status}`);\r\n }\r\n return r;\r\n}\r\n\r\nexport function getVariables(templateVars: VariableModel[]) {\r\n const variables: Array = templateVars.map((v: VariableModel) => {\r\n // Note: any because VariableModel does not define current\r\n const untypedVariableModel: any = v;\r\n\r\n let multi = false;\r\n let value: Array | string | null | undefined = untypedVariableModel?.current?.value;\r\n\r\n if (typeof value === 'string' && value !== '') {\r\n value = [value];\r\n } else if (!Array.isArray(value)) {\r\n value = [];\r\n } else {\r\n multi = true;\r\n }\r\n\r\n return {\r\n name: v.name,\r\n label: v.label ?? '',\r\n type: v.type,\r\n multi: multi,\r\n values: value,\r\n };\r\n });\r\n\r\n return variables;\r\n}\r\n\r\nexport function getVars(options: AnalyticsOptions) {\r\n const templateSrv = getTemplateSrv();\r\n\r\n const server = templateSrv.replace(options.server);\r\n const dashboardName = templateSrv.replace(options.dashboard);\r\n const variables = getVariables(templateSrv.getVariables());\r\n\r\n return {\r\n server,\r\n dashboardName,\r\n variables,\r\n };\r\n}\r\n","import { RawTimeRange, VariableType } from '@grafana/data';\r\nimport { config } from '@grafana/runtime';\r\nimport { getTimestamp, getUidFromPath, unixFromMs } from 'utils';\r\nimport { AnalyticsOptions } from './module';\r\n\r\nexport type TemplateVariable = {\r\n name: string;\r\n label: string | null;\r\n type: VariableType;\r\n multi: boolean;\r\n values: Array;\r\n};\r\n\r\nexport type EventType = 'start' | 'heartbeat' | 'end';\r\n\r\nexport type LicenseInfo = {\r\n hasLicense: boolean;\r\n expiry: number;\r\n stateInfo: string;\r\n};\r\n\r\nexport type BuildInfo = {\r\n version: string;\r\n commit: string;\r\n env: string;\r\n edition: string;\r\n};\r\n\r\nexport type HostInfo = {\r\n hostname: string;\r\n port: string;\r\n protocol: string;\r\n buildInfo: BuildInfo;\r\n licenseInfo: LicenseInfo;\r\n};\r\n\r\nexport type DashboardInfo = {\r\n name: string;\r\n uid: string;\r\n};\r\n\r\nexport type TimeRange = {\r\n from: number;\r\n to: number;\r\n raw: RawTimeRange;\r\n};\r\n\r\nexport type User = {\r\n isSignedIn: boolean;\r\n id: number;\r\n login: string;\r\n email: string;\r\n name: string;\r\n lightTheme: boolean;\r\n orgCount: number;\r\n orgId: number;\r\n orgName: string;\r\n orgRole: string;\r\n isGrafanaAdmin: boolean;\r\n timezone: string;\r\n locale: string;\r\n hasEditPermissionInFolders: boolean;\r\n};\r\n\r\nexport type Payload = {\r\n uuid: string;\r\n type: EventType;\r\n hasFocus: boolean;\r\n options: AnalyticsOptions;\r\n host: HostInfo;\r\n dashboard: DashboardInfo;\r\n user: User;\r\n variables: TemplateVariable[];\r\n timeRange: TimeRange;\r\n timeZone: string;\r\n timeOrigin: number;\r\n time: number;\r\n};\r\n\r\nexport type FlatPayload = any;\r\n\r\nexport function getPayload(\r\n uuid: string,\r\n EventType: EventType,\r\n options: AnalyticsOptions,\r\n timeRange: TimeRange,\r\n timeZone: string,\r\n dashboardName: string,\r\n location: Location,\r\n variables: TemplateVariable[]\r\n): Payload {\r\n const time = getTimestamp();\r\n\r\n const configBuildInfo = config.buildInfo;\r\n const buildInfo: BuildInfo = {\r\n version: configBuildInfo.version ?? '',\r\n commit: configBuildInfo.commit ?? '',\r\n env: configBuildInfo.env ?? '',\r\n edition: configBuildInfo.edition ?? '',\r\n };\r\n\r\n const configLicenseInfo = config.licenseInfo;\r\n const licenseInfo: LicenseInfo = {\r\n hasLicense: configLicenseInfo.hasLicense ?? false,\r\n expiry: configLicenseInfo.expiry ?? 0,\r\n stateInfo: configLicenseInfo.stateInfo ?? '',\r\n };\r\n\r\n const host: HostInfo = {\r\n hostname: location.hostname,\r\n port: location.port,\r\n protocol: location.protocol,\r\n buildInfo: buildInfo,\r\n licenseInfo: licenseInfo,\r\n };\r\n\r\n const path = location.pathname;\r\n const dashboard: DashboardInfo = {\r\n name: dashboardName,\r\n uid: getUidFromPath(path),\r\n };\r\n\r\n const timeOrigin = unixFromMs(window.performance.timeOrigin);\r\n\r\n const configUser: User = config.bootData.user;\r\n const user: User = {\r\n isSignedIn: configUser.isSignedIn ?? false,\r\n id: configUser.id ?? 0,\r\n login: configUser.login ?? '',\r\n email: configUser.email ?? '',\r\n name: configUser.name ?? '',\r\n lightTheme: configUser.lightTheme ?? false,\r\n orgCount: configUser.orgCount ?? 0,\r\n orgId: configUser.orgId ?? 0,\r\n orgName: configUser.orgName ?? '',\r\n orgRole: configUser.orgRole ?? '',\r\n isGrafanaAdmin: configUser.isGrafanaAdmin ?? false,\r\n timezone: configUser.timezone ?? '',\r\n locale: configUser.locale ?? '',\r\n hasEditPermissionInFolders: configUser.hasEditPermissionInFolders ?? false,\r\n };\r\n\r\n return {\r\n uuid: uuid,\r\n type: EventType,\r\n hasFocus: window.document.hasFocus(),\r\n options: options,\r\n host: host,\r\n dashboard: dashboard,\r\n user: user,\r\n variables: variables,\r\n timeRange: timeRange,\r\n timeZone: timeZone,\r\n timeOrigin: timeOrigin,\r\n time: time,\r\n };\r\n}\r\n","import React, { PureComponent } from 'react';\r\nimport { PanelProps } from '@grafana/data';\r\nimport { Button, JSONFormatter, ErrorWithStack } from '@grafana/ui';\r\nimport { flatten } from 'flat';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { Options } from './module';\r\nimport { PLUGIN_NAME } from './constants';\r\nimport { Payload, FlatPayload, getPayload, TimeRange, EventType, TemplateVariable } from 'payload';\r\nimport { getVars, isNew, isValidUrl, throwOnBadResponse } from 'utils';\r\n\r\ninterface Props extends PanelProps {}\r\n\r\nexport class AnalyticsPanel extends PureComponent {\r\n state: {\r\n uuid: string;\r\n interval?: NodeJS.Timeout;\r\n intervalFrequency?: number;\r\n server: string;\r\n dashboardName: string;\r\n variables: TemplateVariable[];\r\n location: Location;\r\n error?: Error;\r\n } = {\r\n uuid: '',\r\n location: JSON.parse(JSON.stringify(window.location)),\r\n ...getVars(this.props.options.analyticsOptions),\r\n };\r\n\r\n getPayloadOrFlatPayload = (uuid: string, eventType: EventType): Payload | FlatPayload => {\r\n const options = this.props.options.analyticsOptions;\r\n\r\n const tr = this.props.timeRange;\r\n const timeRange: TimeRange = {\r\n from: tr.from.unix(),\r\n to: tr.to.unix(),\r\n raw: tr.raw,\r\n };\r\n\r\n const payload = getPayload(\r\n uuid,\r\n eventType,\r\n options,\r\n timeRange,\r\n this.props.timeZone,\r\n this.state.dashboardName,\r\n this.state.location,\r\n this.state.variables\r\n );\r\n if (options.flatten) {\r\n return flatten(payload);\r\n }\r\n return payload;\r\n };\r\n\r\n sendPayload = (eventType: EventType) => {\r\n this.setState({ error: undefined });\r\n\r\n let uuid = '';\r\n if (eventType === 'start') {\r\n uuid = uuidv4();\r\n this.setState({ uuid });\r\n } else {\r\n uuid = this.state.uuid;\r\n }\r\n\r\n const { server, location } = this.state;\r\n\r\n if (isNew(location.pathname)) {\r\n const error = new Error('Dashboard is new and unsaved, and thus no ID was found.');\r\n this.setState({ error });\r\n } else if (!isValidUrl(server)) {\r\n const error = new Error(`\"${server}\" is not a valid URL.`);\r\n this.setState({ error });\r\n } else {\r\n fetch(server, {\r\n method: 'POST',\r\n mode: 'no-cors',\r\n body: JSON.stringify(this.getPayloadOrFlatPayload(uuid, eventType)),\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n },\r\n keepalive: true,\r\n })\r\n .then((r) => throwOnBadResponse(r))\r\n .catch((e: Error) => {\r\n this.setState({ error: e });\r\n });\r\n }\r\n };\r\n\r\n sendHeartbeat = () => {\r\n const { heartbeatAlways } = this.props.options.analyticsOptions;\r\n if (heartbeatAlways || window.document.hasFocus()) {\r\n this.sendPayload('heartbeat');\r\n }\r\n };\r\n\r\n shouldSetVars = (server: string, dashboardName: string, variables: TemplateVariable[]) => {\r\n if (\r\n server !== this.state.server ||\r\n dashboardName !== this.state.dashboardName ||\r\n JSON.stringify(variables) !== JSON.stringify(this.state.variables)\r\n ) {\r\n return true;\r\n }\r\n\r\n return false;\r\n };\r\n\r\n setHeartbeat = () => {\r\n const prevInterval = this.state.interval;\r\n const { postHeartbeat, heartbeatInterval } = this.props.options.analyticsOptions;\r\n const intervalFrequencyMs = heartbeatInterval * 1000;\r\n const prevIntervalFrequency = this.state.intervalFrequency;\r\n\r\n console.log(prevIntervalFrequency, heartbeatInterval);\r\n\r\n if (!postHeartbeat && prevInterval !== undefined) {\r\n // Interval should be disabled.\r\n console.log('Disable the interval.');\r\n clearInterval(prevInterval);\r\n this.setState({ interval: undefined, intervalFrequency: undefined });\r\n } else if (postHeartbeat && prevInterval === undefined) {\r\n // Interval should be created.\r\n console.log('Create the interval.');\r\n const interval = setInterval(this.sendHeartbeat, intervalFrequencyMs);\r\n this.setState({ interval, intervalFrequency: heartbeatInterval });\r\n } else if (prevIntervalFrequency && prevIntervalFrequency !== heartbeatInterval) {\r\n // There may be an interval, but the settings have changed.\r\n console.log('Edit the interval.');\r\n if (prevInterval !== undefined) {\r\n clearInterval(prevInterval);\r\n }\r\n const interval = setInterval(this.sendHeartbeat, intervalFrequencyMs);\r\n this.setState({ interval, intervalFrequency: heartbeatInterval });\r\n } // Else, there is an interval, and nothing has changed.\r\n };\r\n\r\n componentDidMount() {\r\n console.log('componentDidMount');\r\n const { postStart } = this.props.options.analyticsOptions;\r\n\r\n if (postStart) {\r\n this.sendPayload('start');\r\n }\r\n\r\n this.setHeartbeat();\r\n }\r\n\r\n componentDidUpdate() {\r\n console.log('componentDidUpdate');\r\n const vars = getVars(this.props.options.analyticsOptions);\r\n if (this.shouldSetVars(vars.server, vars.dashboardName, vars.variables)) {\r\n this.setState({ ...vars });\r\n }\r\n this.setHeartbeat();\r\n }\r\n\r\n componentWillUnmount() {\r\n console.log('componentWillUnmount');\r\n const { postEnd } = this.props.options.analyticsOptions;\r\n\r\n if (postEnd) {\r\n this.sendPayload('end');\r\n }\r\n\r\n const { interval } = this.state;\r\n if (interval !== undefined) {\r\n clearInterval(interval);\r\n }\r\n }\r\n\r\n render() {\r\n const { width, height } = this.props;\r\n const { showDetails } = this.props.options.analyticsOptions;\r\n const { error, uuid } = this.state;\r\n\r\n if (error && !showDetails) {\r\n throw error;\r\n }\r\n\r\n return (\r\n \r\n {error && (\r\n \r\n \r\n \r\n \r\n )}\r\n {showDetails && }\r\n \r\n );\r\n }\r\n}\r\n","import { PanelPlugin, PanelOptionsEditorBuilder } from '@grafana/data';\r\nimport { AnalyticsPanel } from './AnalyticsPanel';\r\nimport defaults from './defaults.json';\r\n\r\nexport interface AnalyticsOptions {\r\n server: string;\r\n dashboard: string;\r\n showDetails: boolean;\r\n postStart: boolean;\r\n postHeartbeat: boolean;\r\n heartbeatInterval: number;\r\n heartbeatAlways: boolean;\r\n postEnd: boolean;\r\n flatten: boolean;\r\n}\r\n\r\nexport interface Options {\r\n analyticsOptions: AnalyticsOptions;\r\n}\r\n\r\nexport const plugin = new PanelPlugin(AnalyticsPanel).setPanelOptions(\r\n (builder: PanelOptionsEditorBuilder) => {\r\n builder\r\n .addTextInput({\r\n path: 'analyticsOptions.server',\r\n name: 'Endpoint',\r\n defaultValue: defaults.endpoint,\r\n description: 'The endpoint to which to payloads will be sent.',\r\n })\r\n .addTextInput({\r\n path: 'analyticsOptions.dashboard',\r\n name: 'Dashboard',\r\n defaultValue: defaults.dashboard,\r\n description: `The name of the dashboard.\r\n Use \"$__dashboard\" to reference the name of the current dashboard.`,\r\n })\r\n .addBooleanSwitch({\r\n path: 'analyticsOptions.showDetails',\r\n name: 'Show Details',\r\n description: `Shows the printed JSON object on the panel.\r\n Displays any errors as full error with a retry button.\r\n Enabling this option will not allow Grafana to count errors in meta-analytics.\r\n Note that this option may require you to save the dashboard and reload the page to take effect.`,\r\n defaultValue: defaults.showDetails,\r\n })\r\n .addBooleanSwitch({\r\n path: 'analyticsOptions.postStart',\r\n name: 'Post Start',\r\n description: 'Sends a payload with {\"type\": \"start\"} when the dashboard is loaded.',\r\n defaultValue: defaults.postStart,\r\n })\r\n .addBooleanSwitch({\r\n path: 'analyticsOptions.postEnd',\r\n name: 'Post End',\r\n description: `Sends a payload with {\"type\": \"end\"} when the dashboard is exited.\r\n Note that this payload will not be sent if the browser or tab is closed.`,\r\n defaultValue: defaults.postEnd,\r\n })\r\n .addBooleanSwitch({\r\n path: 'analyticsOptions.postHeartbeat',\r\n name: 'Post Heartbeat',\r\n description: 'Sends a payload with {\"type\": \"heartbeat\"} at regular intervals.',\r\n defaultValue: defaults.postHeartbeat,\r\n })\r\n .addNumberInput({\r\n path: 'analyticsOptions.heartbeatInterval',\r\n name: 'Heartbeat Interval',\r\n description: 'Frequency (in seconds) of heartbeat payloads.',\r\n defaultValue: defaults.heartbeatInterval,\r\n showIf: (config: Options) => config.analyticsOptions.postHeartbeat,\r\n })\r\n .addBooleanSwitch({\r\n path: 'analyticsOptions.heartbeatAlways',\r\n name: 'Heartbeat Always',\r\n description: `Send heartbeat payloads even when the dashboard is not in focus.\r\n This will continue messages when the dashboard is not visible or when another window has focus.\r\n Leave this option disabled unless you know what you're doing.`,\r\n defaultValue: defaults.heartbeatAlways,\r\n showIf: (config: Options) => config.analyticsOptions.postHeartbeat,\r\n })\r\n .addBooleanSwitch({\r\n path: 'analyticsOptions.flatten',\r\n name: 'Flatten',\r\n description: `Flattens the payload JSON.\r\n This may make ingestion easier if you use a simple HTTP listener like Telegraf.`,\r\n defaultValue: defaults.flatten,\r\n });\r\n }\r\n);\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/plugin.json b/dist/plugin.json new file mode 100644 index 0000000..90fb2ac --- /dev/null +++ b/dist/plugin.json @@ -0,0 +1,31 @@ +{ + "type": "panel", + "name": "Analytics Panel", + "id": "macropower-analytics-panel", + "info": { + "description": "It's like Google Analytics, but for Grafana dashboards!", + "author": { + "name": "Jacob Colvin", + "url": "https://jacobcolvin.com" + }, + "keywords": ["dashboard", "analytics", "user", "username", "reports", "report", "reporting", "track", "tracking"], + "logos": { + "small": "img/logo.svg", + "large": "img/logo.svg" + }, + "links": [ + { + "name": "Website", + "url": "https://github.com/MacroPower/macropower-analytics-panel" + } + ], + "screenshots": [], + "version": "2.0.0", + "updated": "2021-04-11" + }, + "dependencies": { + "grafanaVersion": "7.x.x", + "grafanaDependency": ">=7.0.0", + "plugins": [] + } +}