How to use the uuid/v4 function in uuid

To help you get started, we’ve selected a few uuid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ZeroX-DG / SnippetStore / browser / lib / analytics.js View on Github external
import ua from 'universal-analytics'
import uuid from 'uuid/v4'
const Store = require('electron-store')
const store = new Store({ name: 'SnippetStoreUserInfo' })
const config = new Store({ name: 'SnippetStoreConf' })

// Retrieve the userid value, and if it's not there, assign it a new uuid.
const userId = store.get('userId') || uuid()
// (re)save the userid, so it persists for the next app session.
store.set('userId', userId)
const user = ua('UA-123395923-2', userId)
export function trackEvent (category, action, label, value) {
  if (config.get('config').allowAnalytics) {
    user
      .event({
        ec: category,
        ea: action,
        el: label,
        ev: value
      })
      .send()
  }
}
github lmiller1990 / firestore-vue-chat / src / store / conversations.js View on Github external
sendMessage ({ commit, rootState }, { text, created, sender, conversationId }) {
		const convoRef = rootState.db.collection('conversations').doc(conversationId)

		convoRef.update({
			messages: [...state.all[conversationId].messages, { id: uuidv4(), created, sender, text }]
		})
		.then(res => console.log('Message sent.'))
		.catch(err => console.log('Error', err))
	},
github AraiEzzra / DDKCORE / core / repository / socket.ts View on Github external
peerRPCRequest(code, data, peer): Promise> {
        const requestId = uuid4();

        return new Promise((resolve) => {

            if (!(PeerRepository.has(peer))) {
                logger.error(`Peer ${peer.ip}:${peer.port} is offline`);
                resolve(new ResponseEntity({ errors: [`Peer ${peer.ip}:${peer.port} is offline`] }));
            }

            if (!peer.socket) {
                peer = PeerRepository.getPeerFromPool(peer);
            }

            const responseListener = (response) => {
                response = new SocketResponseRPC(response);
                if (response.requestId && response.requestId === requestId) {
github buttercup / buttercup-browser-extension / source / setup / components / AddArchivePage.js View on Github external
componentDidMount() {
        this.setState({
            dropboxAuthenticationID: uuid(),
            googleDriveAuthenticationID: uuid()
        });
        this.props.onReady();
    }
github OpenCTI-Platform / opencti / opencti-graphql / src / domain / markingDefinition.js View on Github external
export const addMarkingDefinition = async (user, markingDefinition) => {
  const wTx = await takeWriteTx();
  const internalId = markingDefinition.internal_id
    ? escapeString(markingDefinition.internal_id)
    : uuid();
  const markingDefinitionIterator = await wTx.tx.query(`insert $markingDefinition isa Marking-Definition,
    has internal_id "${internalId}",
    has entity_type "marking-definition",
    has stix_id "${
      markingDefinition.stix_id
        ? escapeString(markingDefinition.stix_id)
        : `marking-definition--${uuid()}`
    }",
    has definition_type "${escapeString(markingDefinition.definition_type)}",
    has definition "${escapeString(markingDefinition.definition)}",
    has color "${escapeString(markingDefinition.color)}",
    has level ${markingDefinition.level},
    has created ${
      markingDefinition.created ? prepareDate(markingDefinition.created) : now()
    },
    has modified ${
github cube-js / cube.js / packages / cubejs-playground / src / events.js View on Github external
const track = async (event) => {
  if (!cookie('playground_anonymous')) {
    cookie('playground_anonymous', uuidv4());
  }
  trackEvents.push({
    ...event,
    id: uuidv4(),
    clientAnonymousId: cookie('playground_anonymous'),
    clientTimestamp: new Date().toJSON()
  });
  const flush = async (toFlush, retries) => {
    if (!toFlush) {
      toFlush = trackEvents;
      trackEvents = [];
    }
    if (!toFlush.length) {
      return null;
    }
    if (retries == null) {
      retries = 10;
    }
    try {
      const sentAt = new Date().toJSON();
github datash / datash / src / client / components / App / index.js View on Github external
const {
      from, encKey, data: dataArr, sharingConfirmationId
    } = data;

    if (sharingConfirmationId) {
      sendWS(globalStates.ws, {
        type: 'share-confirm',
        data: sharingConfirmationId
      });
    }

    if (!from || !encKey || !dataArr) {
      return;
    }

    const notificationId = uuid();
    notification.open({
      key: notificationId,
      duration: 0,
      message: 'New Data',
      description: 'Decrypting...',
      icon: 
    });

    const decKey = textToBytes(decryptAsymmetric(globalStates.privateKey, encKey));

    Promise.all(dataArr.map(datum => Promise.all([
      datum.type,
      decryptObjectSymmetric(
        decKey,
        {
          name: datum.name,
github popcodeorg / popcode / src / actions / console.js View on Github external
  (_input, key = uuid().toString()) => ({key}),
);
github rai-project / mlmodelscope / src / swagger / dlframework.js View on Github external
export function ModelManifests(params) {
  let urlPath = "/registry/models/manifest";
  let body = {},
    queryParameters = {},
    headers = params.headers || {},
    form = {};

  headers["Accept"] = ["application/json"];
  headers["Content-Type"] = ["application/json"];

  if (has(params, "requestId")) {
    headers["X-Request-ID"] = params.requestId;
  } else if (has(params, "X-Request-ID")) {
    headers["X-Request-ID"] = params["X-Request-ID"];
  } else {
    headers["X-Request-ID"] = uuid();
  }

  return function ModelManifestsRequest({ http, path, resolve }) {
    let parameters = params;

    if (parameters === undefined) {
      parameters = {};
    }

    if (parameters["frameworkName"] !== undefined) {
      queryParameters["framework_name"] = resolve.value(
        parameters["frameworkName"]
      );
    }

    if (parameters["frameworkVersion"] !== undefined) {