mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Change analytics url endpoint, refactor all senders to the new api format
This commit is contained in:
parent
f92b4aebe6
commit
3759c2885e
@ -93,18 +93,16 @@ function App() {
|
||||
setTelemetryProperties(properties);
|
||||
|
||||
try {
|
||||
fetch('https://analytics.strapi.io/track', {
|
||||
fetch('https://analytics.strapi.io/api/v2/track', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
// This event is anonymous
|
||||
event: 'didInitializeAdministration',
|
||||
adminUserId: '',
|
||||
deviceId,
|
||||
properties: {
|
||||
eventPropeties: {},
|
||||
userProperties: { environment: appInfo.currentEnvironment },
|
||||
groupProperties: { ...properties, projectId: uuid },
|
||||
},
|
||||
eventPropeties: {},
|
||||
userProperties: { environment: appInfo.currentEnvironment },
|
||||
groupProperties: { ...properties, projectId: uuid },
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@ -12,15 +12,13 @@ const useTracking = () => {
|
||||
trackRef.current = (event, properties) => {
|
||||
if (uuid) {
|
||||
try {
|
||||
axios.post('https://analytics.strapi.io/track', {
|
||||
axios.post('https://analytics.strapi.io/api/v2/track', {
|
||||
event,
|
||||
adminUserId,
|
||||
deviceId,
|
||||
properties: {
|
||||
eventProperties: { ...properties },
|
||||
userProperties: {},
|
||||
groupProperties: { ...telemetryProperties },
|
||||
},
|
||||
eventProperties: { ...properties },
|
||||
userProperties: {},
|
||||
groupProperties: { ...telemetryProperties },
|
||||
});
|
||||
} catch (err) {
|
||||
// Silent
|
||||
|
||||
@ -53,14 +53,12 @@ const generateNewPackageJSON = (packageObj) => {
|
||||
|
||||
const sendEvent = async (uuid) => {
|
||||
try {
|
||||
await fetch('https://analytics.strapi.io/track', {
|
||||
await fetch('https://analytics.strapi.io/api/v2/track', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
event: 'didOptInTelemetry',
|
||||
deviceId: machineID(),
|
||||
properties: {
|
||||
groupProperties: { projectId: uuid },
|
||||
},
|
||||
groupProperties: { projectId: uuid },
|
||||
}),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
|
||||
@ -28,14 +28,12 @@ const writePackageJSON = async (path, file, spacing) => {
|
||||
|
||||
const sendEvent = async (uuid) => {
|
||||
try {
|
||||
await fetch('https://analytics.strapi.io/track', {
|
||||
await fetch('https://analytics.strapi.io/api/v2/track', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
event: 'didOptOutTelemetry',
|
||||
deviceId: machineID(),
|
||||
properties: {
|
||||
groupProperties: { projectId: uuid },
|
||||
},
|
||||
groupProperties: { projectId: uuid },
|
||||
}),
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
|
||||
@ -94,7 +94,7 @@ describe('metrics', () => {
|
||||
send('someEvent');
|
||||
|
||||
expect(fetch).toHaveBeenCalled();
|
||||
expect(fetch.mock.calls[0][0]).toBe('https://analytics.strapi.io/track');
|
||||
expect(fetch.mock.calls[0][0]).toBe('https://analytics.strapi.io/api/v2/track');
|
||||
expect(fetch.mock.calls[0][1].method).toBe('POST');
|
||||
expect(JSON.parse(fetch.mock.calls[0][1].body)).toMatchObject({
|
||||
event: 'someEvent',
|
||||
|
||||
@ -82,7 +82,7 @@ module.exports = (strapi) => {
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await fetch(`${ANALYTICS_URI}/track`, reqParams);
|
||||
const res = await fetch(`${ANALYTICS_URI}/api/v2/track`, reqParams);
|
||||
return res.ok;
|
||||
} catch (err) {
|
||||
return false;
|
||||
|
||||
@ -17,7 +17,7 @@ try {
|
||||
process.env.npm_config_global === 'true' ||
|
||||
JSON.parse(process.env.npm_config_argv).original.includes('global')
|
||||
) {
|
||||
fetch('https://analytics.strapi.io/track', {
|
||||
fetch('https://analytics.strapi.io/api/v2/track', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
event: 'didInstallStrapi',
|
||||
|
||||
@ -87,7 +87,7 @@ function trackEvent(event, payload) {
|
||||
}
|
||||
|
||||
try {
|
||||
return fetch('https://analytics.strapi.io/track', {
|
||||
return fetch('https://analytics.strapi.io/api/v2/track', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
event,
|
||||
@ -108,7 +108,7 @@ function trackError({ scope, error }) {
|
||||
try {
|
||||
return trackEvent('didNotCreateProject', {
|
||||
deviceId: scope.deviceId,
|
||||
properties,
|
||||
...properties,
|
||||
});
|
||||
} catch (err) {
|
||||
/** ignore errors */
|
||||
@ -122,7 +122,7 @@ function trackUsage({ event, scope, error }) {
|
||||
try {
|
||||
return trackEvent(event, {
|
||||
deviceId: scope.deviceId,
|
||||
properties,
|
||||
...properties,
|
||||
});
|
||||
} catch (err) {
|
||||
/** ignore errors */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user