clean-insights-sdk
Version:
A privacy-preserving measurement framework.
94 lines (92 loc) • 2.57 kB
TypeScript
/**
* Insights.ts
* CleanInsightsSDK
*
* Created by Benjamin Erhart on 19.01.21.
* Copyright © 2021 Guardian Project. All rights reserved.
*/
export { Insights };
import { Configuration } from './Configuration';
import { Store } from './Store';
interface DataPointData {
period_start: number;
period_end: number;
times: number;
}
interface VisitData extends DataPointData {
action_name: string;
}
interface EventData extends DataPointData {
category: string;
action: string;
name?: string;
value?: number;
}
declare class Insights {
/**
* Matomo site ID.
*/
idsite: number;
/**
* Preferred user languages as an HTTP Accept header.
*/
lang?: string;
/**
* User Agent string.
*/
ua?: string;
/**
* `Visit` data points.
*/
visits: VisitData[];
/**
* `Event` data points.
*/
events: EventData[];
/**
* Create an `Insights` object according to configuration with all data from the store which
* is due for offloading to the server.
*
* @param {Configuration} conf
* The current configuration.
*
* @param {{consents: Consents, visits: Visit[], events: Event[]}} store
* The current measurement and consents store.
*/
constructor(conf: Configuration, store: Store);
/**
* @returns {boolean}
*/
get isEmpty(): boolean;
/**
* Removes all visits and events from the given `Store`, which are also available in here.
*
* This should be called, when all `Insights` were offloaded at the server successfully.
*
* @param {{consents: Consents, visits: Visit[], events: Event[]}} store
* The store where the `Visit`s and `Event`s in here came from.
*/
clean(store: Store): void;
/**
*
* @param {DataPoint} dp
* @param {{period_start: number, period_end: number, times: number}} data
* @return {boolean}
*/
private static equals;
/**
* Create an HTTP-accept-language-header-like string from the information
* we can get from inside JavaScript.
*
* @private
* @return {string}
*/
private static acceptLanguages;
/**
Removes `DataPoint`s, which are too old. These were never been sent, otherwise, they would have
been removed, already.
Remove them now, if they're over the threshold, to not accumulate too many `DataPoints` and
therefore reduce privacy.
*/
protected static purge(conf: Configuration, store: Store): void;
}