@airgrid/edgekit
Version:
A privacy focused library for cookie-less audience creation.
40 lines • 2.12 kB
JavaScript
import { __awaiter, __generator } from "tslib";
import { viewStore, matchedAudienceStore } from './store';
import * as engine from './engine';
import { waitForConsent } from './gdpr';
var run = function (config) { return __awaiter(void 0, void 0, void 0, function () {
var vendorIds, pageFeatures, pageMetadata, omitGdprConsent, audienceDefinitions, featureStorageSize, hasConsent, pageViews, audiencesToMatch, matchedAudiences;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
vendorIds = config.vendorIds, pageFeatures = config.pageFeatures, pageMetadata = config.pageMetadata, omitGdprConsent = config.omitGdprConsent, audienceDefinitions = config.audienceDefinitions, featureStorageSize = config.featureStorageSize;
if (!!omitGdprConsent) return [3 /*break*/, 2];
return [4 /*yield*/, waitForConsent(vendorIds)];
case 1:
hasConsent = _a.sent();
if (!hasConsent)
return [2 /*return*/];
_a.label = 2;
case 2:
viewStore.setStorageSize(featureStorageSize);
viewStore.savePageView(pageFeatures, pageMetadata);
pageViews = viewStore.getCopyOfPageViews();
matchedAudienceStore.unsetAudiencesIfVersionIncremented(audienceDefinitions);
audiencesToMatch = audienceDefinitions.filter(function (audience) {
return !matchedAudienceStore.isMatched(audience.id, audience.version);
});
matchedAudiences = engine.getMatchingAudiences(audiencesToMatch, pageViews);
matchedAudienceStore.setAudiences(matchedAudiences);
return [2 /*return*/];
}
});
}); };
export var edkt = {
run: run,
getMatchedAudiences: function () { return matchedAudienceStore.getMatchedAudiences(); },
getCopyOfPageViews: function () { return viewStore.getCopyOfPageViews(); },
};
export * from './store';
export * from './gdpr';
export * from '../types';
//# sourceMappingURL=index.js.map