shore(tracker): use .gen sub-extension for generated files

This commit is contained in:
Alex Kaminskii 2022-08-03 12:38:31 +02:00
parent b0d11b3216
commit 9292ba494f
30 changed files with 371 additions and 36 deletions

View file

@ -131,6 +131,7 @@ Dir["templates/*.erb"].each do |tpl|
path = tpl.split '/'
t = '../' + path[1].gsub('~', '/')
t = t[0..-5]
# TODO: .gen subextention
File.write(t, e.result)
puts tpl + ' --> ' + t
end

View file

@ -1,7 +1,7 @@
// Auto-generated, do not edit
import * as Messages from '../../common/messages.js'
export { default } from '../../common/messages.js'
import * as Messages from '../../common/messages.gen.js'
export { default } from '../../common/messages.gen.js'
<% $messages.select { |msg| msg.tracker }.each do |msg| %>
export function <%= msg.name %>(

View file

@ -1,7 +1,7 @@
// Auto-generated, do not edit
import * as Messages from '../common/messages.js'
import Message from '../common/messages.js'
import * as Messages from '../common/messages.gen.js'
import Message from '../common/messages.gen.js'
import PrimitiveEncoder from './PrimitiveEncoder.js'

View file

@ -5,4 +5,4 @@ cjs
build
.cache
.eslintrc.cjs
src/common/messages.ts
*.gen.ts

View file

@ -1,4 +1,4 @@
import Message from './messages.js';
import Message from './messages.gen.js';
export interface Options {
connAttemptCount?: number;

View file

@ -1,5 +1,5 @@
import type Message from './messages.js';
import { Timestamp, Metadata, UserID } from './messages.js';
import type Message from './messages.gen.js';
import { Timestamp, Metadata, UserID } from './messages.gen.js';
import { timestamp, deprecationWarn } from '../utils.js';
import Nodes from './nodes.js';
import Observer from './observer/top_observer.js';

View file

@ -0,0 +1,334 @@
// Auto-generated, do not edit
import * as Messages from '../../common/messages.gen.js';
export { default } from '../../common/messages.gen.js';
export function BatchMetadata(
version: number,
pageNo: number,
firstIndex: number,
timestamp: number,
location: string,
): Messages.BatchMetadata {
return [Messages.Type.BatchMetadata, version, pageNo, firstIndex, timestamp, location];
}
export function PartitionedMessage(partNo: number, partTotal: number): Messages.PartitionedMessage {
return [Messages.Type.PartitionedMessage, partNo, partTotal];
}
export function Timestamp(timestamp: number): Messages.Timestamp {
return [Messages.Type.Timestamp, timestamp];
}
export function SetPageLocation(
url: string,
referrer: string,
navigationStart: number,
): Messages.SetPageLocation {
return [Messages.Type.SetPageLocation, url, referrer, navigationStart];
}
export function SetViewportSize(width: number, height: number): Messages.SetViewportSize {
return [Messages.Type.SetViewportSize, width, height];
}
export function SetViewportScroll(x: number, y: number): Messages.SetViewportScroll {
return [Messages.Type.SetViewportScroll, x, y];
}
export function CreateDocument(): Messages.CreateDocument {
return [Messages.Type.CreateDocument];
}
export function CreateElementNode(
id: number,
parentID: number,
index: number,
tag: string,
svg: boolean,
): Messages.CreateElementNode {
return [Messages.Type.CreateElementNode, id, parentID, index, tag, svg];
}
export function CreateTextNode(
id: number,
parentID: number,
index: number,
): Messages.CreateTextNode {
return [Messages.Type.CreateTextNode, id, parentID, index];
}
export function MoveNode(id: number, parentID: number, index: number): Messages.MoveNode {
return [Messages.Type.MoveNode, id, parentID, index];
}
export function RemoveNode(id: number): Messages.RemoveNode {
return [Messages.Type.RemoveNode, id];
}
export function SetNodeAttribute(
id: number,
name: string,
value: string,
): Messages.SetNodeAttribute {
return [Messages.Type.SetNodeAttribute, id, name, value];
}
export function RemoveNodeAttribute(id: number, name: string): Messages.RemoveNodeAttribute {
return [Messages.Type.RemoveNodeAttribute, id, name];
}
export function SetNodeData(id: number, data: string): Messages.SetNodeData {
return [Messages.Type.SetNodeData, id, data];
}
export function SetNodeScroll(id: number, x: number, y: number): Messages.SetNodeScroll {
return [Messages.Type.SetNodeScroll, id, x, y];
}
export function SetInputTarget(id: number, label: string): Messages.SetInputTarget {
return [Messages.Type.SetInputTarget, id, label];
}
export function SetInputValue(id: number, value: string, mask: number): Messages.SetInputValue {
return [Messages.Type.SetInputValue, id, value, mask];
}
export function SetInputChecked(id: number, checked: boolean): Messages.SetInputChecked {
return [Messages.Type.SetInputChecked, id, checked];
}
export function MouseMove(x: number, y: number): Messages.MouseMove {
return [Messages.Type.MouseMove, x, y];
}
export function ConsoleLog(level: string, value: string): Messages.ConsoleLog {
return [Messages.Type.ConsoleLog, level, value];
}
export function PageLoadTiming(
requestStart: number,
responseStart: number,
responseEnd: number,
domContentLoadedEventStart: number,
domContentLoadedEventEnd: number,
loadEventStart: number,
loadEventEnd: number,
firstPaint: number,
firstContentfulPaint: number,
): Messages.PageLoadTiming {
return [
Messages.Type.PageLoadTiming,
requestStart,
responseStart,
responseEnd,
domContentLoadedEventStart,
domContentLoadedEventEnd,
loadEventStart,
loadEventEnd,
firstPaint,
firstContentfulPaint,
];
}
export function PageRenderTiming(
speedIndex: number,
visuallyComplete: number,
timeToInteractive: number,
): Messages.PageRenderTiming {
return [Messages.Type.PageRenderTiming, speedIndex, visuallyComplete, timeToInteractive];
}
export function JSException(name: string, message: string, payload: string): Messages.JSException {
return [Messages.Type.JSException, name, message, payload];
}
export function RawCustomEvent(name: string, payload: string): Messages.RawCustomEvent {
return [Messages.Type.RawCustomEvent, name, payload];
}
export function UserID(id: string): Messages.UserID {
return [Messages.Type.UserID, id];
}
export function UserAnonymousID(id: string): Messages.UserAnonymousID {
return [Messages.Type.UserAnonymousID, id];
}
export function Metadata(key: string, value: string): Messages.Metadata {
return [Messages.Type.Metadata, key, value];
}
export function CSSInsertRule(id: number, rule: string, index: number): Messages.CSSInsertRule {
return [Messages.Type.CSSInsertRule, id, rule, index];
}
export function CSSDeleteRule(id: number, index: number): Messages.CSSDeleteRule {
return [Messages.Type.CSSDeleteRule, id, index];
}
export function Fetch(
method: string,
url: string,
request: string,
response: string,
status: number,
timestamp: number,
duration: number,
): Messages.Fetch {
return [Messages.Type.Fetch, method, url, request, response, status, timestamp, duration];
}
export function Profiler(
name: string,
duration: number,
args: string,
result: string,
): Messages.Profiler {
return [Messages.Type.Profiler, name, duration, args, result];
}
export function OTable(key: string, value: string): Messages.OTable {
return [Messages.Type.OTable, key, value];
}
export function StateAction(type: string): Messages.StateAction {
return [Messages.Type.StateAction, type];
}
export function Redux(action: string, state: string, duration: number): Messages.Redux {
return [Messages.Type.Redux, action, state, duration];
}
export function Vuex(mutation: string, state: string): Messages.Vuex {
return [Messages.Type.Vuex, mutation, state];
}
export function MobX(type: string, payload: string): Messages.MobX {
return [Messages.Type.MobX, type, payload];
}
export function NgRx(action: string, state: string, duration: number): Messages.NgRx {
return [Messages.Type.NgRx, action, state, duration];
}
export function GraphQL(
operationKind: string,
operationName: string,
variables: string,
response: string,
): Messages.GraphQL {
return [Messages.Type.GraphQL, operationKind, operationName, variables, response];
}
export function PerformanceTrack(
frames: number,
ticks: number,
totalJSHeapSize: number,
usedJSHeapSize: number,
): Messages.PerformanceTrack {
return [Messages.Type.PerformanceTrack, frames, ticks, totalJSHeapSize, usedJSHeapSize];
}
export function ResourceTiming(
timestamp: number,
duration: number,
ttfb: number,
headerSize: number,
encodedBodySize: number,
decodedBodySize: number,
url: string,
initiator: string,
): Messages.ResourceTiming {
return [
Messages.Type.ResourceTiming,
timestamp,
duration,
ttfb,
headerSize,
encodedBodySize,
decodedBodySize,
url,
initiator,
];
}
export function ConnectionInformation(
downlink: number,
type: string,
): Messages.ConnectionInformation {
return [Messages.Type.ConnectionInformation, downlink, type];
}
export function SetPageVisibility(hidden: boolean): Messages.SetPageVisibility {
return [Messages.Type.SetPageVisibility, hidden];
}
export function LongTask(
timestamp: number,
duration: number,
context: number,
containerType: number,
containerSrc: string,
containerId: string,
containerName: string,
): Messages.LongTask {
return [
Messages.Type.LongTask,
timestamp,
duration,
context,
containerType,
containerSrc,
containerId,
containerName,
];
}
export function SetNodeAttributeURLBased(
id: number,
name: string,
value: string,
baseURL: string,
): Messages.SetNodeAttributeURLBased {
return [Messages.Type.SetNodeAttributeURLBased, id, name, value, baseURL];
}
export function SetCSSDataURLBased(
id: number,
data: string,
baseURL: string,
): Messages.SetCSSDataURLBased {
return [Messages.Type.SetCSSDataURLBased, id, data, baseURL];
}
export function TechnicalInfo(type: string, value: string): Messages.TechnicalInfo {
return [Messages.Type.TechnicalInfo, type, value];
}
export function CustomIssue(name: string, payload: string): Messages.CustomIssue {
return [Messages.Type.CustomIssue, name, payload];
}
export function CSSInsertRuleURLBased(
id: number,
rule: string,
index: number,
baseURL: string,
): Messages.CSSInsertRuleURLBased {
return [Messages.Type.CSSInsertRuleURLBased, id, rule, index, baseURL];
}
export function MouseClick(
id: number,
hesitationTime: number,
label: string,
selector: string,
): Messages.MouseClick {
return [Messages.Type.MouseClick, id, hesitationTime, label, selector];
}
export function CreateIFrameDocument(frameID: number, id: number): Messages.CreateIFrameDocument {
return [Messages.Type.CreateIFrameDocument, frameID, id];
}

View file

@ -1,7 +1,7 @@
// Auto-generated, do not edit
import * as Messages from '../../common/messages.js';
export { default } from '../../common/messages.js';
import * as Messages from '../../common/messages.gen.js';
export { default } from '../../common/messages.gen.js';
export function BatchMetadata(
version: number,

View file

@ -1,5 +1,5 @@
import Observer from './observer.js';
import { CreateIFrameDocument } from '../messages.js';
import { CreateIFrameDocument } from '../messages.gen.js';
export default class IFrameObserver extends Observer {
observe(iframe: HTMLIFrameElement) {

View file

@ -8,7 +8,7 @@ import {
CreateElementNode,
MoveNode,
RemoveNode,
} from '../messages.js';
} from '../messages.gen.js';
import App from '../index.js';
import { isRootNode, isTextNode, isElementNode, isSVGElement, hasTag } from '../guards.js';

View file

@ -1,5 +1,5 @@
import Observer from './observer.js';
import { CreateIFrameDocument } from '../messages.js';
import { CreateIFrameDocument } from '../messages.gen.js';
export default class ShadowRootObserver extends Observer {
observe(el: Element) {

View file

@ -4,7 +4,7 @@ import { isElementNode, hasTag } from '../guards.js';
import IFrameObserver from './iframe_observer.js';
import ShadowRootObserver from './shadow_root_observer.js';
import { CreateDocument } from '../messages.js';
import { CreateDocument } from '../messages.gen.js';
import App from '../index.js';
import { IN_BROWSER, hasOpenreplayAttribute } from '../../utils.js';

View file

@ -1,8 +1,8 @@
import App, { DEFAULT_INGEST_POINT } from './app/index.js';
export { default as App } from './app/index.js';
import { UserID, UserAnonymousID, RawCustomEvent, CustomIssue } from './app/messages.js';
import * as _Messages from './app/messages.js';
import { UserID, UserAnonymousID, RawCustomEvent, CustomIssue } from './app/messages.gen.js';
import * as _Messages from './app/messages.gen.js';
export const Messages = _Messages;
import Connection from './modules/connection.js';

View file

@ -1,5 +1,5 @@
import App from '../app/index.js';
import { ConnectionInformation } from '../app/messages.js';
import { ConnectionInformation } from '../app/messages.gen.js';
export default function (app: App): void {
const connection:

View file

@ -1,7 +1,7 @@
import type App from '../app/index.js';
import { hasTag } from '../app/guards.js';
import { IN_BROWSER } from '../utils.js';
import { ConsoleLog } from '../app/messages.js';
import { ConsoleLog } from '../app/messages.gen.js';
const printError: (e: Error) => string =
IN_BROWSER && 'InstallTrigger' in window // detect Firefox

View file

@ -1,5 +1,5 @@
import type App from '../app/index.js';
import { CSSInsertRuleURLBased, CSSDeleteRule, TechnicalInfo } from '../app/messages.js';
import { CSSInsertRuleURLBased, CSSDeleteRule, TechnicalInfo } from '../app/messages.gen.js';
import { hasTag } from '../app/guards.js';
export default function (app: App | null) {

View file

@ -1,6 +1,6 @@
import type App from '../app/index.js';
import type Message from '../app/messages.js';
import { JSException } from '../app/messages.js';
import type Message from '../app/messages.gen.js';
import { JSException } from '../app/messages.gen.js';
import ErrorStackParser from 'error-stack-parser';
export interface Options {

View file

@ -1,6 +1,6 @@
import type App from '../app/index.js';
import { timestamp, isURL } from '../utils.js';
import { ResourceTiming, SetNodeAttributeURLBased, SetNodeAttribute } from '../app/messages.js';
import { ResourceTiming, SetNodeAttributeURLBased, SetNodeAttribute } from '../app/messages.gen.js';
import { hasTag } from '../app/guards.js';
function resolveURL(url: string, location: Location = document.location) {

View file

@ -1,7 +1,7 @@
import type App from '../app/index.js';
import { normSpaces, IN_BROWSER, getLabelAttribute, hasOpenreplayAttribute } from '../utils.js';
import { hasTag } from '../app/guards.js';
import { SetInputTarget, SetInputValue, SetInputChecked } from '../app/messages.js';
import { SetInputTarget, SetInputValue, SetInputChecked } from '../app/messages.gen.js';
const INPUT_TYPES = ['text', 'password', 'email', 'search', 'number', 'range', 'date'];

View file

@ -1,5 +1,5 @@
import type App from '../app/index.js';
import { LongTask } from '../app/messages.js';
import { LongTask } from '../app/messages.gen.js';
// https://w3c.github.io/performance-timeline/#the-performanceentry-interface
interface TaskAttributionTiming extends PerformanceEntry {

View file

@ -1,7 +1,7 @@
import type App from '../app/index.js';
import { hasTag, isSVGElement } from '../app/guards.js';
import { normSpaces, hasOpenreplayAttribute, getLabelAttribute } from '../utils.js';
import { MouseMove, MouseClick } from '../app/messages.js';
import { MouseMove, MouseClick } from '../app/messages.gen.js';
import { getInputLabel } from './input.js';
function _getSelector(target: Element): string {

View file

@ -1,6 +1,6 @@
import type App from '../app/index.js';
import { IN_BROWSER } from '../utils.js';
import { PerformanceTrack } from '../app/messages.js';
import { PerformanceTrack } from '../app/messages.gen.js';
type Perf = {
memory: {

View file

@ -1,5 +1,5 @@
import type App from '../app/index.js';
import { SetViewportScroll, SetNodeScroll } from '../app/messages.js';
import { SetViewportScroll, SetNodeScroll } from '../app/messages.gen.js';
import { isElementNode } from '../app/guards.js';
export default function (app: App): void {

View file

@ -1,7 +1,7 @@
import type App from '../app/index.js';
import { hasTag } from '../app/guards.js';
import { isURL } from '../utils.js';
import { ResourceTiming, PageLoadTiming, PageRenderTiming } from '../app/messages.js';
import { ResourceTiming, PageLoadTiming, PageRenderTiming } from '../app/messages.gen.js';
// Inspired by https://github.com/WPO-Foundation/RUM-SpeedIndex/blob/master/src/rum-speedindex.js

View file

@ -1,5 +1,5 @@
import type App from '../app/index.js';
import { SetPageLocation, SetViewportSize, SetPageVisibility } from '../app/messages.js';
import { SetPageLocation, SetViewportSize, SetPageVisibility } from '../app/messages.gen.js';
export default function (app: App): void {
let url: string, width: number, height: number;

View file

@ -1,6 +1,6 @@
import type Message from '../common/messages.js';
import * as Messages from '../common/messages.js';
import MessageEncoder from './MessageEncoder.js';
import type Message from '../common/messages.gen.js';
import * as Messages from '../common/messages.gen.js';
import MessageEncoder from './MessageEncoder.gen.js';
import PrimitiveEncoder from './PrimitiveEncoder.js';
const SIZE_BYTES = 2;

View file

@ -1,7 +1,7 @@
// Auto-generated, do not edit
import * as Messages from '../common/messages.js';
import Message from '../common/messages.js';
import * as Messages from '../common/messages.gen.js';
import Message from '../common/messages.gen.js';
import PrimitiveEncoder from './PrimitiveEncoder.js';
export default class MessageEncoder extends PrimitiveEncoder {

View file

@ -1,5 +1,5 @@
import type Message from '../common/messages.js';
import { Type as MType } from '../common/messages.js';
import type Message from '../common/messages.gen.js';
import { Type as MType } from '../common/messages.gen.js';
import { WorkerMessageData } from '../common/interaction.js';
import QueueSender from './QueueSender.js';