@artsy/cohesion
Version:
Analytics schema
229 lines (198 loc) • 5.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.unfollowedPartner = exports.followedPartner = exports.unfollowedGene = exports.followedGene = exports.unfollowedFair = exports.followedFair = exports.unfollowedArtist = exports.followedArtist = void 0;
var _Schema = require("../../Schema");
/**
* A user follows an artist
*
* @example
* ```
* followedArtist({
* contextModule: ContextModule.artistSeriesRail
* contextOwnerId: "5359794d2a1e86c3741001f8",
* contextOwnerSlug: "andy-warhol",
* contextOwnerType: OwnerType.artist,
* ownerId: "5359794d1a1e86c3740001f7",
* ownerSlug: "sturtevant",
* })
* ```
*/
var followedArtist = function followedArtist(args) {
return follow(args, _Schema.OwnerType.artist);
};
/**
* A user unfollows an artist
*
* @example
* ```
* unfollowedArtist({
* contextModule: ContextModule.artistSeriesRail
* contextOwnerId: "5359794d2a1e86c3741001f8",
* contextOwnerSlug: "andy-warhol",
* contextOwnerType: OwnerType.artist,
* OwnerId: "5359794d1a1e86c3740001f7",
* OwnerSlug: "sturtevant",
* })
* ```
*/
exports.followedArtist = followedArtist;
var unfollowedArtist = function unfollowedArtist(args) {
return follow(args, _Schema.OwnerType.artist, true);
};
/**
* A user follows a fair
*
* @example
* ```
* followedFair({
* contextModule: ContextModule.otherWorksFromPartnerRail,
* contextOwnerId: "5359794d2a1e86c3741001f8",
* contextOwnerSlug: "andy-warhol-skull",
* contextOwnerType: OwnerType.artwork,
* ownerId: "5359794d1a1e86c3740001f7",
* ownerSlug: "frieze-london",
* })
* ```
*/
exports.unfollowedArtist = unfollowedArtist;
var followedFair = function followedFair(args) {
return follow(args, _Schema.OwnerType.fair);
};
/**
* A user unfollows a fair
*
* @example
* ```
* unfollowedFair({
* contextModule: ContextModule.otherWorksFromPartnerRail,
* contextOwnerId: "5359794d2a1e86c3741001f8",
* contextOwnerSlug: "andy-warhol-skull",
* contextOwnerType: OwnerType.artwork,
* ownerId: "5359794d1a1e86c3740001f7",
* ownerSlug: "frieze-london",
* })
* ```
*/
exports.followedFair = followedFair;
var unfollowedFair = function unfollowedFair(args) {
return follow(args, _Schema.OwnerType.fair, true);
};
/**
* A user follows a gene
*
* @example
* ```
* followedGene({
* contextModule: ContextModule.intextTooltip,
* contextOwnerId: "5359794d2a1e86c3741001f8",
* contextOwnerSlug: "artsy-editorial-future-of-art",
* contextOwnerType: OwnerType.article,
* ownerId: "5359794d1a1e86c3740001f7",
* ownerSlug: "surrealism",
* })
* ```
*/
exports.unfollowedFair = unfollowedFair;
var followedGene = function followedGene(args) {
return follow(args, _Schema.OwnerType.gene);
};
/**
* A user unfollows a gene
*
* @example
* ```
* unfollowedGene({
* contextModule: ContextModule.intextTooltip,
* contextOwnerId: "5359794d2a1e86c3741001f8",
* contextOwnerSlug: "artsy-editorial-future-of-art",
* contextOwnerType: OwnerType.article,
* ownerId: "5359794d1a1e86c3740001f7",
* ownerSlug: "surrealism",
* })
* ```
*/
exports.followedGene = followedGene;
var unfollowedGene = function unfollowedGene(args) {
return follow(args, _Schema.OwnerType.gene, true);
};
/**
* A user follows a partner
*
* @example
* ```
* followedPartner({
* contextModule: ContextModule.aboutTheWork,
* contextOwnerId: "5359794d2a1e86c3741001f8",
* contextOwnerSlug: "andy-warhol-skull",
* contextOwnerType: OwnerType.artwork,
* ownerId: "5359794d1a1e86c3740001f7",
* ownerSlug: "pace-prints",
* })
* ```
*/
exports.unfollowedGene = unfollowedGene;
var followedPartner = function followedPartner(args) {
return follow(args, _Schema.OwnerType.partner);
};
/**
* A user unfollows a partner
*
* @example
* ```
* unfollowedPartner({
* contextModule: ContextModule.aboutTheWork,
* contextOwnerId: "5359794d2a1e86c3741001f8",
* contextOwnerSlug: "andy-warhol-skull",
* contextOwnerType: OwnerType.artwork,
* ownerId: "5359794d1a1e86c3740001f7",
* ownerSlug: "pace-prints",
* })
* ```
*/
exports.followedPartner = followedPartner;
var unfollowedPartner = function unfollowedPartner(args) {
return follow(args, _Schema.OwnerType.partner, true);
};
exports.unfollowedPartner = unfollowedPartner;
var follow = function follow(_ref, ownerType, isUnfollow) {
var contextModule = _ref.contextModule,
contextOwnerId = _ref.contextOwnerId,
contextOwnerSlug = _ref.contextOwnerSlug,
contextOwnerType = _ref.contextOwnerType,
ownerId = _ref.ownerId,
ownerSlug = _ref.ownerSlug;
var action;
switch (ownerType) {
case _Schema.OwnerType.artist:
{
action = isUnfollow ? _Schema.ActionType.unfollowedArtist : _Schema.ActionType.followedArtist;
break;
}
case _Schema.OwnerType.fair:
{
action = isUnfollow ? _Schema.ActionType.unfollowedFair : _Schema.ActionType.followedFair;
break;
}
case _Schema.OwnerType.gene:
{
action = isUnfollow ? _Schema.ActionType.unfollowedGene : _Schema.ActionType.followedGene;
break;
}
case _Schema.OwnerType.partner:
{
action = isUnfollow ? _Schema.ActionType.unfollowedPartner : _Schema.ActionType.followedPartner;
}
}
return {
action: action,
context_module: contextModule,
context_owner_id: contextOwnerId,
context_owner_slug: contextOwnerSlug,
context_owner_type: contextOwnerType,
owner_id: ownerId,
owner_slug: ownerSlug,
owner_type: ownerType
};
};