Skip to content

Commit 7df83b3

Browse files
Merge pull request #563 from cloudinary/change-analytics-algo-letter
change algo letter in analytics
2 parents 3c22f94 + ae8596c commit 7df83b3

File tree

7 files changed

+42
-25
lines changed

7 files changed

+42
-25
lines changed

__TESTS__/unit/analytics/analytics.browser.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ describe('Add analytics to a URL from the browser', () => {
1414
}
1515
});
1616

17-
// ATAAB{NODE_VERSION}0
18-
// ATAAB{AA}0 -> we expect nodeVersion to be 0.0.0 in browser (Since it's missing)
19-
// expect ATAABAA0
20-
expect(url).toContain('sample?_a=ATAABAA0'); // we shouldn't have a query param at all
17+
// BATAAB{NODE_VERSION}0
18+
// BATAAB{AA}0 -> we expect nodeVersion to be 0.0.0 in browser (Since it's missing)
19+
// expect BATAABAA0
20+
expect(url).toContain('sample?_a=BATAABAA0'); // we shouldn't have a query param at all
2121
});
2222

2323
it('Uses default techVersion 0.0.0 when in browser for image with file extension', () => {
@@ -28,10 +28,10 @@ describe('Add analytics to a URL from the browser', () => {
2828
}
2929
});
3030

31-
// ATAAB{NODE_VERSION}0
32-
// ATAAB{AA}0 -> we expect nodeVersion to be 0.0.0 in browser (Since it's missing)
33-
// expect ATAABAA0
34-
expect(url).toContain('sample.jpg?_a=ATAABAA0'); // we shouldn't have a query param at all
31+
// BATAAB{NODE_VERSION}0
32+
// BATAAB{AA}0 -> we expect nodeVersion to be 0.0.0 in browser (Since it's missing)
33+
// expect BATAABAA0
34+
expect(url).toContain('sample.jpg?_a=BATAABAA0'); // we shouldn't have a query param at all
3535
});
3636

3737
it('Uses default techVersion 0.0.0 when in browser for video', () => {
@@ -42,10 +42,10 @@ describe('Add analytics to a URL from the browser', () => {
4242
}
4343
});
4444

45-
// ATAAB{NODE_VERSION}0
46-
// ATAAB{AA}0 -> we expect nodeVersion to be 0.0.0 in browser (Since it's missing)
47-
// expect ATAABAA0
48-
expect(url).toContain('sample?_a=ATAABAA0'); // we shouldn't have a query param at all
45+
// BATAAB{NODE_VERSION}0
46+
// BATAAB{AA}0 -> we expect nodeVersion to be 0.0.0 in browser (Since it's missing)
47+
// expect BATAABAA0
48+
expect(url).toContain('sample?_a=BATAABAA0'); // we shouldn't have a query param at all
4949
});
5050

5151

@@ -57,9 +57,9 @@ describe('Add analytics to a URL from the browser', () => {
5757
}
5858
});
5959

60-
// ATAAB{NODE_VERSION}0
61-
// ATAAB{AA}0 -> we expect nodeVersion to be 0.0.0 in browser (Since it's missing)
62-
// expect ATAABAA0
63-
expect(url).toContain('sample.webm?_a=ATAABAA0'); // we shouldn't have a query param at all
60+
// BATAAB{NODE_VERSION}0
61+
// BATAAB{AA}0 -> we expect nodeVersion to be 0.0.0 in browser (Since it's missing)
62+
// expect BATAABAA0
63+
expect(url).toContain('sample.webm?_a=BATAABAA0'); // we shouldn't have a query param at all
6464
});
6565
});

__TESTS__/unit/analytics/analytics.node.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Add analytics to a regular URL', () => {
4343
techVersion: '12.0.0',
4444
accessibility: true
4545
}
46-
})).toContain('?_a=AZAlhAMD');
46+
})).toContain('?_a=BAZAlhAMD');
4747
});
4848

4949
it('Test lazyload feature value', () => {
@@ -59,7 +59,7 @@ describe('Add analytics to a regular URL', () => {
5959
techVersion: '12.0.0',
6060
lazyload: true
6161
}
62-
})).toContain('?_a=AZAlhAMC');
62+
})).toContain('?_a=BAZAlhAMC');
6363
});
6464

