Giter Site home page Giter Site logo

Comments (6)

wenga86 avatar wenga86 commented on June 8, 2024 3

+1 this

from typewriter.

vidartrojenborg avatar vidartrojenborg commented on June 8, 2024

I have the same issue, but I'm just running npx typewriter init, javascript and node.js as language options.

from typewriter.

tobad357 avatar tobad357 commented on June 8, 2024

I got the same when running in dev mode, however if I changed the function below in the generated code

const ajv = new Ajv({ allErrors: true, verbose: true })

from

function validateAgainstSchema(
  message: TrackMessage<Record<string, any>>,
  schema: object
) {
  const ajv = new Ajv({ allErrors: true, verbose: true });

  if (!ajv.validate(schema, message.properties) && ajv.errors) {
    onViolation(message, ajv.errors);
  }
}

to

function validateAgainstSchema(
  message: TrackMessage<Record<string, any>>,
  schema: object
) {
  const ajv = new Ajv({ allErrors: true, verbose: true });
  ajv.addKeyword("labels");

  if (!ajv.validate(schema, message.properties) && ajv.errors) {
    onViolation(message, ajv.errors);
  }
}

Then it works

from typewriter.

oscb avatar oscb commented on June 8, 2024

Thanks for reporting this. The last update came in with the validation that should've been disabled for production. Pushing a fix right now.

from typewriter.

oscb avatar oscb commented on June 8, 2024

The latest release should fix these errors: https://github.com/segmentio/typewriter/releases/tag/v8.0.10

Ping me if this still happens to you!

from typewriter.

tobad357 avatar tobad357 commented on June 8, 2024

@oscb still happens to me

  1. I upgraded to v8.0.10
  2. I removed my generated client and regenerated it
  3. I get same issue

here is an example event that's been generated

 export function contactAdded(
    message: TrackMessage<ContactAdded>,
    callback?: Callback
): void {
    const event = withTypewriterContext({
        ...message,
        event: 'Contact Added',
        properties: {
            ...message.properties,
        },
    });
    const schema = {"$id":"Contact Added","$schema":"http://json-schema.org/draft-07/schema#","description":"Player adds a contact","labels":{"area":"account","type":"contacts"},"properties":{"id":{"$id":"/properties/id","description":"the user contact id","type":"string"},"type":{"$id":"/properties/type","description":"The type of contact (MOBILE,EMAIL,ADDRESS)","enum":["ADDRESS","EMAIL","MOBILE"],"type":"string"}},"type":"object"};
    validateAgainstSchema(event, schema);

    const a = analytics()
    if (a) {
        a.track(event,callback);
    } else {
        throw missingAnalyticsNodeError
    }
}

and the validateAgainstSchema function

function validateAgainstSchema(
    message: TrackMessage<Record<string, any>>,
    schema: object
) {
    const ajv = new Ajv({ allErrors: true, verbose: true })

    if (!ajv.validate(schema, message.properties) && ajv.errors) {
        onViolation(message, ajv.errors)
    }
}

The error is

Error: strict mode: unknown keyword: "labels"

from typewriter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.