So, i was creating a custom NativeScript Plugin to implement NewRelic for my iOS application. Testing the plugin in the NativeScript Plugin Seed enviroment seems to work fine.
After i added the plugin to my own project, it's getting an error, when it tries to call NewRelic.
This is, how NewRelic is being called in the plugin.
This is the index.ios.ts part:
import { NewRelicCommon, NewRelicOptions } from './common';
import { } from '@nativescript/core';
declare const NewRelic;
@NativeClass()
export class NewRelicAgent extends NewRelicCommon {
constructor() {
super();
}
init(args: NewRelicOptions): void {
NewRelic.startWithApplicationToken(args.token);
}
}
This is the service i build in my project:
import { Injectable } from '@angular/core';
import { NewRelicAgent, NewRelicOptions } from '@companyscope/new-relic';
import { NewRelicService } from '@resident-nx/shared';
const newrelic = new NewRelicAgent();
let args: NewRelicOptions;
@Injectable()
export class NewRelicNSService extends NewRelicService {
constructor() {
super();
}
public initialize() {
args = {
token: 'GENERATED_TOKEN',
};
newrelic.init(args);
}
}
I tried calling the service in my app.component.ts but i get this error:
ERROR ReferenceError: NewRelic is not defined
Does anyone know, if i did something wrong in the plugin part or why is it not finding NewRelic?
I expected NewRelic for iOS to start when the app starts.