Skip to content

Commit 0d2f28a

Browse files
committed
Merge branch 'release/26.15.0'
2 parents 487a9e8 + 6788f26 commit 0d2f28a

15 files changed

Lines changed: 59 additions & 25 deletions

‎CHANGELOG‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
We follow the CalVer (https://calver.org/) versioning scheme: YY.MINOR.MICRO.
44

5+
26.15.0 (2026-08-03)
6+
====================
7+
8+
* Improve tracking for download dashboard.
9+
510
26.14.0 (2026-07-20)
611
====================
712

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "osf",
3-
"version": "26.14.0",
3+
"version": "26.15.0",
44
"scripts": {
55
"ng": "ng",
66
"analyze-bundle": "ng build --configuration=analyze-bundle && source-map-explorer dist/**/*.js --no-border-checks",

‎src/app/features/files/pages/file-detail/file-detail.component.spec.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,14 @@ describe('FileDetailComponent', () => {
169169
setup();
170170
(store.dispatch as Mock).mockClear();
171171
const openSpy = vi.spyOn(window, 'open').mockReturnValue({ focus: vi.fn() } as unknown as Window);
172+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
172173

173174
component.downloadRevision('3');
174175

175176
expect(dataciteService.logIdentifiableDownload).toHaveBeenCalledWith(component.fileMetadata$);
176-
expect(openSpy).toHaveBeenCalledWith('https://osf.test/download/?revision=3');
177+
expect(openSpy).toHaveBeenCalledWith(
178+
`https://osf.test/download/?revision=3&source=file-detail&tz=${encodeURIComponent(timeZone)}`
179+
);
177180
expect(store.dispatch).toHaveBeenCalledWith(new GetFileRevisions('https://osf.test/upload'));
178181
});
179182

@@ -223,11 +226,14 @@ describe('FileDetailComponent', () => {
223226
setup();
224227
(store.dispatch as Mock).mockClear();
225228
const openSpy = vi.spyOn(window, 'open').mockReturnValue({ focus: vi.fn() } as unknown as Window);
229+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
226230

227231
component.downloadFile();
228232

229233
expect(dataciteService.logIdentifiableDownload).toHaveBeenCalledWith(component.fileMetadata$);
230-
expect(openSpy).toHaveBeenCalledWith('https://osf.test/download');
234+
expect(openSpy).toHaveBeenCalledWith(
235+
`https://osf.test/download?source=file-detail&tz=${encodeURIComponent(timeZone)}`
236+
);
231237
openSpy.mockRestore();
232238
});
233239

‎src/app/features/files/pages/file-detail/file-detail.component.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { MetadataTabsComponent } from '@osf/shared/components/metadata-tabs/meta
4040
import { SubHeaderComponent } from '@osf/shared/components/sub-header/sub-header.component';
4141
import { MetadataResourceEnum } from '@osf/shared/enums/metadata-resource.enum';
4242
import { ResourceType } from '@osf/shared/enums/resource-type.enum';
43+
import { appendDownloadTrackingParams } from '@osf/shared/helpers/download-link.helper';
4344
import { getMfrUrlWithVersion } from '@osf/shared/helpers/mfr-url.helper';
4445
import { CustomConfirmationService } from '@osf/shared/services/custom-confirmation.service';
4546
import { DataciteService } from '@osf/shared/services/datacite/datacite.service';
@@ -250,7 +251,8 @@ export class FileDetailComponent implements OnDestroy {
250251
const storageLink = this.file()?.links.upload || '';
251252

252253
if (downloadUrl) {
253-
window.open(`${downloadUrl}/?revision=${version}`)?.focus();
254+
const link = appendDownloadTrackingParams(`${downloadUrl}/?revision=${version}`, 'file-detail');
255+
window.open(link)?.focus();
254256
this.actions.getFileRevisions(storageLink);
255257
}
256258
}
@@ -266,7 +268,7 @@ export class FileDetailComponent implements OnDestroy {
266268
.logIdentifiableDownload(this.fileMetadata$)
267269
.pipe(takeUntilDestroyed(this.destroyRef))
268270
.subscribe();
269-
window.open(link)?.focus();
271+
window.open(appendDownloadTrackingParams(link, 'file-detail'))?.focus();
270272
}
271273

272274
deleteEntry(link: string): void {

‎src/app/features/preprints/components/preprint-details/share-and-download/share-and-download.component.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('ShareAndDownloadComponent', () => {
8585

8686
component.download();
8787

88-
expect(socialShareService.createDownloadUrl).toHaveBeenCalledWith(mockPreprint.id);
88+
expect(socialShareService.createDownloadUrl).toHaveBeenCalledWith(mockPreprint.id, 'preprint');
8989
expect(openSpy).toHaveBeenCalledWith('https://example.com/download');
9090
expect(focus).toHaveBeenCalled();
9191
expect(dataciteService.logIdentifiableDownload).toHaveBeenCalledWith(component.preprint$);
@@ -124,7 +124,7 @@ describe('ShareAndDownloadComponent', () => {
124124

125125
component.download();
126126

127-
expect(socialShareService.createDownloadUrl).toHaveBeenCalledWith(mockPreprint.id);
127+
expect(socialShareService.createDownloadUrl).toHaveBeenCalledWith(mockPreprint.id, 'preprint');
128128
expect(dataciteService.logIdentifiableDownload).not.toHaveBeenCalled();
129129
openSpy.mockRestore();
130130
});

‎src/app/features/preprints/components/preprint-details/share-and-download/share-and-download.component.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class ShareAndDownloadComponent {
4343
return;
4444
}
4545

46-
const downloadLink = this.socialShareService.createDownloadUrl(preprint.id);
46+
const downloadLink = this.socialShareService.createDownloadUrl(preprint.id, 'preprint');
4747
const downloadWindow = window.open(downloadLink);
4848

4949
if (!downloadWindow) {

‎src/app/features/preprints/pages/preprint-download-redirect/preprint-download-redirect.component.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('PreprintDownloadRedirectComponent', () => {
5858
it('should redirect to download URL when id is present in browser', () => {
5959
const redirectSpy = vi.spyOn(PreprintDownloadRedirectComponent.prototype, 'redirect').mockImplementation(vi.fn());
6060
const { mockSocialShareService } = setup({ id: MOCK_ID });
61-
expect(mockSocialShareService.createDownloadUrl).toHaveBeenCalledWith(MOCK_ID);
61+
expect(mockSocialShareService.createDownloadUrl).toHaveBeenCalledWith(MOCK_ID, 'preprint');
6262
expect(redirectSpy).toHaveBeenCalledWith(MOCK_DOWNLOAD_URL);
6363
redirectSpy.mockRestore();
6464
});

‎src/app/features/preprints/pages/preprint-download-redirect/preprint-download-redirect.component.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class PreprintDownloadRedirectComponent {
2424
return;
2525
}
2626

27-
const url = this.socialShareService.createDownloadUrl(id);
27+
const url = this.socialShareService.createDownloadUrl(id, 'preprint');
2828
this.redirect(url);
2929
}
3030

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function appendDownloadTrackingParams(link: string, source: string): string {
2+
const separator = link.includes('?') ? '&' : '?';
3+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
4+
return `${link}${separator}source=${encodeURIComponent(source)}&tz=${encodeURIComponent(tz)}`;
5+
}

‎src/app/shared/services/file-download.service.spec.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('FileDownloadService', () => {
4444
});
4545

4646
expect(dataciteService.logFileDownload).toHaveBeenCalledWith('node-1', 'nodes');
47-
expect(filesService.getFolderDownloadLink).toHaveBeenCalledWith('/folder/download/');
47+
expect(filesService.getFolderDownloadLink).toHaveBeenCalledWith('/folder/download/', 'files');
4848
expect(openSpy).toHaveBeenCalledWith('/folder/download/?zip=', '_blank');
4949
});
5050

@@ -63,6 +63,7 @@ describe('FileDownloadService', () => {
6363

6464
it('logs datacite and opens file download link', () => {
6565
const openSpy = vi.spyOn(window, 'open').mockReturnValue({ focus: vi.fn() } as unknown as Window);
66+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
6667

6768
service.downloadFile({
6869
resourceId: 'node-1',
@@ -71,11 +72,12 @@ describe('FileDownloadService', () => {
7172
});
7273

7374
expect(dataciteService.logFileDownload).toHaveBeenCalledWith('node-1', 'nodes');
74-
expect(openSpy).toHaveBeenCalledWith('/file/download/', '_blank');
75+
expect(openSpy).toHaveBeenCalledWith(`/file/download/?source=files&tz=${encodeURIComponent(timeZone)}`, '_blank');
7576
});
7677

7778
it('downloads file from file model', () => {
7879
const openSpy = vi.spyOn(window, 'open').mockReturnValue({ focus: vi.fn() } as unknown as Window);
80+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
7981
const file = FileModelMock.simple({
8082
kind: FileKind.File,
8183
links: { ...FileModelMock.simple().links, download: '/file/download/' },
@@ -88,7 +90,7 @@ describe('FileDownloadService', () => {
8890
});
8991

9092
expect(dataciteService.logFileDownload).toHaveBeenCalledWith('node-1', 'nodes');
91-
expect(openSpy).toHaveBeenCalledWith('/file/download/', '_blank');
93+
expect(openSpy).toHaveBeenCalledWith(`/file/download/?source=files&tz=${encodeURIComponent(timeZone)}`, '_blank');
9294
});
9395

9496
it('downloads folder zip from file model', () => {
@@ -106,7 +108,7 @@ describe('FileDownloadService', () => {
106108
});
107109

108110
expect(dataciteService.logFileDownload).toHaveBeenCalledWith('node-1', 'nodes');
109-
expect(filesService.getFolderDownloadLink).toHaveBeenCalledWith('/folder/upload/');
111+
expect(filesService.getFolderDownloadLink).toHaveBeenCalledWith('/folder/upload/', 'files');
110112
expect(openSpy).toHaveBeenCalledWith('/folder/upload/?zip=', '_blank');
111113
});
112114
});

0 commit comments

Comments
 (0)