nuxt-yandex-metrika 1.1.0 → 1.2.0

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.0",
3
+ "version": "1.2.0",
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.0";
5
+ const version = "1.2.0";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -1,14 +1,11 @@
1
1
  <script setup lang="ts">
2
- import { useYandexMetrika } from "./composables/useYandexMetrika";
2
+ import { useYandexMetrika } from '../composables/useYandexMetrika';
3
3
  const { id } = useYandexMetrika();
4
4
  </script>
5
5
 
6
6
  <template>
7
7
  <!-- Yandex.Metrika informer -->
8
- <a
9
- :href="`https://metrika.yandex.ru/stat/?id=${id}&amp;from=informer`"
10
- target="_blank"
11
- rel="nofollow"
8
+ <a :href="`https://metrika.yandex.ru/stat/?id=${id}&amp;from=informer`" target="_blank" rel="nofollow"
12
9
  ><img
13
10
  :src="`https://informer.yandex.ru/informer/${id}/3_1_FFFFFFFF_EFEFEFFF_0_pageviews`"
14
11
  style="width: 88px; height: 31px; border: 0"
@@ -1,24 +1,16 @@
1
1
  <script setup lang="ts">
2
- import { useYandexMetrika } from "../composables/useYandexMetrika";
3
- import chalk from "chalk";
2
+ import { useYandexMetrika } from '../composables/useYandexMetrika';
3
+ import chalk from 'chalk';
4
4
 
5
5
  const { verification } = useYandexMetrika();
6
6
 
7
7
  if (!verification) {
8
- console.error(
9
- `${chalk.bgRed(chalk.black("[yandex-metrika]"))} ${chalk.red(
10
- "Verification key not found",
11
- )}`,
12
- );
8
+ console.error(`${chalk.bgRed(chalk.black('[yandex-metrika]'))} ${chalk.red('Verification key not found')}`);
13
9
  }
14
10
  </script>
15
11
 
16
12
  <template>
17
- <Meta
18
- v-if="verification"
19
- name="yandex-verification"
20
- :content="verification"
21
- />
13
+ <Meta v-if="verification" name="yandex-verification" :content="verification" />
22
14
  </template>
23
15
 
24
16
  <style scoped></style>
@@ -1,2 +1,2 @@
1
- import { YandexMetrika } from "../yandex-metrika";
1
+ import { YandexMetrika } from '../yandex-metrika';
2
2
  export declare function useYandexMetrika(): YandexMetrika;
@@ -1,26 +1,15 @@
1
- import {
2
- defineNuxtPlugin,
3
- useHead,
4
- useRouter,
5
- useRuntimeConfig
6
- } from "#imports";
1
+ import { defineNuxtPlugin, useHead, useRouter, useRuntimeConfig } from "#imports";
7
2
  import { Methods, YandexMetrika } from "./yandex-metrika/index.mjs";
