|
|
@@ -1,11 +1,16 @@
|
|
|
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
|
|
|
|
+import {
|
|
|
+ SupportedAction,
|
|
|
+ type SupportedActionType,
|
|
|
+} from '~/interfaces/activity';
|
|
|
+import type { IShareLinkHasId } from '~/interfaces/share-link';
|
|
|
+
|
|
|
import {
|
|
|
getServerSideCommonInitialProps,
|
|
|
getServerSideI18nProps,
|
|
|
} from '../../common-props';
|
|
|
import {
|
|
|
- getActivityAction,
|
|
|
getServerSideGeneralPageProps,
|
|
|
getServerSideRendererConfigProps,
|
|
|
isValidGeneralPageInitialProps,
|
|
|
@@ -23,6 +28,21 @@ const basisProps = {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
+function getActivityAction(props: {
|
|
|
+ isExpired: boolean | undefined;
|
|
|
+ shareLink: IShareLinkHasId | undefined;
|
|
|
+}): SupportedActionType {
|
|
|
+ if (props.isExpired) {
|
|
|
+ return SupportedAction.ACTION_SHARE_LINK_EXPIRED_PAGE_VIEW;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (props.shareLink == null) {
|
|
|
+ return SupportedAction.ACTION_SHARE_LINK_NOT_FOUND;
|
|
|
+ }
|
|
|
+
|
|
|
+ return SupportedAction.ACTION_SHARE_LINK_PAGE_VIEW;
|
|
|
+}
|
|
|
+
|
|
|
export async function getServerSidePropsForInitial(
|
|
|
context: GetServerSidePropsContext,
|
|
|
): Promise<GetServerSidePropsResult<Stage2InitialProps>> {
|
|
|
@@ -67,6 +87,8 @@ export async function getServerSidePropsForInitial(
|
|
|
throw new Error('Invalid merged props structure');
|
|
|
}
|
|
|
|
|
|
- await addActivity(context, getActivityAction(mergedProps));
|
|
|
+ // Persist activity
|
|
|
+ addActivity(context, getActivityAction(mergedProps));
|
|
|
+
|
|
|
return mergedResult;
|
|
|
}
|