Skip to content

Commit

Permalink
Merge pull request Hashnode#130 from Hashnode/remove-old-analytics-in…
Browse files Browse the repository at this point in the history
…gestion

stop sending old analytics data
  • Loading branch information
JannikWempe authored May 8, 2024
2 parents 3a67e00 + 7844a18 commit 1ad712a
Show file tree
Hide file tree
Showing 12 changed files with 2,634 additions and 256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,61 +52,6 @@ export const Analytics = () => {
});
};

const _sendViewsToHashnodeAnalyticsDashboard = async () => {
const LOCATION = window.location;
const NAVIGATOR = window.navigator;
const currentFullURL =
LOCATION.protocol +
'//' +
LOCATION.hostname +
LOCATION.pathname +
LOCATION.search +
LOCATION.hash;

const query = new URL(currentFullURL).searchParams;

const utm_id = query.get('utm_id');
const utm_campaign = query.get('utm_campaign');
const utm_source = query.get('utm_source');
const utm_medium = query.get('utm_medium');
const utm_term = query.get('utm_term');
const utm_content = query.get('utm_content');

let referrer = document.referrer || '';
if (referrer.indexOf(window.location.hostname) !== -1) {
referrer = '';
}

const data = {
publicationId: publication.id,
postId: post && post.id,
timestamp: Date.now(),
url: currentFullURL,
referrer: referrer,
title: document.title,
charset: document.characterSet || document.charset,
lang: NAVIGATOR.language,
userAgent: NAVIGATOR.userAgent,
historyLength: window.history.length,
timezoneOffset: new Date().getTimezoneOffset(),
utm_id,
utm_campaign,
utm_source,
utm_medium,
utm_term,
utm_content,
};

// For Hashnode Blog Dashboard Analytics
fetch(`${BASE_PATH}/ping/view`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ data }),
});
};

function _sendViewsToAdvancedAnalyticsDashboard() {
const publicationId = publication.id;
const postId = post && post.id;
Expand Down Expand Up @@ -189,7 +134,6 @@ export const Analytics = () => {

_sendPageViewsToHashnodeGoogleAnalytics();
_sendViewsToHashnodeInternalAnalytics();
_sendViewsToHashnodeAnalyticsDashboard();
_sendViewsToAdvancedAnalyticsDashboard();
}, []);

Expand Down
95 changes: 94 additions & 1 deletion packages/blog-starter-kit/themes/enterprise/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,12 @@ export type CustomCssFeature = Feature & {
published?: Maybe<CustomCss>;
};

export enum CustomDomainStatus {
Invalid = 'INVALID',
Valid = 'VALID',
Verifying = 'VERIFYING'
}

