@serverless/sdk-beta

npm i --save @serverless/sdk-beta

Usage no npm install needed!

<script type="module">
  import serverlessSdkBeta from 'https://cdn.skypack.dev/@serverless/sdk-beta';
</script>

README

sdk

Install

npm i --save @serverless/sdk-beta

How to use

Wrap your function with the SDK's trackHandler:

const sdk = require('@serverless/sdk-beta')('testAPIKey');

// Your function handler
module.exports.hello = sdk.trackHandler((event, context, cb) => {
  cb(null, {
    message: 'Go Serverless v1.0! Your function executed successfully!', event
  });
});

API

trackHandler(handler, tags)

Track handler function invocations.

Arguments:

  • handler - required - function to track by SDK.
  • tags - optional object with custom tags e.g. {'owner': 'teamA'}. Each key/value pair is treated as separate tag. region and runtime tags are added to each invocation.

Tracking errors

Errors thrown from within handler function are automatically tracked.

module.exports.hello = sdk.trackHandler((event, context, cb) => {
  throw new Error('Whoops!');
});