clarity-js 0.7.5 → 0.7.7

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/src/core/scrub.ts CHANGED
@@ -30,6 +30,7 @@ export function text(value: string, hint: string, privacy: Privacy, mangle: bool
30
30
  case Privacy.TextImage:
31
31
  switch (hint) {
32
32
  case Layout.Constant.TextTag:
33
+ case Layout.Constant.DataAttribute:
33
34
  return mangle ? mangleText(value) : mask(value);
34
35
  case "src":
35
36
  case "srcset":
@@ -48,6 +49,7 @@ export function text(value: string, hint: string, privacy: Privacy, mangle: bool
48
49
  case Privacy.Exclude:
49
50
  switch (hint) {
50
51
  case Layout.Constant.TextTag:
52
+ case Layout.Constant.DataAttribute:
51
53
  return mangle ? mangleText(value) : mask(value);
52
54
  case "value":
53
55
  case "input":
@@ -57,6 +59,25 @@ export function text(value: string, hint: string, privacy: Privacy, mangle: bool
57
59
  case "checksum":
58
60
  return Data.Constant.Empty;
59
61
  }
62
+ break;
63
+ case Privacy.Snapshot:
64
+ switch (hint) {
65
+ case Layout.Constant.TextTag:
66
+ case Layout.Constant.DataAttribute:
67
+ return scrub(value);
68
+ case "value":
69
+ case "input":
70
+ case "click":
71
+ case "change":
72
+ return Array(Data.Setting.WordLength).join(Data.Constant.Mask);
73
+ case "checksum":
74
+ case "src":
75
+ case "srcset":
76
+ case "alt":
77
+ case "title":
78
+ return Data.Constant.Empty;
79
+ }
80
+ break;
60
81
  }
61
82
  }
62
83
  return value;
@@ -83,11 +104,16 @@ function mangleText(value: string): string {
83
104
  }
84
105
  return value;
85
106
  }
86
-
107
+
87
108
  function mask(value: string): string {
88
109
  return value.replace(catchallRegex, Data.Constant.Mask);
89
110
  }
90
111
 
112
+ function scrub(value: string): string {
113
+ regex(); // Initialize regular expressions
114
+ return value.replace(letterRegex, Data.Constant.Letter).replace(digitRegex, Data.Constant.Digit);
115
+ }
116
+
91
117
  function mangleToken(value: string): string {
92
118
  let length = ((Math.floor(value.length / Data.Setting.WordLength) + 1) * Data.Setting.WordLength);
93
119
  let output: string = Layout.Constant.Empty;
@@ -97,14 +123,7 @@ function mangleToken(value: string): string {
97
123
  return output;
98
124
  }
99
125
 
100
- function redact(value: string): string {
101
- let spaceIndex = -1;
102
- let gap = 0;
103
- let hasDigit = false;
104
- let hasEmail = false;
105
- let hasWhitespace = false;
106
- let array = null;
107
-
126
+ function regex(): void {
108
127
  // Initialize unicode regex, if supported by the browser
109
128
  // Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes
110
129
  if (unicodeRegex && digitRegex === null) {
@@ -114,6 +133,17 @@ function redact(value: string): string {
114
133
  currencyRegex = new RegExp("\\p{Sc}", "gu");
115
134
  } catch { unicodeRegex = false; }
116
135
  }
136
+ }
137
+
138
+ function redact(value: string): string {
139
+ let spaceIndex = -1;
140
+ let gap = 0;
141
+ let hasDigit = false;
142
+ let hasEmail = false;
143
+ let hasWhitespace = false;
144
+ let array = null;
145
+
146
+ regex(); // Initialize regular expressions
117
147
 
118
148
  for (let i = 0; i < value.length; i++) {
119
149
  let c = value.charCodeAt(i);
@@ -1,2 +1,2 @@
1
- let version = "0.7.5";
1
+ let version = "0.7.7";
2
2
  export default version;
@@ -108,10 +108,17 @@ export default function(event: Event): void {
108
108
  break;
109
109
  case Event.Extract:
110
110
  let extractKeys = extract.keys;
111
- for (let e of extractKeys) {
111
+ extractKeys.forEach((e => {
112
112
  tokens.push(e);
113
- tokens.push([].concat(...extract.data[e]));
114
- }
113
+ let token = []
114
+ for (let d in extract.data[e]) {
115
+ let key = parseInt(d, 10);
116
+ token.push(key);
117
+ token.push(extract.data[e][d]);
118
+ }
119
+ tokens.push(token);
120
+ }));
121
+
115
122
  extract.reset();
116
123
  queue(tokens, false);
117
124
  }
@@ -3,16 +3,23 @@ import { Event, Setting, ExtractData } from "@clarity-types/data";
3
3
  import encode from "./encode";
4
4
  import * as internal from "@src/diagnostic/internal";
5
5
  import { Code, Constant, Severity } from "@clarity-types/data";
6
+ import { hashText } from "@src/clarity";
6
7
 
7
8
  export let data: ExtractData = {};
8
- export let keys: number[] = [];
9
+ export let keys: Set<number> = new Set();
9
10
 
10
11
  let variables : { [key: number]: { [key: number]: Syntax[] }} = {};
11
12
  let selectors : { [key: number]: { [key: number]: string }} = {};
13
+ let hashes : { [key: number]: { [key: number]: string }} = {};
12
14
  export function start(): void {
13
15
  reset();
14
16
  }
15
17
 
18
+ // Input string is of the following form:
19
+ // EXTRACT 101 { "1": ".class1", "2": "~window.a.b", "3": "!abc"}
20
+ // Which will set up event 101 to grab the contents of the class1 selector into component 1,
21
+ // the javascript evaluated contents of window.a.b into component 2,
22
+ // and the contents of Clarity's hash abc into component 3
16
23
  export function trigger(input: string): void {
17
24
  try {
18
25
  var parts = input && input.length > 0 ? input.split(/ (.*)/) : [Constant.Empty];
@@ -20,10 +27,18 @@ export function trigger(input: string): void {
20
27
  var values = parts.length > 1 ? JSON.parse(parts[1]) : {};
21
28
  variables[key] = {};
22
29
  selectors[key] = {};
30
+ hashes[key] = {};
23
31
  for (var v in values) {
32
+ // values is a set of strings for proper JSON parsing, but it's more efficient
33
+ // to interact with them as numbers
24
34
  let id = parseInt(v);
25
35
  let value = values[v] as string;
26
- let source = value.startsWith(Constant.Tilde) ? ExtractSource.Javascript : ExtractSource.Text;
36
+ let source = ExtractSource.Text;
37
+ if (value.startsWith(Constant.Tilde)) {
38
+ source = ExtractSource.Javascript
39
+ } else if (value.startsWith(Constant.Bang)) {
40
+ source = ExtractSource.Hash
41
+ }
27
42
  switch (source) {
28
43
  case ExtractSource.Javascript:
29
44
  let variable = value.substring(1, value.length);
@@ -32,6 +47,10 @@ export function trigger(input: string): void {
32
47
  case ExtractSource.Text:
33
48
  selectors[key][id] = value;
34
49
  break;
50
+ case ExtractSource.Hash:
51
+ let hash = value.substring(1, value.length);
52
+ hashes[key][id] = hash;
53
+ break;
35
54
  }
36
55
  }
37
56
  }
@@ -48,44 +67,63 @@ export function compute(): void {
48
67
  try {
49
68
  for (let v in variables) {
50
69
  let key = parseInt(v);
51
- if (!(key in keys)) {
52
- let variableData = variables[key];
53
- for (let v in variableData) {
54
- let variableKey = parseInt(v);
55
- let value = str(evaluate(clone(variableData[variableKey])));
56
- if (value) { update(key, variableKey, value); }
70
+ let variableData = variables[key];
71
+ for (let v in variableData) {
72
+ let variableKey = parseInt(v);
73
+ let value = str(evaluate(clone(variableData[variableKey])));
74
+ if (value) {
75
+ update(key, variableKey, value);
57
76
  }
77
+ }
58
78
 
59
- let selectorData = selectors[key];
60
- for (let s in selectorData) {
61
- let selectorKey = parseInt(s);
62
- let nodes = document.querySelectorAll(selectorData[selectorKey]) as NodeListOf<HTMLElement>;
63
- if (nodes) {
64
- let text = Array.from(nodes).map(e => e.innerText)
65
- update(key, selectorKey, text.join(Constant.Seperator).substring(0, Setting.ExtractLimit));
66
- }
79
+ let selectorData = selectors[key];
80
+ for (let s in selectorData) {
81
+ let selectorKey = parseInt(s);
82
+ let nodes = document.querySelectorAll(selectorData[selectorKey]) as NodeListOf<HTMLElement>;
83
+ if (nodes) {
84
+ let text = Array.from(nodes).map(e => e.innerText)
85
+ update(key, selectorKey, text.join(Constant.Seperator).substring(0, Setting.ExtractLimit));
67
86
  }
68
87
  }
88
+
89
+ let hashData = hashes[key];
90
+ for (let h in hashData) {
91
+ let hashKey = parseInt(h);
92
+ let content = hashText(hashData[hashKey]).trim().substring(0, Setting.ExtractLimit);
93
+ update(key, hashKey, content);
94
+ }
95
+ }
96
+
97
+ if (keys.size > 0) {
98
+ encode(Event.Extract);
69
99
  }
70
100
  }
71
101
  catch (e) { internal.log(Code.Selector, Severity.Warning, e ? e.name : null); }
72
-
73
- encode(Event.Extract);
74
102
  }
75
103
 
76
104
  export function reset(): void {
77
- data = {};
78
- keys = [];
79
- variables = {};
80
- selectors = {};
105
+ keys.clear();
81
106
  }
82
107
 
83
- export function update(key: number, subkey: number, value: string): void {
108
+ export function update(key: number, subkey: number, value: string): void {
109
+ var update = false;
84
110
  if (!(key in data)) {
85
- data[key] = []
86
- keys.push(key);
111
+ data[key] = {};
112
+ update = true;
87
113
  }
88
- data[key].push([subkey, value]);
114
+
115
+ if (!isEmpty(hashes[key])
116
+ && (!(subkey in data[key]) || data[key][subkey] != value))
117
+ {
118
+ update = true;
119
+ }
120
+
121
+ data[key][subkey] = value;
122
+ if (update) {
123
+ keys.add(key);
124
+ }
125
+
126
+ return;
89
127
  }
90
128
 
91
129
  export function stop(): void {
@@ -151,4 +189,8 @@ function match(base: Object, condition: string): boolean {
151
189
  }
152
190
 
153
191
  return true;
154
- }
192
+ }
193
+
194
+ function isEmpty(obj: Object): boolean {
195
+ return Object.keys(obj).length == 0;
196
+ }
@@ -85,11 +85,16 @@ export function stop(): void {
85
85
  }
86
86
 
87
87
  export function metadata(cb: MetadataCallback, wait: boolean = true): void {
88
- if (data && wait === false) {
88
+ let upgraded = config.lean ? BooleanFlag.False : BooleanFlag.True;
89
+ // if caller hasn't specified that they want to skip waiting for upgrade but we've already upgraded, we need to
90
+ // directly execute the callback rather than adding to our list as we only process callbacks at the moment
91
+ // we go through the upgrading flow.
92
+ if (data && (upgraded || wait === false)) {
89
93
  // Immediately invoke the callback if the caller explicitly doesn't want to wait for the upgrade confirmation
90
94
  cb(data, !config.lean);
95
+ } else {
96
+ callbacks.push({callback: cb, wait: wait });
91
97
  }
92
- callbacks.push({callback: cb, wait: wait });
93
98
  }
94
99
 
95
100
  export function id(): string {
@@ -49,7 +49,8 @@ export function queue(tokens: Token[], transmit: boolean = true): void {
49
49
  case Event.Discover:
50
50
  discoverBytes += event.length;
51
51
  case Event.Box:
52
- case Event.Mutation:
52
+ case Event.Mutation:
53
+ case Event.Snapshot:
53
54
  playbackBytes += event.length;
54
55
  playback.push(event);
55
56
  break;
@@ -4,6 +4,8 @@ export let data = null;
4
4
  /* Intentionally blank module with empty code */
5
5
 
6
6
  export function start(): void {}
7
- export function observe(): void {}
8
7
  export function reset(): void {}
9
8
  export function stop(): void {}
9
+ export function log(): void {}
10
+ export function observe(): void {}
11
+ export function compute(): void {}
@@ -0,0 +1,61 @@
1
+ import { Privacy } from "@clarity-types/core";
2
+ import { Event, Token } from "@clarity-types/data";
3
+ import { Constant, NodeInfo } from "@clarity-types/layout";
4
+ import * as scrub from "@src/core/scrub";
5
+ import { time } from "@src/core/time";
6
+ import * as baseline from "@src/data/baseline";
7
+ import tokenize from "@src/data/token";
8
+ import { queue } from "@src/data/upload";
9
+ import * as snapshot from "@src/insight/snapshot";
10
+ import * as doc from "@src/layout/document";
11
+
12
+ export default async function (type: Event): Promise<void> {
13
+ let eventTime = time()
14
+ let tokens: Token[] = [eventTime, type];
15
+ switch (type) {
16
+ case Event.Document:
17
+ let d = doc.data;
18
+ tokens.push(d.width);
19
+ tokens.push(d.height);
20
+ baseline.track(type, d.width, d.height);
21
+ queue(tokens);
22
+ break;
23
+ case Event.Snapshot:
24
+ let values = snapshot.values;
25
+ // Only encode and queue DOM updates if we have valid updates to report back
26
+ if (values.length > 0) {
27
+ for (let value of values) {
28
+ let privacy = value.metadata.privacy;
29
+ let data: NodeInfo = value.data;
30
+ for (let key of ["tag", "attributes", "value"]) {
31
+ if (data[key]) {
32
+ switch (key) {
33
+ case "tag":
34
+ tokens.push(value.id);
35
+ if (value.parent) { tokens.push(value.parent); }
36
+ if (value.previous) { tokens.push(value.previous); }
37
+ tokens.push(data[key]);
38
+ break;
39
+ case "attributes":
40
+ for (let attr in data[key]) {
41
+ if (data[key][attr] !== undefined) {
42
+ tokens.push(attribute(attr, data[key][attr], privacy));
43
+ }
44
+ }
45
+ break;
46
+ case "value":
47
+ tokens.push(scrub.text(data[key], data.tag, privacy));
48
+ break;
49
+ }
50
+ }
51
+ }
52
+ }
53
+ queue(tokenize(tokens), true);
54
+ }
55
+ break;
56
+ }
57
+ }
58
+
59
+ function attribute(key: string, value: string, privacy: Privacy): string {
60
+ return `${key}=${scrub.text(value, key.indexOf(Constant.DataAttribute) === 0 ? Constant.DataAttribute : key, privacy)}`;
61
+ }
@@ -0,0 +1,112 @@
1
+ import { OffsetDistance, Privacy } from "@clarity-types/core";
2
+ import { Event } from "@clarity-types/data";
3
+ import { Constant, NodeInfo, NodeValue, TargetMetadata } from "@clarity-types/layout";
4
+ import * as doc from "@src/layout/document";
5
+ import encode from "@src/insight/encode";
6
+ import * as interaction from "@src/interaction";
7
+ export let values: NodeValue[] = [];
8
+ let index: number = 1;
9
+ let idMap: WeakMap<Node, number> = null; // Maps node => id.
10
+
11
+ export function start(): void {
12
+ reset();
13
+ doc.start();
14
+ getId(document.documentElement); // Pre-discover ID for page root
15
+ interaction.observe(document);
16
+ }
17
+
18
+ export function stop(): void {
19
+ reset();
20
+ doc.stop();
21
+ }
22
+
23
+ export function compute(): void { /* Intentionally Blank */ }
24
+ export function iframe(): boolean { return false; }
25
+ export function offset(): OffsetDistance { return { x: 0, y: 0 }; }
26
+ export function hashText(): void { /* Intentionally Blank */ }
27
+
28
+ export function target(evt: UIEvent): Node {
29
+ let path = evt.composed && evt.composedPath ? evt.composedPath() : null;
30
+ let node = (path && path.length > 0 ? path[0] : evt.target) as Node;
31
+ return node.nodeType === Node.DOCUMENT_NODE ? (node as Document).documentElement : node;
32
+ }
33
+
34
+ export function metadata(node: Node): TargetMetadata {
35
+ let output: TargetMetadata = { id: 0, hash: null, privacy: Privacy.Snapshot, node };
36
+ if (node) { output.id = idMap.has(node) ? idMap.get(node) : getId(node); }
37
+ return output;
38
+ }
39
+
40
+ export function snapshot(): void {
41
+ values = [];
42
+ traverse(document);
43
+ encode(Event.Snapshot);
44
+ }
45
+
46
+ function reset(): void {
47
+ idMap = new WeakMap();
48
+ }
49
+
50
+ function traverse(root: Node): void {
51
+ let queue = [root];
52
+ while (queue.length > 0) {
53
+ let attributes = null, tag = null, value = null;
54
+ let node = queue.shift();
55
+ let next = node.firstChild;
56
+ let parent = node.parentElement ? node.parentElement : (node.parentNode ? node.parentNode : null);
57
+
58
+ while (next) {
59
+ queue.push(next);
60
+ next = next.nextSibling;
61
+ }
62
+
63
+ // Process the node
64
+ let type = node.nodeType;
65
+ switch (type) {
66
+ case Node.DOCUMENT_TYPE_NODE:
67
+ let doctype = node as DocumentType;
68
+ tag = Constant.DocumentTag;
69
+ attributes = { name: doctype.name, publicId: doctype.publicId, systemId: doctype.systemId }
70
+ break;
71
+ case Node.TEXT_NODE:
72
+ value = node.nodeValue;
73
+ tag = idMap.get(parent) ? Constant.TextTag : tag;
74
+ break;
75
+ case Node.ELEMENT_NODE:
76
+ let element = node as HTMLElement;
77
+ attributes = getAttributes(element);
78
+ tag = ["NOSCRIPT", "SCRIPT", "STYLE"].indexOf(element.tagName) < 0 ? element.tagName : tag;
79
+ break;
80
+ }
81
+ add(node, parent, { tag, attributes, value });
82
+ }
83
+ }
84
+
85
+ /* Helper Functions - Snapshot Traversal */
86
+ function getAttributes(element: HTMLElement): { [key: string]: string } {
87
+ let output = {};
88
+ let attributes = element.attributes;
89
+ if (attributes && attributes.length > 0) {
90
+ for (let i = 0; i < attributes.length; i++) {
91
+ output[attributes[i].name] = attributes[i].value;
92
+ }
93
+ }
94
+ return output;
95
+ }
96
+
97
+ function getId(node: Node): number {
98
+ if (node === null) { return null; }
99
+ if (idMap.has(node)) { return idMap.get(node); }
100
+ idMap.set(node, index);
101
+ return index++;
102
+ }
103
+
104
+ function add(node: Node, parent: Node, data: NodeInfo): void {
105
+ if (node && data && data.tag) {
106
+ let id = getId(node);
107
+ let parentId = parent ? idMap.get(parent) : null;
108
+ let previous = node.previousSibling ? idMap.get(node.previousSibling) : null;
109
+ let metadata = { active: true, suspend: false, privacy: Privacy.Snapshot, position: null, fraud: null, size: null };
110
+ values.push({ id, parent: parentId, previous, children: [], data, selector: null, hash: null, region: null, metadata });
111
+ }
112
+ }
@@ -5,8 +5,8 @@ import { bind } from "@src/core/event";
5
5
  import { schedule } from "@src/core/task";
6
6
  import { time } from "@src/core/time";
7
7
  import { iframe } from "@src/layout/dom";
8
- import offset from "@src/layout/offset";
9
- import { link, target } from "@src/layout/target";
8
+ import { offset } from "@src/layout/offset";
9
+ import { target } from "@src/layout/target";
10
10
  import encode from "./encode";
11
11
 
12
12
  const UserInputTags = ["input", "textarea", "radio", "button", "canvas"];
@@ -73,6 +73,19 @@ function handler(event: Event, root: Node, evt: MouseEvent): void {
73
73
  }
74
74
  }
75
75
 
76
+ function link(node: Node): HTMLAnchorElement {
77
+ while (node && node !== document) {
78
+ if (node.nodeType === Node.ELEMENT_NODE) {
79
+ let element = node as HTMLElement;
80
+ if (element.tagName === "A") {
81
+ return element as HTMLAnchorElement;
82
+ }
83
+ }
84
+ node = node.parentNode;
85
+ }
86
+ return null;
87
+ }
88
+
76
89
  function text(element: Node): string {
77
90
  let output = null;
78
91
  if (element) {
@@ -47,7 +47,7 @@ export default async function (type: Event, ts: number = null): Promise<void> {
47
47
  for (let entry of click.state) {
48
48
  let cTarget = metadata(entry.data.target as Node, entry.event, entry.data.text);
49
49
  tokens = [entry.time, entry.event];
50
- let cHash = cTarget.hash.join(Constant.Dot);
50
+ let cHash = cTarget.hash ? cTarget.hash.join(Constant.Dot) : Constant.Empty;
51
51
  tokens.push(cTarget.id);
52
52
  tokens.push(entry.data.x);
53
53
  tokens.push(entry.data.y);
@@ -5,7 +5,7 @@ import { schedule } from "@src/core/task";
5
5
  import { time } from "@src/core/time";
6
6
  import { clearTimeout, setTimeout } from "@src/core/timeout";
7
7
  import { iframe } from "@src/layout/dom";
8
- import offset from "@src/layout/offset";
8
+ import { offset } from "@src/layout/offset";
9
9
  import { target } from "@src/layout/target";
10
10
  import encode from "./encode";
11
11
 
@@ -1,6 +1,6 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { DocumentData } from "@clarity-types/layout";
3
- import encode from "./encode";
3
+ import encode from "@src/layout/encode";
4
4
 
5
5
  export let data: DocumentData;
6
6
 
@@ -41,6 +41,6 @@ export function compute(): void {
41
41
  }
42
42
  }
43
43
 
44
- export function end(): void {
44
+ export function stop(): void {
45
45
  reset();
46
46
  }
@@ -106,5 +106,5 @@ function str(input: number): string {
106
106
  }
107
107
 
108
108
  function attribute(key: string, value: string, privacy: Privacy): string {
109
- return `${key}=${scrub.text(value, key, privacy)}`;
109
+ return `${key}=${scrub.text(value, key.indexOf(Constant.DataAttribute) === 0 ? Constant.DataAttribute : key, privacy)}`;
110
110
  }
@@ -20,5 +20,5 @@ export function stop(): void {
20
20
  region.stop();
21
21
  dom.stop();
22
22
  mutation.stop();
23
- doc.end();
23
+ doc.stop();
24
24
  }
@@ -1,7 +1,7 @@
1
1
  import { OffsetDistance } from "@clarity-types/core";
2
2
  import { iframe } from "@src/layout/dom";
3
3
 
4
- export default function(element: HTMLElement): OffsetDistance {
4
+ export function offset(element: HTMLElement): OffsetDistance {
5
5
  let output: OffsetDistance = { x: 0, y: 0 };
6
6
 
7
7
  // Walk up the chain to ensure we compute offset distance correctly
@@ -13,19 +13,6 @@ export function target(evt: UIEvent): Node {
13
13
  return node.nodeType === Node.DOCUMENT_NODE ? (node as Document).documentElement : node;
14
14
  }
15
15
 
16
- export function link(node: Node): HTMLAnchorElement {
17
- while (node && node !== document) {
18
- if (node.nodeType === Node.ELEMENT_NODE) {
19
- let element = node as HTMLElement;
20
- if (element.tagName === "A") {
21
- return element as HTMLAnchorElement;
22
- }
23
- }
24
- node = node.parentNode;
25
- }
26
- return null;
27
- }
28
-
29
16
  export function metadata(node: Node, event: Event, text: string = null): TargetMetadata {
30
17
  // If the node is null, we return a reserved value for id: 0. Valid assignment of id begins from 1+.
31
18
  let output: TargetMetadata = { id: 0, hash: null, privacy: Privacy.Text, node };
@@ -1,13 +1,13 @@
1
1
  import { Task, Timer } from "@clarity-types/core";
2
2
  import { Source } from "@clarity-types/layout";
3
3
  import * as task from "@src/core/task";
4
- import processNode from "./node";
4
+ import node from "@src/layout/node";
5
5
 
6
6
  export default async function(root: Node, timer: Timer, source: Source): Promise<void> {
7
7
  let queue = [root];
8
8
  while (queue.length > 0) {
9
- let node = queue.shift();
10
- let next = node.firstChild;
9
+ let entry = queue.shift();
10
+ let next = entry.firstChild;
11
11
 
12
12
  while (next) {
13
13
  queue.push(next);
@@ -22,7 +22,7 @@ export default async function(root: Node, timer: Timer, source: Source): Promise
22
22
  // Check if processing a node gives us a pointer to one of its sub nodes for traversal
23
23
  // E.g. an element node may give us a pointer to traverse shadowDom if shadowRoot property is set
24
24
  // Or, an iframe from the same origin could give a pointer to it's document for traversing contents of iframe.
25
- let subnode = processNode(node, source);
25
+ let subnode = node(entry, source);
26
26
  if (subnode) { queue.push(subnode); }
27
27
  }
28
28
  }
package/src/queue.ts CHANGED
@@ -9,6 +9,8 @@ export function setup() {
9
9
  if (typeof w !== "undefined") {
10
10
  w[c] = function() {
11
11
  (w[c].q = w[c].q || []).push(arguments);
12
+ // if the start function was called, don't queue it and instead process the queue
13
+ arguments[0] === "start" && w[c].q.unshift(w[c].q.pop()) && process();
12
14
  };
13
15
  }
14
16
  }
package/types/core.d.ts CHANGED
@@ -34,7 +34,8 @@ export const enum ExtractSource {
34
34
  Javascript = 0,
35
35
  Cookie = 1,
36
36
  Text = 2,
37
- Fragment = 3
37
+ Fragment = 3,
38
+ Hash = 4
38
39
  }
39
40
 
40
41
  export const enum Type {
@@ -54,7 +55,8 @@ export const enum Privacy {
54
55
  Sensitive = 1,
55
56
  Text = 2,
56
57
  TextImage = 3,
57
- Exclude = 4
58
+ Exclude = 4,
59
+ Snapshot = 5
58
60
  }
59
61
 
60
62
  /* Helper Interfaces */