-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add new utm attributes to all mongodb links VSCODE-356 (#526)
* chore: add new utm attributes to all mongodb links * chore: add ajs_aid back * chore: move more links to utils/links * chore: add tests * chore: add documentation for anonymous id param
- Loading branch information
1 parent
2974843
commit 1fa3a31
Showing
17 changed files
with
183 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { expect } from 'chai'; | ||
import LINKS from '../../../utils/links'; | ||
|
||
const expectedLinks = { | ||
changelog: 'https://github.com/mongodb-js/vscode/blob/main/CHANGELOG.md', | ||
feedback: | ||
'https://feedback.mongodb.com/forums/929236-mongodb-for-vs-code/?utm_source=vscode&utm_medium=product', | ||
github: 'https://github.com/mongodb-js/vscode', | ||
reportBug: 'https://github.com/mongodb-js/vscode/issues', | ||
atlas: | ||
'https://www.mongodb.com/cloud/atlas?utm_source=vscode&utm_medium=product', | ||
createAtlasCluster: | ||
'https://mongodb.com/products/vs-code/vs-code-atlas-signup?ajs_aid=hi&utm_source=vscode&utm_medium=product', | ||
docs: 'https://docs.mongodb.com/?utm_source=vscode&utm_medium=product', | ||
mongodbDocs: | ||
'https://docs.mongodb.com/manual/?utm_source=vscode&utm_medium=product', | ||
extensionDocs: | ||
'https://docs.mongodb.com/mongodb-vscode/hi?utm_source=vscode&utm_medium=product', | ||
aggregationDocs: | ||
'https://www.mongodb.com/docs/manual/reference/operator/aggregation/hi/?utm_source=vscode&utm_medium=product', | ||
bsonDocs: | ||
'https://www.mongodb.com/docs/mongodb-shell/reference/data-types/?utm_source=vscode&utm_medium=product#hi', | ||
systemVariableDocs: | ||
'https://www.mongodb.com/docs/manual/reference/aggregation-variables/?utm_source=vscode&utm_medium=product#mongodb-variable-variable.hi', | ||
kerberosPrincipalDocs: | ||
'https://docs.mongodb.com/manual/core/kerberos/?utm_source=vscode&utm_medium=product#principals', | ||
ldapDocs: | ||
'https://docs.mongodb.com/manual/core/security-ldap/?utm_source=vscode&utm_medium=product', | ||
authDatabaseDocs: | ||
'https://docs.mongodb.com/manual/core/security-users/?utm_source=vscode&utm_medium=product#user-authentication-database', | ||
sshConnectionDocs: | ||
'https://docs.mongodb.com/compass/current/connect/advanced-connection-options/ssh-connection/?utm_source=vscode&utm_medium=product#ssh-connection', | ||
configureSSLDocs: | ||
'https://docs.mongodb.com/manual/tutorial/configure-ssl/hi?utm_source=vscode&utm_medium=product', | ||
pemKeysDocs: | ||
'https://docs.mongodb.com/manual/reference/configuration-options/?utm_source=vscode&utm_medium=product#net.ssl.PEMKeyPassword', | ||
}; | ||
|
||
suite('LINKS', () => { | ||
test('should have all links', () => { | ||
expect(Object.keys(expectedLinks)).to.deep.eq(Object.keys(LINKS)); | ||
}); | ||
|
||
Object.entries(expectedLinks).forEach(([name, expected]) => { | ||
test(`${name} link should return ${expected}`, () => { | ||
if (typeof LINKS[name] === 'function') { | ||
expect(expected).to.eq(LINKS[name]('hi')); | ||
} else { | ||
expect(expected).to.eq(LINKS[name]); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const addUTMAttrs = (url: string) => { | ||
const parsed = new URL(url); | ||
if (!parsed.host.includes('mongodb')) { | ||
return url; | ||
} | ||
parsed.searchParams.set('utm_source', 'vscode'); | ||
parsed.searchParams.set('utm_medium', 'product'); | ||
return parsed.toString(); | ||
}; | ||
|
||
const LINKS = { | ||
changelog: 'https://github.com/mongodb-js/vscode/blob/main/CHANGELOG.md', | ||
feedback: 'https://feedback.mongodb.com/forums/929236-mongodb-for-vs-code/', | ||
github: 'https://github.com/mongodb-js/vscode', | ||
reportBug: 'https://github.com/mongodb-js/vscode/issues', | ||
atlas: 'https://www.mongodb.com/cloud/atlas', | ||
/** | ||
* @param anonymousId Segment analytics `anonymousId` (not `userId`) {@link https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/querystring/} | ||
*/ | ||
createAtlasCluster: (anonymousId: string) => { | ||
const ajsAid = anonymousId | ||
? `?ajs_aid=${encodeURIComponent(anonymousId)}` | ||
: ''; | ||
return `https://mongodb.com/products/vs-code/vs-code-atlas-signup${ajsAid}`; | ||
}, | ||
docs: 'https://docs.mongodb.com/', | ||
mongodbDocs: 'https://docs.mongodb.com/manual/', | ||
extensionDocs(subcategory = '') { | ||
return `https://docs.mongodb.com/mongodb-vscode/${subcategory}`; | ||
}, | ||
aggregationDocs: (title: string) => { | ||
return `https://www.mongodb.com/docs/manual/reference/operator/aggregation/${title}/`; | ||
}, | ||
bsonDocs: (type: string) => { | ||
return `https://www.mongodb.com/docs/mongodb-shell/reference/data-types/#${type}`; | ||
}, | ||
systemVariableDocs: (name: string) => { | ||
return `https://www.mongodb.com/docs/manual/reference/aggregation-variables/#mongodb-variable-variable.${name}`; | ||
}, | ||
kerberosPrincipalDocs: | ||
'https://docs.mongodb.com/manual/core/kerberos/#principals', | ||
ldapDocs: 'https://docs.mongodb.com/manual/core/security-ldap/', | ||
authDatabaseDocs: | ||
'https://docs.mongodb.com/manual/core/security-users/#user-authentication-database', | ||
sshConnectionDocs: | ||
'https://docs.mongodb.com/compass/current/connect/advanced-connection-options/ssh-connection/#ssh-connection', | ||
configureSSLDocs(subsection = '') { | ||
return `https://docs.mongodb.com/manual/tutorial/configure-ssl/${subsection}`; | ||
}, | ||
pemKeysDocs: | ||
'https://docs.mongodb.com/manual/reference/configuration-options/#net.ssl.PEMKeyPassword', | ||
}; | ||
|
||
export default Object.fromEntries( | ||
Object.entries(LINKS).map(([k, v]) => { | ||
return [ | ||
k, | ||
typeof v === 'string' | ||
? addUTMAttrs(v) | ||
: (name: string) => { | ||
return addUTMAttrs(v(name)); | ||
}, | ||
]; | ||
}) | ||
) as typeof LINKS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.