6565
it('Test responsive feature value', () => {
@@ -75,7 +75,7 @@ describe('Add analytics to a regular URL', () => {
7575
techVersion: '12.0.0',
7676
responsive: true
7777
}
78-
})).toContain('?_a=AZAlhAMA');
78+
})).toContain('?_a=BAZAlhAMA');
7979
});
8080

8181
it('Test placeholder feature value', () => {
@@ -91,7 +91,19 @@ describe('Add analytics to a regular URL', () => {
9191
techVersion: '12.0.0',
9292
placeholder: true
9393
}
94-
})).toContain('?_a=AZAlhAMB');
94+
})).toContain('?_a=BAZAlhAMB');
95+
});
96+
97+
it('Test product letter', () => {
98+
const cldImage = createNewImageWithAnalytics('sample');
99+
expect(cldImage.toURL({
100+
trackedAnalytics: {
101+
sdkCode: 'Z',
102+
sdkSemver: '1.24.0',
103+
techVersion: '12.0.0',
104+
product: 'B'
105+
}
106+
})).toContain('?_a=BBZAlhAM0');
95107
});
96108

97109
it('Can be turned off', () => {

__TESTS__/unit/url/url.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ describe('Tests for URL configuration', () => {
109109
sdkSemver: '1.0.0'
110110
};
111111
const url = image.toURL({trackedAnalytics: analyticsOptions});
112-
expect(url).toEqual(`https://res.cloudinary.com/demo/image/upload/sample?_i=abcde&_a=ATAABAQ0`);
112+
expect(url).toEqual(`https://res.cloudinary.com/demo/image/upload/sample?_i=abcde&_a=BATAABAQ0`);
113113
});
114114
});

src/sdkAnalytics/getAnalyticsOptions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export function getAnalyticsOptions(options: ITrackedPropertiesThroughAnalytics)
1212
sdkSemver: options.sdkSemver,
1313
techVersion: options.techVersion,
1414
sdkCode: options.sdkCode,
15-
feature: '0'
15+
product: options.product,
16+
feature: '0',
1617
};
1718

1819
if (options.accessibility) {

src/sdkAnalytics/getSDKAnalyticsSignature.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function ensureShapeOfTrackedProperties(trackedAnalytics?: Partial<ITrackedPrope
3030
techVersion: getNodeVersion(),
3131
sdkCode: 'T', // Base code
3232
sdkSemver : packageVersion.split('-')[0], // remove -beta, -alpha or other tagged versions from the version string
33+
product: 'A',
3334
responsive: false,
3435
placeholder: false,
3536
lazyload: false,
@@ -71,10 +72,11 @@ export function getSDKAnalyticsSignature(_trackedAnalytics?: Partial<ITrackedPro
7172

7273
const featureCode = analyticsOptions.feature;
7374
const SDKCode = analyticsOptions.sdkCode;
74-
const algoVersion = 'A'; // The algo version is determined here, it should not be an argument
75+
const product = analyticsOptions.product;
76+
const algoVersion = 'B'; // The algo version is determined here, it should not be an argument
7577

7678

77-
return `${algoVersion}${SDKCode}${encodedSDKVersion}${encodedTechVersion}${featureCode}`;
79+
return `${algoVersion}${product}${SDKCode}${encodedSDKVersion}${encodedTechVersion}${featureCode}`;
7880
} catch (e) {
7981
// Either SDK or Node versions were unparsable
8082
return 'E';

src/sdkAnalytics/interfaces/IAnalyticsOptions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export interface IAnalyticsOptions {
55
sdkSemver: string,
66
techVersion: string,
77
sdkCode: string,
8-
feature: string
8+
feature: string,
9+
product: string,
910
}

src/sdkAnalytics/interfaces/ITrackedPropertiesThroughAnalytics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface ITrackedPropertiesThroughAnalytics {
88
sdkSemver: string; // Base Semver
99
techVersion: string; // Node Version or 1.0.0 by default
1010
sdkCode: string; // Constant for Base?
11+
product?: string; // Product code, 'A' for classic, 'B' for integrations
1112
accessibility?: boolean; // Was accessibility used
1213
lazyload?: boolean; // Was lazy-load used
1314
responsive?: boolean; // Was responsive used

0 commit comments

Comments
 (0)