Comments (6)
+1 this
from typewriter.
I have the same issue, but I'm just running npx typewriter init
, javascript and node.js as language options.
from typewriter.
I got the same when running in dev mode, however if I changed the function below in the generated code
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.
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.
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.
@oscb still happens to me
- I upgraded to v8.0.10
- I removed my generated client and regenerated it
- 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)
- Bug: New properties are not immediately pulled in when re-running npx typewriter HOT 2
- CI=true needed to run locally HOT 1
- Is it possible to set custom messageId with the generated client? HOT 2
- Bug: Error when validateAgainstSchema is run HOT 2
- React Native client only generates types for events that have properties HOT 6
- Objective-C Typed Parameters
- Allow variables in typewriter.yml file, for instance to specify output dir HOT 1
- Support generating union types for enum properties in v8+ HOT 2
- Update minimum yaml version to 2.2.2 HOT 1
- In development Mode ajv.validate causes Error: unknown format "date-time"
- Expose initializer with optional parameters in generated Swift code
- Error when running init HOT 4
- Add way to remove additionalProperties ([property: string]: any)
- Error: Cannot infer name for schema HOT 1
- Typewriter JSON Schema Validation Error for Date objects HOT 1
- Security vulnerability due to an outdated plugin HOT 4
- [Kotlin] Missing "import" in segment.kt HOT 1
- [Bug - Swift] `segment` file does not observe `access-level: public` specified in `typewriter.yml`
- npx typewriter init generates yml file, but not client (Windows) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typewriter.