mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 07:33:17 +00:00
Send unique identifier to detect activation (#9545)
This commit is contained in:
parent
a2437c0b5d
commit
f8a0f9f41d
@ -24,6 +24,7 @@ import NotFoundPage from '../NotFoundPage';
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import NotificationProvider from '../NotificationProvider';
|
||||
import Theme from '../Theme';
|
||||
import { getUID } from './utils';
|
||||
import { Content, Wrapper } from './components';
|
||||
import { getDataSucceeded } from './actions';
|
||||
import NewNotification from '../NewNotification';
|
||||
@ -75,11 +76,14 @@ function App(props) {
|
||||
|
||||
if (uuid) {
|
||||
try {
|
||||
const deviceId = await getUID();
|
||||
|
||||
fetch('https://analytics.strapi.io/track', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
event: 'didInitializeAdministration',
|
||||
uuid,
|
||||
deviceId,
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
export { default as getUID } from './unique-identifier';
|
||||
export { default as routes } from './routes';
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
import FingerprintJS from '@fingerprintjs/fingerprintjs';
|
||||
|
||||
const getUniqueIdentifier = async () => {
|
||||
const fp = await FingerprintJS.load();
|
||||
const result = await fp.get();
|
||||
|
||||
return result.visitorId;
|
||||
};
|
||||
|
||||
export default getUniqueIdentifier;
|
||||
@ -31,6 +31,7 @@
|
||||
"@buffetjs/styles": "3.3.4",
|
||||
"@buffetjs/utils": "3.3.4",
|
||||
"@casl/ability": "^4.1.5",
|
||||
"@fingerprintjs/fingerprintjs": "3.0.5",
|
||||
"@fortawesome/fontawesome-free": "^5.11.2",
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
||||
"@fortawesome/free-brands-svg-icons": "^5.15.2",
|
||||
|
||||
@ -56,16 +56,27 @@ function generateTarget(options, cb) {
|
||||
return sb(err);
|
||||
}
|
||||
if (!isValidTarget(target)) {
|
||||
return sb(new Error('Generator Error :: Could not resolve target `' + scope.rootPath + '` (probably a recursive loop)'));
|
||||
return sb(
|
||||
new Error(
|
||||
'Generator Error :: Could not resolve target `' +
|
||||
scope.rootPath +
|
||||
'` (probably a recursive loop)'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Pass down parent Generator's template directory abs path.
|
||||
scope.templatesDirectory = parentGenerator.templatesDirectory;
|
||||
|
||||
if (target.copy) {
|
||||
scope = mergeSubtargetScope(scope, typeof target.copy === 'string' ? {
|
||||
templatePath: target.copy
|
||||
} : target.copy);
|
||||
scope = mergeSubtargetScope(
|
||||
scope,
|
||||
typeof target.copy === 'string'
|
||||
? {
|
||||
templatePath: target.copy,
|
||||
}
|
||||
: target.copy
|
||||
);
|
||||
return copyHelper(scope, sb);
|
||||
}
|
||||
|
||||
@ -75,9 +86,14 @@ function generateTarget(options, cb) {
|
||||
}
|
||||
|
||||
if (target.template) {
|
||||
scope = mergeSubtargetScope(scope, typeof target.template === 'string' ? {
|
||||
templatePath: target.template
|
||||
} : target.template);
|
||||
scope = mergeSubtargetScope(
|
||||
scope,
|
||||
typeof target.template === 'string'
|
||||
? {
|
||||
templatePath: target.template,
|
||||
}
|
||||
: target.template
|
||||
);
|
||||
|
||||
return templateHelper(scope, sb);
|
||||
}
|
||||
@ -87,7 +103,7 @@ function generateTarget(options, cb) {
|
||||
scope = mergeSubtargetScope(scope, target.jsonfile);
|
||||
} else if (typeof target.jsonfile === 'function') {
|
||||
scope = _.merge(scope, {
|
||||
data: target.jsonfile(scope)
|
||||
data: target.jsonfile(scope),
|
||||
});
|
||||
}
|
||||
return jsonFileHelper(scope, sb);
|
||||
@ -98,7 +114,13 @@ function generateTarget(options, cb) {
|
||||
// call this method recursively on it, passing along our
|
||||
// callback.
|
||||
if (++scope._depth > scope.maxHops) {
|
||||
return sb(new Error('`maxHops` (' + scope.maxHops + ') exceeded! There is probably a recursive loop in one of your generators.'));
|
||||
return sb(
|
||||
new Error(
|
||||
'`maxHops` (' +
|
||||
scope.maxHops +
|
||||
') exceeded! There is probably a recursive loop in one of your generators.'
|
||||
)
|
||||
);
|
||||
}
|
||||
return recursiveGenerate(target, scope, sb);
|
||||
}
|
||||
@ -141,7 +163,7 @@ function targetIsHelper(target) {
|
||||
function parseTarget(target, scope, cb) {
|
||||
if (typeof target === 'string') {
|
||||
target = {
|
||||
generator: target
|
||||
generator: target,
|
||||
};
|
||||
}
|
||||
|
||||
@ -151,19 +173,22 @@ function parseTarget(target, scope, cb) {
|
||||
}
|
||||
|
||||
if (target.generator) {
|
||||
|
||||
// Normalize the subgenerator reference.
|
||||
let subGeneratorRef;
|
||||
if (typeof target.generator === 'string') {
|
||||
subGeneratorRef = {
|
||||
module: target.generator
|
||||
module: target.generator,
|
||||
};
|
||||
} else if (typeof target.generator === 'object') {
|
||||
subGeneratorRef = target.generator;
|
||||
}
|
||||
|
||||
if (!subGeneratorRef) {
|
||||
return cb(new Error('Generator Error :: Invalid subgenerator referenced for target `' + scope.rootPath + '`'));
|
||||
return cb(
|
||||
new Error(
|
||||
'Generator Error :: Invalid subgenerator referenced for target `' + scope.rootPath + '`'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Now normalize the sub-generator.
|
||||
@ -179,7 +204,6 @@ function parseTarget(target, scope, cb) {
|
||||
|
||||
// Otherwise, we'll attempt to load this subgenerator.
|
||||
if (typeof subGeneratorRef.module === 'string') {
|
||||
|
||||
// Lookup the generator by name if a `module` was specified
|
||||
// This allows the module for a given generator to be
|
||||
// overridden.
|
||||
@ -235,9 +259,15 @@ function parseTarget(target, scope, cb) {
|
||||
if (!subGenerator && !module.match(/^strapi-generate-/)) {
|
||||
try {
|
||||
if (process.mainModule.filename.indexOf('yarn') !== -1) {
|
||||
subGenerator = require(path.resolve(process.mainModule.paths[2], 'strapi-generate-' + module));
|
||||
subGenerator = require(path.resolve(
|
||||
process.mainModule.paths[2],
|
||||
'strapi-generate-' + module
|
||||
));
|
||||
} else {
|
||||
subGenerator = require(path.resolve(process.mainModule.paths[1], 'strapi-generate-' + module));
|
||||
subGenerator = require(path.resolve(
|
||||
process.mainModule.paths[1],
|
||||
'strapi-generate-' + module
|
||||
));
|
||||
}
|
||||
} catch (e1) {
|
||||
requireError = e1;
|
||||
@ -250,10 +280,25 @@ function parseTarget(target, scope, cb) {
|
||||
}
|
||||
|
||||
// But if we still can't find it, give up.
|
||||
return cb(new Error('Error: Failed to load `' + subGeneratorRef.module + '`...' + (requireError ? ' (' + requireError + ')' : '') +''));
|
||||
return cb(
|
||||
new Error(
|
||||
'Error: Failed to load `' +
|
||||
subGeneratorRef.module +
|
||||
'`...' +
|
||||
(requireError ? ' (' + requireError + ')' : '') +
|
||||
''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return cb(new Error('Unrecognized generator syntax in `targets["' + scope.keyPath + '"]` ::\n' + util.inspect(target)));
|
||||
return cb(
|
||||
new Error(
|
||||
'Unrecognized generator syntax in `targets["' +
|
||||
scope.keyPath +
|
||||
'"]` ::\n' +
|
||||
util.inspect(target)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1437,6 +1437,13 @@
|
||||
unique-filename "^1.1.1"
|
||||
which "^1.3.1"
|
||||
|
||||
"@fingerprintjs/fingerprintjs@3.0.5":
|
||||
version "3.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@fingerprintjs/fingerprintjs/-/fingerprintjs-3.0.5.tgz#c7a35e57c6c50b493c4db9f69106d5a3f4850c7f"
|
||||
integrity sha512-VCC7S3ExuScyIfRS8X5pmHj8Nb+GCKssD7DqXjMwgQdlijVKHG8Yo/tvShwdjwz3L7yL2iWF/bq7z6mEwQ8vQQ==
|
||||
dependencies:
|
||||
tslib "^2.0.1"
|
||||
|
||||
"@formatjs/ecma402-abstract@^1.2.2":
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/@formatjs/ecma402-abstract/-/ecma402-abstract-1.2.2.tgz#4810bdbd696d3805c535fd0620b7c8f45ab3164f"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user