Skip to content

Commit

Permalink
Merge pull request #618 from microsoft/samart/conversions
Browse files Browse the repository at this point in the history
Conversion config supporting click text reporting
  • Loading branch information
ender336 authored Jun 17, 2024
2 parents 3c85714 + f59a3de commit c8cb2cc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/clarity-js/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ let config: Config = {
action: null,
dob: null,
delayDom: false,
throttleDom: true
throttleDom: true,
conversions: false,
};

export default config;
3 changes: 2 additions & 1 deletion packages/clarity-js/src/insight/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Constant, NodeInfo, NodeValue, TargetMetadata } from "@clarity-types/la
import * as doc from "@src/layout/document";
import encode from "@src/insight/encode";
import * as interaction from "@src/interaction";
import config from "@src/core/config";
export let values: NodeValue[] = [];
let index: number = 1;
let idMap: WeakMap<Node, number> = null; // Maps node => id.
Expand Down Expand Up @@ -32,7 +33,7 @@ export function target(evt: UIEvent): Node {
}

export function metadata(node: Node): TargetMetadata {
let output: TargetMetadata = { id: 0, hash: null, privacy: Privacy.Snapshot, node };
let output: TargetMetadata = { id: 0, hash: null, privacy: config.conversions ? Privacy.Text : Privacy.Snapshot, node };
if (node) { output.id = idMap.has(node) ? idMap.get(node) : getId(node); }
return output;
}
Expand Down
1 change: 1 addition & 0 deletions packages/clarity-js/types/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export interface Config {
dob?: number;
delayDom?: boolean;
throttleDom?: boolean;
conversions?: boolean;
}

export const enum Constant {
Expand Down

0 comments on commit c8cb2cc

Please sign in to comment.