Add automatic classification
This commit is contained in:
parent
729a60a998
commit
0960006a5a
|
@ -28,13 +28,15 @@ function Report() {
|
||||||
{marked_entries.map((entry) => (
|
{marked_entries.map((entry) => (
|
||||||
<tr>
|
<tr>
|
||||||
<td>{entry.request.shorthost}</td>
|
<td>{entry.request.shorthost}</td>
|
||||||
<td>
|
<td style={{ overflowWrap: "anywhere" }}>
|
||||||
{entry.source}:{entry.name}
|
{entry.source}:{entry.name}
|
||||||
{entry.markedKeys.join(",")}
|
{entry.markedKeys.join(",")}
|
||||||
</td>
|
</td>
|
||||||
<td>{entry.value}</td>
|
<td style={{ width: "400px", overflowWrap: "anywhere" }}>
|
||||||
|
{entry.value}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select>
|
<select value={entry.classification}>
|
||||||
{[
|
{[
|
||||||
["history", "Historia przeglądania"],
|
["history", "Historia przeglądania"],
|
||||||
["id", "Sztucznie nadane id"],
|
["id", "Sztucznie nadane id"],
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
import { TCModel } from "@iabtcf/core";
|
import { TCModel } from "@iabtcf/core";
|
||||||
import ExtendedRequest from "./extended-request";
|
import ExtendedRequest from "./extended-request";
|
||||||
import { getMemory } from "./memory";
|
import { getMemory } from "./memory";
|
||||||
import { isJSONObject, isURL, parseToObject } from "./util";
|
import {
|
||||||
|
isJSONObject,
|
||||||
|
isURL,
|
||||||
|
parseToObject,
|
||||||
|
reduceConcat,
|
||||||
|
unique,
|
||||||
|
} from "./util";
|
||||||
|
|
||||||
export type Sources = "cookie" | "pathname" | "queryparams" | "header";
|
export type Sources = "cookie" | "pathname" | "queryparams" | "header";
|
||||||
|
|
||||||
|
export const Classifications = <const>{
|
||||||
|
id: "Sztucznie nadane ID",
|
||||||
|
history: "Część historii przeglądania",
|
||||||
|
};
|
||||||
|
|
||||||
const id = (function* id() {
|
const id = (function* id() {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -18,6 +29,7 @@ export class StolenDataEntry {
|
||||||
public iab: TCModel | null = null;
|
public iab: TCModel | null = null;
|
||||||
public id: number;
|
public id: number;
|
||||||
public markedKeys: string[] = [];
|
public markedKeys: string[] = [];
|
||||||
|
public classification: keyof typeof Classifications;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public request: ExtendedRequest,
|
public request: ExtendedRequest,
|
||||||
|
@ -31,6 +43,7 @@ export class StolenDataEntry {
|
||||||
// this.isIAB = true;
|
// this.isIAB = true;
|
||||||
// } catch (e) {}
|
// } catch (e) {}
|
||||||
this.id = id.next().value as number;
|
this.id = id.next().value as number;
|
||||||
|
this.classification = this.classify();
|
||||||
}
|
}
|
||||||
|
|
||||||
getPriority() {
|
getPriority() {
|
||||||
|
@ -112,10 +125,26 @@ export class StolenDataEntry {
|
||||||
this.addMark(key);
|
this.addMark(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private classify(): keyof typeof Classifications {
|
||||||
|
if (this.value.includes(this.request.origin)) {
|
||||||
|
return "history";
|
||||||
|
} else {
|
||||||
|
return "id";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MergedStolenDataEntry {
|
export class MergedStolenDataEntry {
|
||||||
constructor(public entries: StolenDataEntry[]) {}
|
constructor(public entries: StolenDataEntry[]) {
|
||||||
|
const all_marks = unique(
|
||||||
|
entries.map((entry) => entry.markedKeys).reduce(reduceConcat, [])
|
||||||
|
);
|
||||||
|
for (const entry of entries) {
|
||||||
|
entry.markedKeys = all_marks;
|
||||||
|
}
|
||||||
|
// getMemory().emit("change"); // to trigger render
|
||||||
|
}
|
||||||
|
|
||||||
hasValue(value: string) {
|
hasValue(value: string) {
|
||||||
return this.entries.some((entry) => entry.value === value);
|
return this.entries.some((entry) => entry.value === value);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user