Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test: () => {
const analyticsStream = jest.fn();
const ArticleTopicsWithTracking = withTrackingContext(ArticleTopics, {
trackingObjectName: "Article"
});
const testInstance = TestRenderer.create(
{}}
topics={topicData}
/>
);
const [link] = testInstance.root.findAll(node => node.type === Link);
link.props.onPress("event");
expect(analyticsStream.mock.calls).toMatchSnapshot();
component: (_, { decorateAction }) => {
const PaginationWithTrackingContext = withTrackingContext(Pagination, {
trackingObjectName: "Story"
});
return (
`?page=${pageNum}`}
hideResults
onNext={preventDefaultedAction(decorateAction)("onNext")}
onPrev={preventDefaultedAction(decorateAction)("onPrev")}
page={2}
/>
);
},
name: "Tracking",
export default Component =>
withTrackingContext(Component, {
getAttrs: ({ data, pageSection, navigationMode, referralUrl = "" }) => {
let editionType = "";
if (navigationMode) {
const { isMyArticles, isPastSixDays } = navigationMode;
if (isMyArticles) {
editionType = "my articles";
} else {
editionType = isPastSixDays ? "past 6 days" : "current edition";
}
}
return {
articleId: get(data, "id", ""),
article_topic_tags: get(data, "topics", []).map(topic => topic.name),
bylines: get(
data,
export default Component =>
withTrackingContext(Component, {
getAttrs: ({ author, page, pageSize }) => ({
articlesCount: get(author, "articles.count", 0),
authorName: author && author.name,
page,
pageSize
}),
trackingObjectName: "AuthorProfile"
});
export default Component =>
withTrackingContext(Component, {
getAttrs: ({ data, pageSection, referralUrl = "" }) => ({
articleId: get(data, "id", ""),
byline: get(data, "byline[0].children[0].attributes.value", ""),
headline: get(data, "headline", ""),
label: get(data, "label", ""),
pageName: `${get(data, "slug", "")}-${get(data, "shortIdentifier", "")}`,
publishedTime: get(data, "publishedTime", ""),
referralUrl,
section: pageSection || get(data, "section", ""),
template: get(data, "template", "Default"),
topics: get(data, "topics", [])
.map(topic => topic.name)
.join(",")
}),
trackingObjectName: "Article"
});
}
]);
const getProps = decorateAction => ({
adConfig,
analyticsStream: storybookReporter,
emptyStateMessage:
"Unfortunately, there are no articles relating to this page",
fetchMore: () => Promise.resolve(),
onArticlePress: preventDefaultedAction(decorateAction)("onArticlePress"),
onNext: preventDefaultedAction(decorateAction)("onNext"),
onPrev: preventDefaultedAction(decorateAction)("onPrev"),
refetch: preventDefaultedAction(decorateAction)("refetch")
});
const TrackedArticleList = withTrackingContext(ArticleList, {
trackingObjectName: "ArticleList"
});
const articleImageRatio = "3:2";
const count = 200;
const emptyStateMessage = "Empty State";
const page = 1;
const pageSize = 10;
const slug = "deborah-haynes";
export default {
children: [
{
component: (_, { decorateAction }) => (
export default Component =>
withTrackingContext(Component, {
getAttrs: ({ slice }) => {
const { items, lead, opinion, sliceName, support1, support2 } = slice;
if (!sliceName) return null;
const supports = [support1, support2];
const supportsTracking = roles =>
supports
.filter(support => support !== undefined)
.map(({ article }, index) => {
const { headline, id, shortHeadline } = article;
return {
headline: getHeadline(headline, shortHeadline),
id,
role: roles[index + 1]
};
});
export default Component =>
withTrackingContext(Component, {
getAttrs: ({ section }) => {
const { slices } = section;
const firstSlice = slices[0];
const nonName = Object.keys(firstSlice).filter(n => n !== "name")[0];
const { article: data } = firstSlice[nonName];
const published = DateTime.fromJSDate(
new Date(get(data, "publishedTime", ""))
);
const current = DateTime.local();
const diff = current.diff(published, "days");
const { days } = diff.values || { days: 0.0 };
const editionType = days > 1.0 ? "past 6 days" : "current edition";
return {
sectionName: section && section.title,
edition_type: editionType,
past_edition_date:
export default Component =>
withTrackingContext(Component, {
getAttrs: ({ topic, page, pageSize }) => ({
page,
pageSize,
topicName: topic && topic.name
}),
trackingObjectName: "Topic"
});
export default Component =>
withTrackingContext(Component, {
getAttrs: ({ data, pageSection, referralUrl = "" }) => {
const published = DateTime.fromJSDate(
new Date(get(data, "publishedTime", ""))
);
const current = DateTime.local();
const diff = current.diff(published, "days");
const { days } = diff.values || { days: 0.0 };
const editionType = days > 1.0 ? "past 6 days" : "current edition";
return {
articleId: get(data, "id", ""),
article_topic_tags: get(data, "topics", []).map(topic => topic.slug),
bylines: get(
data,
"bylines[0].byline[0].children[0].attributes.value",
""
),