-
Notifications
You must be signed in to change notification settings - Fork 0
add conversion tracking and encrypted link methods #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds encrypted link creation and client-side conversion tracking to the Shortio SDK.
- Extends
CreateLinkRequest
andCreateLinkResponse
with encryption and tracking-related fields. - Adds
createSecure
utility and newtrackConversion
,getClickId
, andcreateEncryptedLink
methods toShortioClient
. - Updates tests to cover conversion tracking and encrypted link behavior, and refreshes lint and package configurations.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
src/types.ts | Expanded link request/response types and added conversion-tracking types |
src/shortio.ts | Added base64encode , createSecure , trackConversion , getClickId , and createEncryptedLink |
src/index.ts | Exported new conversion-tracking types |
src/tests/shortio.test.ts | Added tests for conversion tracking, click ID retrieval, and encrypted link creation |
package.json | Updated ESLint plugin versions, added tslib |
.eslintrc.js | Removed TypeScript-recommended rules and defined new globals |
Comments suppressed due to low confidence (2)
src/types.ts:68
- [nitpick] The field
FolderId
uses PascalCase while the request type usesfolderId
in camelCase. Consider renaming tofolderId
for consistency.
FolderId: string | null,
.eslintrc.js:4
- [nitpick] Removing
@typescript-eslint/recommended
will disable many useful TypeScript-specific rules. Consider reinstating it or selectively re-enabling important rules.
'eslint:recommended'
const encryptedUrl = await crypto.subtle.encrypt({ name: "AES-GCM", iv }, cryptoKey, urlData); | ||
const encryptedUrlBase64 = base64encode(encryptedUrl); | ||
const encryptedIvBase64 = base64encode(iv.buffer); | ||
const securedOriginalURL = `shortsecure://${encryptedUrlBase64}?${encryptedIvBase64}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Embedding raw Base64 in a URL may introduce unsafe characters. Consider applying encodeURIComponent
to both encryptedUrlBase64
and encryptedIvBase64
.
const securedOriginalURL = `shortsecure://${encryptedUrlBase64}?${encryptedIvBase64}`; | |
const securedOriginalURL = `shortsecure://${encodeURIComponent(encryptedUrlBase64)}?${encodeURIComponent(encryptedIvBase64)}`; |
Copilot uses AI. Check for mistakes.
'https://example.com/.shortio/conversion?clid=test-click-id' | ||
); | ||
expect(result).toEqual({ | ||
success: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In trackConversion
, conversionId
is always present (possibly undefined
). The test omits this field, causing a mismatch. Either omit undefined properties in the return or include conversionId: undefined
in the expected object.
success: true, | |
success: true, | |
conversionId: undefined, |
Copilot uses AI. Check for mistakes.
No description provided.