@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
19 lines • 903 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOldCampaignIds = exports.generateAnonymousId = exports.getBrazeCampaignCutoff = void 0;
const NUMBER_OF_MONTHS = 3;
const MILLISECONDS_IN_A_MONTH = 30 * 24 * 60 * 60 * 1000;
const getBrazeCampaignCutoff = (now) => now.getTime() - NUMBER_OF_MONTHS * MILLISECONDS_IN_A_MONTH;
exports.getBrazeCampaignCutoff = getBrazeCampaignCutoff;
const generateAnonymousId = () => {
return "anonymous_id_" + (Math.floor(Math.random() * 20) + 1);
};
exports.generateAnonymousId = generateAnonymousId;
const getOldCampaignIds = (campaigns) => {
const cutoff = (0, exports.getBrazeCampaignCutoff)(new Date());
return Object.entries(campaigns)
.filter(([_, timestamp]) => timestamp < cutoff)
.map(([id, _]) => id);
};
exports.getOldCampaignIds = getOldCampaignIds;
//# sourceMappingURL=anonymousUsers.js.map