nuxt-yandex-metrika 1.3.1 → 2.0.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 +9 -13
- package/dist/module.d.mts +67 -7
- package/dist/module.json +2 -2
- package/dist/module.mjs +9 -9
- package/dist/runtime/composable.d.ts +3 -0
- package/dist/runtime/composable.js +58 -0
- package/dist/runtime/plugin.d.ts +1 -6
- package/dist/runtime/plugin.js +5 -69
- package/dist/runtime/scheme.d.ts +30 -0
- package/dist/runtime/scheme.js +41 -0
- package/dist/runtime/yandex-metrika/index.d.ts +1 -1
- package/dist/runtime/yandex-metrika/index.js +1 -1
- package/dist/runtime/yandex-metrika/metrika.d.ts +3 -0
- package/dist/runtime/yandex-metrika/metrika.js +54 -0
- package/dist/runtime/yandex-metrika/types.d.ts +30 -19
- package/dist/runtime/yandex-metrika/types.js +15 -16
- package/package.json +85 -68
- package/dist/runtime/components/yandex-metrika-informer.d.vue.ts +0 -3
- package/dist/runtime/components/yandex-metrika-informer.vue +0 -19
- package/dist/runtime/components/yandex-metrika-informer.vue.d.ts +0 -3
- package/dist/runtime/components/yandex-verification.d.vue.ts +0 -3
- package/dist/runtime/components/yandex-verification.vue +0 -12
- package/dist/runtime/components/yandex-verification.vue.d.ts +0 -3
- package/dist/runtime/composables/useYandexMetrika.d.ts +0 -2
- package/dist/runtime/composables/useYandexMetrika.js +0 -5
- package/dist/runtime/yandex-metrika/YandexMetrika.d.ts +0 -25
- package/dist/runtime/yandex-metrika/YandexMetrika.js +0 -76
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ npm install --save-dev nuxt-yandex-metrika
|
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
export default defineNuxtConfig({
|
|
34
|
-
|
|
34
|
+
modules: ['nuxt-yandex-metrika']
|
|
35
35
|
});
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -56,7 +56,7 @@ export default defineNuxtConfig({
|
|
|
56
56
|
## Options
|
|
57
57
|
|
|
58
58
|
| Name | Default value | Type | Description |
|
|
59
|
-
|
|
59
|
+
| ------------------- | ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
60
60
|
| accurateTrackBounce | true | Boolean | Number | Accurate bounce rate The parameter can accept these values: true — Enable the accurate bounce rate, with a non-bounce event registered after 15000 ms (15 s). false — Don't enable the accurate bounce rate. <N> (integer) — Enable the accurate bounce rate. Non-bounce events are recorded after <N> ms. |
|
|
61
61
|
| childIframe | false | Boolean | Whether to record iframe contents without a tag in a child window |
|
|
62
62
|
| clickmap | true | Boolean | Whether to collect data for a click map |
|
|
@@ -75,25 +75,21 @@ For more information:
|
|
|
75
75
|
|
|
76
76
|
- [Documentation for Ya.Metrika](https://yandex.com/support/metrica/code/counter-initialize.html)
|
|
77
77
|
|
|
78
|
-
## Usage
|
|
79
|
-
|
|
80
|
-
| Component Name | Auto Imported | Description |
|
|
81
|
-
|-----------------------------|---------------|----------------------------------|
|
|
82
|
-
| `<YandexMetrikaInformer />` | ✅ | Shows informer |
|
|
83
|
-
| `<YandexVerification />` | ✅ | Verification in Yandex Webmaster |
|
|
84
78
|
|
|
85
79
|
### Methods
|
|
86
80
|
|
|
87
81
|
```vue
|
|
88
|
-
<template>
|
|
89
|
-
<button @click.prevent.stop="reachGoal('click', {})">click</button>
|
|
90
|
-
</template>
|
|
91
|
-
|
|
92
82
|
<script setup lang="ts">
|
|
93
|
-
import { useYandexMetrika } from
|
|
83
|
+
import { useYandexMetrika } from '#imports';
|
|
94
84
|
|
|
95
85
|
const { reachGoal } = useYandexMetrika();
|
|
96
86
|
</script>
|
|
87
|
+
|
|
88
|
+
<template>
|
|
89
|
+
<button @click.prevent.stop="reachGoal('click', {})">
|
|
90
|
+
click
|
|
91
|
+
</button>
|
|
92
|
+
</template>
|
|
97
93
|
```
|
|
98
94
|
|
|
99
95
|
- [For more information](https://yandex.com/support/metrica/objects/method-reference.html?lang=en)
|
package/dist/module.d.mts
CHANGED
|
@@ -1,15 +1,75 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { InitParameters } from '../dist/runtime/yandex-metrika/index.js';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
declare const _default: _nuxt_schema.NuxtModule<{
|
|
5
4
|
id: string;
|
|
6
5
|
debug: boolean;
|
|
6
|
+
delay: number;
|
|
7
7
|
cdn: boolean;
|
|
8
|
+
verification?: string | null | undefined;
|
|
9
|
+
options?: {
|
|
10
|
+
accurateTrackBounce?: number | boolean | undefined;
|
|
11
|
+
childIframe?: boolean | undefined;
|
|
12
|
+
clickmap?: boolean | undefined;
|
|
13
|
+
ecommerce?: string | boolean | any[] | undefined;
|
|
14
|
+
params?: ({
|
|
15
|
+
order_price?: number | undefined;
|
|
16
|
+
currency?: string | undefined;
|
|
17
|
+
} & {
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
})[] | ({
|
|
20
|
+
order_price?: number | undefined;
|
|
21
|
+
currency?: string | undefined;
|
|
22
|
+
} & {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}) | undefined;
|
|
25
|
+
userParams?: ({
|
|
26
|
+
UserID?: number | undefined;
|
|
27
|
+
} & {
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}) | undefined;
|
|
30
|
+
trackHash?: boolean | undefined;
|
|
31
|
+
trackLinks?: boolean | undefined;
|
|
32
|
+
trustedDomain?: string[] | undefined;
|
|
33
|
+
type?: number | undefined;
|
|
34
|
+
webvisor?: boolean | undefined;
|
|
35
|
+
triggerEvent?: boolean | undefined;
|
|
36
|
+
sendTitle?: boolean | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
id: string;
|
|
40
|
+
debug: boolean;
|
|
8
41
|
delay: number;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
42
|
+
cdn: boolean;
|
|
43
|
+
verification?: string | null | undefined;
|
|
44
|
+
options?: {
|
|
45
|
+
accurateTrackBounce?: number | boolean | undefined;
|
|
46
|
+
childIframe?: boolean | undefined;
|
|
47
|
+
clickmap?: boolean | undefined;
|
|
48
|
+
ecommerce?: string | boolean | any[] | undefined;
|
|
49
|
+
params?: ({
|
|
50
|
+
order_price?: number | undefined;
|
|
51
|
+
currency?: string | undefined;
|
|
52
|
+
} & {
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
})[] | ({
|
|
55
|
+
order_price?: number | undefined;
|
|
56
|
+
currency?: string | undefined;
|
|
57
|
+
} & {
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}) | undefined;
|
|
60
|
+
userParams?: ({
|
|
61
|
+
UserID?: number | undefined;
|
|
62
|
+
} & {
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}) | undefined;
|
|
65
|
+
trackHash?: boolean | undefined;
|
|
66
|
+
trackLinks?: boolean | undefined;
|
|
67
|
+
trustedDomain?: string[] | undefined;
|
|
68
|
+
type?: number | undefined;
|
|
69
|
+
webvisor?: boolean | undefined;
|
|
70
|
+
triggerEvent?: boolean | undefined;
|
|
71
|
+
sendTitle?: boolean | undefined;
|
|
72
|
+
} | undefined;
|
|
73
|
+
}, false>;
|
|
14
74
|
|
|
15
75
|
export { _default as default };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin,
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addImports } from '@nuxt/kit';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
|
|
4
4
|
const module$1 = defineNuxtModule({
|
|
@@ -6,10 +6,14 @@ const module$1 = defineNuxtModule({
|
|
|
6
6
|
name: "nuxt-yandex-metrika",
|
|
7
7
|
configKey: "yandexMetrika",
|
|
8
8
|
compatibility: {
|
|
9
|
-
nuxt: ">=
|
|
9
|
+
nuxt: ">=4.0.0"
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
moduleDependencies() {
|
|
13
|
+
return {
|
|
14
|
+
"@nuxt/scripts": {}
|
|
15
|
+
};
|
|
16
|
+
},
|
|
13
17
|
defaults: {
|
|
14
18
|
id: "xxx",
|
|
15
19
|
debug: import.meta.env.NODE_ENV !== "production",
|
|
@@ -20,7 +24,6 @@ const module$1 = defineNuxtModule({
|
|
|
20
24
|
accurateTrackBounce: true,
|
|
21
25
|
childIframe: true,
|
|
22
26
|
clickmap: true,
|
|
23
|
-
defer: false,
|
|
24
27
|
ecommerce: false,
|
|
25
28
|
trackHash: false,
|
|
26
29
|
trackLinks: true,
|
|
@@ -29,7 +32,7 @@ const module$1 = defineNuxtModule({
|
|
|
29
32
|
sendTitle: true
|
|
30
33
|
}
|
|
31
34
|
},
|
|
32
|
-
setup(options, nuxt) {
|
|
35
|
+
async setup(options, nuxt) {
|
|
33
36
|
nuxt.options.runtimeConfig.public.yandexMetrika = defu(
|
|
34
37
|
nuxt.options.runtimeConfig.public.yandexMetrika ?? {},
|
|
35
38
|
options,
|
|
@@ -58,13 +61,10 @@ const module$1 = defineNuxtModule({
|
|
|
58
61
|
mode: "all",
|
|
59
62
|
src: resolver.resolve("./runtime/plugin")
|
|
60
63
|
});
|
|
61
|
-
void addComponentsDir({
|
|
62
|
-
path: resolver.resolve("runtime/components")
|
|
63
|
-
});
|
|
64
64
|
addImports({
|
|
65
65
|
name: "useYandexMetrika",
|
|
66
66
|
as: "useYandexMetrika",
|
|
67
|
-
from: resolver.resolve("runtime/
|
|
67
|
+
from: resolver.resolve("runtime/composable")
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#app";
|
|
2
|
+
import { useHead, useScriptTriggerIdleTimeout } from "#imports";
|
|
3
|
+
import { useRegistryScript } from "#nuxt-scripts/utils";
|
|
4
|
+
import { YandexMetrikaSchemeOptions } from "./scheme.js";
|
|
5
|
+
import { metrika } from "./yandex-metrika/index.js";
|
|
6
|
+
export function useYandexMetrikaScript() {
|
|
7
|
+
return useRegistryScript(
|
|
8
|
+
"yandex-metrika",
|
|
9
|
+
(config) => {
|
|
10
|
+
const { id, cdn, delay, debug, verification, options = {} } = config;
|
|
11
|
+
const api = metrika(id, debug);
|
|
12
|
+
if (import.meta.dev) {
|
|
13
|
+
useHead({
|
|
14
|
+
script: [
|
|
15
|
+
{
|
|
16
|
+
innerHTML: "window.ym=window.ym||function(){(window.ym.a=window.ym.a||[]).push(arguments)};window.ym.l=(new Date).getTime();"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
useHead({
|
|
22
|
+
noscript: [
|
|
23
|
+
{
|
|
24
|
+
innerHTML: `<div><img src="https://mc.yandex.ru/watch/${id}" style="position:absolute; left:-9999px;" alt="" />`
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (verification) {
|
|
30
|
+
useHead({
|
|
31
|
+
meta: [{ name: "yandex-verification", content: verification }]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
scriptInput: {
|
|
36
|
+
src: cdn ? "https://cdn.jsdelivr.net/npm/yandex-metrica-watch/tag.js" : "https://mc.yandex.ru/metrika/tag.js"
|
|
37
|
+
},
|
|
38
|
+
schema: YandexMetrikaSchemeOptions,
|
|
39
|
+
scriptOptions: {
|
|
40
|
+
key: "yandex-metrika",
|
|
41
|
+
bundle: false,
|
|
42
|
+
tagDuplicateStrategy: "replace",
|
|
43
|
+
trigger: delay ? useScriptTriggerIdleTimeout({ timeout: delay }) : void 0,
|
|
44
|
+
use() {
|
|
45
|
+
return api;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
clientInit: import.meta.server ? void 0 : () => {
|
|
49
|
+
api.init(options);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
useRuntimeConfig().public.yandexMetrika
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
export function useYandexMetrika() {
|
|
57
|
+
return useYandexMetrikaScript().proxy;
|
|
58
|
+
}
|
package/dist/runtime/plugin.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare const _default: import("#app").Plugin<{
|
|
3
|
-
yandexMetrika: YandexMetrika;
|
|
4
|
-
}> & import("#app").ObjectPlugin<{
|
|
5
|
-
yandexMetrika: YandexMetrika;
|
|
6
|
-
}>;
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
7
2
|
export default _default;
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -1,62 +1,10 @@
|
|
|
1
|
-
import { defineNuxtPlugin
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { defineNuxtPlugin } from "#app";
|
|
2
|
+
import { useRouter } from "#imports";
|
|
3
|
+
import { useYandexMetrikaScript } from "./composable.js";
|
|
4
4
|
export default defineNuxtPlugin({
|
|
5
5
|
parallel: true,
|
|
6
6
|
setup() {
|
|
7
|
-
const
|
|
8
|
-
const { id, cdn = false, delay = 0, debug, verification = null, options = {} } = config;
|
|
9
|
-
if (import.meta.dev) {
|
|
10
|
-
useHead({
|
|
11
|
-
script: [
|
|
12
|
-
{
|
|
13
|
-
key: "yandex-metrika-ym",
|
|
14
|
-
innerHTML: `window.ym=window.ym||function(){(window.ym.a=window.ym.a||[]).push(arguments)};window.ym.l=(new Date).getTime();`
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
});
|
|
18
|
-
} else {
|
|
19
|
-
useHead({
|
|
20
|
-
noscript: [
|
|
21
|
-
{
|
|
22
|
-
key: "yandex-metrika-noscript",
|
|
23
|
-
innerHTML: `<div><img src="https://mc.yandex.ru/watch/${id}" style="position:absolute; left:-9999px;" alt="" />`
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
});
|
|
27
|
-
if (delay && delay > 0) {
|
|
28
|
-
if (import.meta.client) {
|
|
29
|
-
setTimeout(() => {
|
|
30
|
-
const script = document.createElement("script");
|
|
31
|
-
script.defer = true;
|
|
32
|
-
script.src = YandexMetrika.src(cdn);
|
|
33
|
-
document.head.append(script);
|
|
34
|
-
}, delay);
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
useHead({
|
|
38
|
-
script: [
|
|
39
|
-
{
|
|
40
|
-
key: "yandex-metrika",
|
|
41
|
-
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(
|
|
42
|
-
cdn
|
|
43
|
-
)}", "ym");`
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
useHead({
|
|
50
|
-
script: [
|
|
51
|
-
{
|
|
52
|
-
key: "yandex-metrika-init",
|
|
53
|
-
innerHTML: `ym("${id}","${Methods.Init}", ${JSON.stringify(options)});`
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
const yandexMetrika = new YandexMetrika(id);
|
|
58
|
-
yandexMetrika.debug = debug;
|
|
59
|
-
yandexMetrika.verification = verification;
|
|
7
|
+
const { proxy } = useYandexMetrikaScript();
|
|
60
8
|
if (import.meta.client) {
|
|
61
9
|
let ready = false;
|
|
62
10
|
const router = useRouter();
|
|
@@ -67,22 +15,10 @@ export default defineNuxtPlugin({
|
|
|
67
15
|
if (!ready) {
|
|
68
16
|
return;
|
|
69
17
|
}
|
|
70
|
-
|
|
18
|
+
proxy.hit(to.fullPath, {
|
|
71
19
|
referer: from.fullPath
|
|
72
20
|
});
|
|
73
21
|
});
|
|
74
22
|
}
|
|
75
|
-
return {
|
|
76
|
-
provide: {
|
|
77
|
-
yandexMetrika: new Proxy(yandexMetrika, {
|
|
78
|
-
get(target, name) {
|
|
79
|
-
if (typeof target[name] === "function") {
|
|
80
|
-
return target[name].bind(target);
|
|
81
|
-
}
|
|
82
|
-
return target[name];
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
23
|
}
|
|
88
24
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const YandexMetrikaSchemeOptions: import("valibot").ObjectSchema<{
|
|
2
|
+
readonly id: import("valibot").StringSchema<undefined>;
|
|
3
|
+
readonly debug: import("valibot").BooleanSchema<undefined>;
|
|
4
|
+
readonly delay: import("valibot").NumberSchema<undefined>;
|
|
5
|
+
readonly cdn: import("valibot").BooleanSchema<undefined>;
|
|
6
|
+
readonly verification: import("valibot").NullishSchema<import("valibot").StringSchema<undefined>, undefined>;
|
|
7
|
+
readonly options: import("valibot").OptionalSchema<import("valibot").ObjectSchema<{
|
|
8
|
+
readonly accurateTrackBounce: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").NumberSchema<undefined>, import("valibot").BooleanSchema<undefined>], undefined>, undefined>;
|
|
9
|
+
readonly childIframe: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
|
|
10
|
+
readonly clickmap: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
|
|
11
|
+
readonly ecommerce: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").BooleanSchema<undefined>, import("valibot").ArraySchema<import("valibot").AnySchema, undefined>], undefined>, undefined>;
|
|
12
|
+
readonly params: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").ArraySchema<import("valibot").LooseObjectSchema<{
|
|
13
|
+
readonly order_price: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
|
|
14
|
+
readonly currency: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
|
|
15
|
+
}, undefined>, undefined>, import("valibot").LooseObjectSchema<{
|
|
16
|
+
readonly order_price: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
|
|
17
|
+
readonly currency: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, undefined>;
|
|
18
|
+
}, undefined>], undefined>, undefined>;
|
|
19
|
+
readonly userParams: import("valibot").OptionalSchema<import("valibot").LooseObjectSchema<{
|
|
20
|
+
readonly UserID: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
|
|
21
|
+
}, undefined>, undefined>;
|
|
22
|
+
readonly trackHash: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
|
|
23
|
+
readonly trackLinks: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
|
|
24
|
+
readonly trustedDomain: import("valibot").OptionalSchema<import("valibot").ArraySchema<import("valibot").StringSchema<undefined>, undefined>, undefined>;
|
|
25
|
+
readonly type: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, undefined>;
|
|
26
|
+
readonly webvisor: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
|
|
27
|
+
readonly triggerEvent: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
|
|
28
|
+
readonly sendTitle: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, undefined>;
|
|
29
|
+
}, undefined>, undefined>;
|
|
30
|
+
}, undefined>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { any, array, boolean, looseObject, nullish, number, object, optional, string, union } from "valibot";
|
|
2
|
+
const options = object({
|
|
3
|
+
accurateTrackBounce: optional(union([number(), boolean()])),
|
|
4
|
+
childIframe: optional(boolean()),
|
|
5
|
+
clickmap: optional(boolean()),
|
|
6
|
+
ecommerce: optional(union([string(), boolean(), array(any())])),
|
|
7
|
+
params: optional(
|
|
8
|
+
union([
|
|
9
|
+
array(
|
|
10
|
+
looseObject({
|
|
11
|
+
order_price: optional(number()),
|
|
12
|
+
currency: optional(string())
|
|
13
|
+
})
|
|
14
|
+
),
|
|
15
|
+
looseObject({
|
|
16
|
+
order_price: optional(number()),
|
|
17
|
+
currency: optional(string())
|
|
18
|
+
})
|
|
19
|
+
])
|
|
20
|
+
),
|
|
21
|
+
userParams: optional(
|
|
22
|
+
looseObject({
|
|
23
|
+
UserID: optional(number())
|
|
24
|
+
})
|
|
25
|
+
),
|
|
26
|
+
trackHash: optional(boolean()),
|
|
27
|
+
trackLinks: optional(boolean()),
|
|
28
|
+
trustedDomain: optional(array(string())),
|
|
29
|
+
type: optional(number()),
|
|
30
|
+
webvisor: optional(boolean()),
|
|
31
|
+
triggerEvent: optional(boolean()),
|
|
32
|
+
sendTitle: optional(boolean())
|
|
33
|
+
});
|
|
34
|
+
export const YandexMetrikaSchemeOptions = object({
|
|
35
|
+
id: string(),
|
|
36
|
+
debug: boolean(),
|
|
37
|
+
delay: number(),
|
|
38
|
+
cdn: boolean(),
|
|
39
|
+
verification: nullish(string()),
|
|
40
|
+
options: optional(options)
|
|
41
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { consola } from "consola";
|
|
2
|
+
import { Methods } from "./types.js";
|
|
3
|
+
export * from "./types.js";
|
|
4
|
+
export function metrika(id, debug = false) {
|
|
5
|
+
function call(type, ...args) {
|
|
6
|
+
if (debug) {
|
|
7
|
+
consola.info(`[yandex-metrika] ${type}`, ...args);
|
|
8
|
+
}
|
|
9
|
+
if (typeof window !== "undefined" && window.ym) {
|
|
10
|
+
window.ym(id, type, ...args);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
init(options = {}) {
|
|
15
|
+
call(Methods.Init, ...arguments);
|
|
16
|
+
},
|
|
17
|
+
addFileExtension(extensions) {
|
|
18
|
+
call(Methods.AddFileExtension, ...arguments);
|
|
19
|
+
},
|
|
20
|
+
extLink(url, options = {}) {
|
|
21
|
+
call(Methods.ExtLink, ...arguments);
|
|
22
|
+
},
|
|
23
|
+
file(url, options) {
|
|
24
|
+
call(Methods.File, ...arguments);
|
|
25
|
+
},
|
|
26
|
+
firstPartyParams(people) {
|
|
27
|
+
call(Methods.FirstPartyParams, ...arguments);
|
|
28
|
+
},
|
|
29
|
+
firstPartyParamsHashed(people) {
|
|
30
|
+
call(Methods.FirstPartyParamsHashed, ...arguments);
|
|
31
|
+
},
|
|
32
|
+
getClientID(cb) {
|
|
33
|
+
call(Methods.GetClientID, ...arguments);
|
|
34
|
+
},
|
|
35
|
+
hit(url = "", options) {
|
|
36
|
+
call(Methods.Hit, ...arguments);
|
|
37
|
+
},
|
|
38
|
+
notBounce(options = {}) {
|
|
39
|
+
call(Methods.NotBounce, ...arguments);
|
|
40
|
+
},
|
|
41
|
+
params(params = {}) {
|
|
42
|
+
call(Methods.Params, ...arguments);
|
|
43
|
+
},
|
|
44
|
+
reachGoal(target, params, callback, ctx) {
|
|
45
|
+
call(Methods.ReachGoal, ...arguments);
|
|
46
|
+
},
|
|
47
|
+
setUserID(userId) {
|
|
48
|
+
call(Methods.SetUserID, ...arguments);
|
|
49
|
+
},
|
|
50
|
+
userParams(params = {}) {
|
|
51
|
+
call(Methods.UserParams, ...arguments);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -19,7 +19,6 @@ export interface InitParameters {
|
|
|
19
19
|
accurateTrackBounce?: boolean | number;
|
|
20
20
|
childIframe?: boolean;
|
|
21
21
|
clickmap?: boolean;
|
|
22
|
-
defer?: boolean;
|
|
23
22
|
ecommerce?: boolean | string | any[];
|
|
24
23
|
params?: VisitParameters | VisitParameters[];
|
|
25
24
|
userParams?: UserParameters;
|
|
@@ -29,7 +28,7 @@ export interface InitParameters {
|
|
|
29
28
|
type?: number;
|
|
30
29
|
webvisor?: boolean;
|
|
31
30
|
triggerEvent?: boolean;
|
|
32
|
-
sendTitle
|
|
31
|
+
sendTitle?: boolean;
|
|
33
32
|
}
|
|
34
33
|
export interface HitOptions<CTX> {
|
|
35
34
|
callback?: (this: CTX) => void;
|
|
@@ -52,21 +51,33 @@ export interface People {
|
|
|
52
51
|
country?: string;
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
|
-
export declare const
|
|
56
|
-
Init
|
|
57
|
-
AddFileExtension
|
|
58
|
-
ExtLink
|
|
59
|
-
File
|
|
60
|
-
FirstPartyParams
|
|
61
|
-
FirstPartyParamsHashed
|
|
62
|
-
GetClientID
|
|
63
|
-
Hit
|
|
64
|
-
NotBounce
|
|
65
|
-
Params
|
|
66
|
-
ReachGoal
|
|
67
|
-
SetUserID
|
|
68
|
-
UserParams
|
|
69
|
-
}
|
|
70
|
-
export type Events = {
|
|
71
|
-
[key in Methods]: (...args: any[]) => void;
|
|
54
|
+
export declare const Methods: {
|
|
55
|
+
readonly Init: "init";
|
|
56
|
+
readonly AddFileExtension: "addFileExtension";
|
|
57
|
+
readonly ExtLink: "extLink";
|
|
58
|
+
readonly File: "file";
|
|
59
|
+
readonly FirstPartyParams: "firstPartyParams";
|
|
60
|
+
readonly FirstPartyParamsHashed: "firstPartyParamsHashed";
|
|
61
|
+
readonly GetClientID: "getClientID";
|
|
62
|
+
readonly Hit: "hit";
|
|
63
|
+
readonly NotBounce: "notBounce";
|
|
64
|
+
readonly Params: "params";
|
|
65
|
+
readonly ReachGoal: "reachGoal";
|
|
66
|
+
readonly SetUserID: "setUserID";
|
|
67
|
+
readonly UserParams: "userParams";
|
|
72
68
|
};
|
|
69
|
+
export interface YandexMetrikaApi {
|
|
70
|
+
init: (options: Partial<InitParameters>) => void;
|
|
71
|
+
addFileExtension: (extensions?: string | string[]) => void;
|
|
72
|
+
extLink: <CTX>(url: string, options: Omit<HitOptions<CTX>, 'referer'>) => void;
|
|
73
|
+
file: <CTX>(url: string, options?: HitOptions<CTX>) => void;
|
|
74
|
+
firstPartyParams: (people: People) => void;
|
|
75
|
+
firstPartyParamsHashed: (people: People) => void;
|
|
76
|
+
getClientID: (cb: (clientID: number) => void) => void;
|
|
77
|
+
hit: <CTX>(url: string, options?: HitOptions<CTX>) => void;
|
|
78
|
+
notBounce: <CTX>(options: Pick<HitOptions<CTX>, 'ctx' | 'callback'>) => void;
|
|
79
|
+
params: (params: VisitParameters) => void;
|
|
80
|
+
reachGoal: <CTX>(target: string, params: VisitParameters, callback?: (this: CTX) => void, ctx?: CTX) => void;
|
|
81
|
+
setUserID: (userId: string) => void;
|
|
82
|
+
userParams: (params: UserParameters) => void;
|
|
83
|
+
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})(Methods || {});
|
|
1
|
+
export const Methods = {
|
|
2
|
+
Init: "init",
|
|
3
|
+
AddFileExtension: "addFileExtension",
|
|
4
|
+
ExtLink: "extLink",
|
|
5
|
+
File: "file",
|
|
6
|
+
FirstPartyParams: "firstPartyParams",
|
|
7
|
+
FirstPartyParamsHashed: "firstPartyParamsHashed",
|
|
8
|
+
GetClientID: "getClientID",
|
|
9
|
+
Hit: "hit",
|
|
10
|
+
NotBounce: "notBounce",
|
|
11
|
+
Params: "params",
|
|
12
|
+
ReachGoal: "reachGoal",
|
|
13
|
+
SetUserID: "setUserID",
|
|
14
|
+
UserParams: "userParams"
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,69 +1,86 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
2
|
+
"name": "nuxt-yandex-metrika",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.0.1",
|
|
5
|
+
"packageManager": "pnpm@10.26.2",
|
|
6
|
+
"description": "Add Yandex Metrika to your Nuxt 4 application.",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "TakNePoidet <https://taknepoidet.xyz/>",
|
|
9
|
+
"url": "https://github.com/TakNePoidet"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "TakNePoidet/nuxt-yandex-metrika",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/TakNePoidet/nuxt-yandex-metrika.git"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/types.d.mts",
|
|
20
|
+
"import": "./dist/module.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/module.mjs",
|
|
24
|
+
"types": "./dist/types.d.mts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"prepack": "nuxt-module-build build",
|
|
30
|
+
"dev": "nuxi dev playground",
|
|
31
|
+
"dev:build": "nuxi build playground build",
|
|
32
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
33
|
+
"release": "pnpm run lint && npm run prepack && changelogen --release --major && npm publish && git push --follow-tags",
|
|
34
|
+
"test:type": "tsc --noEmit",
|
|
35
|
+
"test": "pnpm run lint && pnpm run test:type",
|
|
36
|
+
"lint": "pnpm run lint:code && pnpm run lint:format",
|
|
37
|
+
"lint:code": "eslint --cache --cache-strategy content \"**/*.ts\"",
|
|
38
|
+
"lint:format": "prettier --check --cache --cache-strategy content \"!**/*.{ts,vue}\" .",
|
|
39
|
+
"fix": "pnpm run fix:code && pnpm run fix:format",
|
|
40
|
+
"fix:code": "eslint --fix --cache --cache-strategy content \"**/*.ts\"",
|
|
41
|
+
"fix:format": "prettier --cache --cache-strategy content --write \"!**/*.{ts,vue}\" .",
|
|
42
|
+
"prepare": "husky install"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@nuxt/scripts": "^0.13.2"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@nuxt/kit": "^4.2.2",
|
|
52
|
+
"@prleasing/utility": "^5.0.1",
|
|
53
|
+
"consola": "^3.4.2",
|
|
54
|
+
"defu": "^6.1.4",
|
|
55
|
+
"valibot": "^1.2.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@nuxt/devtools": "^3.1.1",
|
|
59
|
+
"@nuxt/eslint-config": "^1.12.1",
|
|
60
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
61
|
+
"@nuxt/schema": "^4.2.2",
|
|
62
|
+
"@poidet/prettier": "^0.8.4",
|
|
63
|
+
"@prleasing/eslint": "^5.0.1",
|
|
64
|
+
"@prleasing/prettier": "^5.0.1",
|
|
65
|
+
"@types/node": "^25.0.3",
|
|
66
|
+
"changelogen": "^0.6.2",
|
|
67
|
+
"eslint": "^9.39.2",
|
|
68
|
+
"eslint-plugin-format": "^1.1.0",
|
|
69
|
+
"husky": "^9.1.7",
|
|
70
|
+
"lint-staged": "^16.2.7",
|
|
71
|
+
"nuxt": "^4.2.2",
|
|
72
|
+
"prettier": "^3.7.4",
|
|
73
|
+
"typescript": "5.9.3",
|
|
74
|
+
"vue-tsc": "^3.2.1"
|
|
75
|
+
},
|
|
76
|
+
"lint-staged": {
|
|
77
|
+
"**/*.(ts|vue)": [
|
|
78
|
+
"eslint --fix",
|
|
79
|
+
"git add"
|
|
80
|
+
],
|
|
81
|
+
"**/*.*": [
|
|
82
|
+
"prettier --write",
|
|
83
|
+
"git add"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
-
declare const _default: typeof __VLS_export;
|
|
3
|
-
export default _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
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}&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>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
-
declare const _default: typeof __VLS_export;
|
|
3
|
-
export default _default;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
-
declare const _default: typeof __VLS_export;
|
|
3
|
-
export default _default;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { useYandexMetrika } from "../composables/useYandexMetrika";
|
|
4
|
-
const { verification } = useYandexMetrika();
|
|
5
|
-
if (!verification) {
|
|
6
|
-
console.error(`${chalk.bgRed(chalk.black("[yandex-metrika]"))} ${chalk.red("Verification key not found")}`);
|
|
7
|
-
}
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<template>
|
|
11
|
-
<Meta v-if="verification" name="yandex-verification" :content="verification" />
|
|
12
|
-
</template>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
-
declare const _default: typeof __VLS_export;
|
|
3
|
-
export default _default;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Events, HitOptions, InitParameters, People, UserParameters, VisitParameters } from './types.js';
|
|
2
|
-
export * from './types.js';
|
|
3
|
-
export declare class YandexMetrika implements Events {
|
|
4
|
-
#private;
|
|
5
|
-
static src(cdn?: boolean): "https://cdn.jsdelivr.net/npm/yandex-metrica-watch/tag.js" | "https://mc.yandex.ru/metrika/tag.js";
|
|
6
|
-
constructor(id: string);
|
|
7
|
-
get debug(): boolean;
|
|
8
|
-
set debug(value: boolean);
|
|
9
|
-
get verification(): string | null;
|
|
10
|
-
set verification(value: string | null);
|
|
11
|
-
get id(): string;
|
|
12
|
-
init(options?: Partial<InitParameters>): void;
|
|
13
|
-
addFileExtension(extensions?: string | string[]): void;
|
|
14
|
-
extLink<CTX>(url: string, options?: Omit<HitOptions<CTX>, 'referer'>): void;
|
|
15
|
-
file<CTX>(url: string, options?: HitOptions<CTX>): void;
|
|
16
|
-
firstPartyParams(people: People): void;
|
|
17
|
-
firstPartyParamsHashed(people: People): void;
|
|
18
|
-
getClientID(cb: (clientID: number) => void): void;
|
|
19
|
-
hit<CTX>(url?: string, options?: HitOptions<CTX>): void;
|
|
20
|
-
notBounce<CTX>(options?: Pick<HitOptions<CTX>, 'ctx' | 'callback'>): void;
|
|
21
|
-
params(params?: VisitParameters): void;
|
|
22
|
-
reachGoal<CTX>(target: string, params: VisitParameters, callback?: (this: CTX) => void, ctx?: CTX): void;
|
|
23
|
-
setUserID(userId: string): void;
|
|
24
|
-
userParams(params?: UserParameters): void;
|
|
25
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { Methods } from "./types.js";
|
|
3
|
-
export * from "./types.js";
|
|
4
|
-
export class YandexMetrika {
|
|
5
|
-
#id;
|
|
6
|
-
#debug = false;
|
|
7
|
-
#verification = null;
|
|
8
|
-
static src(cdn = false) {
|
|
9
|
-
return cdn ? "https://cdn.jsdelivr.net/npm/yandex-metrica-watch/tag.js" : "https://mc.yandex.ru/metrika/tag.js";
|
|
10
|
-
}
|
|
11
|
-
constructor(id) {
|
|
12
|
-
this.#id = id;
|
|
13
|
-
}
|
|
14
|
-
get debug() {
|
|
15
|
-
return this.#debug;
|
|
16
|
-
}
|
|
17
|
-
set debug(value) {
|
|
18
|
-
this.#debug = value;
|
|
19
|
-
}
|
|
20
|
-
get verification() {
|
|
21
|
-
return this.#verification;
|
|
22
|
-
}
|
|
23
|
-
set verification(value) {
|
|
24
|
-
this.#verification = value;
|
|
25
|
-
}
|
|
26
|
-
get id() {
|
|
27
|
-
return this.#id;
|
|
28
|
-
}
|
|
29
|
-
init(options = {}) {
|
|
30
|
-
this.#call(Methods.Init, ...arguments);
|
|
31
|
-
}
|
|
32
|
-
addFileExtension(extensions) {
|
|
33
|
-
this.#call(Methods.AddFileExtension, ...arguments);
|
|
34
|
-
}
|
|
35
|
-
extLink(url, options = {}) {
|
|
36
|
-
this.#call(Methods.ExtLink, ...arguments);
|
|
37
|
-
}
|
|
38
|
-
file(url, options) {
|
|
39
|
-
this.#call(Methods.File, ...arguments);
|
|
40
|
-
}
|
|
41
|
-
firstPartyParams(people) {
|
|
42
|
-
this.#call(Methods.FirstPartyParams, ...arguments);
|
|
43
|
-
}
|
|
44
|
-
firstPartyParamsHashed(people) {
|
|
45
|
-
this.#call(Methods.FirstPartyParamsHashed, ...arguments);
|
|
46
|
-
}
|
|
47
|
-
getClientID(cb) {
|
|
48
|
-
this.#call(Methods.GetClientID, ...arguments);
|
|
49
|
-
}
|
|
50
|
-
hit(url = "", options) {
|
|
51
|
-
this.#call(Methods.Hit, ...arguments);
|
|
52
|
-
}
|
|
53
|
-
notBounce(options = {}) {
|
|
54
|
-
this.#call(Methods.NotBounce, ...arguments);
|
|
55
|
-
}
|
|
56
|
-
params(params = {}) {
|
|
57
|
-
this.#call(Methods.Params, ...arguments);
|
|
58
|
-
}
|
|
59
|
-
reachGoal(target, params, callback, ctx) {
|
|
60
|
-
this.#call(Methods.ReachGoal, ...arguments);
|
|
61
|
-
}
|
|
62
|
-
setUserID(userId) {
|
|
63
|
-
this.#call(Methods.SetUserID, ...arguments);
|
|
64
|
-
}
|
|
65
|
-
userParams(params = {}) {
|
|
66
|
-
this.#call(Methods.UserParams, ...arguments);
|
|
67
|
-
}
|
|
68
|
-
#call(type, ...args) {
|
|
69
|
-
if (this.#debug) {
|
|
70
|
-
console.log(`${chalk.bgGreen(chalk.black("[yandex-metrika]"))} ${chalk.blue(type)}`, ...args);
|
|
71
|
-
}
|
|
72
|
-
if (typeof window !== "undefined" && window.ym) {
|
|
73
|
-
window.ym(this.id, type, ...args);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|