Skip to content

Commit 9612942

Browse files
committed
MC:2978 Added utm source, utm medium and utm campaign at login flow
1 parent 809cff2 commit 9612942

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/sdk/src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,15 @@ export class MermaidChart {
7575
public async getAuthorizationData({
7676
state,
7777
scope = ['email'],
78+
utm_source,
79+
utm_medium,
80+
utm_campaign
7881
}: {
7982
state?: string;
8083
scope?: string[];
84+
utm_source?: string;
85+
utm_medium?: string;
86+
utm_campaign?: string;
8187
} = {}): Promise<AuthorizationData> {
8288
if (!this.redirectURI) {
8389
throw new Error('redirectURI is not set');
@@ -90,12 +96,20 @@ export class MermaidChart {
9096
this.pendingStates[stateID] = {
9197
codeVerifier,
9298
};
99+
100+
const extraParams: Record<string, string> = {};
101+
if (utm_source && utm_medium && utm_campaign) {
102+
extraParams.utm_source = utm_source;
103+
extraParams.utm_medium = utm_medium;
104+
extraParams.utm_campaign = utm_campaign;
105+
}
93106

94107
const url = await this.oauth.authorizationCode.getAuthorizeUri({
95108
redirectUri: this.redirectURI,
96109
state: stateID,
97110
codeVerifier,
98111
scope,
112+
...(Object.keys(extraParams).length > 0 && { extraParams }),
99113
});
100114

101115
// Deletes the state after 60 seconds

0 commit comments

Comments
 (0)