nuxt-yandex-metrika 1.0.4 → 1.1.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/README.md CHANGED
@@ -45,6 +45,7 @@ export default defineNuxtConfig({
45
45
  // debug: process.env.NODE_ENV !== "production",
46
46
  // delay: 0,
47
47
  // cdn: false,
48
+ // verification: null, // Verification in Yandex Webmaster
48
49
  // options: {
49
50
  // webvisor: true
50
51
  // },
@@ -76,9 +77,10 @@ For more information:
76
77
 
77
78
  ## Usage
78
79
 
79
- | Component Name | Auto Imported | Description |
80
- |-----------------------------|---------------|----------------|
81
- | `<YandexMetrikaInformer />` | ✅ | Shows informer |
80
+ | Component Name | Auto Imported | Description |
81
+ |-----------------------------|---------------|----------------------------------|
82
+ | `<YandexMetrikaInformer />` | ✅ | Shows informer |
83
+ | `<YandexVerification />` | ✅ | Verification in Yandex Webmaster |
82
84
 
83
85
  ### Methods
84
86
 
package/dist/module.d.ts CHANGED
@@ -38,6 +38,7 @@ type YandexMetrikaModuleOptions = {
38
38
  debug: boolean;
39
39
  cdn: boolean;
40
40
  delay: number;
41
+ verification: null | string;
41
42
  options: Partial<InitParameters>;
42
43
  };
43
44
 
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-yandex-metrika",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "configKey": "yandexMetrika",
5
5
  "compatibility": {
6
6
  "nuxt": "^3"
package/dist/module.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addComponent, addImportsDir } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addPlugin, addComponentsDir, addImportsDir } from '@nuxt/kit';
2
2
  import { defu } from 'defu';
3
3
 
4
4
  const name = "nuxt-yandex-metrika";
5
- const version = "1.0.4";
5
+ const version = "1.1.1";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -19,6 +19,7 @@ const module = defineNuxtModule({
19
19
  debug: process.env.NODE_ENV !== "production",
20
20
  delay: 0,
21
21
  cdn: false,
22
+ verification: null,
22
23
  options: {}
23
24
  },
24
25
  setup(options, nuxt) {
@@ -31,9 +32,8 @@ const module = defineNuxtModule({
31
32
  mode: "all",
32
33
  src: resolver.resolve("./runtime/plugin")
33
34
  });
34
- void addComponent({
35
- name: "yandex-metrika-informer",
36
- filePath: resolver.resolve("./runtime/yandex-metrika-informer.vue")
35
+ void addComponentsDir({
36
+ path: resolver.resolve("runtime/components")
37
37
  });
38
38
  addImportsDir(resolver.resolve("runtime/composables"));
39
39
  }
@@ -0,0 +1,19 @@
1
+ <script setup lang="ts">
2
+ import { useYandexMetrika } from '../composables/useYandexMetrika';
3
+ const { id } = useYandexMetrika();
4
+ </script>
5
+
6
+ <template>
7
+ <!-- Yandex.Metrika informer -->
8
+ <a :href="`https://metrika.yandex.ru/stat/?id=${id}&amp;from=informer`" target="_blank" rel="nofollow"
9
+ ><img
10
+ :src="`https://informer.yandex.ru/informer/${id}/3_1_FFFFFFFF_EFEFEFFF_0_pageviews`"
11
+ style="width: 88px; height: 31px; border: 0"
12
+ alt="Яндекс.Метрика"
13
+ title="Яндекс.Метрика: данные за сегодня (просмотры, визиты и уникальные посетители)"
14
+ class="ym-advanced-informer"
15
+ :data-cid="id"
16
+ data-lang="ru"
17
+ /></a>
18
+ <!-- /Yandex.Metrika informer -->
19
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { useYandexMetrika } from '../composables/useYandexMetrika';
3
+ import chalk from 'chalk';
4
+
5
+ const { verification } = useYandexMetrika();
6
+
7
+ if (!verification) {
8
+ console.error(`${chalk.bgRed(chalk.black('[yandex-metrika]'))} ${chalk.red('Verification key not found')}`);
9
+ }
10
+ </script>
11
+
12
+ <template>
13
+ <Meta v-if="verification" name="yandex-verification" :content="verification" />
14
+ </template>
15
+
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,15 +1,10 @@
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 { id, cdn = false, delay = 0, debug, options = {} } = config;
7
+ const { id, cdn = false, delay = 0, debug, verification = null, options = {} } = config;
13
8
  if (!debug) {
14
9
  useHead({
15
10
  noscript: [
@@ -19,8 +14,6 @@ export default defineNuxtPlugin({
19
14
  ]
20
15
  });
21
16
  }
22
- function useYandexMetrikaHead() {
23
- }
24
17
  if (debug || delay) {
25
18
  useHead({
26
19
  script: [
@@ -28,9 +21,7 @@ export default defineNuxtPlugin({
28
21
  innerHTML: `window.ym=window.ym||function(){(window.ym.a=window.ym.a||[]).push(arguments)};window.ym.l=(new Date).getTime();`
29
22
  },
30
23
  {
31
- innerHTML: `ym("${id}","${Methods.Init}", ${JSON.stringify(
32
- options
33
- )});`
24
+ innerHTML: `ym("${id}","${Methods.Init}", ${JSON.stringify(options)});`
34
25
  }
35
26
  ]
36
27
  });
@@ -55,6 +46,7 @@ export default defineNuxtPlugin({
55
46
  }
56
47
  const yandexMetrika = new YandexMetrika(id);
57
48
  yandexMetrika.debug = debug;
49
+ yandexMetrika.verification = verification;
58
50
  if (process.client) {
59
51
  let ready = false;
60
52
  const router = useRouter();
@@ -1,21 +1,23 @@
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";
6
6
  constructor(id: string);
7
7
  get debug(): boolean;
8
8
  set debug(value: boolean);
9
+ get verification(): string | null;
10
+ set verification(value: string | null);
9
11
  get id(): string;
10
12
  init(options?: InitParameters): void;
11
13
  addFileExtension(extensions?: string | string[]): void;
12
- extLink<CTX>(url: string, options?: Omit<HitOptions<CTX>, "referer">): void;
14
+ extLink<CTX>(url: string, options?: Omit<HitOptions<CTX>, 'referer'>): void;
13
15
  file<CTX>(url: string, options?: HitOptions<CTX>): void;
14
16
  firstPartyParams(people: People): void;
15
17
  firstPartyParamsHashed(people: People): void;
16
18
  getClientID(cb: (clientID: number) => void): void;
17
19
  hit<CTX>(url?: string, options?: HitOptions<CTX>): void;
18
- notBounce<CTX>(options?: Pick<HitOptions<CTX>, "ctx" | "callback">): void;
20
+ notBounce<CTX>(options?: Pick<HitOptions<CTX>, 'ctx' | 'callback'>): void;
19
21
  params(params?: VisitParameters): void;
20
22
  reachGoal<CTX>(target: string, params: VisitParameters, callback?: (this: CTX) => void, ctx?: CTX): void;
21
23
  setUserID(userId: string): void;
@@ -1,11 +1,10 @@
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;
8
6
  #debug = false;
7
+ #verification = null;
9
8
  static src(cdn = false) {
10
9
  return cdn ? "https://cdn.jsdelivr.net/npm/yandex-metrica-watch/tag.js" : "https://mc.yandex.ru/metrika/tag.js";
11
10
  }
@@ -18,6 +17,12 @@ export class YandexMetrika {
18
17
  set debug(value) {
19
18
  this.#debug = value;
20
19
  }
20
+ get verification() {
21
+ return this.#verification;
22
+ }
23
+ set verification(value) {
24
+ this.#verification = value;
25
+ }
21
26
  get id() {
22
27
  return this.#id;
23
28
  }
@@ -62,12 +67,7 @@ export class YandexMetrika {
62
67
  }
63
68
  #call(type, ...args) {
64
69
  if (this.#debug) {
65
- console.debug(
66
- `${chalk.bgGreen(chalk.black("[yandex - metrika]"))} ${chalk.blue(
67
- type
68
- )}`,
69
- ...args
70
- );
70
+ console.debug(`${chalk.bgGreen(chalk.black("[yandex-metrika]"))} ${chalk.blue(type)}`, ...args);
71
71
  }
72
72
  if (typeof window !== "undefined") {
73
73
  window.ym(this.id, type, ...args);
@@ -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.0.4",
3
+ "version": "1.1.1",
4
4
  "description": "Add Yandex Metrika to your Nuxt 3 application.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,22 +0,0 @@
1
- <script setup lang="ts">
2
- import { useYandexMetrika } from "./composables/useYandexMetrika";
3
- const { id } = useYandexMetrika();
4
- </script>
5
-
6
- <template>
7
- <!-- Yandex.Metrika informer -->
8
- <a
9
- :href="`https://metrika.yandex.ru/stat/?id=${id}&amp;from=informer`"
10
- target="_blank"
11
- rel="nofollow"
12
- ><img
13
- :src="`https://informer.yandex.ru/informer/${id}/3_1_FFFFFFFF_EFEFEFFF_0_pageviews`"
14
- style="width: 88px; height: 31px; border: 0"
15
- alt="Яндекс.Метрика"
16
- title="Яндекс.Метрика: данные за сегодня (просмотры, визиты и уникальные посетители)"
17
- class="ym-advanced-informer"
18
- :data-cid="id"
19
- data-lang="ru"
20
- ></a>
21
- <!-- /Yandex.Metrika informer -->
22
- </template>