nuxt-yandex-metrika 1.1.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-yandex-metrika",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "configKey": "yandexMetrika",
5
5
  "compatibility": {
6
6
  "nuxt": "^3"
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { defineNuxtModule, createResolver, addPlugin, addComponentsDir, addImpor
2
2
  import { defu } from 'defu';
3
3
 
4
4
  const name = "nuxt-yandex-metrika";
5
- const version = "1.1.1";
5
+ const version = "1.2.1";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -1,4 +1,4 @@
1
- import { useNuxtApp } from "#imports";
1
+ import { useNuxtApp } from "#app";
2
2
  export function useYandexMetrika() {
3
3
  const { $yandexMetrika } = useNuxtApp();
4
4
  return $yandexMetrika;
@@ -1,4 +1,4 @@
1
- import { defineNuxtPlugin, useHead, useRouter, useRuntimeConfig } from "#imports";
1
+ import { defineNuxtPlugin, useHead, useRouter, useRuntimeConfig } from "#app";
2
2
  import { Methods, YandexMetrika } from "./yandex-metrika/index.mjs";
3
3
  export default defineNuxtPlugin({
4
4
  parallel: true,
@@ -9,6 +9,7 @@ export default defineNuxtPlugin({
9
9
  useHead({
10
10
  noscript: [
11
11
  {
12
+ key: "yandex-metrika-noscript",
12
13
  innerHTML: `<div><img src="https://mc.yandex.ru/watch/${id}" style="position:absolute; left:-9999px;" alt="" />`
13
14
  }
14
15
  ]
@@ -18,9 +19,11 @@ export default defineNuxtPlugin({
18
19
  useHead({
19
20
  script: [
20
21
  {
22
+ key: "yandex-metrika-ym",
21
23
  innerHTML: `window.ym=window.ym||function(){(window.ym.a=window.ym.a||[]).push(arguments)};window.ym.l=(new Date).getTime();`
22
24
  },
23
25
  {
26
+ key: "yandex-metrika-init",
24
27
  innerHTML: `ym("${id}","${Methods.Init}", ${JSON.stringify(options)});`
25
28
  }
26
29
  ]
@@ -29,6 +32,7 @@ export default defineNuxtPlugin({
29
32
  useHead({
30
33
  script: [
31
34
  {
35
+ key: "yandex-metrika",
32
36
  innerHTML: `(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date(); for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }} k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "${YandexMetrika.src(
33
37
  cdn
34
38
  )}", "ym");`
@@ -51,6 +55,7 @@ export default defineNuxtPlugin({
51
55
  let ready = false;
52
56
  const router = useRouter();
53
57
  void router.isReady().then(() => {
58
+ console.log(router.options.routes);
54
59
  ready = true;
55
60
  });
56
61
  router.afterEach((to, from) => {
@@ -69,7 +69,7 @@ export class YandexMetrika {
69
69
  if (this.#debug) {
70
70
  console.debug(`${chalk.bgGreen(chalk.black("[yandex-metrika]"))} ${chalk.blue(type)}`, ...args);
71
71
  }
72
- if (typeof window !== "undefined") {
72
+ if (typeof window !== "undefined" && window.ym) {
73
73
  window.ym(this.id, type, ...args);
74
74
  }
75
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-yandex-metrika",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "Add Yandex Metrika to your Nuxt 3 application.",
5
5
  "repository": {
6
6
  "type": "git",