This repository has been archived by the owner on Apr 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* (BREAKING CHANGE) Give LocalPerformer access to Model; * Add Rollbar; * Add logo; * Prettify; * Add .editorconfig; * Fixes some `package.json` and `yarn.lock`; * Code cleanups; * Bump to 0.0.2. NOTE: Uses `url.path` as Rollbar's scope (different from what we are using now).
- Loading branch information
Showing
25 changed files
with
584 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# http://editorconfig.org | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 80 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = 0 | ||
trim_trailing_whitespace = false | ||
|
||
[*.elm] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[COMMIT_EDITMSG] | ||
max_line_length = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
**/elm-stuff/ | ||
**/elm.json | ||
**/.cache | ||
example/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
module Paack.Rollbar exposing | ||
( MaybeToken(..) | ||
, RollbarErrorPayload | ||
, RollbarPayload(..) | ||
, codedErrorPayload | ||
, errorPayload | ||
, initToken | ||
, notToRoll | ||
, prependDescription | ||
, withEntry | ||
, withPagination | ||
) | ||
|
||
{-| Composes the error payload | ||
-} | ||
|
||
import Dict exposing (Dict) | ||
import Json.Encode as Encode exposing (Value) | ||
import Rollbar | ||
|
||
|
||
type alias RollbarErrorPayload = | ||
{ description : String | ||
, details : Dict String Value | ||
} | ||
|
||
|
||
type RollbarPayload | ||
= RollError RollbarErrorPayload | ||
| NotToRoll | ||
|
||
|
||
type MaybeToken | ||
= DisabledForDevelopment | ||
| JustToken Rollbar.Token | ||
|
||
|
||
notToRoll : RollbarPayload | ||
notToRoll = | ||
NotToRoll | ||
|
||
|
||
errorPayload : String -> RollbarPayload | ||
errorPayload description = | ||
RollError | ||
{ description = description | ||
, details = Dict.empty | ||
} | ||
|
||
|
||
{-| A shortcut for InternalServerError and any GraphqlError error with { code : String } | ||
-} | ||
codedErrorPayload : { description : String, code : String } -> RollbarPayload | ||
codedErrorPayload { description, code } = | ||
RollError | ||
{ description = description | ||
, details = | ||
Dict.insert "code" | ||
(Encode.string code) | ||
Dict.empty | ||
} | ||
|
||
|
||
withEntry : String -> Value -> RollbarPayload -> RollbarPayload | ||
withEntry key value payload = | ||
case payload of | ||
RollError ({ details } as error) -> | ||
RollError { error | details = Dict.insert key value details } | ||
|
||
NotToRoll -> | ||
payload | ||
|
||
|
||
withPagination : { pageSize : Int, offset : Int } -> RollbarPayload -> RollbarPayload | ||
withPagination { pageSize, offset } = | ||
Encode.object | ||
[ ( "page", Encode.int pageSize ) | ||
, ( "offset", Encode.int offset ) | ||
] | ||
|> withEntry "pagination" | ||
|
||
|
||
prependDescription : String -> RollbarPayload -> RollbarPayload | ||
prependDescription parent payload = | ||
-- If ever needed, feel free to expose this function | ||
case payload of | ||
RollError ({ description } as error) -> | ||
RollError { error | description = parent ++ "/" ++ description } | ||
|
||
NotToRoll -> | ||
payload | ||
|
||
|
||
initToken : String -> MaybeToken | ||
initToken tokenFromFlags = | ||
if String.isEmpty tokenFromFlags then | ||
DisabledForDevelopment | ||
|
||
else | ||
JustToken <| Rollbar.token tokenFromFlags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module Paack.Rollbar.Dispatch exposing (sendError) | ||
|
||
{-| Composes the error effect | ||
-} | ||
|
||
import Dict | ||
import Effects.Local as LocalEffects | ||
import Json.Encode as Encode | ||
import Paack.Effects as Effects exposing (Effects) | ||
import Paack.Rollbar exposing (RollbarPayload(..)) | ||
import Paack.Rollbar.Effect as RollbarEffect | ||
import Rollbar | ||
|
||
|
||
{-| | ||
- parent: The (Elm) message where did it occurred. | ||
In rollbar as "body"."message"."parent" | ||
E.g.: `"Pages.FleetAssignment.DriversFetched"` | ||
- payload.description: The error union identification. | ||
In rollbar as "body"."message"."description" | ||
E.g.: `"Api.Drivers.List.InternalServerError"` | ||
- payload.details: Custom additions to "body"."message" | ||
E.g.: `Dict.fromList [ "bad-status", (Encode.int 404) ]` | ||
-} | ||
sendError : | ||
String | ||
-> RollbarPayload | ||
-> Effects msg | ||
sendError parent payload = | ||
case payload of | ||
NotToRoll -> | ||
Effects.none | ||
|
||
RollError { description, details } -> | ||
RollbarEffect.Send | ||
{ body = | ||
details | ||
|> Dict.insert "description" (Encode.string description) | ||
|> Dict.insert "parent" (Encode.string parent) | ||
, title = | ||
parent ++ "/" ++ description | ||
, level = | ||
Rollbar.Error | ||
} | ||
|> LocalEffects.RollbarEffect | ||
|> Effects.fromLocal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Paack.Rollbar.Effect exposing (Effect(..), Payload, RollbarResult) | ||
|
||
{-| Perform the error effect | ||
-} | ||
|
||
import Dict exposing (Dict) | ||
import Http as ElmHttp | ||
import Json.Encode exposing (Value) | ||
import Rollbar | ||
|
||
|
||
type Effect | ||
= Send Payload | ||
|
||
|
||
{-| | ||
- title: Usually `(parent ++ "/" ++ description)` | ||
- body: In rollbar as "body"."message" | ||
- level: As seen in rollbar dashboard | ||
-} | ||
type alias Payload = | ||
{ title : String | ||
, body : Dict String Value | ||
, level : Rollbar.Level | ||
} | ||
|
||
|
||
type alias RollbarResult = | ||
Result ElmHttp.Error () |
Oops, something went wrong.