nuxt-yandex-metrika 1.0.1 → 1.0.2
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 +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/useYandexMetrika.d.ts +1 -1
- package/dist/runtime/plugin.mjs +1 -1
- package/dist/runtime/yandex-metrika/YandexMetrika.d.ts +23 -0
- package/dist/runtime/yandex-metrika/YandexMetrika.mjs +77 -0
- package/dist/runtime/yandex-metrika/index.d.ts +2 -0
- package/dist/runtime/yandex-metrika/index.mjs +2 -0
- package/dist/runtime/yandex-metrika/types.d.ts +71 -0
- package/dist/runtime/yandex-metrika/types.mjs +16 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { YandexMetrika } from "
|
|
1
|
+
import { YandexMetrika } from "../yandex-metrika";
|
|
2
2
|
export declare function useYandexMetrika(): YandexMetrika;
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Events, HitOptions, InitParameters, People, UserParameters, VisitParameters } from "./types";
|
|
2
|
+
export * from "./types";
|
|
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 id(): string;
|
|
10
|
+
init(options?: InitParameters): void;
|
|
11
|
+
addFileExtension(extensions?: string | string[]): void;
|
|
12
|
+
extLink<CTX>(url: string, options?: Omit<HitOptions<CTX>, "referer">): void;
|
|
13
|
+
file<CTX>(url: string, options?: HitOptions<CTX>): void;
|
|
14
|
+
firstPartyParams(people: People): void;
|
|
15
|
+
firstPartyParamsHashed(people: People): void;
|
|
16
|
+
getClientID(cb: (clientID: number) => void): void;
|
|
17
|
+
hit<CTX>(url?: string, options?: HitOptions<CTX>): void;
|
|
18
|
+
notBounce<CTX>(options?: Pick<HitOptions<CTX>, "ctx" | "callback">): void;
|
|
19
|
+
params(params?: VisitParameters): void;
|
|
20
|
+
reachGoal<CTX>(target: string, params: VisitParameters, callback?: (this: CTX) => void, ctx?: CTX): void;
|
|
21
|
+
setUserID(userId: string): void;
|
|
22
|
+
userParams(params?: UserParameters): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import {
|
|
3
|
+
Methods
|
|
4
|
+
} from "./types.mjs";
|
|
5
|
+
export * from "./types.mjs";
|
|
6
|
+
export class YandexMetrika {
|
|
7
|
+
#id;
|
|
8
|
+
#debug = false;
|
|
9
|
+
static src(cdn = false) {
|
|
10
|
+
return cdn ? "https://cdn.jsdelivr.net/npm/yandex-metrica-watch/tag.js" : "https://mc.yandex.ru/metrika/tag.js";
|
|
11
|
+
}
|
|
12
|
+
constructor(id) {
|
|
13
|
+
this.#id = id;
|
|
14
|
+
}
|
|
15
|
+
get debug() {
|
|
16
|
+
return this.#debug;
|
|
17
|
+
}
|
|
18
|
+
set debug(value) {
|
|
19
|
+
this.#debug = value;
|
|
20
|
+
}
|
|
21
|
+
get id() {
|
|
22
|
+
return this.#id;
|
|
23
|
+
}
|
|
24
|
+
init(options = {}) {
|
|
25
|
+
this.#call(Methods.Init, ...arguments);
|
|
26
|
+
}
|
|
27
|
+
addFileExtension(extensions) {
|
|
28
|
+
this.#call(Methods.AddFileExtension, ...arguments);
|
|
29
|
+
}
|
|
30
|
+
extLink(url, options = {}) {
|
|
31
|
+
this.#call(Methods.ExtLink, ...arguments);
|
|
32
|
+
}
|
|
33
|
+
file(url, options) {
|
|
34
|
+
this.#call(Methods.File, ...arguments);
|
|
35
|
+
}
|
|
36
|
+
firstPartyParams(people) {
|
|
37
|
+
this.#call(Methods.FirstPartyParams, ...arguments);
|
|
38
|
+
}
|
|
39
|
+
firstPartyParamsHashed(people) {
|
|
40
|
+
this.#call(Methods.FirstPartyParamsHashed, ...arguments);
|
|
41
|
+
}
|
|
42
|
+
getClientID(cb) {
|
|
43
|
+
this.#call(Methods.GetClientID, ...arguments);
|
|
44
|
+
}
|
|
45
|
+
hit(url = "", options) {
|
|
46
|
+
this.#call(Methods.Hit, ...arguments);
|
|
47
|
+
}
|
|
48
|
+
notBounce(options = {}) {
|
|
49
|
+
this.#call(Methods.NotBounce, ...arguments);
|
|
50
|
+
}
|
|
51
|
+
params(params = {}) {
|
|
52
|
+
this.#call(Methods.Params, ...arguments);
|
|
53
|
+
}
|
|
54
|
+
reachGoal(target, params, callback, ctx) {
|
|
55
|
+
this.#call(Methods.ReachGoal, ...arguments);
|
|
56
|
+
}
|
|
57
|
+
setUserID(userId) {
|
|
58
|
+
this.#call(Methods.SetUserID, ...arguments);
|
|
59
|
+
}
|
|
60
|
+
userParams(params = {}) {
|
|
61
|
+
this.#call(Methods.UserParams, ...arguments);
|
|
62
|
+
}
|
|
63
|
+
#call(type, ...args) {
|
|
64
|
+
if (this.#debug) {
|
|
65
|
+
console.debug(
|
|
66
|
+
`${chalk.bgGreen(chalk.black("[yandex - metrika]"))} ${chalk.blue(
|
|
67
|
+
type
|
|
68
|
+
)}`,
|
|
69
|
+
...args
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
if (typeof window !== "undefined") {
|
|
73
|
+
console.log(window.ym);
|
|
74
|
+
window.ym(this.id, type, ...args);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
ym: ((...args: any[]) => void) & {
|
|
4
|
+
a: any[];
|
|
5
|
+
l: number;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export interface VisitParameters {
|
|
10
|
+
order_price?: number;
|
|
11
|
+
currency?: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
export interface UserParameters {
|
|
15
|
+
UserID?: number;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
export interface InitParameters {
|
|
19
|
+
accurateTrackBounce?: boolean | number;
|
|
20
|
+
childIframe?: boolean;
|
|
21
|
+
clickmap?: boolean;
|
|
22
|
+
defer?: boolean;
|
|
23
|
+
ecommerce?: boolean | string | any[];
|
|
24
|
+
params?: VisitParameters | VisitParameters[];
|
|
25
|
+
userParams?: UserParameters;
|
|
26
|
+
trackHash?: boolean;
|
|
27
|
+
trackLinks?: boolean;
|
|
28
|
+
trustedDomains?: string[];
|
|
29
|
+
type?: number;
|
|
30
|
+
webvisor?: boolean;
|
|
31
|
+
triggerEvent?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface HitOptions<CTX> {
|
|
34
|
+
callback?: (this: CTX) => void;
|
|
35
|
+
ctx?: CTX;
|
|
36
|
+
params?: VisitParameters;
|
|
37
|
+
referer?: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface People {
|
|
41
|
+
email?: string;
|
|
42
|
+
phone_number?: string;
|
|
43
|
+
first_name?: string;
|
|
44
|
+
last_name?: string;
|
|
45
|
+
yandex_cid?: number;
|
|
46
|
+
home_address?: {
|
|
47
|
+
street?: string;
|
|
48
|
+
city?: string;
|
|
49
|
+
region?: string;
|
|
50
|
+
postal_code?: number;
|
|
51
|
+
country?: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export declare const enum Methods {
|
|
55
|
+
Init = "init",
|
|
56
|
+
AddFileExtension = "addFileExtension",
|
|
57
|
+
ExtLink = "extLink",
|
|
58
|
+
File = "file",
|
|
59
|
+
FirstPartyParams = "firstPartyParams",
|
|
60
|
+
FirstPartyParamsHashed = "firstPartyParamsHashed",
|
|
61
|
+
GetClientID = "getClientID",
|
|
62
|
+
Hit = "hit",
|
|
63
|
+
NotBounce = "notBounce",
|
|
64
|
+
Params = "params",
|
|
65
|
+
ReachGoal = "reachGoal",
|
|
66
|
+
SetUserID = "setUserID",
|
|
67
|
+
UserParams = "userParams"
|
|
68
|
+
}
|
|
69
|
+
export type Events = {
|
|
70
|
+
[key in Methods]: (...args: any[]) => void;
|
|
71
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var Methods = /* @__PURE__ */ ((Methods2) => {
|
|
2
|
+
Methods2["Init"] = "init";
|
|
3
|
+
Methods2["AddFileExtension"] = "addFileExtension";
|
|
4
|
+
Methods2["ExtLink"] = "extLink";
|
|
5
|
+
Methods2["File"] = "file";
|
|
6
|
+
Methods2["FirstPartyParams"] = "firstPartyParams";
|
|
7
|
+
Methods2["FirstPartyParamsHashed"] = "firstPartyParamsHashed";
|
|
8
|
+
Methods2["GetClientID"] = "getClientID";
|
|
9
|
+
Methods2["Hit"] = "hit";
|
|
10
|
+
Methods2["NotBounce"] = "notBounce";
|
|
11
|
+
Methods2["Params"] = "params";
|
|
12
|
+
Methods2["ReachGoal"] = "reachGoal";
|
|
13
|
+
Methods2["SetUserID"] = "setUserID";
|
|
14
|
+
Methods2["UserParams"] = "userParams";
|
|
15
|
+
return Methods2;
|
|
16
|
+
})(Methods || {});
|