8
3
  export default defineNuxtPlugin({
9
4
  parallel: true,
10
5
  setup() {
11
6
  const config = useRuntimeConfig().public.yandexMetrika;
12
- const {
13
- id,
14
- cdn = false,
15
- delay = 0,
16
- debug,
17
- verification = null,
18
- options = {}
19
- } = config;
7
+ const { id, cdn = false, delay = 0, debug, verification = null, options = {} } = config;
20
8
  if (!debug) {
21
9
  useHead({
22
10
  noscript: [
23
11
  {
12
+ key: "yandex-metrika-noscript",
24
13
  innerHTML: `<div><img src="https://mc.yandex.ru/watch/${id}" style="position:absolute; left:-9999px;" alt="" />`
25
14
  }
26
15
  ]
@@ -30,12 +19,12 @@ export default defineNuxtPlugin({
30
19
  useHead({
31
20
  script: [
32
21
  {
22
+ key: "yandex-metrika-ym",
33
23
  innerHTML: `window.ym=window.ym||function(){(window.ym.a=window.ym.a||[]).push(arguments)};window.ym.l=(new Date).getTime();`
34
24
  },
35
25
  {
36
- innerHTML: `ym("${id}","${Methods.Init}", ${JSON.stringify(
37
- options
38
- )});`
26
+ key: "yandex-metrika-init",
27
+ innerHTML: `ym("${id}","${Methods.Init}", ${JSON.stringify(options)});`
39
28
  }
40
29
  ]
41
30
  });
@@ -43,6 +32,7 @@ export default defineNuxtPlugin({
43
32
  useHead({
44
33
  script: [
45
34
  {
35
+ key: "yandex-metrika",
46
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(
47
37
  cdn
48
38
  )}", "ym");`
@@ -1,5 +1,5 @@
1
- import { Events, HitOptions, InitParameters, People, UserParameters, VisitParameters } from "./types";
2
- export * from "./types";
1
+ import { Events, HitOptions, InitParameters, People, UserParameters, VisitParameters } from './types';
2
+ export * from './types';
3
3
  export declare class YandexMetrika implements Events {
4
4
  #private;
5
5
  static src(cdn?: boolean): "https://cdn.jsdelivr.net/npm/yandex-metrica-watch/tag.js" | "https://mc.yandex.ru/metrika/tag.js";
@@ -11,13 +11,13 @@ export declare class YandexMetrika implements Events {
11
11
  get id(): string;
12
12
  init(options?: InitParameters): void;
13
13
  addFileExtension(extensions?: string | string[]): void;
14
- extLink<CTX>(url: string, options?: Omit<HitOptions<CTX>, "referer">): void;
14
+ extLink<CTX>(url: string, options?: Omit<HitOptions<CTX>, 'referer'>): void;
15
15
  file<CTX>(url: string, options?: HitOptions<CTX>): void;
16
16
  firstPartyParams(people: People): void;
17
17
  firstPartyParamsHashed(people: People): void;
18
18
  getClientID(cb: (clientID: number) => void): void;
19
19
  hit<CTX>(url?: string, options?: HitOptions<CTX>): void;
20
- notBounce<CTX>(options?: Pick<HitOptions<CTX>, "ctx" | "callback">): void;
20
+ notBounce<CTX>(options?: Pick<HitOptions<CTX>, 'ctx' | 'callback'>): void;
21
21
  params(params?: VisitParameters): void;
22
22
  reachGoal<CTX>(target: string, params: VisitParameters, callback?: (this: CTX) => void, ctx?: CTX): void;
23
23
  setUserID(userId: string): void;
@@ -1,7 +1,5 @@
1
1
  import chalk from "chalk";
2
- import {
3
- Methods
4
- } from "./types.mjs";
2
+ import { Methods } from "./types.mjs";
5
3
  export * from "./types.mjs";
6
4
  export class YandexMetrika {
7
5
  #id;
@@ -69,12 +67,9 @@ export class YandexMetrika {
69
67
  }
70
68
  #call(type, ...args) {
71
69
  if (this.#debug) {
72
- console.debug(
73
- `${chalk.bgGreen(chalk.black("[yandex-metrika]"))} ${chalk.blue(type)}`,
74
- ...args
75
- );
70
+ console.debug(`${chalk.bgGreen(chalk.black("[yandex-metrika]"))} ${chalk.blue(type)}`, ...args);
76
71
  }
77
- if (typeof window !== "undefined") {
72
+ if (typeof window !== "undefined" && window.ym) {
78
73
  window.ym(this.id, type, ...args);
79
74
  }
80
75
  }
@@ -1,2 +1,2 @@
1
- export { YandexMetrika } from "./YandexMetrika";
2
- export * from "./types";
1
+ export { YandexMetrika } from './YandexMetrika';
2
+ export * from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-yandex-metrika",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Add Yandex Metrika to your Nuxt 3 application.",
5
5
  "repository": {
6
6
  "type": "git",