/** Contains the publication's dark mode preferences. */
export type DarkModePreferences = {
__typename?: 'DarkModePreferences';
Expand All @@ -895,6 +901,19 @@ export type DarkModePreferences = {
logo?: Maybe<Scalars['String']['output']>;
};

export type DeleteRoleBasedInviteInput = {
/** The ID of the role based invite. */
inviteId: Scalars['ID']['input'];
publicationId: Scalars['ID']['input'];
};

/** Response to deleting a role based invite. */
export type DeleteRoleBasedInvitePayload = {
__typename?: 'DeleteRoleBasedInvitePayload';
/** Deleted invite. */
invite: RoleBasedInvite;
};

export type DeleteWebhookPayload = {
__typename?: 'DeleteWebhookPayload';
webhook?: Maybe<Webhook>;
Expand Down Expand Up @@ -929,6 +948,13 @@ export type DomainStatus = {
host: Scalars['String']['output'];
/** A flag indicating if the publication domain is ready. */
ready: Scalars['Boolean']['output'];
/** A flag indicating the status of a publication domain */
status: CustomDomainStatus;
/**
* A timestamp indicating when the domain was verified.
* It is only present if the domain is verified.
*/
verifiedAt?: Maybe<Scalars['DateTime']['output']>;
};

/**
Expand Down Expand Up @@ -1512,6 +1538,8 @@ export type Mutation = {
/** Creates a new series. */
createSeries: CreateSeriesPayload;
createWebhook: CreateWebhookPayload;
/** Deletes a role based invite. */
deleteRoleBasedInvite: DeleteRoleBasedInvitePayload;
deleteWebhook: DeleteWebhookPayload;
/** Likes a comment. */
likeComment: LikeCommentPayload;
Expand Down Expand Up @@ -1595,6 +1623,11 @@ export type MutationCreateWebhookArgs = {
};


export type MutationDeleteRoleBasedInviteArgs = {
input: DeleteRoleBasedInviteInput;
};


export type MutationDeleteWebhookArgs = {
id: Scalars['ID']['input'];
};
Expand Down Expand Up @@ -2374,6 +2407,7 @@ export type Publication = Node & {
post?: Maybe<Post>;
/** Returns the list of posts in the publication. */
posts: PublicationPostConnection;
postsViaPage: PublicationPostPageConnection;
/** The publication preferences around layout, theme and other personalisations. */
preferences: Preferences;
/** Publications that are recommended by this publication. */
Expand Down Expand Up @@ -2441,6 +2475,16 @@ export type PublicationPostsArgs = {
};


/**
* Contains basic information about the publication.
* A publication is a blog that can be created for a user or a team.
*/
export type PublicationPostsViaPageArgs = {
page: Scalars['Int']['input'];
pageSize: Scalars['Int']['input'];
};


/**
* Contains basic information about the publication.
* A publication is a blog that can be created for a user or a team.
Expand Down Expand Up @@ -2614,12 +2658,24 @@ export type PublicationMember = Node & {
__typename?: 'PublicationMember';
/** The ID of the publication member. */
id: Scalars['ID']['output'];
/**
* Denotes if the member is public or private
* A private member is not visible on members page
*/
privacyState?: Maybe<PublicationMemberPrivacyState>;
/** The role of the user in the publication. */
role: UserPublicationRole;
/** The user who is a member of the publication. */
user?: Maybe<User>;
};

export enum PublicationMemberPrivacyState {
/** The member is private and not visible on the members page. */
Private = 'PRIVATE',
/** The member is public and visible on the members page. */
Public = 'PUBLIC'
}

/** Contains the publication's navbar items. */
export type PublicationNavbarItem = {
__typename?: 'PublicationNavbarItem';
Expand Down Expand Up @@ -2690,6 +2746,16 @@ export type PublicationPostConnectionFilter = {
tags?: InputMaybe<Array<Scalars['ObjectId']['input']>>;
};

export type PublicationPostPageConnection = PageConnection & {
__typename?: 'PublicationPostPageConnection';
/** The posts belonging to the publication. */
nodes: Array<Post>;
/** Information to aid in pagination. */
pageInfo: OffsetPageInfo;
/** The total number of posts. */
totalDocuments: Scalars['Int']['output'];
};

/**
* Contains the publication's Sponsorship information.
* User can sponsor their favorite publications and pay them directly using Stripe.
Expand Down Expand Up @@ -3066,6 +3132,22 @@ export type RestorePostPayload = {
post?: Maybe<Post>;
};

export type RoleBasedInvite = Node & {
__typename?: 'RoleBasedInvite';
/** The capacity of how many members to be invited by the link. */
capacity?: Maybe<Scalars['Int']['output']>;
/** The expiry date of the invite. */
expiryDate?: Maybe<Scalars['DateTime']['output']>;
/** The ID of the role based invite. */
id: Scalars['ID']['output'];
/** Invite link of the role based invite. */
inviteLink?: Maybe<Scalars['String']['output']>;
/** Boolean that signifies if the invite has unlimited capacity. */
isUnlimitedCapacity?: Maybe<Scalars['Boolean']['output']>;
/** The role assigned to the user in the publication. */
role: UserPublicationRole;
};

/** Information to help in seo related meta tags. */
export type Seo = {
__typename?: 'SEO';
Expand Down Expand Up @@ -3120,6 +3202,7 @@ export enum Scope {
DocsEditorOrOwner = 'docs_editor_or_owner',
DocsOwner = 'docs_owner',
ImportSubscribersToPublication = 'import_subscribers_to_publication',
InvitedTeamUser = 'invited_team_user',
PublicationAdmin = 'publication_admin',
PublicationMember = 'publication_member',
PublishComment = 'publish_comment',
Expand Down Expand Up @@ -3165,6 +3248,16 @@ export type SearchPostsOfPublicationFilter = {
query: Scalars['String']['input'];
};

export type SearchUser = Node & {
__typename?: 'SearchUser';
/** ID of the user. */
id: Scalars['ID']['output'];
/** Signifies if the user has a pending invite to the publication. Returned when the filter has pendingInviteStatus set to true. */
pendingInviteStatus?: Maybe<Scalars['Boolean']['output']>;
/** User node containing the user information. */
user: User;
};

/**
* Contains basic information about the series.
* A series is a collection of posts that are related to each other.
Expand Down Expand Up @@ -3784,7 +3877,7 @@ export enum UserPublicationRole {

/**
* Connection to get list of publications.
* Returns a list of edges which contains the documentation project and cursor to the last item of the previous page.
* Returns a list of edges which contains the publications and cursor to the last item of the previous page.
*/
export type UserPublicationsConnection = Connection & {
__typename?: 'UserPublicationsConnection';
Expand Down
Loading

0 comments on commit 1ad712a

Please sign in to comment.