Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nrjinua
Copy link
Collaborator

@nrjinua nrjinua commented Jul 10, 2025

No description provided.

@Copilot Copilot AI review requested due to automatic review settings July 10, 2025 11:32
Copy link

@Copilot Copilot AI left a 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 and CreateLinkResponse with encryption and tracking-related fields.
  • Adds createSecure utility and new trackConversion, getClickId, and createEncryptedLink methods to ShortioClient.
  • 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 uses folderId in camelCase. Consider renaming to folderId 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}`;
Copy link
Preview

Copilot AI Jul 10, 2025

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.

Suggested change
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,
Copy link
Preview

Copilot AI Jul 10, 2025

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.

Suggested change
success: true,
success: true,
conversionId: undefined,

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant