@airgrid/edgekit
Version:
A privacy focused library for cookie-less audience creation.
43 lines • 2.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.edkt = void 0;
var tslib_1 = require("tslib");
var store_1 = require("./store");
var engine = tslib_1.__importStar(require("./engine"));
var gdpr_1 = require("./gdpr");
var run = function (config) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var vendorIds, pageFeatures, pageMetadata, omitGdprConsent, audienceDefinitions, featureStorageSize, hasConsent, pageViews, audiencesToMatch, matchedAudiences;
return tslib_1.__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*/, gdpr_1.waitForConsent(vendorIds)];
case 1:
hasConsent = _a.sent();
if (!hasConsent)
return [2 /*return*/];
_a.label = 2;
case 2:
store_1.viewStore.setStorageSize(featureStorageSize);
store_1.viewStore.savePageView(pageFeatures, pageMetadata);
pageViews = store_1.viewStore.getCopyOfPageViews();
store_1.matchedAudienceStore.unsetAudiencesIfVersionIncremented(audienceDefinitions);
audiencesToMatch = audienceDefinitions.filter(function (audience) {
return !store_1.matchedAudienceStore.isMatched(audience.id, audience.version);
});
matchedAudiences = engine.getMatchingAudiences(audiencesToMatch, pageViews);
store_1.matchedAudienceStore.setAudiences(matchedAudiences);
return [2 /*return*/];
}
});
}); };
exports.edkt = {
run: run,
getMatchedAudiences: function () { return store_1.matchedAudienceStore.getMatchedAudiences(); },
getCopyOfPageViews: function () { return store_1.viewStore.getCopyOfPageViews(); },
};
tslib_1.__exportStar(require("./store"), exports);
tslib_1.__exportStar(require("./gdpr"), exports);
tslib_1.__exportStar(require("../types"), exports);
//# sourceMappingURL=index.js.map