├── .gitattributes ├── .gitignore ├── yarn.lock ├── .editorconfig ├── package.json ├── lib ├── plugin.js └── index.js ├── LICENSE └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | # IDE 4 | .idea 5 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@netsells/nuxt-hotjar", 3 | "version": "0.1.3", 4 | "description": "Nuxt hotjar plugin", 5 | "author": { 6 | "name": "Neveena", 7 | "email": "neveena.ferrao@netsells.co.uk" 8 | }, 9 | "files": [ 10 | "lib" 11 | ], 12 | "main": "lib/index.js", 13 | "keywords": [ 14 | "Vue", 15 | "Nuxt", 16 | "Hotjar", 17 | "nuxt-hotjar" 18 | ], 19 | "engines": { 20 | "npm": ">= 4.0.0" 21 | }, 22 | "repository": "netsells/nuxt-hotjar", 23 | "license": "MIT" 24 | } 25 | -------------------------------------------------------------------------------- /lib/plugin.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | if (typeof window !== 'undefined') { 3 | (function (h, o, t, j, a, r) { 4 | h.hj = h.hj || function () { 5 | (h.hj.q = h.hj.q || []).push(arguments); 6 | }; 7 | h._hjSettings = { 8 | hjid: '<%= options.id %>', 9 | hjsv: '<%= options.sv %>' 10 | }; 11 | a = o.getElementsByTagName('head')[0]; 12 | r = o.createElement('script'); 13 | r.async = 1; 14 | r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv; 15 | a.appendChild(r); 16 | })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv='); 17 | } -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const { defaultsDeep } = require("lodash"); 3 | 4 | module.exports = function(_options) { 5 | const options = defaultsDeep({}, _options, this.options.hotjar, { 6 | id: null, 7 | sv: null, 8 | }); 9 | 10 | // Don't include when run in dev mode 11 | if (options.dev) { 12 | return; 13 | } 14 | 15 | // Don't include when no hotjar id is given 16 | if (!options.id) { 17 | return; 18 | } 19 | 20 | // Register plugin 21 | this.addPlugin({ 22 | src: path.resolve(__dirname, "plugin.js"), 23 | fileName: "hotjar.js", 24 | ssr: false, 25 | options 26 | }); 27 | }; 28 | 29 | module.exports.meta = require("../package.json"); 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Netsells 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nuxt Hotjar [![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] 2 | > Add nuxt hotjar to your nuxt.js application. 3 | 4 | **Note:** nuxt hotjar is not enabled in dev mode. 5 | You can set environment variable `NODE_ENV` to `production` for testing in dev mode. 6 | 7 | ## Setup 8 | - Add `@netsells/nuxt-hotjar` dependency using yarn or npm to your project 9 | - Add `@netsells/nuxt-hotjar` to `modules` section of `nuxt.config.js` 10 | ```js 11 | modules: [ 12 | ['@netsells/nuxt-hotjar', { 13 | id: 'hjid', 14 | sv: 'hjsv', 15 | }], 16 | ] 17 | ``` 18 | 19 | ## Options 20 | 21 | ### `id` 22 | - Required 23 | - Hotjar ID 24 | 25 | ### `sv` 26 | - Hotjar Snippet Version 27 | 28 | 29 | ## License 30 | 31 | MIT © [Netsells](https://netsells.co.uk) 32 | 33 | 34 | [npm-image]: https://badge.fury.io/js/%40netsells%2Fnuxt-hotjar.svg 35 | [npm-url]: https://npmjs.org/package/@netsells/nuxt-hotjar 36 | [travis-image]: https://travis-ci.org/netsells/nuxt-hotjar.svg?branch=master 37 | [travis-url]: https://travis-ci.org/netsells/nuxt-hotjar 38 | [daviddm-image]: https://david-dm.org/netsells/nuxt-hotjar.svg?theme=shields.io 39 | [daviddm-url]: https://david-dm.org/netsells/nuxt-hotjar 40 | [coveralls-image]: https://coveralls.io/repos/netsells/nuxt-hotjar/badge.svg 41 | [coveralls-url]: https://coveralls.io/r/netsells/nuxt-hotjar 42 | --------------------------------------------------------------------------------