summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/api/models/metrics/metrics.js
blob: 23e26bd73500265556d1662113d6a3f4c545deae (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
 * Created by joel on 2/13/17.
 */
import * as JetMetrics from "@jet/environment/types/metrics";
import * as models from "../base";
// TS only allows extending **type information** in `declare module`s.
// These members **must** be initialized.
// TODO: The root cause for this workaround is because the Jet type `PageInvocationPoint` is not a `const enum`.
//       Consider changing the Jet type to a `const enum`, and the compiler will automatically inline these values.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const extendedPageInvocationPoint = JetMetrics.PageInvocationPoint;
extendedPageInvocationPoint["search"] = "search";
extendedPageInvocationPoint["timer"] = "timer";
extendedPageInvocationPoint["never"] = "never";
extendedPageInvocationPoint["pageChange"] = "pageChange";
/** @public */
export class AppStoreMetricsData {
    constructor(fields, includingFields, excludingFields, topic, shouldFlush = false) {
        this.fields = fields;
        this.includingFields = includingFields;
        this.excludingFields = excludingFields;
        this.topic = topic;
        this.shouldFlush = shouldFlush;
    }
}
/** @public */
export class LintedMetricsEvent extends models.Model {
    constructor(fields) {
        super();
        this.fields = fields;
    }
}
/** @public */
export class ActionMetrics extends models.Model {
    constructor(events) {
        super();
        this.data = events || [];
        this.custom = {};
    }
    addMetricsData(data) {
        this.data.push(data);
    }
    addManyMetricsData(dataArray) {
        for (const data of dataArray) {
            this.addMetricsData(data);
        }
    }
    clearAll() {
        this.data.length = 0;
    }
}
/** @public */
export class PageMetrics extends models.Model {
    constructor() {
        super();
        this.instructions = [];
        this.custom = {};
    }
    addInstruction(instruction) {
        this.instructions.push(instruction);
    }
    addManyInstructions(instructions) {
        for (const instruction of instructions) {
            this.addInstruction(instruction);
        }
    }
    addData(data, invocationPoints) {
        const event = {
            data,
            invocationPoints,
        };
        this.instructions.push(event);
    }
    addManyData(dataArray, invocationPoints) {
        for (const data of dataArray) {
            this.addData(data, invocationPoints);
        }
    }
}
// TODO: This needs to be migrated to the JetEngine version of ImpressionMetrics
// The primary challenge is ID is required in the JetEngine representation, which will require
// some refactoring both in JS and native to get right
/** @public */
export class ImpressionMetrics {
    constructor(fields, id, custom) {
        this.fields = fields;
        this.id = id;
        this.custom = custom;
    }
}
/** @public */
export class FastImpressionMetrics extends ImpressionMetrics {
    constructor(metrics, isFast) {
        super(metrics.fields, metrics.id, metrics.custom || {});
        if (this.custom !== undefined) {
            this.custom["isFast"] = isFast;
        }
        this.isFast = isFast;
    }
}
//# sourceMappingURL=metrics.js.map